Rev 1616 | Rev 1814 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1616 | Rev 1776 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | package pt.estgp.estgweb.domain; |
1 | package pt.estgp.estgweb.domain; |
2 | 2 | ||
3 | import com.owlike.genson.Genson; |
3 | import com.owlike.genson.Genson; |
4 | import com.owlike.genson.TransformationException; |
- | |
5 | import org.apache.log4j.Logger; |
4 | import org.apache.log4j.Logger; |
6 | import org.json.JSONArray; |
5 | import org.json.JSONArray; |
7 | import org.json.JSONException; |
6 | import org.json.JSONException; |
8 | import pt.estgp.estgweb.services.pageContent.PageContentAccessPolicyAcl; |
7 | import pt.estgp.estgweb.services.pageContent.PageContentAccessPolicyAcl; |
9 | 8 | ||
Line 239... | Line 238... | ||
239 | /** |
238 | /** |
240 | * sets the string Acl with the json built from given List |
239 | * sets the string Acl with the json built from given List |
241 | * @param acls |
240 | * @param acls |
242 | * @throws JSONException |
241 | * @throws JSONException |
243 | */ |
242 | */ |
244 | public void setAclList(ArrayList<Acl> acls) throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException { |
243 | public void setAclList(ArrayList<Acl> acls) throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
245 | if(acls == null || acls.size() == 0) |
244 | if(acls == null || acls.size() == 0) |
246 | { |
245 | { |
247 | setAcl(null); |
246 | setAcl(null); |
248 | return; |
247 | return; |
249 | } |
248 | } |
Line 253... | Line 252... | ||
253 | /** |
252 | /** |
254 | * Empty Array Means no ACL's defined allays |
253 | * Empty Array Means no ACL's defined allays |
255 | * @return allays a list if no acls return empty list |
254 | * @return allays a list if no acls return empty list |
256 | * @throws JSONException |
255 | * @throws JSONException |
257 | */ |
256 | */ |
258 | public ArrayList<Acl> getAclList() throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException { |
257 | public ArrayList<Acl> getAclList() throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
259 | ArrayList<Acl> acls = new ArrayList<Acl>(); |
258 | ArrayList<Acl> acls = new ArrayList<Acl>(); |
260 | if(getAcl() == null || getAcl().trim().length() == 0) |
259 | if(getAcl() == null || getAcl().trim().length() == 0) |
261 | return acls; |
260 | return acls; |
262 | Genson genson = getGenson(); |
261 | Genson genson = getGenson(); |
263 | ArrayList<HashMap<String,String>> aclsDes = genson.deserialize(getAcl(),1.5.0/docs/api/java/util/ArrayList.html">ArrayList.class); |
262 | ArrayList<HashMap<String,String>> aclsDes = genson.deserialize(getAcl(),1.5.0/docs/api/java/util/ArrayList.html">ArrayList.class); |
Line 275... | Line 274... | ||
275 | 274 | ||
276 | /** |
275 | /** |
277 | * Add a acl to String json at the end |
276 | * Add a acl to String json at the end |
278 | * @param acl |
277 | * @param acl |
279 | * @throws IOException |
278 | * @throws IOException |
280 | * @throws TransformationException |
- | |
281 | * @throws JSONException |
279 | * @throws JSONException |
282 | */ |
280 | */ |
283 | public void addAcl(1.5.0/docs/api/java/security/acl/Acl.html">Acl acl) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException, JSONException { |
281 | public void addAcl(1.5.0/docs/api/java/security/acl/Acl.html">Acl acl) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
284 | if(acl == null) |
282 | if(acl == null) |
285 | return; |
283 | return; |
286 | ArrayList<Acl> acls = getAclList(); |
284 | ArrayList<Acl> acls = getAclList(); |
287 | acls.add(acl); |
285 | acls.add(acl); |
288 | setAclList(acls); |
286 | setAclList(acls); |
Line 302... | Line 300... | ||
302 | /** |
300 | /** |
303 | * Utilitário |
301 | * Utilitário |
304 | * @param aclList |
302 | * @param aclList |
305 | * @return |
303 | * @return |
306 | * @throws IOException |
304 | * @throws IOException |
307 | * @throws TransformationException |
- | |
308 | * @throws JSONException |
305 | * @throws JSONException |
309 | */ |
306 | */ |
310 | public static JSONArray getAclJson(ArrayList<Acl> aclList) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException, JSONException { |
307 | public static JSONArray getAclJson(ArrayList<Acl> aclList) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
311 | if(aclList == null) |
308 | if(aclList == null) |
312 | return new JSONArray(); |
309 | return new JSONArray(); |
313 | Genson genson = getGenson(); |
310 | Genson genson = getGenson(); |
314 | 1.5.0/docs/api/java/lang/String.html">String json = genson.serialize(aclList); |
311 | 1.5.0/docs/api/java/lang/String.html">String json = genson.serialize(aclList); |
315 | //System.out.println(json); |
312 | //System.out.println(json); |
Line 335... | Line 332... | ||
335 | 332 | ||
336 | /** |
333 | /** |
337 | * Metodo de testes |
334 | * Metodo de testes |
338 | * @param args |
335 | * @param args |
339 | * @throws IOException |
336 | * @throws IOException |
340 | * @throws TransformationException |
- | |
341 | * @throws JSONException |
337 | * @throws JSONException |
342 | */ |
338 | */ |
343 | public static void main(1.5.0/docs/api/java/lang/String.html">String [] args) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException, JSONException { |
339 | public static void main(1.5.0/docs/api/java/lang/String.html">String [] args) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException { |
344 | 340 | ||
345 | 341 | ||
346 | 342 | ||
347 | } |
343 | } |
348 | 344 |