Revision a39e5b47
b/web_client/src/gr/grnet/pithos/web/client/AbstractPropertiesDialog.java | ||
---|---|---|
90 | 90 |
} |
91 | 91 |
/** |
92 | 92 |
* Retrieves all user tags from the server and updates the FlowPanel |
93 |
* |
|
94 |
* @param userId |
|
95 | 93 |
*/ |
96 | 94 |
protected void updateTags() { |
97 | 95 |
GetCommand<TagsResource> tc = new GetCommand<TagsResource>(TagsResource.class, Pithos.get().getCurrentUserResource().getTagsPath(),null) { |
b/web_client/src/gr/grnet/pithos/web/client/FileList.java | ||
---|---|---|
663 | 663 |
Folder selectedItem = treeView.getSelection(); |
664 | 664 |
|
665 | 665 |
provider.setList(files); |
666 |
selectionModel.clear(); |
|
666 | 667 |
} |
667 | 668 |
|
668 | 669 |
/** |
b/web_client/src/gr/grnet/pithos/web/client/FilePropertiesDialog.java | ||
---|---|---|
35 | 35 |
package gr.grnet.pithos.web.client; |
36 | 36 |
|
37 | 37 |
import com.google.gwt.core.client.Scheduler; |
38 |
import com.google.gwt.json.client.JSONArray; |
|
39 |
import com.google.gwt.json.client.JSONString; |
|
40 |
import com.google.gwt.user.client.ui.Anchor; |
|
41 |
import com.google.gwt.user.client.ui.Label; |
|
38 | 42 |
import gr.grnet.pithos.web.client.foldertree.File; |
39 | 43 |
import gr.grnet.pithos.web.client.foldertree.Resource; |
40 | 44 |
import gr.grnet.pithos.web.client.rest.PostCommand; |
45 |
import gr.grnet.pithos.web.client.rest.PostRequest; |
|
41 | 46 |
import gr.grnet.pithos.web.client.rest.PutRequest; |
42 | 47 |
import gr.grnet.pithos.web.client.rest.RestException; |
43 | 48 |
|
... | ... | |
62 | 67 |
import com.google.gwt.user.client.ui.HorizontalPanel; |
63 | 68 |
import com.google.gwt.user.client.ui.TextBox; |
64 | 69 |
import com.google.gwt.user.client.ui.VerticalPanel; |
70 |
import gr.grnet.pithos.web.client.tagtree.Tag; |
|
71 |
import java.util.Iterator; |
|
65 | 72 |
|
66 | 73 |
/** |
67 | 74 |
* The 'File properties' dialog box implementation. |
... | ... | |
170 | 177 |
|
171 | 178 |
focusPanel.setFocus(true); |
172 | 179 |
setWidget(outer); |
173 |
|
|
174 |
// Asynchronously retrieve the tags defined by this user. |
|
175 |
DeferredCommand.addCommand(new Command() { |
|
176 |
|
|
177 |
@Override |
|
178 |
public void execute() { |
|
179 |
// updateTags(); |
|
180 |
} |
|
181 |
}); |
|
182 | 180 |
} |
183 | 181 |
|
184 | 182 |
private VerticalPanel createGeneralPanel() { |
... | ... | |
188 | 186 |
generalTable.setText(1, 0, "Folder"); |
189 | 187 |
generalTable.setText(2, 0, "Owner"); |
190 | 188 |
generalTable.setText(3, 0, "Last modified"); |
191 |
// generalTable.setText(4, 0, "Tags");
|
|
189 |
generalTable.setText(4, 0, "Tags"); |
|
192 | 190 |
|
193 | 191 |
name.setWidth("100%"); |
194 | 192 |
name.setText(file.getName()); |
... | ... | |
202 | 200 |
final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a"); |
203 | 201 |
generalTable.setText(3, 1, formatter.format(file.getLastModified())); |
204 | 202 |
|
205 |
// Get the tags. |
|
206 |
// StringBuffer tagsBuffer = new StringBuffer(); |
|
207 |
// Iterator i = file.getTags().iterator(); |
|
208 |
// while (i.hasNext()) { |
|
209 |
// String tag = (String) i.next(); |
|
210 |
// tagsBuffer.append(tag).append(", "); |
|
211 |
// } |
|
212 |
// if (tagsBuffer.length() > 1) |
|
213 |
// tagsBuffer.delete(tagsBuffer.length() - 2, tagsBuffer.length() - 1); |
|
214 |
// initialTagText = tagsBuffer.toString(); |
|
215 |
// tags.setWidth("100%"); |
|
216 |
// tags.getElement().setId("filePropertiesDialog.textBox.tags"); |
|
217 |
// tags.setText(initialTagText); |
|
218 |
// generalTable.setWidget(4, 1, tags); |
|
203 |
StringBuffer tagsBuffer = new StringBuffer(); |
|
204 |
for (String t : file.getTags()) |
|
205 |
tagsBuffer.append(t).append(", "); |
|
206 |
if (tagsBuffer.length() > 1) |
|
207 |
tagsBuffer.delete(tagsBuffer.length() - 2, tagsBuffer.length() - 1); |
|
208 |
initialTagText = tagsBuffer.toString(); |
|
209 |
tags.setWidth("100%"); |
|
210 |
tags.setText(initialTagText); |
|
211 |
generalTable.setWidget(4, 1, tags); |
|
219 | 212 |
|
220 | 213 |
generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels"); |
221 | 214 |
generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels"); |
222 | 215 |
generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels"); |
223 | 216 |
generalTable.getFlexCellFormatter().setStyleName(3, 0, "props-labels"); |
224 |
// generalTable.getFlexCellFormatter().setStyleName(4, 0, "props-labels");
|
|
217 |
generalTable.getFlexCellFormatter().setStyleName(4, 0, "props-labels"); |
|
225 | 218 |
generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values"); |
226 | 219 |
generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values"); |
227 | 220 |
generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values"); |
228 | 221 |
generalTable.getFlexCellFormatter().setStyleName(3, 1, "props-values"); |
229 |
// generalTable.getFlexCellFormatter().setStyleName(4, 1, "props-values");
|
|
222 |
generalTable.getFlexCellFormatter().setStyleName(4, 1, "props-values"); |
|
230 | 223 |
generalTable.setCellSpacing(4); |
231 | 224 |
|
232 | 225 |
generalPanel.add(generalTable); |
... | ... | |
234 | 227 |
DisclosurePanel allTags = new DisclosurePanel("All tags"); |
235 | 228 |
allTagsContent = new FlowPanel(); |
236 | 229 |
allTagsContent.setWidth("100%"); |
230 |
for (Tag t : app.getAllTags()) { |
|
231 |
final Anchor tagAnchor = new Anchor(t.getName(), false); |
|
232 |
tagAnchor.addStyleName("pithos-tag"); |
|
233 |
allTagsContent.add(tagAnchor); |
|
234 |
Label separator = new Label(", "); |
|
235 |
separator.addStyleName("pithos-tag"); |
|
236 |
allTagsContent.add(separator); |
|
237 |
tagAnchor.addClickHandler(new ClickHandler() { |
|
238 |
|
|
239 |
@Override |
|
240 |
public void onClick(ClickEvent event) { |
|
241 |
String existing = tags.getText().trim(); |
|
242 |
if (MULTIPLE_VALUES_TEXT.equals(existing)) |
|
243 |
existing = ""; |
|
244 |
String newTag = tagAnchor.getText().trim(); |
|
245 |
// insert the new tag only if it is not in the list |
|
246 |
// already |
|
247 |
if (existing.indexOf(newTag) == -1) |
|
248 |
tags.setText(existing + (existing.length() > 0 ? ", " : "") + newTag); |
|
249 |
} |
|
250 |
}); |
|
251 |
} |
|
237 | 252 |
allTags.setContent(allTagsContent); |
238 | 253 |
generalPanel.add(allTags); |
239 | 254 |
generalPanel.setSpacing(4); |
... | ... | |
389 | 404 |
// permList.updatePermissionsAccordingToInput(); |
390 | 405 |
// Set<PermissionHolder> perms = permList.getPermissions(); |
391 | 406 |
// JSONObject json = new JSONObject(); |
392 |
if (!name.getText().equals(file.getName())) { |
|
393 |
newFilename = name.getText(); |
|
407 |
if (!name.getText().trim().equals(file.getName())) {
|
|
408 |
newFilename = name.getText().trim();
|
|
394 | 409 |
// json.put("name", new JSONString(newFilename)); |
395 | 410 |
} |
396 | 411 |
// if (versioned.getValue() != file.isVersioned()) |
... | ... | |
418 | 433 |
// } |
419 | 434 |
// json.put("permissions", perma); |
420 | 435 |
// } |
421 |
// JSONArray taga = new JSONArray(); |
|
422 |
// i = 0; |
|
423 |
// if (!tags.getText().equals(initialTagText)) { |
|
424 |
// String[] tagset = tags.getText().split(","); |
|
425 |
// for (String t : tagset) { |
|
426 |
// JSONString to = new JSONString(t); |
|
427 |
// taga.set(i, to); |
|
428 |
// i++; |
|
429 |
// } |
|
430 |
// json.put("tags", taga); |
|
431 |
// } |
|
436 |
String[] tagset = null; |
|
437 |
if (!tags.getText().equals(initialTagText)) |
|
438 |
tagset = tags.getText().split(","); |
|
432 | 439 |
// String jsonString = json.toString(); |
433 | 440 |
// if(jsonString.equals("{}")){ |
434 | 441 |
// GWT.log("NO CHANGES", null); |
435 | 442 |
// return; |
436 | 443 |
// } |
437 |
final String newFilenameFinal = newFilename; |
|
444 |
final String[] newTags = tagset; |
|
445 |
|
|
446 |
if (newFilename != null) { |
|
447 |
final String path = app.getApiPath() + app.getUsername() + file.getParent().getUri() + "/" + newFilename; |
|
448 |
PutRequest updateFile = new PutRequest(path) { |
|
449 |
@Override |
|
450 |
public void onSuccess(Resource result) { |
|
451 |
if (newTags != null) |
|
452 |
updateMetaData(path + "?update=", newTags); |
|
453 |
else |
|
454 |
app.updateFolder(file.getParent()); |
|
455 |
} |
|
456 |
|
|
457 |
@Override |
|
458 |
public void onError(Throwable t) { |
|
459 |
GWT.log("", t); |
|
460 |
app.displayError("System error modifying file:" + t.getMessage()); |
|
461 |
} |
|
462 |
}; |
|
463 |
updateFile.setHeader("X-Auth-Token", app.getToken()); |
|
464 |
updateFile.setHeader("X-Move-From", file.getUri()); |
|
465 |
updateFile.setHeader("Content-Type", file.getContentType()); |
|
466 |
Scheduler.get().scheduleDeferred(updateFile); |
|
467 |
} |
|
468 |
else if (newTags != null) |
|
469 |
updateMetaData(app.getApiPath() + app.getUsername() + file.getUri() + "?update=", newTags); |
|
470 |
} |
|
438 | 471 |
|
439 |
if (newFilename == null) |
|
440 |
return; |
|
441 |
String path = app.getApiPath() + app.getUsername() + file.getParent().getUri() + "/" + newFilename; |
|
442 |
PutRequest updateFile = new PutRequest(path) { |
|
472 |
private void updateMetaData(String path, String[] newTags) { |
|
473 |
PostRequest updateFile = new PostRequest(path) { |
|
443 | 474 |
@Override |
444 | 475 |
public void onSuccess(Resource result) { |
445 | 476 |
app.updateFolder(file.getParent()); |
... | ... | |
452 | 483 |
} |
453 | 484 |
}; |
454 | 485 |
updateFile.setHeader("X-Auth-Token", app.getToken()); |
455 |
updateFile.setHeader("X-Move-From", file.getUri());
|
|
456 |
updateFile.setHeader("Content-Type", file.getContentType());
|
|
486 |
for (String t : newTags)
|
|
487 |
updateFile.setHeader("X-Object-Meta-" + t.trim(), "true");
|
|
457 | 488 |
Scheduler.get().scheduleDeferred(updateFile); |
458 |
}
|
|
489 |
}
|
|
459 | 490 |
|
460 | 491 |
private void removeAllOldVersions() { |
461 | 492 |
JSONObject json = new JSONObject(); |
b/web_client/src/gr/grnet/pithos/web/client/Pithos.java | ||
---|---|---|
74 | 74 |
import gr.grnet.pithos.web.client.tagtree.TagTreeViewModel; |
75 | 75 |
import java.util.ArrayList; |
76 | 76 |
import java.util.Arrays; |
77 |
import java.util.Collection; |
|
77 | 78 |
import java.util.Date; |
78 | 79 |
import java.util.HashMap; |
79 | 80 |
import java.util.Iterator; |
... | ... | |
141 | 142 |
} |
142 | 143 |
|
143 | 144 |
public void updateTags() { |
144 |
tagTreeViewModel.initialize(account); |
|
145 |
tagTreeViewModel.initialize(getAllTags()); |
|
146 |
} |
|
147 |
|
|
148 |
public List<Tag> getAllTags() { |
|
149 |
List<Tag> tagList = new ArrayList<Tag>(); |
|
150 |
for (Folder f : account.getContainers()) { |
|
151 |
for (String t : f.getTags()) { |
|
152 |
tagList.add(new Tag(t)); |
|
153 |
} |
|
154 |
} |
|
155 |
return tagList; |
|
145 | 156 |
} |
146 | 157 |
|
147 | 158 |
/** |
... | ... | |
461 | 472 |
|
462 | 473 |
// Window.Location.assign(GWT.getModuleBaseURL() + conf.loginUrl() + "?next=" + Window.Location.getHref()); |
463 | 474 |
Cookies.setCookie(conf.authCookie(), "test" + conf.cookieSeparator() + "0000"); |
464 |
Window.Location.assign(GWT.getModuleBaseURL() + "Pithos.html");
|
|
475 |
Window.Location.assign(GWT.getModuleBaseURL() + "pithos.html");
|
|
465 | 476 |
} |
466 | 477 |
|
467 | 478 |
private void fetchAccount() { |
b/web_client/src/gr/grnet/pithos/web/client/foldertree/File.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
package gr.grnet.pithos.web.client.foldertree; |
37 | 37 |
|
38 |
import com.google.gwt.http.client.Header; |
|
38 | 39 |
import com.google.gwt.http.client.Response; |
39 | 40 |
import com.google.gwt.i18n.client.DateTimeFormat; |
40 | 41 |
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat; |
... | ... | |
42 | 43 |
import com.google.gwt.json.client.JSONObject; |
43 | 44 |
import com.google.gwt.json.client.JSONParser; |
44 | 45 |
import com.google.gwt.json.client.JSONValue; |
46 |
import java.io.StringWriter; |
|
47 |
import java.security.Key; |
|
45 | 48 |
import java.util.Date; |
49 |
import java.util.HashSet; |
|
50 |
import java.util.Set; |
|
46 | 51 |
|
47 | 52 |
public class File extends Resource { |
48 | 53 |
private String name; |
... | ... | |
71 | 76 |
|
72 | 77 |
private Folder parent; |
73 | 78 |
|
79 |
private Set<String> tags = new HashSet<String>(); |
|
80 |
|
|
74 | 81 |
public String getContentType() { |
75 | 82 |
return contentType; |
76 | 83 |
} |
... | ... | |
149 | 156 |
modifiedBy = unmarshallString(o, "modified_by"); |
150 | 157 |
versionTimestamp = unmarshallDate(o, "version_timestamp"); |
151 | 158 |
this.container = container; |
159 |
|
|
160 |
for (String key : o.keySet()) |
|
161 |
if (key.startsWith("x_object_meta_") && !key.equals("x_object_meta_trash")) |
|
162 |
tags.add(key.substring("x_object_meta_".length()).trim().toLowerCase()); |
|
152 | 163 |
} |
153 | 164 |
|
154 | 165 |
public boolean equals(Object other) { |
... | ... | |
173 | 184 |
} |
174 | 185 |
|
175 | 186 |
private void populate(Response response) { |
187 |
for (Header h : response.getHeaders()) { |
|
188 |
String header = h.getName(); |
|
189 |
if (header.startsWith("X-Object-Meta-") && !header.equals("X-Object-Meta-Trash")) |
|
190 |
tags.add(header.substring("X-Object-Meta-".length()).trim().toLowerCase()); |
|
191 |
|
|
192 |
} |
|
176 | 193 |
String header = response.getHeader("X-Object-Meta-Trash"); |
177 | 194 |
if (header != null) |
178 | 195 |
inTrash = Boolean.valueOf(header); |
... | ... | |
186 | 203 |
public Folder getParent() { |
187 | 204 |
return parent; |
188 | 205 |
} |
206 |
|
|
207 |
public Set<String> getTags() { |
|
208 |
return tags; |
|
209 |
} |
|
189 | 210 |
} |
b/web_client/src/gr/grnet/pithos/web/client/foldertree/Folder.java | ||
---|---|---|
142 | 142 |
inTrash = true; |
143 | 143 |
|
144 | 144 |
header = response.getHeader("X-Container-Object-Meta"); |
145 |
if (header != null && header.length() > 2) { |
|
146 |
String tagStr = header.substring(1, header.length() - 1); |
|
147 |
while (tagStr.indexOf(",") > -1) { |
|
148 |
String tag = tagStr.substring(2, tagStr.indexOf(",") - 1); |
|
149 |
tags.add(tag); |
|
150 |
tagStr = tagStr.substring(tagStr.indexOf(",") + 1).trim(); |
|
145 |
if (header != null && header.length() > 0) { |
|
146 |
for (String t : header.split(",")) { |
|
147 |
tags.add(t.toLowerCase().trim()); |
|
151 | 148 |
} |
152 |
tags.add(tagStr.substring(2, tagStr.length() - 1)); |
|
153 | 149 |
} |
154 | 150 |
|
155 | 151 |
subfolders.clear(); //This is necessary in case we update a pre-existing Folder so that stale subfolders won't show up |
b/web_client/src/gr/grnet/pithos/web/client/tagtree/TagTreeViewModel.java | ||
---|---|---|
203 | 203 |
} |
204 | 204 |
} |
205 | 205 |
|
206 |
public void initialize(AccountResource account) { |
|
207 |
List<Tag> tagList = tagDataProvider.getList(); |
|
208 |
for (Folder f : account.getContainers()) { |
|
209 |
for (String t : f.getTags()) |
|
210 |
tagList.add(new Tag(t)); |
|
211 |
} |
|
206 |
public void initialize(List<Tag> allTags) { |
|
207 |
tagDataProvider.getList().addAll(allTags); |
|
212 | 208 |
rootDataProvider.getList().add("Tags"); |
213 | 209 |
} |
214 | 210 |
} |
Also available in: Unified diff