use of org.wso2.carbon.identity.api.server.common.error.APIError in project identity-api-server by wso2.
the class SecretManagementService method handleSecretMgtException.
private APIError handleSecretMgtException(SecretManagementException e, SecretManagementConstants.ErrorMessage errorEnum, String data) {
ErrorResponse errorResponse;
Response.Status status;
if (e instanceof SecretManagementClientException) {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e.getMessage());
if (e.getErrorCode() != null) {
String errorCode = e.getErrorCode();
errorResponse.setCode(errorCode);
}
errorResponse.setDescription(e.getMessage());
if (ERROR_CODE_SECRET_ALREADY_EXISTS.getCode().equals(e.getErrorCode())) {
status = Response.Status.CONFLICT;
} else if (ERROR_CODE_SECRET_DOES_NOT_EXISTS.getCode().equals(e.getErrorCode())) {
status = Response.Status.NOT_FOUND;
} else {
status = Response.Status.BAD_REQUEST;
}
} else if (e instanceof SecretManagementServerException) {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e, errorEnum.getDescription());
if (e.getErrorCode() != null) {
String errorCode = e.getErrorCode();
errorResponse.setCode(errorCode);
}
errorResponse.setDescription(e.getMessage());
status = Response.Status.INTERNAL_SERVER_ERROR;
} else {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e, errorEnum.getDescription());
status = Response.Status.INTERNAL_SERVER_ERROR;
}
return new APIError(status, errorResponse);
}
use of org.wso2.carbon.identity.api.server.common.error.APIError in project identity-api-server by wso2.
the class SecretTypeManagementService method handleSecretMgtException.
private APIError handleSecretMgtException(SecretManagementException e, SecretManagementConstants.ErrorMessage errorEnum, String data) {
ErrorResponse errorResponse;
Response.Status status;
if (e instanceof SecretManagementClientException) {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e.getMessage());
if (e.getErrorCode() != null) {
String errorCode = e.getErrorCode();
errorResponse.setCode(errorCode);
}
errorResponse.setDescription(e.getMessage());
if (ERROR_CODE_SECRET_TYPE_ALREADY_EXISTS.getCode().equals(e.getErrorCode())) {
status = Response.Status.CONFLICT;
} else if (ERROR_CODE_SECRET_TYPE_DOES_NOT_EXISTS.getCode().equals(e.getErrorCode())) {
status = Response.Status.NOT_FOUND;
} else {
status = Response.Status.BAD_REQUEST;
}
} else if (e instanceof SecretManagementServerException) {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e, errorEnum.getDescription());
if (e.getErrorCode() != null) {
String errorCode = e.getErrorCode();
errorResponse.setCode(errorCode);
}
errorResponse.setDescription(e.getMessage());
status = Response.Status.INTERNAL_SERVER_ERROR;
} else {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e, errorEnum.getDescription());
status = Response.Status.INTERNAL_SERVER_ERROR;
}
return new APIError(status, errorResponse);
}
use of org.wso2.carbon.identity.api.server.common.error.APIError in project identity-api-server by wso2.
the class ServerTenantManagementService method handleNotImplementedCapabilities.
/**
* Return Not Implemented error response for tenant List filtering which are not yet supported by the server.
*
* @param filter Filter string.
*/
private void handleNotImplementedCapabilities(String filter) {
TenantManagementConstants.ErrorMessage errorEnum = null;
if (filter != null) {
errorEnum = TenantManagementConstants.ErrorMessage.ERROR_CODE_FILTER_NOT_IMPLEMENTED;
}
if (errorEnum != null) {
ErrorResponse errorResponse = getErrorBuilder(errorEnum, null).build(log, errorEnum.getDescription());
Response.Status status = Response.Status.NOT_IMPLEMENTED;
throw new APIError(status, errorResponse);
}
}
use of org.wso2.carbon.identity.api.server.common.error.APIError in project identity-api-server by wso2.
the class ServerTenantManagementService method handleResourceLimitReached.
private APIError handleResourceLimitReached() {
ErrorResponse errorResponse = getErrorBuilder(ERROR_CODE_TENANT_LIMIT_REACHED, null).build(log, ERROR_CODE_TENANT_LIMIT_REACHED.getDescription());
Response.Status status = Response.Status.FORBIDDEN;
return new APIError(status, errorResponse);
}
use of org.wso2.carbon.identity.api.server.common.error.APIError in project identity-api-server by wso2.
the class ServerTenantManagementService method handleTenantManagementException.
/**
* Handle TenantMgtException, extract error code, error description and status code to be sent
* in the response.
*
* @param e TenantMgtException
* @param errorEnum Error Message information.
* @return APIError.
*/
private APIError handleTenantManagementException(TenantMgtException e, TenantManagementConstants.ErrorMessage errorEnum, String data) {
ErrorResponse errorResponse;
Response.Status status;
if (e instanceof TenantManagementClientException) {
if (ERROR_CODE_RESOURCE_LIMIT_REACHED.equals(e.getErrorCode())) {
return handleResourceLimitReached();
}
errorResponse = getErrorBuilder(errorEnum, data).build(log, e.getMessage());
if (e.getErrorCode() != null) {
String errorCode = e.getErrorCode();
errorResponse.setCode(errorCode);
}
errorResponse.setDescription(e.getMessage());
status = Response.Status.BAD_REQUEST;
} else if (e instanceof TenantManagementServerException) {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e, errorEnum.getDescription());
if (e.getErrorCode() != null) {
String errorCode = e.getErrorCode();
errorResponse.setCode(errorCode);
}
errorResponse.setDescription(e.getMessage());
status = Response.Status.INTERNAL_SERVER_ERROR;
} else {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e, errorEnum.getDescription());
status = Response.Status.INTERNAL_SERVER_ERROR;
}
return new APIError(status, errorResponse);
}
Aggregations