22
22
23
23
import play .Logger ;
24
24
25
+ import com .baasbox .db .DbHelper ;
25
26
import com .baasbox .enumerations .Permissions ;
26
27
import com .google .common .collect .ImmutableMap ;
28
+ import com .orientechnologies .orient .core .db .graph .OGraphDatabase ;
27
29
import com .orientechnologies .orient .core .db .record .OIdentifiable ;
28
30
import com .orientechnologies .orient .core .id .ORID ;
29
31
import com .orientechnologies .orient .core .metadata .schema .OType ;
@@ -134,10 +136,14 @@ public static ODocument grant(ODocument document, Permissions permission,
134
136
Logger .warn ("role is null! Grant command skipped" );
135
137
return document ;
136
138
}
139
+ OGraphDatabase db = DbHelper .getConnection ();
140
+ db .getMetadata ().getSecurity ().allowIdentity (document , permission .toString (), role .getDocument ().getIdentity ());
141
+ /*
137
142
Set<ORID> set = document.field( permission.toString(), OType.LINKSET );
138
143
if (set==null) set = new HashSet<ORID>();
139
144
set.add( role.getDocument().getIdentity() );
140
145
document.field( permission.toString(), set, OType.LINKSET );
146
+ */
141
147
document .save ();
142
148
Logger .trace ("Method End" );
143
149
return document ;
@@ -146,10 +152,14 @@ public static ODocument grant(ODocument document, Permissions permission,
146
152
public static ODocument grant (ODocument document , Permissions permission ,
147
153
OUser user ) {
148
154
Logger .trace ("Method Start" );
155
+ OGraphDatabase db = DbHelper .getConnection ();
156
+ db .getMetadata ().getSecurity ().allowIdentity (document , permission .toString (), user .getDocument ().getIdentity ());
157
+ /*
149
158
Set<ORID> set = document.field( permission.toString(), OType.LINKSET );
150
159
if (set==null) set = new HashSet<ORID>();
151
160
set.add( user.getDocument().getIdentity() );
152
161
document.field( permission.toString(), set, OType.LINKSET );
162
+ */
153
163
document .save ();
154
164
Logger .trace ("Method End" );
155
165
return document ;
@@ -158,22 +168,30 @@ public static ODocument grant(ODocument document, Permissions permission,
158
168
public static ODocument revoke (ODocument document , Permissions permission ,
159
169
ORole role ) {
160
170
Logger .trace ("Method Start" );
171
+ OGraphDatabase db = DbHelper .getConnection ();
172
+ db .getMetadata ().getSecurity ().disallowIdentity (document , permission .toString (), role .getDocument ().getIdentity ());
173
+ /*
161
174
Set<ORID> set = document.field( permission.toString(), OType.LINKSET );
162
175
if (set==null) return document;
163
176
set.remove( role.getDocument().getIdentity() );
164
- document .field ( permission .toString (), set , OType .LINKSET );
165
- document .save ();
177
+ document.field( permission.toString(), set, OType.LINKSET );
178
+ */
179
+ document .save ();
166
180
Logger .trace ("Method End" );
167
181
return document ;
168
182
}
169
183
170
184
public static ODocument revoke (ODocument document , Permissions permission ,
171
185
OUser user ) {
172
186
Logger .trace ("Method Start" );
187
+ OGraphDatabase db = DbHelper .getConnection ();
188
+ db .getMetadata ().getSecurity ().disallowIdentity (document , permission .toString (), user .getDocument ().getIdentity ());
189
+ /*
173
190
Set<ORID> set = document.field( permission.toString(), OType.LINKSET );
174
191
if (set==null) return document;
175
192
set.remove( user.getDocument().getIdentity() );
176
193
document.field( permission.toString(), set, OType.LINKSET );
194
+ */
177
195
document .save ();
178
196
Logger .trace ("Method End" );
179
197
return document ;
0 commit comments