use of com.nexblocks.authguard.api.dto.entities.Error in project AuthGuard by AuthGuard.
the class ExceptionHandlers method idempotencyException.
public static void idempotencyException(final IdempotencyException e, final Context context) {
final IdempotentRecordBO record = e.getIdempotentRecord();
final Error error = new Error(ErrorCode.IDEMPOTENCY_ERROR.getCode(), String.format("Idempotent key %s was already used to create entity %s of type %s", record.getIdempotentKey(), record.getEntityId(), record.getEntityType()));
context.status(409).json(error);
}
use of com.nexblocks.authguard.api.dto.entities.Error in project AuthGuard by AuthGuard.
the class ExceptionHandlers method serviceConflictException.
public static void serviceConflictException(final ServiceConflictException e, final Context context) {
LOG.info("Service conflict exception was thrown");
final Error error = new Error(e.getErrorCode(), e.getMessage());
context.status(409).json(error);
}
use of com.nexblocks.authguard.api.dto.entities.Error in project AuthGuard by AuthGuard.
the class AccountsRoute method getById.
public void getById(final Context context) {
final String accountId = context.pathParam("id");
final Optional<AccountDTO> account = accountsService.getById(accountId).map(restMapper::toDTO);
if (account.isPresent()) {
context.status(200).json(account.get());
} else {
context.status(404).json(new Error(ErrorCode.ACCOUNT_DOES_NOT_EXIST.getCode(), "Account not found"));
}
}
use of com.nexblocks.authguard.api.dto.entities.Error in project AuthGuard by AuthGuard.
the class AccountsRoute method getByExternalId.
public void getByExternalId(final Context context) {
final String accountId = context.pathParam("id");
final Optional<AccountDTO> account = accountsService.getByExternalId(accountId).map(restMapper::toDTO);
if (account.isPresent()) {
context.status(200).json(account.get());
} else {
context.status(404).json(new Error(ErrorCode.ACCOUNT_DOES_NOT_EXIST.getCode(), "Account not found"));
}
}
use of com.nexblocks.authguard.api.dto.entities.Error in project AuthGuard by AuthGuard.
the class AccountsRoute method deactivate.
public void deactivate(final Context context) {
final String accountId = context.pathParam("id");
final Optional<AccountDTO> account = accountsService.deactivate(accountId).map(restMapper::toDTO);
if (account.isPresent()) {
context.status(200).json(account.get());
} else {
context.status(404).json(new Error("404", "No account with ID " + accountId + " exists"));
}
}
Aggregations