Пример #1
0
  /**
   * Deletes a group from the system.
   *
   * @param group the group to delete.
   */
  public void deleteGroup(Group group) {
    // Fire event.
    GroupEventDispatcher.dispatchEvent(
        group, GroupEventDispatcher.EventType.group_deleting, Collections.emptyMap());

    // Delete the group.
    provider.deleteGroup(group.getName());

    // Expire all relevant caches.
    groupCache.remove(group.getName());
  }
Пример #2
0
  /**
   * Factory method for creating a new Group. A unique name is the only required field.
   *
   * @param name the new and unique name for the group.
   * @return a new Group.
   * @throws GroupAlreadyExistsException if the group name already exists in the system.
   */
  public Group createGroup(String name) throws GroupAlreadyExistsException {
    synchronized (name.intern()) {
      Group newGroup = null;
      try {
        getGroup(name);
        // The group already exists since now exception, so:
        throw new GroupAlreadyExistsException();
      } catch (GroupNotFoundException unfe) {
        // The group doesn't already exist so we can create a new group
        newGroup = provider.createGroup(name);
        groupCache.put(name, newGroup);

        // Fire event.
        GroupEventDispatcher.dispatchEvent(
            newGroup, GroupEventDispatcher.EventType.group_created, Collections.emptyMap());
      }
      return newGroup;
    }
  }