use of org.craftercms.profile.exceptions.AccessTokenExistsException in project profile by craftercms.
the class AccessTokenServiceImpl method createToken.
@Override
public AccessToken createToken(AccessToken token) throws ProfileException {
checkIfTokenActionIsAllowed(null, Action.CREATE_TOKEN);
if (token.getId() == null) {
token.setId(UUID.randomUUID().toString());
}
try {
accessTokenRepository.insert(token);
} catch (DuplicateKeyException e) {
throw new AccessTokenExistsException(token.getId());
} catch (MongoDataException e) {
throw new I10nProfileException(ERROR_KEY_CREATE_ACCESS_TOKEN_ERROR, e, token);
}
logger.debug(LOG_KEY_ACCESS_TOKEN_CREATED, token);
return token;
}
Aggregations