示例#1
0
  /**
   * saveGroups
   *
   * @throws java.lang.Exception if any.
   */
  public synchronized void saveGroups() throws Exception {
    Header header = m_oldHeader;

    if (header != null) header.setCreated(EventConstants.formatToString(new Date()));

    Groups groups = new Groups();
    for (Group grp : m_groups.values()) {
      groups.addGroup(grp);
    }

    Roles roles = new Roles();
    for (Role role : m_roles.values()) {
      roles.addRole(role);
    }

    Groupinfo groupinfo = new Groupinfo();
    groupinfo.setGroups(groups);
    if (roles.getRoleCount() > 0) groupinfo.setRoles(roles);
    groupinfo.setHeader(header);

    m_oldHeader = header;

    // marshal to a string first, then write the string to the file. This
    // way the original configuration
    // isn't lost if the XML from the marshal is hosed.
    StringWriter stringWriter = new StringWriter();
    Marshaller.marshal(groupinfo, stringWriter);
    String data = stringWriter.toString();
    saveXml(data);
  }
示例#2
0
  private void initializeGroupsAndRoles(Groupinfo groupinfo) {
    Groups groups = groupinfo.getGroups();
    m_groups = new LinkedHashMap<String, Group>();
    m_oldHeader = groupinfo.getHeader();
    for (Group curGroup : groups.getGroupCollection()) {
      m_groups.put(curGroup.getName(), curGroup);
    }
    buildDutySchedules(m_groups);

    Roles roles = groupinfo.getRoles();
    m_roles = new LinkedHashMap<String, Role>();
    if (roles != null) {
      for (Role role : roles.getRoleCollection()) {
        m_roles.put(role.getName(), role);
      }
    }
  }