use of org.apache.directory.fortress.core.UpdateException in project directory-fortress-core by apache.
the class OrgUnitDAO method update.
/**
* @param entity
* @return
* @throws org.apache.directory.fortress.core.UpdateException
*/
OrgUnit update(OrgUnit entity) throws UpdateException {
LdapConnection ld = null;
Dn dn = getDn(entity);
try {
List<Modification> mods = new ArrayList<Modification>();
if (entity.getDescription() != null && entity.getDescription().length() > 0) {
mods.add(new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, SchemaConstants.DESCRIPTION_AT, entity.getDescription()));
}
loadAttrs(entity.getParents(), mods, GlobalIds.PARENT_NODES);
if (mods.size() > 0) {
ld = getAdminConnection();
modify(ld, dn, mods, entity);
}
} catch (LdapException e) {
String error = "update orgUnit name [" + entity.getName() + "] type [" + entity.getType() + "] root [" + dn + "] caught LdapException=" + e;
int errCode;
if (entity.getType() == OrgUnit.Type.PERM) {
errCode = GlobalErrIds.ORG_UPDATE_FAILED_PERM;
} else {
errCode = GlobalErrIds.ORG_UPDATE_FAILED_USER;
}
throw new UpdateException(errCode, error, e);
} finally {
closeAdminConnection(ld);
}
return entity;
}
Aggregations