use of org.apache.directory.fortress.core.UpdateException in project directory-fortress-core by apache.
the class AdminRoleDAO method deleteParent.
/**
* @param entity
* @throws UpdateException
*/
void deleteParent(AdminRole entity) throws UpdateException {
LdapConnection ld = null;
String dn = getDn(entity);
try {
List<Modification> mods = new ArrayList<Modification>();
mods.add(new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, GlobalIds.PARENT_NODES));
ld = getAdminConnection();
modify(ld, dn, mods, entity);
} catch (LdapException e) {
String error = "deleteParent name [" + entity.getName() + "] caught LdapException=" + e.getMessage();
throw new UpdateException(GlobalErrIds.ARLE_REMOVE_PARENT_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
}
use of org.apache.directory.fortress.core.UpdateException in project directory-fortress-core by apache.
the class RoleDAO method update.
/**
* @param entity
* @return
* @throws org.apache.directory.fortress.core.UpdateException
*/
Role update(Role entity) throws UpdateException {
LdapConnection ld = null;
String dn = getDn(entity.getName(), entity.getContextId());
try {
List<Modification> mods = new ArrayList<Modification>();
if (StringUtils.isNotEmpty(entity.getDescription())) {
mods.add(new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, SchemaConstants.DESCRIPTION_AT, entity.getDescription()));
}
if (entity.isTemporalSet()) {
String szRawData = ConstraintUtil.setConstraint(entity);
if (StringUtils.isNotEmpty(szRawData)) {
mods.add(new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, GlobalIds.CONSTRAINT, szRawData));
}
}
loadAttrs(entity.getParents(), mods, GlobalIds.PARENT_NODES);
if (mods.size() > 0) {
ld = getAdminConnection();
modify(ld, dn, mods, entity);
}
} catch (LdapException e) {
String error = "update name [" + entity.getName() + "] caught LdapException=" + e.getMessage();
throw new UpdateException(GlobalErrIds.ROLE_UPDATE_FAILED, error, e);
} catch (Exception e) {
String error = "update name [" + entity.getName() + "] caught LdapException=" + e.getMessage();
throw new UpdateException(GlobalErrIds.ROLE_UPDATE_FAILED, error, e);
} finally {
try {
closeAdminConnection(ld);
} catch (Exception e) {
String error = "update name [" + entity.getName() + "] caught LdapException=" + e.getMessage();
throw new UpdateException(GlobalErrIds.ROLE_UPDATE_FAILED, error, e);
}
}
return entity;
}
use of org.apache.directory.fortress.core.UpdateException in project directory-fortress-core by apache.
the class RoleDAO method deassign.
/**
* @param entity
* @param userDn
* @return
* @throws org.apache.directory.fortress.core.UpdateException
*/
Role deassign(Role entity, String userDn) throws UpdateException {
LdapConnection ld = null;
String dn = getDn(entity.getName(), entity.getContextId());
try {
List<Modification> mods = new ArrayList<Modification>();
mods.add(new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, SchemaConstants.ROLE_OCCUPANT_AT, userDn));
ld = getAdminConnection();
modify(ld, dn, mods, entity);
} catch (LdapException e) {
String error = "deassign role name [" + entity.getName() + "] user dn [" + userDn + "] caught LdapException=" + e.getMessage();
throw new UpdateException(GlobalErrIds.ROLE_USER_DEASSIGN_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return entity;
}
use of org.apache.directory.fortress.core.UpdateException in project directory-fortress-core by apache.
the class GroupDAO method assign.
/**
* @param entity
* @param userDn
* @return
* @throws org.apache.directory.fortress.core.UpdateException
*/
Group assign(Group entity, String userDn) throws FinderException, UpdateException {
LdapConnection ld = null;
String dn = getDn(entity.getName(), entity.getContextId());
LOG.debug("assign group property dn [{}], member dn [{}]", dn, userDn);
try {
List<Modification> mods = new ArrayList<Modification>();
mods.add(new DefaultModification(ModificationOperation.ADD_ATTRIBUTE, SchemaConstants.MEMBER_AT, userDn));
ld = getAdminConnection();
modify(ld, dn, mods, entity);
} catch (LdapException e) {
String error = "assign group name [" + entity.getName() + "] user dn [" + userDn + "] caught " + "LDAPException=" + e.getMessage();
throw new UpdateException(GlobalErrIds.GROUP_USER_ASSIGN_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return get(entity);
}
use of org.apache.directory.fortress.core.UpdateException in project directory-fortress-core by apache.
the class OrgUnitDAO method deleteParent.
/**
* @param entity
* @throws org.apache.directory.fortress.core.UpdateException
*/
void deleteParent(OrgUnit entity) throws UpdateException {
LdapConnection ld = null;
Dn dn = getDn(entity);
try {
List<Modification> mods = new ArrayList<Modification>();
mods.add(new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, GlobalIds.PARENT_NODES));
ld = getAdminConnection();
modify(ld, dn, mods, entity);
} catch (LdapException e) {
String error = "deleteParent orgUnit name [" + entity.getName() + "] type [" + entity.getType() + "] root [" + dn + "] caught LdapException=" + e;
int errCode;
if (entity.getType() == OrgUnit.Type.PERM) {
errCode = GlobalErrIds.ORG_REMOVE_PARENT_FAILED_PERM;
} else {
errCode = GlobalErrIds.ORG_REMOVE_PARENT_FAILED_USER;
}
throw new UpdateException(errCode, error, e);
} finally {
closeAdminConnection(ld);
}
}
Aggregations