LdapGroupVO ldapGroup = null;
if(attrs.get("cn") != null)
{
String name = (String)attrs.get("cn").get(0); // TODO: what is this name for
ldapGroup = new LdapGroupDAO().getByName(name);
if(ldapGroup == null)
{
if(log.isDebugEnabled())
log.debug("creating new ldapGroup: " + name);
ldapGroup = new LdapGroupVO();
ldapGroup.setName(groupDN);
ldapGroup.setOwnerGroup(adminUser.getProfile().getDefaultUsergroup().getId());
ldapGroup.setOwnerUser(adminUser.getId());
ldapGroup.setPriority(new LdapGroupDAO().getAll().size());
ldapGroup.setAccessUser(Access.WRITE_SYSTEM);
ldapGroup.setAccessGroup(Access.NONE);
ldapGroup.setAccessGlobal(Access.NONE);
ProfileVO profile = new ProfileVO();
profile.setAccessGlobal(Access.READ);
profile.setAccessGroup(Access.READ);
profile.setAccessUser(Access.WRITE_SYSTEM);
profile.setIpPattern("*");
profile.setTimeLock(30);
profile.setRole(new RoleDAO().getByName("User"));
profile.setDefaultUsergroup(profile.getRole().getDefaultUsergroup());
profile.setOwnerUser(adminUser.getId());
profile.setOwnerGroup(adminUser.getProfile().getDefaultUsergroup().getId());
ldapGroup.setProfile(profile);
new LdapGroupDAO().insert(ldapGroup,adminUser);
}
else
{
if(log.isDebugEnabled())
log.debug("ldapGroup already exists: " + name);