use of org.wso2.carbon.identity.scim2.common.extenstion.SCIMUserStoreException in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class SCIMUserManager method resolveError.
/**
* Iterate through the registered error resolver implementations and try to resolve the error.
* If couldn't resolve, default CharonException will be returned with 500 Status code.
*
* @param e User store exception to be resolved.
* @return Resolved charon exception.
*/
private CharonException resolveError(UserStoreException e, String defaultMsg) {
if (log.isDebugEnabled()) {
log.debug(e);
}
for (SCIMUserStoreErrorResolver resolver : SCIMCommonComponentHolder.getScimUserStoreErrorResolverList()) {
SCIMUserStoreException scimUserStoreException = resolver.resolve(e);
if (scimUserStoreException != null) {
CharonException charonException = new CharonException();
charonException.setDetail(scimUserStoreException.getMessage());
charonException.setStatus(scimUserStoreException.getHttpStatusCode());
return charonException;
}
}
// If all resolvers failed to resolve, log error and throw 500 status error.
log.error(defaultMsg, e);
return new CharonException(defaultMsg, e);
}
use of org.wso2.carbon.identity.scim2.common.extenstion.SCIMUserStoreException in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class DefaultSCIMUserStoreErrorResolverTest method testResolveUnHappyPath.
@Test(dataProvider = "dataProviderForResolveUnHappyPath")
public void testResolveUnHappyPath(Object userStoreException) {
DefaultSCIMUserStoreErrorResolver defaultSCIMUserStoreErrorResolver = new DefaultSCIMUserStoreErrorResolver();
SCIMUserStoreException scimUserStoreException = defaultSCIMUserStoreErrorResolver.resolve((UserStoreException) userStoreException);
assertNull(scimUserStoreException);
}
use of org.wso2.carbon.identity.scim2.common.extenstion.SCIMUserStoreException in project identity-inbound-provisioning-scim2 by wso2-extensions.
the class DefaultSCIMUserStoreErrorResolverTest method testResolveHappyPath.
@Test(dataProvider = "dataProviderForResolveUserNameMandatory")
public void testResolveHappyPath(Object userStoreException, int expected) {
DefaultSCIMUserStoreErrorResolver defaultSCIMUserStoreErrorResolver = new DefaultSCIMUserStoreErrorResolver();
SCIMUserStoreException scimUserStoreException = defaultSCIMUserStoreErrorResolver.resolve((UserStoreException) userStoreException);
assertEquals(scimUserStoreException.getHttpStatusCode(), expected);
}
Aggregations