Revision 8ddb4627
b/src/gr/grnet/pithos/web/client/Const.java | ||
---|---|---|
5 | 5 |
/** |
6 | 6 |
* Gathers application-wide constants, like <code>X-Auth-Token</code> |
7 | 7 |
*/ |
8 |
public class Const { |
|
8 |
public final class Const {
|
|
9 | 9 |
public static final String X_AUTH_TOKEN = "X-Auth-Token"; |
10 | 10 |
public static final String OTHER_PROPERTIES = "otherProperties"; |
11 | 11 |
public static final String LOGIN_URL = "loginUrl"; |
... | ... | |
28 | 28 |
private Const() {} |
29 | 29 |
|
30 | 30 |
|
31 |
public static String PurgeContainer(String name) { |
|
32 |
return "Purge Container [" + name + "]"; |
|
33 |
} |
|
31 | 34 |
} |
b/src/gr/grnet/pithos/web/client/FolderContextMenu.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package gr.grnet.pithos.web.client; |
36 | 36 |
|
37 |
import gr.grnet.pithos.web.client.commands.CopyCommand; |
|
38 |
import gr.grnet.pithos.web.client.commands.CutCommand; |
|
39 |
import gr.grnet.pithos.web.client.commands.DeleteCommand; |
|
40 |
import gr.grnet.pithos.web.client.commands.EmptyContainerCommand; |
|
41 |
import gr.grnet.pithos.web.client.commands.NewFolderCommand; |
|
42 |
import gr.grnet.pithos.web.client.commands.PasteCommand; |
|
43 |
import gr.grnet.pithos.web.client.commands.PropertiesCommand; |
|
44 |
import gr.grnet.pithos.web.client.commands.RefreshCommand; |
|
45 |
import gr.grnet.pithos.web.client.commands.RestoreTrashCommand; |
|
46 |
import gr.grnet.pithos.web.client.commands.ToTrashCommand; |
|
37 |
import gr.grnet.pithos.web.client.commands.*; |
|
38 |
import gr.grnet.pithos.web.client.commands.PurgeContainerCommand; |
|
47 | 39 |
import gr.grnet.pithos.web.client.foldertree.Folder; |
48 | 40 |
|
49 | 41 |
import com.google.gwt.user.client.ui.AbstractImagePrototype; |
... | ... | |
136 | 128 |
} |
137 | 129 |
|
138 | 130 |
if (folder.isContainer()) { |
139 |
MenuItem emptyContainer = new MenuItem("<span>Empty Container</span>", true, new EmptyContainerCommand(app, this, folder)); |
|
140 |
contextMenu.addItem(emptyContainer); |
|
131 |
MenuItem purgeContainer = new MenuItem( |
|
132 |
"<span>" + Const.PurgeContainer(folder.getName()) + "</span>", |
|
133 |
true, |
|
134 |
new PurgeContainerCommand(app, this, folder) |
|
135 |
); |
|
136 |
contextMenu.addItem(purgeContainer); |
|
141 | 137 |
} |
142 | 138 |
} |
143 | 139 |
} |
... | ... | |
150 | 146 |
contextMenu.addItem(delete); |
151 | 147 |
} |
152 | 148 |
else { |
153 |
MenuItem emptyTrash = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Empty Trash</span>", true, new EmptyContainerCommand(app, this, folder));
|
|
149 |
MenuItem emptyTrash = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Empty Trash</span>", true, new PurgeContainerCommand(app, this, folder));
|
|
154 | 150 |
contextMenu.addItem(emptyTrash); |
155 | 151 |
} |
156 | 152 |
} |
b/src/gr/grnet/pithos/web/client/Pithos.java | ||
---|---|---|
340 | 340 |
if(false) { |
341 | 341 |
final StringBuilder sb = new StringBuilder(); |
342 | 342 |
for(Object arg : args) { |
343 |
sb.append(arg); |
|
344 | 343 |
if(arg instanceof Throwable) { |
345 |
sb.append("\nCauses (including original):\n"); |
|
346 | 344 |
final Throwable error = (Throwable) arg; |
347 |
Throwable cause = error; |
|
348 |
while(cause != null) { |
|
349 |
sb.append(" "); |
|
350 |
sb.append(cause.toString()); |
|
345 |
sb.append("\nException: [" + error.toString().replace("\n", "\n ") + "]"); |
|
346 |
Throwable cause = error.getCause(); |
|
347 |
if(cause != null) { |
|
348 |
sb.append("\nCauses:\n"); |
|
349 |
while(cause != null) { |
|
350 |
sb.append(" "); |
|
351 |
sb.append("[" + cause.toString().replace("\n", "\n ") + "]"); |
|
352 |
sb.append("\n"); |
|
353 |
cause = cause.getCause(); |
|
354 |
} |
|
355 |
} |
|
356 |
else { |
|
351 | 357 |
sb.append("\n"); |
352 |
cause = cause.getCause(); |
|
353 | 358 |
} |
354 | 359 |
|
355 |
sb.append("Stack trace of original: "); |
|
356 |
sb.append(error.toString()); |
|
357 |
sb.append("\n"); |
|
358 | 360 |
StackTraceElement[] stackTrace = error.getStackTrace(); |
359 |
for(StackTraceElement errorElem : stackTrace) { |
|
360 |
sb.append(" "); |
|
361 |
sb.append("Stack trace (" + stackTrace.length + " elements):\n"); |
|
362 |
for(int i = 0; i < stackTrace.length; i++) { |
|
363 |
StackTraceElement errorElem = stackTrace[i]; |
|
364 |
sb.append(" [" + i + "] "); |
|
361 | 365 |
sb.append(errorElem.toString()); |
362 | 366 |
sb.append("\n"); |
363 | 367 |
} |
364 | 368 |
} |
369 |
else { |
|
370 |
sb.append(arg); |
|
371 |
} |
|
365 | 372 |
} |
366 | 373 |
|
367 | 374 |
|
... | ... | |
614 | 621 |
scheduleResfresh(); |
615 | 622 |
} |
616 | 623 |
else if(retries >= MAX_RETRIES) { |
617 |
GWT.log("Error heading folder", t);
|
|
624 |
LOG("Error heading folder. ", t);
|
|
618 | 625 |
setError(t); |
619 | 626 |
if(t instanceof RestException) { |
620 | 627 |
displayError("Error heading folder: " + ((RestException) t).getHttpStatusText()); |
... | ... | |
624 | 631 |
} |
625 | 632 |
} |
626 | 633 |
else {//retry |
627 |
GWT.log("Retry " + retries);
|
|
634 |
LOG("Retry ", retries);
|
|
628 | 635 |
Scheduler.get().scheduleDeferred(this); |
629 | 636 |
} |
630 | 637 |
} |
... | ... | |
761 | 768 |
|
762 | 769 |
@Override |
763 | 770 |
public void onError(Throwable t) { |
764 |
GWT.log("Error getting account", t);
|
|
771 |
LOG("Error getting account", t);
|
|
765 | 772 |
setError(t); |
766 | 773 |
if(t instanceof RestException) { |
767 | 774 |
displayError("Error getting account: " + ((RestException) t).getHttpStatusText()); |
... | ... | |
790 | 797 |
|
791 | 798 |
@Override |
792 | 799 |
public void onError(Throwable t) { |
793 |
GWT.log("Error getting account", t);
|
|
800 |
LOG("Error getting account", t);
|
|
794 | 801 |
setError(t); |
795 | 802 |
if(t instanceof RestException) { |
796 | 803 |
displayError("Error getting account: " + ((RestException) t).getHttpStatusText()); |
... | ... | |
824 | 831 |
|
825 | 832 |
@Override |
826 | 833 |
public void onError(Throwable t) { |
827 |
GWT.log("Error creating pithos", t);
|
|
834 |
LOG("Error creating pithos", t);
|
|
828 | 835 |
setError(t); |
829 | 836 |
if(t instanceof RestException) { |
830 | 837 |
displayError("Error creating pithos: " + ((RestException) t).getHttpStatusText()); |
... | ... | |
853 | 860 |
|
854 | 861 |
@Override |
855 | 862 |
public void onError(Throwable t) { |
856 |
GWT.log("Error creating pithos", t);
|
|
863 |
LOG("Error creating pithos", t);
|
|
857 | 864 |
setError(t); |
858 | 865 |
if(t instanceof RestException) { |
859 | 866 |
displayError("Error creating pithos: " + ((RestException) t).getHttpStatusText()); |
... | ... | |
1038 | 1045 |
|
1039 | 1046 |
@Override |
1040 | 1047 |
public void onError(Throwable t) { |
1041 |
GWT.log("", t);
|
|
1048 |
LOG(t);
|
|
1042 | 1049 |
setError(t); |
1043 | 1050 |
if(t instanceof RestException) { |
1044 | 1051 |
if(((RestException) t).getHttpStatusCode() != Response.SC_NOT_FOUND) { |
... | ... | |
1074 | 1081 |
|
1075 | 1082 |
@Override |
1076 | 1083 |
public void onError(Throwable t) { |
1077 |
GWT.log("", t);
|
|
1084 |
LOG(t);
|
|
1078 | 1085 |
setError(t); |
1079 | 1086 |
if(t instanceof RestException) { |
1080 | 1087 |
displayError("Unable to copy file: " + ((RestException) t).getHttpStatusText()); |
... | ... | |
1114 | 1121 |
|
1115 | 1122 |
@Override |
1116 | 1123 |
public void onError(Throwable t) { |
1117 |
GWT.log("", t);
|
|
1124 |
LOG(t);
|
|
1118 | 1125 |
setError(t); |
1119 | 1126 |
if(t instanceof RestException) { |
1120 | 1127 |
displayError("Unable to copy folder: " + ((RestException) t).getHttpStatusText()); |
... | ... | |
1357 | 1364 |
|
1358 | 1365 |
@Override |
1359 | 1366 |
public void onError(Throwable _t) { |
1360 |
GWT.log("", _t);
|
|
1367 |
LOG(_t);
|
|
1361 | 1368 |
setError(_t); |
1362 | 1369 |
if(_t instanceof RestException) { |
1363 | 1370 |
displayError("Unable to create folder: " + ((RestException) _t).getHttpStatusText()); |
... | ... | |
1389 | 1396 |
displayError("System error heading folder: " + t.getMessage()); |
1390 | 1397 |
} |
1391 | 1398 |
|
1392 |
GWT.log("Error heading folder", t);
|
|
1399 |
LOG("Error heading folder", t);
|
|
1393 | 1400 |
setError(t); |
1394 | 1401 |
} |
1395 | 1402 |
|
... | ... | |
1415 | 1422 |
|
1416 | 1423 |
@Override |
1417 | 1424 |
public void onError(Throwable t) { |
1418 |
GWT.log("Error heading file", t);
|
|
1425 |
LOG("Error heading file", t);
|
|
1419 | 1426 |
setError(t); |
1420 | 1427 |
if(t instanceof RestException) { |
1421 | 1428 |
displayError("Error heading file: " + ((RestException) t).getHttpStatusText()); |
... | ... | |
1516 | 1523 |
fileList.selectByUrl(selectedUrls); |
1517 | 1524 |
} |
1518 | 1525 |
|
1519 |
public void emptyContainer(final Folder container) {
|
|
1526 |
public void purgeContainer(final Folder container) {
|
|
1520 | 1527 |
String path = "/" + container.getName() + "?delimiter=/"; |
1521 | 1528 |
DeleteRequest delete = new DeleteRequest(getApiPath(), getUserID(), path) { |
1522 | 1529 |
|
... | ... | |
1532 | 1539 |
|
1533 | 1540 |
@Override |
1534 | 1541 |
public void onError(Throwable t) { |
1535 |
GWT.log("Error deleting trash", t);
|
|
1542 |
LOG("Error deleting trash", t);
|
|
1536 | 1543 |
setError(t); |
1537 | 1544 |
if(t instanceof RestException) { |
1538 | 1545 |
displayError("Error deleting trash: " + ((RestException) t).getHttpStatusText()); |
b/src/gr/grnet/pithos/web/client/PurgeContainerDialog.java | ||
---|---|---|
1 |
/* |
|
2 |
* Copyright 2011-2013 GRNET S.A. All rights reserved. |
|
3 |
* |
|
4 |
* Redistribution and use in source and binary forms, with or |
|
5 |
* without modification, are permitted provided that the following |
|
6 |
* conditions are met: |
|
7 |
* |
|
8 |
* 1. Redistributions of source code must retain the above |
|
9 |
* copyright notice, this list of conditions and the following |
|
10 |
* disclaimer. |
|
11 |
* |
|
12 |
* 2. Redistributions in binary form must reproduce the above |
|
13 |
* copyright notice, this list of conditions and the following |
|
14 |
* disclaimer in the documentation and/or other materials |
|
15 |
* provided with the distribution. |
|
16 |
* |
|
17 |
* THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS |
|
18 |
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
19 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
20 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR |
|
21 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
22 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
23 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
24 |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
25 |
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
26 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
27 |
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
28 |
* POSSIBILITY OF SUCH DAMAGE. |
|
29 |
* |
|
30 |
* The views and conclusions contained in the software and |
|
31 |
* documentation are those of the authors and should not be |
|
32 |
* interpreted as representing official policies, either expressed |
|
33 |
* or implied, of GRNET S.A. |
|
34 |
*/ |
|
35 |
package gr.grnet.pithos.web.client; |
|
36 |
|
|
37 |
import com.google.gwt.dom.client.NativeEvent; |
|
38 |
import com.google.gwt.event.dom.client.ClickEvent; |
|
39 |
import com.google.gwt.event.dom.client.ClickHandler; |
|
40 |
import com.google.gwt.event.dom.client.KeyCodes; |
|
41 |
import com.google.gwt.event.dom.client.KeyDownEvent; |
|
42 |
import com.google.gwt.event.logical.shared.ValueChangeEvent; |
|
43 |
import com.google.gwt.event.logical.shared.ValueChangeHandler; |
|
44 |
import com.google.gwt.user.client.Command; |
|
45 |
import com.google.gwt.user.client.Event.NativePreviewEvent; |
|
46 |
import com.google.gwt.user.client.ui.*; |
|
47 |
import gr.grnet.pithos.web.client.commands.AddUserCommand; |
|
48 |
import gr.grnet.pithos.web.client.foldertree.Folder; |
|
49 |
import gr.grnet.pithos.web.client.grouptree.Group; |
|
50 |
|
|
51 |
/** |
|
52 |
* The 'Purge Container' dialog box implementation. |
|
53 |
*/ |
|
54 |
public class PurgeContainerDialog extends DialogBox { |
|
55 |
private final Pithos app; |
|
56 |
private final Folder container; |
|
57 |
|
|
58 |
private final CheckBox yesIAgree; |
|
59 |
|
|
60 |
private final VerticalPanel inner; |
|
61 |
|
|
62 |
public PurgeContainerDialog(Pithos app, Folder container) { |
|
63 |
this.app = app; |
|
64 |
this.container = container; |
|
65 |
this.yesIAgree = new CheckBox("I want to purge all contents of " + container.getName()); |
|
66 |
|
|
67 |
this.yesIAgree.setValue(false); |
|
68 |
|
|
69 |
Anchor close = new Anchor("close"); |
|
70 |
close.addStyleName("close"); |
|
71 |
close.addClickHandler(new ClickHandler() { |
|
72 |
|
|
73 |
@Override |
|
74 |
public void onClick(ClickEvent event) { |
|
75 |
hide(); |
|
76 |
} |
|
77 |
}); |
|
78 |
|
|
79 |
setGlassEnabled(true); |
|
80 |
setStyleName("pithos-DialogBox"); |
|
81 |
|
|
82 |
// Enable IE selection for the dialog (must disable it upon closing it) |
|
83 |
Pithos.enableIESelection(); |
|
84 |
|
|
85 |
// Use this opportunity to set the dialog's caption. |
|
86 |
setText(Const.PurgeContainer(container.getName())); |
|
87 |
|
|
88 |
// Outer contains inner and buttons |
|
89 |
VerticalPanel outer = new VerticalPanel(); |
|
90 |
outer.add(close); |
|
91 |
// Inner contains generalPanel and permPanel |
|
92 |
inner = new VerticalPanel(); |
|
93 |
inner.addStyleName("inner"); |
|
94 |
|
|
95 |
VerticalPanel generalPanel = new VerticalPanel(); |
|
96 |
FlexTable generalTable = new FlexTable(); |
|
97 |
generalTable.setText(0, 0, "Are you sure?"); |
|
98 |
|
|
99 |
generalTable.setWidget(0, 1, yesIAgree); |
|
100 |
|
|
101 |
generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels"); |
|
102 |
generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values"); |
|
103 |
generalTable.setCellSpacing(4); |
|
104 |
generalPanel.add(generalTable); |
|
105 |
inner.add(generalPanel); |
|
106 |
|
|
107 |
outer.add(inner); |
|
108 |
|
|
109 |
// Create the 'Create/Update' button, along with a listener that hides the dialog |
|
110 |
// when the button is clicked and quits the application. |
|
111 |
String okLabel = "Purge Container"; |
|
112 |
final Button ok = new Button(okLabel, new ClickHandler() { |
|
113 |
@Override |
|
114 |
public void onClick(ClickEvent event) { |
|
115 |
purgeContainer(); |
|
116 |
closeDialog(); |
|
117 |
} |
|
118 |
}); |
|
119 |
ok.addStyleName("button"); |
|
120 |
ok.setEnabled(false); |
|
121 |
ok.setVisible(false); |
|
122 |
outer.add(ok); |
|
123 |
|
|
124 |
this.yesIAgree.addValueChangeHandler(new ValueChangeHandler<Boolean>() { |
|
125 |
@Override |
|
126 |
public void onValueChange(ValueChangeEvent<Boolean> event) { |
|
127 |
ok.setVisible(event.getValue()); |
|
128 |
ok.setEnabled(event.getValue()); |
|
129 |
} |
|
130 |
}); |
|
131 |
|
|
132 |
outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER); |
|
133 |
|
|
134 |
setWidget(outer); |
|
135 |
} |
|
136 |
|
|
137 |
@Override |
|
138 |
public void center() { |
|
139 |
super.center(); |
|
140 |
yesIAgree.setFocus(false); |
|
141 |
} |
|
142 |
|
|
143 |
@Override |
|
144 |
protected void onPreviewNativeEvent(NativePreviewEvent preview) { |
|
145 |
super.onPreviewNativeEvent(preview); |
|
146 |
|
|
147 |
NativeEvent evt = preview.getNativeEvent(); |
|
148 |
if (evt.getType().equals(KeyDownEvent.getType().getName())) |
|
149 |
// Exit the dialog on Escape |
|
150 |
switch (evt.getKeyCode()) { |
|
151 |
case KeyCodes.KEY_ESCAPE: |
|
152 |
closeDialog(); |
|
153 |
break; |
|
154 |
} |
|
155 |
} |
|
156 |
|
|
157 |
|
|
158 |
/** |
|
159 |
* Enables IE selection prevention and hides the dialog |
|
160 |
* (we disable the prevention on creation of the dialog) |
|
161 |
*/ |
|
162 |
public void closeDialog() { |
|
163 |
Pithos.preventIESelection(); |
|
164 |
hide(); |
|
165 |
} |
|
166 |
|
|
167 |
private void purgeContainer() { |
|
168 |
app.purgeContainer(container); |
|
169 |
} |
|
170 |
} |
b/src/gr/grnet/pithos/web/client/ToolsMenu.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package gr.grnet.pithos.web.client; |
36 | 36 |
|
37 |
import gr.grnet.pithos.web.client.commands.AddUserCommand; |
|
38 |
import gr.grnet.pithos.web.client.commands.CopyCommand; |
|
39 |
import gr.grnet.pithos.web.client.commands.CreateGroupCommand; |
|
40 |
import gr.grnet.pithos.web.client.commands.CutCommand; |
|
41 |
import gr.grnet.pithos.web.client.commands.DeleteCommand; |
|
42 |
import gr.grnet.pithos.web.client.commands.DeleteGroupCommand; |
|
43 |
import gr.grnet.pithos.web.client.commands.EmptyContainerCommand; |
|
44 |
import gr.grnet.pithos.web.client.commands.PasteCommand; |
|
45 |
import gr.grnet.pithos.web.client.commands.PropertiesCommand; |
|
46 |
import gr.grnet.pithos.web.client.commands.RemoveUserCommand; |
|
47 |
import gr.grnet.pithos.web.client.commands.RestoreTrashCommand; |
|
48 |
import gr.grnet.pithos.web.client.commands.ToTrashCommand; |
|
37 |
import gr.grnet.pithos.web.client.commands.*; |
|
38 |
import gr.grnet.pithos.web.client.commands.PurgeContainerCommand; |
|
49 | 39 |
import gr.grnet.pithos.web.client.foldertree.File; |
50 | 40 |
import gr.grnet.pithos.web.client.foldertree.Folder; |
51 | 41 |
import gr.grnet.pithos.web.client.grouptree.Group; |
... | ... | |
200 | 190 |
empty = false; |
201 | 191 |
} |
202 | 192 |
if (isFolderTreeSelected && folder.isContainer()) { |
203 |
MenuItem emptyContainer = new MenuItem("<span>Empty Container</span>", true, new EmptyContainerCommand(app, this, folder)); |
|
193 |
MenuItem emptyContainer = new MenuItem( |
|
194 |
"<span>" + Const.PurgeContainer(folder.getName()) + "</span>", |
|
195 |
true, |
|
196 |
new PurgeContainerCommand(app, this, folder) |
|
197 |
); |
|
204 | 198 |
contextMenu.addItem(emptyContainer); |
205 | 199 |
empty = false; |
206 | 200 |
} |
... | ... | |
220 | 214 |
empty = false; |
221 | 215 |
} |
222 | 216 |
else { |
223 |
MenuItem emptyTrash = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Empty Trash</span>", true, new EmptyContainerCommand(app, this, folder));
|
|
217 |
MenuItem emptyTrash = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Empty Trash</span>", true, new PurgeContainerCommand(app, this, folder));
|
|
224 | 218 |
contextMenu.addItem(emptyTrash); |
225 | 219 |
empty = false; |
226 | 220 |
} |
b/src/gr/grnet/pithos/web/client/catalog/GetUserCatalogs.java | ||
---|---|---|
137 | 137 |
} |
138 | 138 |
|
139 | 139 |
public void onError(Request request, Throwable t) { |
140 |
app.LOG("GetUserCatalogs ", t);
|
|
140 |
app.LOG("GetUserCatalogs", t); |
|
141 | 141 |
} |
142 | 142 |
|
143 | 143 |
@Override |
... | ... | |
145 | 145 |
final RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, getURL()); |
146 | 146 |
rb.setHeader(Const.X_AUTH_TOKEN, userToken); |
147 | 147 |
final String requestData = makeRequestData().toString(); |
148 |
app.LOG("GetUserCatalog => ", requestData); |
|
149 |
app.LOG(new Exception());
|
|
148 |
app.LOG("GetUserCatalogs => ", requestData);
|
|
149 |
Pithos.LOG("POST ", getURL());
|
|
150 | 150 |
|
151 | 151 |
try { |
152 | 152 |
rb.sendRequest(requestData, new RequestCallback() { |
... | ... | |
155 | 155 |
final int statusCode = response.getStatusCode(); |
156 | 156 |
|
157 | 157 |
if(statusCode != SuccessCode) { |
158 |
app.LOG("GetUserCatalog <= [", statusCode, " ", response.getStatusText(), "]"); |
|
158 |
app.LOG("GetUserCatalogs <= [", statusCode, " ", response.getStatusText(), "]");
|
|
159 | 159 |
GetUserCatalogs.this.onBadStatusCode(request, response); |
160 | 160 |
return; |
161 | 161 |
} |
162 | 162 |
|
163 | 163 |
final String responseText = response.getText(); |
164 | 164 |
final JSONValue jsonValue = JSONParser.parseStrict(responseText); |
165 |
app.LOG("GetUserCatalog <= ", jsonValue.toString()); |
|
165 |
app.LOG("GetUserCatalogs <= ", jsonValue.toString());
|
|
166 | 166 |
final JSONObject result = jsonValue.isObject(); |
167 | 167 |
|
168 | 168 |
if(result == null) { |
... | ... | |
182 | 182 |
}); |
183 | 183 |
} |
184 | 184 |
catch(Exception e) { |
185 |
app.LOG("GetUserCatalogs. ", e);
|
|
185 |
app.LOG("GetUserCatalogs", e); |
|
186 | 186 |
} |
187 | 187 |
} |
188 | 188 |
|
/dev/null | ||
---|---|---|
1 |
/* |
|
2 |
* Copyright 2011-2013 GRNET S.A. All rights reserved. |
|
3 |
* |
|
4 |
* Redistribution and use in source and binary forms, with or |
|
5 |
* without modification, are permitted provided that the following |
|
6 |
* conditions are met: |
|
7 |
* |
|
8 |
* 1. Redistributions of source code must retain the above |
|
9 |
* copyright notice, this list of conditions and the following |
|
10 |
* disclaimer. |
|
11 |
* |
|
12 |
* 2. Redistributions in binary form must reproduce the above |
|
13 |
* copyright notice, this list of conditions and the following |
|
14 |
* disclaimer in the documentation and/or other materials |
|
15 |
* provided with the distribution. |
|
16 |
* |
|
17 |
* THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS |
|
18 |
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
19 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
20 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR |
|
21 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
22 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
23 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
24 |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
25 |
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
26 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
27 |
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
28 |
* POSSIBILITY OF SUCH DAMAGE. |
|
29 |
* |
|
30 |
* The views and conclusions contained in the software and |
|
31 |
* documentation are those of the authors and should not be |
|
32 |
* interpreted as representing official policies, either expressed |
|
33 |
* or implied, of GRNET S.A. |
|
34 |
*/ |
|
35 |
package gr.grnet.pithos.web.client.commands; |
|
36 |
|
|
37 |
import gr.grnet.pithos.web.client.Pithos; |
|
38 |
import gr.grnet.pithos.web.client.foldertree.Folder; |
|
39 |
|
|
40 |
import com.google.gwt.user.client.Command; |
|
41 |
import com.google.gwt.user.client.ui.PopupPanel; |
|
42 |
|
|
43 |
|
|
44 |
/** |
|
45 |
* Command to empty trash bin. |
|
46 |
*/ |
|
47 |
public class EmptyContainerCommand implements Command{ |
|
48 |
private PopupPanel containerPanel; |
|
49 |
|
|
50 |
Pithos app; |
|
51 |
|
|
52 |
Folder container; |
|
53 |
|
|
54 |
public EmptyContainerCommand(Pithos _app, PopupPanel _containerPanel, Folder _container){ |
|
55 |
app = _app; |
|
56 |
containerPanel = _containerPanel; |
|
57 |
container = _container; |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
public void execute() { |
|
62 |
if (containerPanel != null) |
|
63 |
containerPanel.hide(); |
|
64 |
|
|
65 |
app.emptyContainer(container); |
|
66 |
} |
|
67 |
} |
b/src/gr/grnet/pithos/web/client/commands/PurgeContainerCommand.java | ||
---|---|---|
1 |
/* |
|
2 |
* Copyright 2011-2013 GRNET S.A. All rights reserved. |
|
3 |
* |
|
4 |
* Redistribution and use in source and binary forms, with or |
|
5 |
* without modification, are permitted provided that the following |
|
6 |
* conditions are met: |
|
7 |
* |
|
8 |
* 1. Redistributions of source code must retain the above |
|
9 |
* copyright notice, this list of conditions and the following |
|
10 |
* disclaimer. |
|
11 |
* |
|
12 |
* 2. Redistributions in binary form must reproduce the above |
|
13 |
* copyright notice, this list of conditions and the following |
|
14 |
* disclaimer in the documentation and/or other materials |
|
15 |
* provided with the distribution. |
|
16 |
* |
|
17 |
* THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS |
|
18 |
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
19 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
20 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR |
|
21 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
22 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
23 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
24 |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
25 |
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
26 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
27 |
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
28 |
* POSSIBILITY OF SUCH DAMAGE. |
|
29 |
* |
|
30 |
* The views and conclusions contained in the software and |
|
31 |
* documentation are those of the authors and should not be |
|
32 |
* interpreted as representing official policies, either expressed |
|
33 |
* or implied, of GRNET S.A. |
|
34 |
*/ |
|
35 |
package gr.grnet.pithos.web.client.commands; |
|
36 |
|
|
37 |
import gr.grnet.pithos.web.client.GroupCreateDialog; |
|
38 |
import gr.grnet.pithos.web.client.Pithos; |
|
39 |
import gr.grnet.pithos.web.client.PurgeContainerDialog; |
|
40 |
import gr.grnet.pithos.web.client.foldertree.Folder; |
|
41 |
|
|
42 |
import com.google.gwt.user.client.Command; |
|
43 |
import com.google.gwt.user.client.ui.PopupPanel; |
|
44 |
|
|
45 |
|
|
46 |
/** |
|
47 |
* Command to empty trash bin. |
|
48 |
*/ |
|
49 |
public class PurgeContainerCommand implements Command{ |
|
50 |
private final PopupPanel containerPanel; |
|
51 |
|
|
52 |
private final Pithos app; |
|
53 |
|
|
54 |
private final Folder container; |
|
55 |
|
|
56 |
public PurgeContainerCommand(Pithos app, PopupPanel containerPanel, Folder container){ |
|
57 |
this.app = app; |
|
58 |
this.containerPanel = containerPanel; |
|
59 |
this.container = container; |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public void execute() { |
|
64 |
if(containerPanel != null) { |
|
65 |
containerPanel.hide(); |
|
66 |
} |
|
67 |
PurgeContainerDialog dlg = new PurgeContainerDialog(app, container); |
|
68 |
dlg.center(); |
|
69 |
} |
|
70 |
} |
b/src/gr/grnet/pithos/web/client/rest/DeleteRequest.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
package gr.grnet.pithos.web.client.rest; |
37 | 37 |
|
38 |
import gr.grnet.pithos.web.client.Pithos; |
|
38 | 39 |
import gr.grnet.pithos.web.client.Resource; |
39 | 40 |
|
40 | 41 |
import java.util.HashMap; |
... | ... | |
77 | 78 |
|
78 | 79 |
@Override |
79 | 80 |
public void execute() { |
81 |
Pithos.LOG("DELETE api = ", api, ", owner = ", owner, ", path = ", path); |
|
82 |
Pithos.LOG(" ==> ", api + owner + path); |
|
80 | 83 |
RequestBuilder builder = new RequestBuilder(RequestBuilder.DELETE, api + owner + path); |
81 | 84 |
for (String header : headers.keySet()) { |
82 | 85 |
builder.setHeader(header, headers.get(header)); |
... | ... | |
112 | 115 |
retries++; |
113 | 116 |
} |
114 | 117 |
catch (RequestException e) { |
118 |
Pithos.LOG(e); |
|
115 | 119 |
} |
116 | 120 |
} |
117 | 121 |
|
b/src/gr/grnet/pithos/web/client/rest/GetRequest.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
package gr.grnet.pithos.web.client.rest; |
37 | 37 |
|
38 |
import gr.grnet.pithos.web.client.Pithos; |
|
38 | 39 |
import gr.grnet.pithos.web.client.Resource; |
39 | 40 |
|
40 | 41 |
import java.util.HashMap; |
... | ... | |
82 | 83 |
|
83 | 84 |
public GetRequest(Class<T> resourceClass, String api, String owner, String path) { |
84 | 85 |
this(resourceClass, api, owner, path, -1, null); |
85 |
LOG("GetRequest() resourceClass = ", resourceClass.getName(), ", api=", api, ", owner=", owner, ", path=", path); |
|
86 |
Pithos.LOG("GetRequest() resourceClass = ", resourceClass.getName(), ", api=", api, ", owner=", owner, ", path=", path);
|
|
86 | 87 |
} |
87 | 88 |
|
88 | 89 |
public GetRequest(Class<T> resourceClass, String api, String owner, String path, T result) { |
89 | 90 |
this(resourceClass, api, owner, path, -1, result); |
90 | 91 |
} |
91 | 92 |
|
92 |
static native void __ConsoleLog(String message) /*-{ |
|
93 |
try { |
|
94 |
console.log(message); |
|
95 |
} catch (e) { |
|
96 |
} |
|
97 |
}-*/; |
|
98 |
|
|
99 |
public static void LOG(Object ...args) { |
|
100 |
if(false) { |
|
101 |
final StringBuilder sb = new StringBuilder(); |
|
102 |
for(Object arg : args) { |
|
103 |
sb.append(arg); |
|
104 |
} |
|
105 |
if(sb.length() > 0) { |
|
106 |
__ConsoleLog(sb.toString()); |
|
107 |
} |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 | 93 |
@Override |
112 | 94 |
public void execute() { |
113 | 95 |
if (path.contains("?")) |
114 | 96 |
path += "&t=" + System.currentTimeMillis(); |
115 | 97 |
else |
116 | 98 |
path += "?t=" + System.currentTimeMillis(); |
117 |
LOG("GET api = ", api, ", owner = ", owner, ", path = ", path); |
|
118 |
LOG(" ==> ", api + owner + path); |
|
99 |
Pithos.LOG("GET api = ", api, ", owner = ", owner, ", path = ", path);
|
|
100 |
Pithos.LOG(" ==> ", api + owner + path);
|
|
119 | 101 |
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, api + owner + path); |
120 | 102 |
|
121 | 103 |
for (String header : headers.keySet()) { |
... | ... | |
137 | 119 |
public void onError(Request request, Throwable throwable) { |
138 | 120 |
if (throwable instanceof RestException) { |
139 | 121 |
if (((RestException) throwable).getHttpStatusCode() == 304 && result != null){ |
140 |
GWT.log("Using cache: " + result.toString(), null);
|
|
122 |
Pithos.LOG("Using cache: ", result.toString());
|
|
141 | 123 |
onSuccess(result); |
142 | 124 |
return; |
143 | 125 |
} |
... | ... | |
153 | 135 |
retries++; |
154 | 136 |
} |
155 | 137 |
catch (RequestException e) { |
156 |
LOG("Error in GetRequest: ", e.toString());
|
|
138 |
Pithos.LOG("Error in GetRequest", e);
|
|
157 | 139 |
} |
158 | 140 |
} |
159 | 141 |
|
b/src/gr/grnet/pithos/web/client/rest/HeadRequest.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
package gr.grnet.pithos.web.client.rest; |
37 | 37 |
|
38 |
import gr.grnet.pithos.web.client.Pithos; |
|
38 | 39 |
import gr.grnet.pithos.web.client.Resource; |
39 | 40 |
|
40 | 41 |
import java.util.HashMap; |
... | ... | |
96 | 97 |
path += "&t=" + System.currentTimeMillis(); |
97 | 98 |
else |
98 | 99 |
path += "?t=" + System.currentTimeMillis(); |
100 |
Pithos.LOG("HEAD api = ", api, ", owner = ", owner, ", path = ", path); |
|
101 |
Pithos.LOG(" ==> ", api + owner + path); |
|
99 | 102 |
RequestBuilder builder = new RequestBuilder(RequestBuilder.HEAD, api + owner + path); |
100 | 103 |
for (String header : headers.keySet()) { |
101 | 104 |
builder.setHeader(header, headers.get(header)); |
... | ... | |
132 | 135 |
retries++; |
133 | 136 |
} |
134 | 137 |
catch (RequestException e) { |
138 |
Pithos.LOG(e); |
|
135 | 139 |
} |
136 | 140 |
} |
137 | 141 |
|
b/src/gr/grnet/pithos/web/client/rest/PostRequest.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
package gr.grnet.pithos.web.client.rest; |
37 | 37 |
|
38 |
import gr.grnet.pithos.web.client.Pithos; |
|
38 | 39 |
import gr.grnet.pithos.web.client.Resource; |
39 | 40 |
|
40 | 41 |
import java.util.HashMap; |
... | ... | |
79 | 80 |
@Override |
80 | 81 |
public void execute() { |
81 | 82 |
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, api + owner + path); |
83 |
Pithos.LOG("POST api = ", api, ", owner = ", owner, ", path = ", path); |
|
84 |
Pithos.LOG(" ==> ", api + owner + path); |
|
82 | 85 |
for (String header : headers.keySet()) { |
83 | 86 |
builder.setHeader(header, headers.get(header)); |
84 | 87 |
} |
... | ... | |
106 | 109 |
}); |
107 | 110 |
} |
108 | 111 |
catch (RequestException e) { |
109 |
GWT.log("", e);
|
|
112 |
Pithos.LOG(e);
|
|
110 | 113 |
} |
111 | 114 |
} |
112 | 115 |
|
b/src/gr/grnet/pithos/web/client/rest/PutRequest.java | ||
---|---|---|
70 | 70 |
|
71 | 71 |
package gr.grnet.pithos.web.client.rest; |
72 | 72 |
|
73 |
import gr.grnet.pithos.web.client.Pithos; |
|
73 | 74 |
import gr.grnet.pithos.web.client.Resource; |
74 | 75 |
|
75 | 76 |
import java.util.HashMap; |
... | ... | |
104 | 105 |
@Override |
105 | 106 |
public void execute() { |
106 | 107 |
RequestBuilder builder = new RequestBuilder(RequestBuilder.PUT, api + owner + path); |
108 |
Pithos.LOG("PUT api = ", api, ", owner = ", owner, ", path = ", path); |
|
109 |
Pithos.LOG(" ==> ", api + owner + path); |
|
107 | 110 |
for (String header : headers.keySet()) { |
108 | 111 |
builder.setHeader(header, headers.get(header)); |
109 | 112 |
} |
... | ... | |
131 | 134 |
}); |
132 | 135 |
} |
133 | 136 |
catch (RequestException e) { |
137 |
Pithos.LOG(e); |
|
134 | 138 |
} |
135 | 139 |
} |
136 | 140 |
|
b/src/gr/grnet/pithos/web/client/rest/RestRequestCallback.java | ||
---|---|---|
38 | 38 |
import com.google.gwt.http.client.Request; |
39 | 39 |
import com.google.gwt.http.client.RequestCallback; |
40 | 40 |
import com.google.gwt.http.client.Response; |
41 |
import gr.grnet.pithos.web.client.Pithos; |
|
41 | 42 |
import gr.grnet.pithos.web.client.Resource; |
42 | 43 |
|
43 | 44 |
public abstract class RestRequestCallback<T extends Resource> implements RequestCallback { |
... | ... | |
81 | 82 |
onError(request, new RestException(path, response.getStatusCode(), statusText, text)); |
82 | 83 |
} |
83 | 84 |
} catch (Exception e) { |
85 |
Pithos.LOG(e); |
|
84 | 86 |
onError(request, e); |
85 | 87 |
} |
86 | 88 |
} |
Also available in: Unified diff