Rev 1692 | Rev 1755 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1692 | Rev 1732 | ||
---|---|---|---|
Line 23... | Line 23... | ||
23 | 23 | ||
24 | 24 | ||
25 | 25 | ||
26 | 26 | ||
27 | static Genson genson; |
27 | static Genson genson; |
- | 28 | static Genson gensonSimpleFields; |
|
28 | 29 | ||
29 | static { |
30 | static { |
30 | Genson.Builder gensonBuilder = new Genson.Builder() |
31 | Genson.Builder gensonBuilder = new Genson.Builder() |
31 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
32 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
32 | .include(RepositoryDocumentCollectionImpl.class) |
33 | .include(RepositoryDocumentCollectionImpl.class) |
- | 34 | .include("name", RepositoryDocumentCollection.class) |
|
- | 35 | .include("description",RepositoryDocumentCollection.class) |
|
- | 36 | .include("legacyUrl", RepositoryDocumentCollection.class) |
|
- | 37 | .include("treeName", RepositoryDocumentCollection.class) |
|
- | 38 | .include("pathName", RepositoryDocumentCollection.class) |
|
- | 39 | .include("treeHiffens", RepositoryDocumentCollection.class) |
|
- | 40 | .include("collectionManagers", RepositoryDocumentCollection.class) |
|
33 | .include(1.5.0/docs/api/java/lang/String.html">String.class) |
41 | .include("id",UserImpl.class) |
- | 42 | .include("name",UserImpl.class) |
|
- | 43 | .include("sigesCode",SigesUserImpl.class) |
|
34 | .exclude("parent", RepositoryDocumentCollection.class); |
44 | .exclude("parent", RepositoryDocumentCollection.class); |
- | 45 | ||
35 | genson = gensonBuilder.create(); |
46 | genson = gensonBuilder.create(); |
36 | 47 | ||
- | 48 | Genson.Builder gensonBuilderSimpleFields = new Genson.Builder() |
|
- | 49 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
|
- | 50 | .include(RepositoryDocumentCollectionImpl.class) |
|
- | 51 | .include("name", RepositoryDocumentCollection.class) |
|
- | 52 | .include("description",RepositoryDocumentCollection.class) |
|
- | 53 | .include("legacyUrl", RepositoryDocumentCollection.class) |
|
- | 54 | .include("treeName", RepositoryDocumentCollection.class) |
|
- | 55 | .include("pathName", RepositoryDocumentCollection.class) |
|
- | 56 | .include("treeHiffens", RepositoryDocumentCollection.class) |
|
- | 57 | .exclude("parent", RepositoryDocumentCollection.class); |
|
- | 58 | ||
- | 59 | gensonSimpleFields = gensonBuilderSimpleFields.create(); |
|
- | 60 | ||
37 | } |
61 | } |
38 | public 1.5.0/docs/api/java/lang/String.html">String toJson() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
62 | public 1.5.0/docs/api/java/lang/String.html">String toJson() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException |
39 | { |
63 | { |
40 | return genson.serialize(this); |
64 | return genson.serialize(this); |
41 | } |
65 | } |
Line 51... | Line 75... | ||
51 | 75 | ||
52 | public static JSONArray toJsonArray(List<RepositoryDocumentCollectionImpl> collections) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException, JSONException { |
76 | public static JSONArray toJsonArray(List<RepositoryDocumentCollectionImpl> collections) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException, JSONException { |
53 | return new JSONArray(genson.serialize(collections)); |
77 | return new JSONArray(genson.serialize(collections)); |
54 | } |
78 | } |
55 | 79 | ||
- | 80 | public static JSONArray toJsonArraySimpleFields(List<RepositoryDocumentCollectionImpl> collections) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException, JSONException { |
|
- | 81 | return new JSONArray(gensonSimpleFields.serialize(collections)); |
|
- | 82 | } |
|
- | 83 | ||
56 | public static RepositoryDocumentCollectionImpl loadFromJson(1.5.0/docs/api/java/lang/String.html">String json) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException { |
84 | public static RepositoryDocumentCollectionImpl loadFromJson(1.5.0/docs/api/java/lang/String.html">String json) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException { |
57 | return genson.deserialize(json, RepositoryDocumentCollectionImpl.class); |
85 | return genson.deserialize(json, RepositoryDocumentCollectionImpl.class); |
58 | } |
86 | } |
59 | 87 | ||
60 | public JSONObject toJsonObject() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException, JSONException { |
88 | public JSONObject toJsonObject() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException, JSONException { |
Line 84... | Line 112... | ||
84 | else |
112 | else |
85 | return getParent().getTreeHiffens() + getName(); |
113 | return getParent().getTreeHiffens() + getName(); |
86 | } |
114 | } |
87 | public void setTreeName(1.5.0/docs/api/java/lang/String.html">String name) |
115 | public void setTreeName(1.5.0/docs/api/java/lang/String.html">String name) |
88 | {} |
116 | {} |
- | 117 | ||
- | 118 | ||
- | 119 | public boolean isManager(UserSession userSession) |
|
- | 120 | { |
|
- | 121 | if(userSession.getUser() == null) |
|
- | 122 | return false; |
|
- | 123 | return checkCollectionManagerInTree(userSession.getUser()); |
|
- | 124 | } |
|
- | 125 | ||
- | 126 | private boolean checkCollectionManagerInTree(User u) |
|
- | 127 | { |
|
- | 128 | if(getCollectionManagers() != null) |
|
- | 129 | { |
|
- | 130 | for(User manager :getCollectionManagers()) |
|
- | 131 | { |
|
- | 132 | if(manager.getId() == u.getId()) |
|
- | 133 | return true; |
|
- | 134 | } |
|
- | 135 | return getParent() != null && getParent().checkCollectionManagerInTree(u); |
|
- | 136 | } |
|
- | 137 | return false; |
|
- | 138 | } |
|
89 | } |
139 | } |
90 | 140 |