All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ow2.bonita.identity.Group Maven / Gradle / Ivy

/**
 * Copyright (C) 2007  Bull S. A. S.
 * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation
 * version 2.1 of the License.
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License along with this
 * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
 * Floor, Boston, MA  02110-1301, USA.
 **/
package org.ow2.bonita.identity;

import java.security.Permission;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;

/**
 * @author "Pierre Vigneras"
 * @date Dec 6, 2007
 */
public class Group implements GroupMBean {
  final GroupOp group;

  final IdentityServiceOp service;

  Group(GroupOp group, IdentityServiceOp service) {
    this.group = group;
    this.service = service;
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.ow2.bonita.identity.GroupMBean#getChildren()
   */
  public Set getChildren() {
    final Set childs = group.getChildren();
    final Set childsId = new HashSet();
    for (GroupOp g : childs) {
      childsId.add(g.getId());
    }
    return childsId;
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.ow2.bonita.identity.GroupMBean#getId()
   */
  public String getId() {
    return group.getId();
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.ow2.bonita.identity.GroupMBean#getParent()
   */
  public String getParent() {
    return group.getParent().getId();
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.ow2.bonita.identity.GroupMBean#getPermissions()
   */
  public Set getPermissions() {
    return group.getPermissions();
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.ow2.bonita.identity.GroupMBean#getProperties()
   */
  public Properties getProperties() {
    return group.getProperties();
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.ow2.bonita.identity.GroupMBean#getRoot()
   */
  public String getRoot() {
    return group.getRoot().getId();
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.ow2.bonita.identity.GroupMBean#getUsers()
   */
  public Set getUsers() {
    final Set memberships = group.getMemberships();
    final Set usersId = new HashSet();
    for (Membership m : memberships) {
      usersId.add(m.getUser().getId());
    }
    return usersId;
  }

  /*
   * (non-Javadoc)
   * 
   * @see org.ow2.bonita.identity.GroupMBean#setProperty(java.lang.String,
   * java.lang.String)
   */
  public void setProperty(String key, String value) throws CommitException {
    final Properties properties = group.getProperties();
    properties.setProperty(key, value);
    group.setProperties(properties);
    try {
      service.modifyGroup(group);
    } catch (GroupNotFoundException gnfe) {
      throw new RuntimeException(gnfe);
    }
    service.commit();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy