]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/IsUserInGroup.java
Merge "Removed extra modules OntologyModule imported to namespace" into release/1...
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / request / IsUserInGroup.java
1 package org.simantics.db.layer0.request;
2
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.common.request.ResourceRead2;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.user.UserResource;
8
9 public class IsUserInGroup extends ResourceRead2<Boolean> {
10
11     public IsUserInGroup(Resource user, Resource group) {
12         super(user, group);
13     }
14     
15     @Override
16     public Boolean perform(ReadGraph graph) throws DatabaseException {
17         UserResource USER = UserResource.getInstance(graph);
18         if(resource.equals(resource2)) return true;
19         for(Resource part : graph.getObjects(resource2, USER.Group_Contains)) {
20             if(graph.syncRequest(new IsUserInGroup(resource, part))) return true;
21         }
22         return false;
23     }
24     
25 }