/** * 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); }