Statistics
| Branch: | Tag: | Revision:

root / src / gr / grnet / pithos / web / client / FilePropertiesDialog.java @ cae2a8db

History | View | Annotate | Download (12.8 kB)

1 a57faaf0 Christos Stathis
/*
2 cae2a8db Christos Stathis
 * Copyright 2011-2012 GRNET S.A. All rights reserved.
3 63366925 Christos Stathis
 *
4 63366925 Christos Stathis
 * Redistribution and use in source and binary forms, with or
5 63366925 Christos Stathis
 * without modification, are permitted provided that the following
6 63366925 Christos Stathis
 * conditions are met:
7 63366925 Christos Stathis
 *
8 63366925 Christos Stathis
 *   1. Redistributions of source code must retain the above
9 63366925 Christos Stathis
 *      copyright notice, this list of conditions and the following
10 63366925 Christos Stathis
 *      disclaimer.
11 63366925 Christos Stathis
 *
12 63366925 Christos Stathis
 *   2. Redistributions in binary form must reproduce the above
13 63366925 Christos Stathis
 *      copyright notice, this list of conditions and the following
14 63366925 Christos Stathis
 *      disclaimer in the documentation and/or other materials
15 63366925 Christos Stathis
 *      provided with the distribution.
16 63366925 Christos Stathis
 *
17 63366925 Christos Stathis
 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18 63366925 Christos Stathis
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 63366925 Christos Stathis
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 63366925 Christos Stathis
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21 63366925 Christos Stathis
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 63366925 Christos Stathis
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 63366925 Christos Stathis
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24 63366925 Christos Stathis
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 63366925 Christos Stathis
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 63366925 Christos Stathis
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 63366925 Christos Stathis
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 63366925 Christos Stathis
 * POSSIBILITY OF SUCH DAMAGE.
29 63366925 Christos Stathis
 *
30 63366925 Christos Stathis
 * The views and conclusions contained in the software and
31 63366925 Christos Stathis
 * documentation are those of the authors and should not be
32 63366925 Christos Stathis
 * interpreted as representing official policies, either expressed
33 63366925 Christos Stathis
 * or implied, of GRNET S.A.
34 a57faaf0 Christos Stathis
 */
35 a57faaf0 Christos Stathis
package gr.grnet.pithos.web.client;
36 a57faaf0 Christos Stathis
37 31997f49 Christos Stathis
import gr.grnet.pithos.web.client.foldertree.File;
38 31997f49 Christos Stathis
import gr.grnet.pithos.web.client.foldertree.Resource;
39 ef5b664d Christos Stathis
import gr.grnet.pithos.web.client.rest.PostRequest;
40 31997f49 Christos Stathis
import gr.grnet.pithos.web.client.rest.PutRequest;
41 7811b9d1 Christos Stathis
42 947da718 Christos Stathis
import java.util.HashMap;
43 7811b9d1 Christos Stathis
import java.util.Map;
44 a57faaf0 Christos Stathis
45 a57faaf0 Christos Stathis
import com.google.gwt.core.client.GWT;
46 7811b9d1 Christos Stathis
import com.google.gwt.core.client.Scheduler;
47 a57faaf0 Christos Stathis
import com.google.gwt.event.dom.client.ClickEvent;
48 a57faaf0 Christos Stathis
import com.google.gwt.event.dom.client.ClickHandler;
49 9539e23d Christos Stathis
import com.google.gwt.http.client.Response;
50 ea94470a Christos Stathis
import com.google.gwt.http.client.URL;
51 a57faaf0 Christos Stathis
import com.google.gwt.i18n.client.DateTimeFormat;
52 3601b114 Christos Stathis
import com.google.gwt.user.client.Command;
53 7811b9d1 Christos Stathis
import com.google.gwt.user.client.ui.Anchor;
54 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.Button;
55 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.FlexTable;
56 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
57 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.HorizontalPanel;
58 947da718 Christos Stathis
import com.google.gwt.user.client.ui.Image;
59 7811b9d1 Christos Stathis
import com.google.gwt.user.client.ui.Label;
60 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.TextBox;
61 a57faaf0 Christos Stathis
import com.google.gwt.user.client.ui.VerticalPanel;
62 a57faaf0 Christos Stathis
63 a57faaf0 Christos Stathis
/**
64 a57faaf0 Christos Stathis
 * The 'File properties' dialog box implementation.
65 a57faaf0 Christos Stathis
 *
66 a57faaf0 Christos Stathis
 */
67 a57faaf0 Christos Stathis
public class FilePropertiesDialog extends AbstractPropertiesDialog {
68 a57faaf0 Christos Stathis
69 a57faaf0 Christos Stathis
        /**
70 a57faaf0 Christos Stathis
         * The widget that holds the name of the file.
71 a57faaf0 Christos Stathis
         */
72 a57faaf0 Christos Stathis
        private TextBox name = new TextBox();
73 a57faaf0 Christos Stathis
74 31997f49 Christos Stathis
        final File file;
75 a57faaf0 Christos Stathis
76 904447e4 Christos Stathis
    FlexTable metaTable;
77 a57faaf0 Christos Stathis
        /**
78 a57faaf0 Christos Stathis
         * The widget's constructor.
79 a57faaf0 Christos Stathis
         */
80 749068ba Christos Stathis
        public FilePropertiesDialog(Pithos _app, File _file) {
81 a7c43f26 Christos Stathis
        super(_app);
82 31997f49 Christos Stathis
        file = _file;
83 a57faaf0 Christos Stathis
84 4420a247 Christos Stathis
                Anchor close = new Anchor();
85 4420a247 Christos Stathis
                close.addStyleName("close");
86 4420a247 Christos Stathis
                close.addClickHandler(new ClickHandler() {
87 4420a247 Christos Stathis
                        
88 4420a247 Christos Stathis
                        @Override
89 ebead1b5 Christos Stathis
                        public void onClick(ClickEvent event) {
90 4420a247 Christos Stathis
                                hide();
91 4420a247 Christos Stathis
                        }
92 4420a247 Christos Stathis
                });
93 a57faaf0 Christos Stathis
                // Set the dialog's caption.
94 a57faaf0 Christos Stathis
                setText("File properties");
95 4420a247 Christos Stathis
                setAnimationEnabled(true);
96 4420a247 Christos Stathis
                setGlassEnabled(true);
97 4420a247 Christos Stathis
                setStyleName("pithos-DialogBox");
98 a57faaf0 Christos Stathis
99 a57faaf0 Christos Stathis
                // Outer contains inner and buttons.
100 a57faaf0 Christos Stathis
                final VerticalPanel outer = new VerticalPanel();
101 4420a247 Christos Stathis
                outer.add(close);
102 a57faaf0 Christos Stathis
                // Inner contains generalPanel and permPanel.
103 9326b841 Christos Stathis
                inner = new VerticalPanel();
104 4420a247 Christos Stathis
                inner.addStyleName("inner");
105 a57faaf0 Christos Stathis
106 9326b841 Christos Stathis
        inner.add(createGeneralPanel());
107 a57faaf0 Christos Stathis
108 31997f49 Christos Stathis
        outer.add(inner);
109 31997f49 Christos Stathis
110 a57faaf0 Christos Stathis
                // Create the 'OK' button, along with a listener that hides the dialog
111 a57faaf0 Christos Stathis
                // when the button is clicked.
112 a57faaf0 Christos Stathis
                final Button ok = new Button("OK", new ClickHandler() {
113 a57faaf0 Christos Stathis
                        @Override
114 ebead1b5 Christos Stathis
                        public void onClick(ClickEvent event) {
115 31997f49 Christos Stathis
                                accept();
116 31997f49 Christos Stathis
                                closeDialog();
117 a57faaf0 Christos Stathis
                        }
118 a57faaf0 Christos Stathis
                });
119 4420a247 Christos Stathis
                ok.addStyleName("button");
120 31997f49 Christos Stathis
121 4420a247 Christos Stathis
        outer.add(ok);
122 4420a247 Christos Stathis
        outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
123 31997f49 Christos Stathis
124 31997f49 Christos Stathis
        setWidget(outer);
125 a57faaf0 Christos Stathis
        }
126 a57faaf0 Christos Stathis
127 611de529 Christos Stathis
        private VerticalPanel createGeneralPanel() {
128 31997f49 Christos Stathis
        final VerticalPanel generalPanel = new VerticalPanel();
129 31997f49 Christos Stathis
        final FlexTable generalTable = new FlexTable();
130 31997f49 Christos Stathis
        generalTable.setText(0, 0, "Name");
131 31997f49 Christos Stathis
        generalTable.setText(1, 0, "Folder");
132 31997f49 Christos Stathis
        generalTable.setText(2, 0, "Owner");
133 31997f49 Christos Stathis
        generalTable.setText(3, 0, "Last modified");
134 31997f49 Christos Stathis
135 31997f49 Christos Stathis
        name.setWidth("100%");
136 31997f49 Christos Stathis
        name.setText(file.getName());
137 31997f49 Christos Stathis
        generalTable.setWidget(0, 1, name);
138 31997f49 Christos Stathis
        if(file.getParent() != null)
139 31997f49 Christos Stathis
            generalTable.setText(1, 1, file.getParent().getName());
140 31997f49 Christos Stathis
        else
141 31997f49 Christos Stathis
            generalTable.setText(1, 1, "-");
142 31997f49 Christos Stathis
        generalTable.setText(2, 1, file.getOwner());
143 31997f49 Christos Stathis
144 31997f49 Christos Stathis
        final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
145 f3c8bd5b Christos Stathis
        generalTable.setText(3, 1, file.getLastModified() != null ? formatter.format(file.getLastModified()) : "");
146 31997f49 Christos Stathis
147 31997f49 Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels");
148 31997f49 Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels");
149 31997f49 Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels");
150 31997f49 Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(3, 0, "props-labels");
151 ef5b664d Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(4, 0, "props-labels");
152 31997f49 Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values");
153 31997f49 Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values");
154 31997f49 Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values");
155 31997f49 Christos Stathis
        generalTable.getFlexCellFormatter().setStyleName(3, 1, "props-values");
156 31997f49 Christos Stathis
        generalTable.setCellSpacing(4);
157 31997f49 Christos Stathis
158 31997f49 Christos Stathis
        generalPanel.add(generalTable);
159 31997f49 Christos Stathis
160 904447e4 Christos Stathis
        HorizontalPanel metaTitlePanel = new HorizontalPanel();
161 904447e4 Christos Stathis
        metaTitlePanel.setSpacing(5);
162 947da718 Christos Stathis
        Label meta = new Label("Meta data");
163 904447e4 Christos Stathis
        meta.addStyleName("pithos-metaTitle");
164 904447e4 Christos Stathis
        metaTitlePanel.add(meta);
165 904447e4 Christos Stathis
        
166 947da718 Christos Stathis
                Image plus = new Image("images/plus.png");
167 904447e4 Christos Stathis
                plus.addStyleName("pithos-addMetaImg");
168 904447e4 Christos Stathis
                metaTitlePanel.add(plus);
169 904447e4 Christos Stathis
                
170 904447e4 Christos Stathis
                generalPanel.add(metaTitlePanel);
171 947da718 Christos Stathis
                
172 947da718 Christos Stathis
                metaTable = new FlexTable();
173 947da718 Christos Stathis
                metaTable.setCellSpacing(0);
174 947da718 Christos Stathis
                metaTable.setHTML(0, 0, "Name");
175 947da718 Christos Stathis
                metaTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels");
176 947da718 Christos Stathis
                metaTable.setText(0, 1, "Value");
177 947da718 Christos Stathis
                metaTable.getFlexCellFormatter().setStyleName(0, 1, "props-labels");
178 947da718 Christos Stathis
                int rows = 1;
179 947da718 Christos Stathis
                for (String metaKey : file.getMeta().keySet()) {
180 947da718 Christos Stathis
                        addFormLine(metaTable, rows++, metaKey, file.getMeta().get(metaKey));
181 947da718 Christos Stathis
                }
182 904447e4 Christos Stathis
                if (rows == 1) //If no meta add an empty line
183 904447e4 Christos Stathis
                        addFormLine(metaTable, rows++, "", "");
184 947da718 Christos Stathis
                
185 947da718 Christos Stathis
                plus.addClickHandler(new ClickHandler() {
186 947da718 Christos Stathis
                        
187 947da718 Christos Stathis
                        @Override
188 ebead1b5 Christos Stathis
                        public void onClick(ClickEvent event) {
189 947da718 Christos Stathis
                                addFormLine(metaTable, metaTable.getRowCount(), "", "");
190 947da718 Christos Stathis
                        }
191 947da718 Christos Stathis
                });
192 ef5b664d Christos Stathis
193 947da718 Christos Stathis
                generalPanel.add(metaTable);
194 31997f49 Christos Stathis
        generalPanel.setSpacing(4);
195 31997f49 Christos Stathis
        return generalPanel;
196 31997f49 Christos Stathis
    }
197 31997f49 Christos Stathis
198 904447e4 Christos Stathis
        void addFormLine(final FlexTable table, int row, String _name, String _value) {
199 947da718 Christos Stathis
                TextBox nameBox = new TextBox();
200 904447e4 Christos Stathis
                nameBox.setText(_name);
201 904447e4 Christos Stathis
                nameBox.addStyleName("pithos-metaName");
202 947da718 Christos Stathis
                table.setWidget(row, 0, nameBox);
203 947da718 Christos Stathis
                table.getFlexCellFormatter().setStyleName(1, 0, "props-values");
204 947da718 Christos Stathis
205 947da718 Christos Stathis
                TextBox valueBox = new TextBox();
206 904447e4 Christos Stathis
                valueBox.setText(_value);
207 904447e4 Christos Stathis
                valueBox.addStyleName("pithos-metaValue");
208 947da718 Christos Stathis
                table.setWidget(row, 1, valueBox);
209 947da718 Christos Stathis
                table.getFlexCellFormatter().setStyleName(1, 1, "props-values");
210 947da718 Christos Stathis
                
211 947da718 Christos Stathis
                Image delete = new Image("images/delete.png");
212 904447e4 Christos Stathis
                delete.addStyleName("pithos-metaDeleteImg");
213 947da718 Christos Stathis
                delete.addClickHandler(new ClickHandler() {
214 947da718 Christos Stathis
                        
215 947da718 Christos Stathis
                        @Override
216 947da718 Christos Stathis
                        public void onClick(ClickEvent event) {
217 947da718 Christos Stathis
                                int rowIndex = table.getCellForEvent(event).getRowIndex();
218 947da718 Christos Stathis
                                table.removeRow(rowIndex);
219 947da718 Christos Stathis
                        }
220 947da718 Christos Stathis
                });
221 947da718 Christos Stathis
                table.setWidget(row, 2, delete);
222 947da718 Christos Stathis
        }
223 947da718 Christos Stathis
224 a57faaf0 Christos Stathis
        /**
225 a57faaf0 Christos Stathis
         * Accepts any change and updates the file
226 a57faaf0 Christos Stathis
         *
227 a57faaf0 Christos Stathis
         */
228 a57faaf0 Christos Stathis
        @Override
229 a57faaf0 Christos Stathis
        protected void accept() {
230 a57faaf0 Christos Stathis
                String newFilename = null;
231 ecf95c9e Christos Stathis
232 ef5b664d Christos Stathis
                if (!name.getText().trim().equals(file.getName())) {
233 ef5b664d Christos Stathis
                        newFilename = name.getText().trim();
234 a57faaf0 Christos Stathis
                }
235 ecf95c9e Christos Stathis
236 947da718 Christos Stathis
        final Map<String, String> newMeta = new HashMap<String, String>();
237 947da718 Christos Stathis
        for (int row = 1; row < metaTable.getRowCount(); row++) {
238 947da718 Christos Stathis
                String key = ((TextBox) metaTable.getWidget(row, 0)).getText().trim();
239 947da718 Christos Stathis
                String value = ((TextBox) metaTable.getWidget(row, 1)).getText().trim();
240 904447e4 Christos Stathis
                if (key.length() > 0 && value.length() > 0)
241 904447e4 Christos Stathis
                        newMeta.put(key, value);
242 947da718 Christos Stathis
        }
243 ef5b664d Christos Stathis
244 ef5b664d Christos Stathis
        if (newFilename != null) {
245 b51c628b Christos Stathis
            final String path = file.getParent().getUri() + "/" + newFilename;
246 b51c628b Christos Stathis
            PutRequest updateFile = new PutRequest(app.getApiPath(), app.getUsername(), path) {
247 ef5b664d Christos Stathis
                @Override
248 ebead1b5 Christos Stathis
                public void onSuccess(Resource result) {
249 9326b841 Christos Stathis
                    updateMetaData(app.getApiPath(), file.getOwner(), path + "?update=", newMeta);
250 ef5b664d Christos Stathis
                }
251 ef5b664d Christos Stathis
252 ef5b664d Christos Stathis
                @Override
253 ef5b664d Christos Stathis
                public void onError(Throwable t) {
254 ef5b664d Christos Stathis
                    GWT.log("", t);
255 3f8622d4 Christos Stathis
                                        app.setError(t);
256 ef5b664d Christos Stathis
                    app.displayError("System error modifying file:" + t.getMessage());
257 ef5b664d Christos Stathis
                }
258 9539e23d Christos Stathis
259 9539e23d Christos Stathis
                                @Override
260 ebead1b5 Christos Stathis
                                protected void onUnauthorized(Response response) {
261 9539e23d Christos Stathis
                                        app.sessionExpired();
262 9539e23d Christos Stathis
                                }
263 ef5b664d Christos Stathis
            };
264 ef5b664d Christos Stathis
            updateFile.setHeader("X-Auth-Token", app.getToken());
265 a2411896 Christos Stathis
            updateFile.setHeader("X-Move-From", URL.encodePathSegment(file.getUri()));
266 ef5b664d Christos Stathis
            updateFile.setHeader("Content-Type", file.getContentType());
267 3601b114 Christos Stathis
            for (String key : file.getMeta().keySet())
268 3601b114 Christos Stathis
                updateFile.setHeader("X-Object-Meta-" + URL.encodePathSegment(key.trim()), URL.encodePathSegment(newMeta.get(key)));
269 3601b114 Christos Stathis
            if (file.isPublished())
270 3601b114 Christos Stathis
                updateFile.setHeader("X-Object-Public", "true");
271 3601b114 Christos Stathis
            String readPermHeader = "read=";
272 3601b114 Christos Stathis
            String writePermHeader = "write=";
273 3601b114 Christos Stathis
            for (String u : file.getPermissions().keySet()) {
274 3601b114 Christos Stathis
                Boolean[] p = file.getPermissions().get(u);
275 3601b114 Christos Stathis
                if (p[0] != null && p[0])
276 3601b114 Christos Stathis
                    readPermHeader += u + ",";
277 3601b114 Christos Stathis
                if (p[1] != null && p[1])
278 3601b114 Christos Stathis
                    writePermHeader += u + ",";
279 3601b114 Christos Stathis
            }
280 3601b114 Christos Stathis
            if (readPermHeader.endsWith("="))
281 3601b114 Christos Stathis
                readPermHeader = "";
282 3601b114 Christos Stathis
            else if (readPermHeader.endsWith(","))
283 3601b114 Christos Stathis
                readPermHeader = readPermHeader.substring(0, readPermHeader.length() - 1);
284 3601b114 Christos Stathis
            if (writePermHeader.endsWith("="))
285 3601b114 Christos Stathis
                writePermHeader = "";
286 3601b114 Christos Stathis
            else if (writePermHeader.endsWith(","))
287 3601b114 Christos Stathis
                writePermHeader = writePermHeader.substring(0, writePermHeader.length() - 1);
288 3601b114 Christos Stathis
            String permHeader = readPermHeader +  ((readPermHeader.length()  > 0 && writePermHeader.length() > 0) ?  ";" : "") + writePermHeader;
289 3601b114 Christos Stathis
            if (permHeader.length() == 0)
290 3601b114 Christos Stathis
                permHeader="~";
291 3601b114 Christos Stathis
            else
292 3601b114 Christos Stathis
                    permHeader = URL.encodePathSegment(permHeader);
293 3601b114 Christos Stathis
            updateFile.setHeader("X-Object-Sharing", permHeader);
294 3601b114 Christos Stathis
295 ef5b664d Christos Stathis
            Scheduler.get().scheduleDeferred(updateFile);
296 ef5b664d Christos Stathis
        }
297 ecf95c9e Christos Stathis
        else
298 9326b841 Christos Stathis
            updateMetaData(app.getApiPath(), app.getUsername(), file.getUri() + "?update=", newMeta);
299 ef5b664d Christos Stathis
        }
300 a57faaf0 Christos Stathis
301 9326b841 Christos Stathis
        protected void updateMetaData(String api, String owner, String path, Map<String, String> newMeta) {
302 9326b841 Christos Stathis
        if (newMeta != null) {
303 ecf95c9e Christos Stathis
            PostRequest updateFile = new PostRequest(api, owner, path) {
304 ecf95c9e Christos Stathis
                @Override
305 ebead1b5 Christos Stathis
                public void onSuccess(Resource result) {
306 3601b114 Christos Stathis
                    app.updateFolder(file.getParent(), true, new Command() {
307 3601b114 Christos Stathis
                                                
308 3601b114 Christos Stathis
                                                @Override
309 3601b114 Christos Stathis
                                                public void execute() {
310 3601b114 Christos Stathis
                                                        app.updateMySharedRoot();
311 3601b114 Christos Stathis
                                                }
312 3601b114 Christos Stathis
                                        });
313 ecf95c9e Christos Stathis
                }
314 31997f49 Christos Stathis
315 ecf95c9e Christos Stathis
                @Override
316 ecf95c9e Christos Stathis
                public void onError(Throwable t) {
317 ecf95c9e Christos Stathis
                    GWT.log("", t);
318 3f8622d4 Christos Stathis
                                        app.setError(t);
319 ecf95c9e Christos Stathis
                    app.displayError("System error modifying file:" + t.getMessage());
320 ecf95c9e Christos Stathis
                }
321 9539e23d Christos Stathis
322 9539e23d Christos Stathis
                                @Override
323 ebead1b5 Christos Stathis
                                protected void onUnauthorized(Response response) {
324 9539e23d Christos Stathis
                                        app.sessionExpired();
325 9539e23d Christos Stathis
                                }
326 ecf95c9e Christos Stathis
            };
327 ecf95c9e Christos Stathis
            updateFile.setHeader("X-Auth-Token", app.getToken());
328 904447e4 Christos Stathis
            
329 9326b841 Christos Stathis
            for (String t : file.getMeta().keySet()) {
330 9326b841 Christos Stathis
                        updateFile.setHeader("X-Object-Meta-" + URL.encodePathSegment(t.trim()), "~");
331 ea94470a Christos Stathis
            }
332 947da718 Christos Stathis
            
333 9326b841 Christos Stathis
            for (String key : newMeta.keySet())
334 9326b841 Christos Stathis
                updateFile.setHeader("X-Object-Meta-" + URL.encodePathSegment(key.trim()), URL.encodePathSegment(newMeta.get(key)));
335 9326b841 Christos Stathis
            
336 ecf95c9e Christos Stathis
            Scheduler.get().scheduleDeferred(updateFile);
337 ecf95c9e Christos Stathis
        }
338 ecf95c9e Christos Stathis
        else
339 3601b114 Christos Stathis
            app.updateFolder(file.getParent(), true, new Command() {
340 3601b114 Christos Stathis
                                
341 3601b114 Christos Stathis
                                @Override
342 3601b114 Christos Stathis
                                public void execute() {
343 3601b114 Christos Stathis
                                        if (file.isShared())
344 3601b114 Christos Stathis
                                                app.updateMySharedRoot();
345 3601b114 Christos Stathis
                                }
346 3601b114 Christos Stathis
                        });
347 ef5b664d Christos Stathis
    }
348 a57faaf0 Christos Stathis
}