コード例 #1
0
 private boolean isAdminUser(User user) {
   if (user == null) {
     return false;
   }
   for (Group group : user.getGroups()) {
     if (ADMIN_GROUP.equals(group.getName())) {
       return true;
     }
   }
   return false;
 }
コード例 #2
0
 private boolean isWorldAllowedOperation(ProjectInstance projectInstance, Operation operation) {
   for (GroupOperation groupOperation : projectInstance.getAllowedGroupOperations()) {
     Group group = groupOperation.getAllowedGroup();
     String groupName = group.getName();
     if (MetaProjectConstants.USER_WORLD.equals(groupName)) {
       Set<Operation> operations = groupOperation.getAllowedOperations();
       if (operations.contains(operation)) {
         return true;
       }
     }
   }
   return false;
 }
コード例 #3
0
 /**
  * Determines if the signed in user is an admin.
  *
  * @return <code>true</code> if there is a user signed in AND the signed in user corresponds to a
  *     user which exists where that user is an admin, otherwise <code>false</code>
  */
 protected boolean isSignedInUserAdmin() {
   UserId userId = getUserInSession();
   if (userId.isGuest()) {
     return false;
   }
   MetaProjectManager mpm = getMetaProjectManager();
   MetaProject metaProject = mpm.getMetaProject();
   User user = metaProject.getUser(userId.getUserName());
   if (user == null) {
     return false;
   }
   for (Group group : user.getGroups()) {
     if (OntologyShareAccessConstants.ADMIN_GROUP.equals(group.getName())) {
       return true;
     }
   }
   return false;
 }