root / web_client / src / gr / grnet / pithos / web / client / foldertree / Folder.java @ b6e41e8b
History | View | Annotate | Download (10.8 kB)
1 | 9e8e14e4 | Christos Stathis | /*
|
---|---|---|---|
2 | 58777026 | Christos Stathis | * Copyright 2011 GRNET S.A. All rights reserved.
|
3 | 58777026 | Christos Stathis | *
|
4 | 58777026 | Christos Stathis | * Redistribution and use in source and binary forms, with or
|
5 | 58777026 | Christos Stathis | * without modification, are permitted provided that the following
|
6 | 58777026 | Christos Stathis | * conditions are met:
|
7 | 58777026 | Christos Stathis | *
|
8 | 58777026 | Christos Stathis | * 1. Redistributions of source code must retain the above
|
9 | 58777026 | Christos Stathis | * copyright notice, this list of conditions and the following
|
10 | 58777026 | Christos Stathis | * disclaimer.
|
11 | 58777026 | Christos Stathis | *
|
12 | 58777026 | Christos Stathis | * 2. Redistributions in binary form must reproduce the above
|
13 | 58777026 | Christos Stathis | * copyright notice, this list of conditions and the following
|
14 | 58777026 | Christos Stathis | * disclaimer in the documentation and/or other materials
|
15 | 58777026 | Christos Stathis | * provided with the distribution.
|
16 | 58777026 | Christos Stathis | *
|
17 | 58777026 | Christos Stathis | * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
18 | 58777026 | Christos Stathis | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19 | 58777026 | Christos Stathis | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
20 | 58777026 | Christos Stathis | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
21 | 58777026 | Christos Stathis | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22 | 58777026 | Christos Stathis | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23 | 58777026 | Christos Stathis | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
24 | 58777026 | Christos Stathis | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
25 | 58777026 | Christos Stathis | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
26 | 58777026 | Christos Stathis | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
27 | 58777026 | Christos Stathis | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28 | 58777026 | Christos Stathis | * POSSIBILITY OF SUCH DAMAGE.
|
29 | 58777026 | Christos Stathis | *
|
30 | 58777026 | Christos Stathis | * The views and conclusions contained in the software and
|
31 | 58777026 | Christos Stathis | * documentation are those of the authors and should not be
|
32 | 58777026 | Christos Stathis | * interpreted as representing official policies, either expressed
|
33 | 58777026 | Christos Stathis | * or implied, of GRNET S.A.
|
34 | 9e8e14e4 | Christos Stathis | */
|
35 | 9e8e14e4 | Christos Stathis | |
36 | 9e8e14e4 | Christos Stathis | package gr.grnet.pithos.web.client.foldertree; |
37 | 9e8e14e4 | Christos Stathis | |
38 | 5cd18037 | Christos Stathis | import com.google.gwt.http.client.Response; |
39 | 5cd18037 | Christos Stathis | import com.google.gwt.i18n.client.DateTimeFormat; |
40 | 5cd18037 | Christos Stathis | import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat; |
41 | 5cd18037 | Christos Stathis | import com.google.gwt.json.client.JSONArray; |
42 | 5cd18037 | Christos Stathis | import com.google.gwt.json.client.JSONObject; |
43 | 5cd18037 | Christos Stathis | import com.google.gwt.json.client.JSONParser; |
44 | 5cd18037 | Christos Stathis | import com.google.gwt.json.client.JSONValue; |
45 | fbff60ff | Christos Stathis | import java.util.ArrayList; |
46 | 5cd18037 | Christos Stathis | import java.util.Date; |
47 | 9fce5629 | Christos Stathis | import java.util.HashMap; |
48 | 4d3dcdf6 | Christos Stathis | import java.util.Iterator; |
49 | 5cd18037 | Christos Stathis | import java.util.LinkedHashSet; |
50 | fbff60ff | Christos Stathis | import java.util.List; |
51 | 9fce5629 | Christos Stathis | import java.util.Map; |
52 | 5cd18037 | Christos Stathis | import java.util.Set; |
53 | 3da18014 | Christos Stathis | import java.util.StringTokenizer; |
54 | 9e8e14e4 | Christos Stathis | |
55 | 5cd18037 | Christos Stathis | public class Folder extends Resource { |
56 | 1ac430a1 | Christos Stathis | /*
|
57 | 1ac430a1 | Christos Stathis | * The name of the folder. If the folder is a container this is its name. If it is a virtual folder this is the
|
58 | 1ac430a1 | Christos Stathis | * last part of its path
|
59 | 1ac430a1 | Christos Stathis | */
|
60 | 5cd18037 | Christos Stathis | private String name = null; |
61 | 9e8e14e4 | Christos Stathis | |
62 | 5cd18037 | Christos Stathis | private Date lastModified = null; |
63 | 9e8e14e4 | Christos Stathis | |
64 | 5cd18037 | Christos Stathis | private long bytesUsed = 0; |
65 | 5cd18037 | Christos Stathis | |
66 | 3ca8cd89 | Christos Stathis | private Folder parent = null; |
67 | 3ca8cd89 | Christos Stathis | |
68 | 5cd18037 | Christos Stathis | private Set<Folder> subfolders = new LinkedHashSet<Folder>(); |
69 | 1ac430a1 | Christos Stathis | /*
|
70 | 1ac430a1 | Christos Stathis | * The name of the container that this folder belongs to. If this folder is container, this field equals name
|
71 | 1ac430a1 | Christos Stathis | */
|
72 | 5cd18037 | Christos Stathis | private String container = null; |
73 | 5cd18037 | Christos Stathis | |
74 | 1ac430a1 | Christos Stathis | /*
|
75 | 1ac430a1 | Christos Stathis | * This is the full path of the folder (prefix is a misnomer but it was named so because this is used as a prefix=
|
76 | 1ac430a1 | Christos Stathis | * parameter in the request that fetches its children). If the folder is a cointainer this is empty string
|
77 | 1ac430a1 | Christos Stathis | */
|
78 | 5cd18037 | Christos Stathis | private String prefix = ""; |
79 | 5cd18037 | Christos Stathis | |
80 | fbff60ff | Christos Stathis | private Set<File> files = new LinkedHashSet<File>(); |
81 | fbff60ff | Christos Stathis | |
82 | 4d3dcdf6 | Christos Stathis | private boolean inTrash = false; |
83 | 4d3dcdf6 | Christos Stathis | |
84 | 5eef5c8a | Christos Stathis | /*
|
85 | 5eef5c8a | Christos Stathis | * Flag that indicates that this folder is the Trash
|
86 | 5eef5c8a | Christos Stathis | */
|
87 | 5eef5c8a | Christos Stathis | private boolean trash = false; |
88 | 5eef5c8a | Christos Stathis | |
89 | ba0078a6 | Christos Stathis | private Set<String> tags = new LinkedHashSet<String>(); |
90 | ba0078a6 | Christos Stathis | |
91 | 12190a0c | Christos Stathis | private String owner; |
92 | 12190a0c | Christos Stathis | |
93 | 9fce5629 | Christos Stathis | private Map<String, Boolean[]> permissions = new HashMap<String, Boolean[]>(); |
94 | 9fce5629 | Christos Stathis | |
95 | 9fce5629 | Christos Stathis | private String inheritedPermissionsFrom; |
96 | 9fce5629 | Christos Stathis | |
97 | 5cd18037 | Christos Stathis | public Folder() {};
|
98 | 9e8e14e4 | Christos Stathis | |
99 | 9e8e14e4 | Christos Stathis | public Folder(String name) { |
100 | 9e8e14e4 | Christos Stathis | this.name = name;
|
101 | 9e8e14e4 | Christos Stathis | } |
102 | 5cd18037 | Christos Stathis | |
103 | 5cd18037 | Christos Stathis | public String getName() { |
104 | 5cd18037 | Christos Stathis | return name;
|
105 | 5cd18037 | Christos Stathis | } |
106 | 9e8e14e4 | Christos Stathis | |
107 | 5cd18037 | Christos Stathis | public Date getLastModified() { |
108 | 5cd18037 | Christos Stathis | return lastModified;
|
109 | 9e8e14e4 | Christos Stathis | } |
110 | 9e8e14e4 | Christos Stathis | |
111 | 5cd18037 | Christos Stathis | public long getBytesUsed() { |
112 | 5cd18037 | Christos Stathis | return bytesUsed;
|
113 | 9e8e14e4 | Christos Stathis | } |
114 | 9e8e14e4 | Christos Stathis | |
115 | 5cd18037 | Christos Stathis | public void setLastModified(Date lastModified) { |
116 | 5cd18037 | Christos Stathis | this.lastModified = lastModified;
|
117 | 5cd18037 | Christos Stathis | } |
118 | 5cd18037 | Christos Stathis | |
119 | 5cd18037 | Christos Stathis | public Set<Folder> getSubfolders() { |
120 | 9e8e14e4 | Christos Stathis | return subfolders;
|
121 | 9e8e14e4 | Christos Stathis | } |
122 | 9e8e14e4 | Christos Stathis | |
123 | 5cd18037 | Christos Stathis | public void setSubfolders(Set<Folder> subfolders) { |
124 | 9e8e14e4 | Christos Stathis | this.subfolders = subfolders;
|
125 | 9e8e14e4 | Christos Stathis | } |
126 | 5cd18037 | Christos Stathis | |
127 | 5cd18037 | Christos Stathis | public String getContainer() { |
128 | 5cd18037 | Christos Stathis | return container;
|
129 | 5cd18037 | Christos Stathis | } |
130 | 5cd18037 | Christos Stathis | |
131 | 5cd18037 | Christos Stathis | public String getPrefix() { |
132 | 5cd18037 | Christos Stathis | return prefix;
|
133 | 5cd18037 | Christos Stathis | } |
134 | 5cd18037 | Christos Stathis | |
135 | 5cd18037 | Christos Stathis | public void setPrefix(String prefix) { |
136 | 5cd18037 | Christos Stathis | this.prefix = prefix;
|
137 | 5cd18037 | Christos Stathis | } |
138 | 5cd18037 | Christos Stathis | |
139 | 9fce5629 | Christos Stathis | private void parsePermissions(String rawPermissions) { |
140 | 9fce5629 | Christos Stathis | String[] readwrite = rawPermissions.split(";"); |
141 | 9fce5629 | Christos Stathis | for (String s : readwrite) { |
142 | 9fce5629 | Christos Stathis | String[] part = s.split("="); |
143 | 9fce5629 | Christos Stathis | String perm = part[0].trim(); |
144 | 9fce5629 | Christos Stathis | String[] users = part[1].split(","); |
145 | 9fce5629 | Christos Stathis | for (String u : users) { |
146 | 9fce5629 | Christos Stathis | String user = u.trim();
|
147 | 9fce5629 | Christos Stathis | Boolean[] userPerm = permissions.get(u); |
148 | 9fce5629 | Christos Stathis | if (userPerm == null) { |
149 | 9fce5629 | Christos Stathis | userPerm = new Boolean[2]; |
150 | 9fce5629 | Christos Stathis | permissions.put(user, userPerm); |
151 | 9fce5629 | Christos Stathis | } |
152 | 9fce5629 | Christos Stathis | if (perm.equals("read")) { |
153 | 9fce5629 | Christos Stathis | userPerm[0] = Boolean.TRUE; |
154 | 9fce5629 | Christos Stathis | } |
155 | 9fce5629 | Christos Stathis | else if (perm.equals("write")) { |
156 | 9fce5629 | Christos Stathis | userPerm[1] = Boolean.TRUE; |
157 | 9fce5629 | Christos Stathis | } |
158 | 9fce5629 | Christos Stathis | } |
159 | 9fce5629 | Christos Stathis | } |
160 | 9fce5629 | Christos Stathis | } |
161 | 9fce5629 | Christos Stathis | |
162 | 12190a0c | Christos Stathis | public void populate(String owner, Response response) { |
163 | 12190a0c | Christos Stathis | this.owner = owner;
|
164 | 5cd18037 | Christos Stathis | String header = response.getHeader("Last-Modified"); |
165 | 5cd18037 | Christos Stathis | if (header != null) |
166 | 5cd18037 | Christos Stathis | lastModified = DateTimeFormat.getFormat(PredefinedFormat.RFC_2822).parse(header); |
167 | 5cd18037 | Christos Stathis | |
168 | 5cd18037 | Christos Stathis | header = response.getHeader("X-Container-Bytes-Used");
|
169 | 5cd18037 | Christos Stathis | if (header != null) |
170 | 5cd18037 | Christos Stathis | bytesUsed = Long.valueOf(header);
|
171 | 5cd18037 | Christos Stathis | |
172 | 4d3dcdf6 | Christos Stathis | header = response.getHeader("X-Object-Meta-Trash");
|
173 | 4d3dcdf6 | Christos Stathis | if (header != null && header.equals("true")) |
174 | 4d3dcdf6 | Christos Stathis | inTrash = true;
|
175 | 4d3dcdf6 | Christos Stathis | |
176 | ba0078a6 | Christos Stathis | header = response.getHeader("X-Container-Object-Meta");
|
177 | a39e5b47 | Christos Stathis | if (header != null && header.length() > 0) { |
178 | a39e5b47 | Christos Stathis | for (String t : header.split(",")) { |
179 | a39e5b47 | Christos Stathis | tags.add(t.toLowerCase().trim()); |
180 | 3da18014 | Christos Stathis | } |
181 | ba0078a6 | Christos Stathis | } |
182 | ba0078a6 | Christos Stathis | |
183 | 9fce5629 | Christos Stathis | inheritedPermissionsFrom = response.getHeader("X-Object-Shared-By");
|
184 | 9fce5629 | Christos Stathis | String rawPermissions = response.getHeader("X-Object-Sharing"); |
185 | 9fce5629 | Christos Stathis | if (rawPermissions != null) |
186 | 9fce5629 | Christos Stathis | parsePermissions(rawPermissions); |
187 | 9fce5629 | Christos Stathis | |
188 | 3ca8cd89 | Christos Stathis | subfolders.clear(); //This is necessary in case we update a pre-existing Folder so that stale subfolders won't show up
|
189 | 816de19f | Christos Stathis | files.clear(); |
190 | 5cd18037 | Christos Stathis | JSONValue json = JSONParser.parseStrict(response.getText()); |
191 | 5cd18037 | Christos Stathis | JSONArray array = json.isArray(); |
192 | 5cd18037 | Christos Stathis | if (array != null) { |
193 | 5cd18037 | Christos Stathis | for (int i=0; i<array.size(); i++) { |
194 | 5cd18037 | Christos Stathis | JSONObject o = array.get(i).isObject(); |
195 | 5cd18037 | Christos Stathis | if (o != null) { |
196 | 1ac430a1 | Christos Stathis | String contentType = unmarshallString(o, "content_type"); |
197 | 0bc032bf | Christos Stathis | if (o.containsKey("subdir") || (contentType != null && (contentType.startsWith("application/directory") || contentType.startsWith("application/folder")))) { |
198 | 5cd18037 | Christos Stathis | Folder f = new Folder();
|
199 | 12190a0c | Christos Stathis | f.populate(this, o, owner, container);
|
200 | 5cd18037 | Christos Stathis | subfolders.add(f); |
201 | 5cd18037 | Christos Stathis | } |
202 | 967d4483 | Christos Stathis | else if (!(o.containsKey("x_object_meta_trash") && o.get("x_object_meta_trash").isString().stringValue().equals("true"))) { |
203 | fbff60ff | Christos Stathis | File file = new File(); |
204 | 12190a0c | Christos Stathis | file.populate(this, o, owner, container);
|
205 | fbff60ff | Christos Stathis | files.add(file); |
206 | 5cd18037 | Christos Stathis | } |
207 | 5cd18037 | Christos Stathis | } |
208 | 5cd18037 | Christos Stathis | } |
209 | 967d4483 | Christos Stathis | //This step is necessary to remove the trashed folders. Trashed folders are added initially because we need to
|
210 | 967d4483 | Christos Stathis | //avoid having in the list the virtual folders of the form {"subdir":"folder1"} which have no indication of thrash
|
211 | 4d3dcdf6 | Christos Stathis | Iterator<Folder> iter = subfolders.iterator();
|
212 | 4d3dcdf6 | Christos Stathis | while (iter.hasNext()) {
|
213 | 4d3dcdf6 | Christos Stathis | Folder f = iter.next(); |
214 | 4d3dcdf6 | Christos Stathis | if (f.isInTrash())
|
215 | 4d3dcdf6 | Christos Stathis | iter.remove(); |
216 | 4d3dcdf6 | Christos Stathis | } |
217 | 5cd18037 | Christos Stathis | } |
218 | 5cd18037 | Christos Stathis | } |
219 | 5cd18037 | Christos Stathis | |
220 | 12190a0c | Christos Stathis | public void populate(Folder parent, JSONObject o, String owner, String aContainer) { |
221 | 3ca8cd89 | Christos Stathis | this.parent = parent;
|
222 | 1ac430a1 | Christos Stathis | String path = null; |
223 | 5cd18037 | Christos Stathis | if (o.containsKey("subdir")) { |
224 | 1ac430a1 | Christos Stathis | path = unmarshallString(o, "subdir");
|
225 | 5cd18037 | Christos Stathis | } |
226 | 5cd18037 | Christos Stathis | else {
|
227 | 1ac430a1 | Christos Stathis | path = unmarshallString(o, "name");
|
228 | 5cd18037 | Christos Stathis | lastModified = unmarshallDate(o, "last_modified");
|
229 | 5cd18037 | Christos Stathis | } |
230 | 1ac430a1 | Christos Stathis | if (path.endsWith("/")) |
231 | 1ac430a1 | Christos Stathis | path = path.substring(0, path.length() - 1); |
232 | 1ac430a1 | Christos Stathis | if (path.contains("/")) |
233 | 1ac430a1 | Christos Stathis | name = path.substring(path.lastIndexOf("/") + 1, path.length()); //strip the prefix |
234 | 1ac430a1 | Christos Stathis | else
|
235 | 1ac430a1 | Christos Stathis | name = path; |
236 | 1ac430a1 | Christos Stathis | if (aContainer != null) { |
237 | 1ac430a1 | Christos Stathis | container = aContainer; |
238 | 1ac430a1 | Christos Stathis | prefix = path; |
239 | 1ac430a1 | Christos Stathis | } |
240 | 1ac430a1 | Christos Stathis | else {
|
241 | 1ac430a1 | Christos Stathis | container = name; |
242 | 1ac430a1 | Christos Stathis | prefix = "";
|
243 | 1ac430a1 | Christos Stathis | } |
244 | 12190a0c | Christos Stathis | this.owner = owner;
|
245 | 4d3dcdf6 | Christos Stathis | if (o.containsKey("x_object_meta_trash") && o.get("x_object_meta_trash").isString().stringValue().equals("true")) |
246 | 4d3dcdf6 | Christos Stathis | inTrash = true;
|
247 | 9fce5629 | Christos Stathis | |
248 | 9fce5629 | Christos Stathis | inheritedPermissionsFrom = unmarshallString(o, "x_object_shared_by");
|
249 | 9fce5629 | Christos Stathis | String rawPermissions = unmarshallString(o, "x_object_sharing"); |
250 | 9fce5629 | Christos Stathis | if (rawPermissions != null) |
251 | 9fce5629 | Christos Stathis | parsePermissions(rawPermissions); |
252 | 5cd18037 | Christos Stathis | } |
253 | 5cd18037 | Christos Stathis | |
254 | 12190a0c | Christos Stathis | public static Folder createFromResponse(String owner, Response response, Folder result) { |
255 | 5cd18037 | Christos Stathis | Folder f = null;
|
256 | 5cd18037 | Christos Stathis | if (result == null) |
257 | 5cd18037 | Christos Stathis | f = new Folder();
|
258 | 5cd18037 | Christos Stathis | else
|
259 | 5cd18037 | Christos Stathis | f = result; |
260 | 5cd18037 | Christos Stathis | |
261 | 12190a0c | Christos Stathis | f.populate(owner, response); |
262 | 5cd18037 | Christos Stathis | return f;
|
263 | 5cd18037 | Christos Stathis | } |
264 | 5cd18037 | Christos Stathis | |
265 | 5cd18037 | Christos Stathis | @Override
|
266 | 5cd18037 | Christos Stathis | public boolean equals(Object other) { |
267 | 5cd18037 | Christos Stathis | if (other instanceof Folder) { |
268 | 5cd18037 | Christos Stathis | Folder o = (Folder) other; |
269 | 19a73342 | Christos Stathis | return getUri().equals(o.getUri());
|
270 | 5cd18037 | Christos Stathis | } |
271 | 5cd18037 | Christos Stathis | return false; |
272 | 5cd18037 | Christos Stathis | } |
273 | 5cd18037 | Christos Stathis | |
274 | 5cd18037 | Christos Stathis | @Override
|
275 | 5cd18037 | Christos Stathis | public int hashCode() { |
276 | 19a73342 | Christos Stathis | return getUri().hashCode();
|
277 | 5cd18037 | Christos Stathis | } |
278 | fbff60ff | Christos Stathis | |
279 | fbff60ff | Christos Stathis | public Set<File> getFiles() { |
280 | fbff60ff | Christos Stathis | return files;
|
281 | fbff60ff | Christos Stathis | } |
282 | 3ca8cd89 | Christos Stathis | |
283 | 3ca8cd89 | Christos Stathis | public Folder getParent() {
|
284 | 3ca8cd89 | Christos Stathis | return parent;
|
285 | 3ca8cd89 | Christos Stathis | } |
286 | 26cbae7a | Christos Stathis | |
287 | 26cbae7a | Christos Stathis | public String getUri() { |
288 | 26cbae7a | Christos Stathis | return "/" + container + (prefix.length() == 0 ? "" : "/" + prefix); |
289 | 26cbae7a | Christos Stathis | } |
290 | 4d3dcdf6 | Christos Stathis | |
291 | 4d3dcdf6 | Christos Stathis | public boolean isInTrash() { |
292 | 4d3dcdf6 | Christos Stathis | return inTrash;
|
293 | 4d3dcdf6 | Christos Stathis | } |
294 | cf2dddff | Christos Stathis | |
295 | cf2dddff | Christos Stathis | public boolean isContainer() { |
296 | cf2dddff | Christos Stathis | return parent == null; |
297 | cf2dddff | Christos Stathis | } |
298 | 5eef5c8a | Christos Stathis | |
299 | 5eef5c8a | Christos Stathis | public boolean isTrash() { |
300 | 5eef5c8a | Christos Stathis | return trash;
|
301 | 5eef5c8a | Christos Stathis | } |
302 | 5eef5c8a | Christos Stathis | |
303 | 5eef5c8a | Christos Stathis | public void setTrash(boolean trash) { |
304 | 5eef5c8a | Christos Stathis | this.trash = trash;
|
305 | 5eef5c8a | Christos Stathis | } |
306 | 5eef5c8a | Christos Stathis | |
307 | 5eef5c8a | Christos Stathis | public void setContainer(String container) { |
308 | 5eef5c8a | Christos Stathis | this.container = container;
|
309 | 5eef5c8a | Christos Stathis | } |
310 | ba0078a6 | Christos Stathis | |
311 | ba0078a6 | Christos Stathis | public Set<String> getTags() { |
312 | ba0078a6 | Christos Stathis | return tags;
|
313 | ba0078a6 | Christos Stathis | } |
314 | 6e522e4f | Christos Stathis | |
315 | 6e522e4f | Christos Stathis | public String getInheritedPermissionsFrom() { |
316 | 6e522e4f | Christos Stathis | return inheritedPermissionsFrom;
|
317 | 6e522e4f | Christos Stathis | } |
318 | 6e522e4f | Christos Stathis | |
319 | 6e522e4f | Christos Stathis | public Map<String, Boolean[]> getPermissions() { |
320 | 6e522e4f | Christos Stathis | return permissions;
|
321 | 6e522e4f | Christos Stathis | } |
322 | 6e522e4f | Christos Stathis | |
323 | 6e522e4f | Christos Stathis | public String getOwner() { |
324 | 6e522e4f | Christos Stathis | return owner;
|
325 | 6e522e4f | Christos Stathis | } |
326 | 6e522e4f | Christos Stathis | |
327 | 6e522e4f | Christos Stathis | public boolean existChildrenPermissions() { |
328 | 6e522e4f | Christos Stathis | for (File f : files) |
329 | 6e522e4f | Christos Stathis | if (!f.getPermissions().isEmpty() && f.getInheritedPermissionsFrom() == null) |
330 | 6e522e4f | Christos Stathis | return true; |
331 | 6e522e4f | Christos Stathis | |
332 | 6e522e4f | Christos Stathis | for (Folder fo : subfolders)
|
333 | 6e522e4f | Christos Stathis | if ((!fo.getPermissions().isEmpty() && fo.getInheritedPermissionsFrom() == null) || fo.existChildrenPermissions()) |
334 | 6e522e4f | Christos Stathis | return true; |
335 | 6e522e4f | Christos Stathis | return false; |
336 | 6e522e4f | Christos Stathis | } |
337 | b6e41e8b | Christos Stathis | |
338 | b6e41e8b | Christos Stathis | public boolean isShared() { |
339 | b6e41e8b | Christos Stathis | return !permissions.isEmpty();
|
340 | b6e41e8b | Christos Stathis | } |
341 | 9e8e14e4 | Christos Stathis | } |