Search in sources :

Example 1 with RetryErrorResponse

use of org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RetryErrorResponse in project identity-api-user by wso2.

the class RecoveryUtil method buildRetryPasswordResetObject.

/**
 * Returns a new PreconditionFailedException.
 *
 * @param className     Class name
 * @param tenantDomain  Tenant domain
 * @param description   Description of the exception
 * @param code          Error code
 * @param resetCode     Reset code given to the user by confirmation API
 * @param correlationId Correlation Id
 * @return A new PreconditionFailedException with the specified details as a response
 */
private static PreconditionFailedException buildRetryPasswordResetObject(String className, String tenantDomain, String description, String code, String resetCode, String correlationId) {
    // Build next API calls.
    ArrayList<APICall> apiCallsArrayList = new ArrayList<>();
    apiCallsArrayList.add(RecoveryUtil.buildApiCall(Constants.APICall.RESET_PASSWORD_API.getType(), Constants.RelationStates.NEXT_REL, buildURIForBody(tenantDomain, Constants.APICall.RESET_PASSWORD_API.getApiUrl(), Constants.ACCOUNT_RECOVERY_ENDPOINT_BASEPATH), null));
    RetryErrorResponse retryErrorResponse = buildRetryErrorResponse(Constants.STATUS_PRECONDITION_FAILED_MESSAGE_DEFAULT, code, description, resetCode, correlationId, apiCallsArrayList);
    if (StringUtils.isNotBlank(className)) {
        description = String.format("%s : %s - %s", LOG_MESSAGE_PREFIX, className, description);
    }
    log.error(description);
    return new PreconditionFailedException(retryErrorResponse);
}
Also used : APICall(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.APICall) ArrayList(java.util.ArrayList) RetryErrorResponse(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RetryErrorResponse) PreconditionFailedException(org.wso2.carbon.identity.rest.api.user.recovery.v1.impl.core.exceptions.PreconditionFailedException)

Example 2 with RetryErrorResponse

use of org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RetryErrorResponse in project identity-api-user by wso2.

the class RecoveryUtil method buildRetryErrorResponse.

/**
 * Build the RetryErrorResponse for not valid password scenario.
 *
 * @param message           Error message
 * @param description       Error description
 * @param code              Error code
 * @param resetCode         Password reset code
 * @param correlationId     Trace Id
 * @param apiCallsArrayList Available APIs
 * @return RetryErrorResponse
 */
private static RetryErrorResponse buildRetryErrorResponse(String message, String description, String code, String resetCode, String correlationId, ArrayList<APICall> apiCallsArrayList) {
    RetryErrorResponse retryErrorResponse = new RetryErrorResponse();
    retryErrorResponse.setCode(code);
    retryErrorResponse.setMessage(message);
    retryErrorResponse.setDescription(description);
    retryErrorResponse.setResetCode(resetCode);
    retryErrorResponse.setTraceId(correlationId);
    retryErrorResponse.setLinks(apiCallsArrayList);
    return retryErrorResponse;
}
Also used : RetryErrorResponse(org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RetryErrorResponse)

Aggregations

RetryErrorResponse (org.wso2.carbon.identity.rest.api.user.recovery.v1.model.RetryErrorResponse)2 ArrayList (java.util.ArrayList)1 PreconditionFailedException (org.wso2.carbon.identity.rest.api.user.recovery.v1.impl.core.exceptions.PreconditionFailedException)1 APICall (org.wso2.carbon.identity.rest.api.user.recovery.v1.model.APICall)1