use of org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException in project directory-fortress-core by apache.
the class PermDAO method getPerm.
/**
* @param permission
* @return
* @throws org.apache.directory.fortress.core.FinderException
*/
Permission getPerm(Permission permission) throws FinderException {
Permission entity = null;
LdapConnection ld = null;
String dn = getOpRdn(permission.getOpName(), permission.getObjId()) + "," + GlobalIds.POBJ_NAME + "=" + permission.getObjName() + "," + getRootDn(permission.isAdmin(), permission.getContextId());
try {
ld = getAdminConnection();
Entry findEntry = read(ld, dn, PERMISSION_OP_ATRS);
if (findEntry == null) {
String warning = "getPerm no entry found dn [" + dn + "]";
throw new FinderException(GlobalErrIds.PERM_OP_NOT_FOUND, warning);
}
entity = unloadPopLdapEntry(findEntry, 0, permission.isAdmin());
} catch (LdapNoSuchObjectException e) {
String warning = "getPerm Op COULD NOT FIND ENTRY for dn [" + dn + "]";
throw new FinderException(GlobalErrIds.PERM_OP_NOT_FOUND, warning);
} catch (LdapException e) {
String error = "getUser [" + dn + "] caught LdapException=" + e.getMessage();
throw new FinderException(GlobalErrIds.PERM_READ_OP_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return entity;
}
use of org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException in project directory-fortress-core by apache.
the class PolicyDAO method getPolicy.
/**
* @param policy
* @return
* @throws org.apache.directory.fortress.core.FinderException
*/
PwPolicy getPolicy(PwPolicy policy) throws FinderException {
PwPolicy entity = null;
LdapConnection ld = null;
String dn = getDn(policy);
try {
ld = getAdminConnection();
Entry findEntry = read(ld, dn, PASSWORD_POLICY_ATRS);
entity = unloadLdapEntry(findEntry, 0);
} catch (LdapNoSuchObjectException e) {
String warning = "getPolicy Obj COULD NOT FIND ENTRY for dn [" + dn + "]";
throw new FinderException(GlobalErrIds.PSWD_NOT_FOUND, warning);
} catch (LdapException e) {
String error = "getPolicy name [" + policy.getName() + "] caught LdapException=" + e.getMessage();
throw new FinderException(GlobalErrIds.PSWD_READ_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return entity;
}
use of org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException in project directory-fortress-core by apache.
the class PropertyDAO method getProperties.
/**
* Get properties on the provided entity using the provided property provider
*
* @param entity A FortressEntity that supports properties (Role, AdminRole, Group, Permission, PermObj)
* @param propProvider DAO for entity type that implements property provider interface
* @return Current properties of entity
* @throws FinderException
*/
Properties getProperties(FortEntity entity, PropertyProvider propProvider) throws FinderException {
Properties props = null;
LdapConnection ld = null;
String entityDn = propProvider.getDn(entity);
try {
ld = getAdminConnection();
Entry findEntry = read(ld, entityDn, new String[] { GlobalIds.PROPS });
props = PropUtil.getProperties(getAttributes(findEntry, GlobalIds.PROPS));
if (props == null) {
props = new Properties();
}
} catch (LdapNoSuchObjectException e) {
String warning = "get properties COULD NOT FIND ENTRY for entity [" + entityDn + "]";
throw new FinderException(GlobalErrIds.ENTITY_PROPS_NOT_FOUND, warning);
} catch (LdapException e) {
String error = "get properties [" + entityDn + "]= caught LDAPException=" + e.getMessage();
throw new FinderException(GlobalErrIds.ENTITY_PROPS_LOAD_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return props;
}
use of org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException in project directory-fortress-core by apache.
the class OrgUnitDAO method findByKey.
/**
* @param entity
* @return
* @throws FinderException
*/
OrgUnit findByKey(OrgUnit entity) throws FinderException {
OrgUnit oe = null;
LdapConnection ld = null;
Dn dn = getDn(entity);
try {
ld = getAdminConnection();
Entry findEntry = read(ld, dn, ORGUNIT_ATRS);
if (findEntry == null) {
String warning = "findByKey orgUnit name [" + entity.getName() + "] type [" + entity.getType() + "] COULD NOT FIND ENTRY for dn [" + dn + "]";
int errCode;
if (entity.getType() == OrgUnit.Type.PERM) {
errCode = GlobalErrIds.ORG_NOT_FOUND_PERM;
} else {
errCode = GlobalErrIds.ORG_NOT_FOUND_USER;
}
throw new FinderException(errCode, warning);
}
oe = getEntityFromLdapEntry(findEntry, 0, entity.getContextId());
} catch (LdapNoSuchObjectException e) {
String warning = "findByKey orgUnit name [" + entity.getName() + "] type [" + entity.getType() + "] COULD NOT FIND ENTRY for dn [" + dn + "]";
int errCode;
if (entity.getType() == OrgUnit.Type.PERM) {
errCode = GlobalErrIds.ORG_NOT_FOUND_PERM;
} else {
errCode = GlobalErrIds.ORG_NOT_FOUND_USER;
}
throw new FinderException(errCode, warning);
} catch (LdapException e) {
String error = "findByKey orgUnitName [" + entity.getName() + "] type [" + entity.getType() + "] dn [" + dn + "] caught LdapException=" + e;
int errCode;
if (entity.getType() == OrgUnit.Type.PERM) {
errCode = GlobalErrIds.ORG_READ_FAILED_PERM;
} else {
errCode = GlobalErrIds.ORG_READ_FAILED_USER;
}
throw new FinderException(errCode, error, e);
} finally {
closeAdminConnection(ld);
}
return oe;
}
use of org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException in project directory-fortress-core by apache.
the class SdDAO method getSD.
/**
* @param sdSet
* @return
* @throws FinderException
*/
SDSet getSD(SDSet sdSet) throws FinderException {
SDSet entity = null;
LdapConnection ld = null;
String dn = getDn(sdSet.getName(), sdSet.getContextId());
try {
ld = getAdminConnection();
Entry findEntry = read(ld, dn, SD_SET_ATRS);
if (findEntry == null) {
String warning = "getSD no entry found dn [" + dn + "]";
throw new FinderException(GlobalErrIds.SSD_NOT_FOUND, warning);
}
entity = unloadLdapEntry(findEntry, 0);
} catch (LdapNoSuchObjectException e) {
String warning = "getSD Obj COULD NOT FIND ENTRY for dn [" + dn + "]";
throw new FinderException(GlobalErrIds.SSD_NOT_FOUND, warning);
} catch (LdapException e) {
String error = "getSSD dn [" + dn + "] LEXCD=" + e;
int errCode;
if (sdSet.getType() == SDSet.SDType.DYNAMIC) {
errCode = GlobalErrIds.DSD_READ_FAILED;
} else {
errCode = GlobalErrIds.SSD_READ_FAILED;
}
throw new FinderException(errCode, error, e);
} finally {
closeAdminConnection(ld);
}
return entity;
}
Aggregations