Search in sources :

Example 1 with SCIMUserStoreException

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);
}
Also used : SCIMUserStoreErrorResolver(org.wso2.carbon.identity.scim2.common.extenstion.SCIMUserStoreErrorResolver) SCIMUserStoreException(org.wso2.carbon.identity.scim2.common.extenstion.SCIMUserStoreException) CharonException(org.wso2.charon3.core.exceptions.CharonException)

Example 2 with SCIMUserStoreException

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);
}
Also used : SCIMUserStoreException(org.wso2.carbon.identity.scim2.common.extenstion.SCIMUserStoreException) Test(org.testng.annotations.Test)

Example 3 with 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);
}
Also used : SCIMUserStoreException(org.wso2.carbon.identity.scim2.common.extenstion.SCIMUserStoreException) Test(org.testng.annotations.Test)

Aggregations

SCIMUserStoreException (org.wso2.carbon.identity.scim2.common.extenstion.SCIMUserStoreException)3 Test (org.testng.annotations.Test)2 SCIMUserStoreErrorResolver (org.wso2.carbon.identity.scim2.common.extenstion.SCIMUserStoreErrorResolver)1 CharonException (org.wso2.charon3.core.exceptions.CharonException)1