예제 #1
0
 @Override
 public Set<GroupModel> getGroups() {
   // we query ids only as the group  might be cached and following the @ManyToOne will result in a
   // load
   // even if we're getting just the id.
   TypedQuery<String> query = em.createNamedQuery("userGroupIds", String.class);
   query.setParameter("user", getEntity());
   List<String> ids = query.getResultList();
   Set<GroupModel> groups = new HashSet<>();
   for (String groupId : ids) {
     GroupModel group = realm.getGroupById(groupId);
     if (group == null) continue;
     groups.add(group);
   }
   return groups;
 }
예제 #2
0
  @DELETE
  @NoCache
  @Path("default-groups/{groupId}")
  public void removeDefaultGroup(@PathParam("groupId") String groupId) {
    auth.requireManage();

    GroupModel group = realm.getGroupById(groupId);
    if (group == null) {
      throw new NotFoundException("Group not found");
    }
    realm.removeDefaultGroup(group);

    adminEvent
        .operation(OperationType.DELETE)
        .resource(ResourceType.GROUP)
        .resourcePath(uriInfo)
        .success();
  }