Search in sources :

Example 1 with USER

use of io.gravitee.repository.management.model.Audit.AuditProperties.USER in project gravitee-management-rest-api by gravitee-io.

the class UserServiceImpl method findAll.

@Override
public Set<UserEntity> findAll(boolean loadRoles) {
    try {
        LOGGER.debug("Find all users");
        Set<User> users = userRepository.findAll();
        return users.stream().map(u -> convert(u, loadRoles)).collect(Collectors.toSet());
    } catch (TechnicalException ex) {
        LOGGER.error("An error occurs while trying to find all users", ex);
        throw new TechnicalManagementException("An error occurs while trying to find all users", ex);
    }
}
Also used : RoleScope(io.gravitee.repository.management.model.RoleScope) java.util(java.util) BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder) NotificationParamsBuilder(io.gravitee.management.service.notification.NotificationParamsBuilder) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) MembershipDefaultReferenceId(io.gravitee.repository.management.model.MembershipDefaultReferenceId) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) EmailNotificationBuilder(io.gravitee.management.service.builder.EmailNotificationBuilder) StringUtils(org.apache.commons.lang3.StringUtils) Value(org.springframework.beans.factory.annotation.Value) DEFAULT_JWT_EMAIL_REGISTRATION_EXPIRE_AFTER(io.gravitee.management.service.common.JWTHelper.DefaultValues.DEFAULT_JWT_EMAIL_REGISTRATION_EXPIRE_AFTER) JWTVerifier(com.auth0.jwt.JWTVerifier) UUID(io.gravitee.common.utils.UUID) ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) io.gravitee.management.model(io.gravitee.management.model) UserRepository(io.gravitee.repository.management.api.UserRepository) JWTSigner(com.auth0.jwt.JWTSigner) DEFAULT_JWT_ISSUER(io.gravitee.management.service.common.JWTHelper.DefaultValues.DEFAULT_JWT_ISSUER) UserNotFoundException(io.gravitee.management.service.exceptions.UserNotFoundException) Claims(io.gravitee.management.service.common.JWTHelper.Claims) MembershipReferenceType(io.gravitee.repository.management.model.MembershipReferenceType) UsernameAlreadyExistsException(io.gravitee.management.service.exceptions.UsernameAlreadyExistsException) Logger(org.slf4j.Logger) DefaultRoleNotFoundException(io.gravitee.management.service.exceptions.DefaultRoleNotFoundException) TechnicalManagementException(io.gravitee.management.service.exceptions.TechnicalManagementException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) PortalHook(io.gravitee.management.service.notification.PortalHook) Collectors(java.util.stream.Collectors) IOUtils(org.apache.commons.io.IOUtils) Component(org.springframework.stereotype.Component) PasswordEncoder(org.springframework.security.crypto.password.PasswordEncoder) USER(io.gravitee.repository.management.model.Audit.AuditProperties.USER) io.gravitee.management.service(io.gravitee.management.service) User(io.gravitee.repository.management.model.User) io.gravitee.common.utils(io.gravitee.common.utils) DatatypeConverter(javax.xml.bind.DatatypeConverter) User(io.gravitee.repository.management.model.User) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) TechnicalManagementException(io.gravitee.management.service.exceptions.TechnicalManagementException)

Example 2 with USER

use of io.gravitee.repository.management.model.Audit.AuditProperties.USER in project gravitee-management-rest-api by gravitee-io.

the class UserServiceImpl method findByIds.

@Override
public Set<UserEntity> findByIds(List<String> ids) {
    try {
        LOGGER.debug("Find users by ID: {}", ids);
        Set<User> users = userRepository.findByIds(ids);
        if (!users.isEmpty()) {
            return users.stream().map(u -> this.convert(u, false)).collect(Collectors.toSet());
        }
        Optional<String> idsAsString = ids.stream().reduce((a, b) -> a + '/' + b);
        if (idsAsString.isPresent()) {
            throw new UserNotFoundException(idsAsString.get());
        } else {
            throw new UserNotFoundException("?");
        }
    } catch (TechnicalException ex) {
        Optional<String> idsAsString = ids.stream().reduce((a, b) -> a + '/' + b);
        LOGGER.error("An error occurs while trying to find users using their ID {}", idsAsString, ex);
        throw new TechnicalManagementException("An error occurs while trying to find users using their ID " + idsAsString, ex);
    }
}
Also used : RoleScope(io.gravitee.repository.management.model.RoleScope) java.util(java.util) BCryptPasswordEncoder(org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder) NotificationParamsBuilder(io.gravitee.management.service.notification.NotificationParamsBuilder) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) MembershipDefaultReferenceId(io.gravitee.repository.management.model.MembershipDefaultReferenceId) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) EmailNotificationBuilder(io.gravitee.management.service.builder.EmailNotificationBuilder) StringUtils(org.apache.commons.lang3.StringUtils) Value(org.springframework.beans.factory.annotation.Value) DEFAULT_JWT_EMAIL_REGISTRATION_EXPIRE_AFTER(io.gravitee.management.service.common.JWTHelper.DefaultValues.DEFAULT_JWT_EMAIL_REGISTRATION_EXPIRE_AFTER) JWTVerifier(com.auth0.jwt.JWTVerifier) UUID(io.gravitee.common.utils.UUID) ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) io.gravitee.management.model(io.gravitee.management.model) UserRepository(io.gravitee.repository.management.api.UserRepository) JWTSigner(com.auth0.jwt.JWTSigner) DEFAULT_JWT_ISSUER(io.gravitee.management.service.common.JWTHelper.DefaultValues.DEFAULT_JWT_ISSUER) UserNotFoundException(io.gravitee.management.service.exceptions.UserNotFoundException) Claims(io.gravitee.management.service.common.JWTHelper.Claims) MembershipReferenceType(io.gravitee.repository.management.model.MembershipReferenceType) UsernameAlreadyExistsException(io.gravitee.management.service.exceptions.UsernameAlreadyExistsException) Logger(org.slf4j.Logger) DefaultRoleNotFoundException(io.gravitee.management.service.exceptions.DefaultRoleNotFoundException) TechnicalManagementException(io.gravitee.management.service.exceptions.TechnicalManagementException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) PortalHook(io.gravitee.management.service.notification.PortalHook) Collectors(java.util.stream.Collectors) IOUtils(org.apache.commons.io.IOUtils) Component(org.springframework.stereotype.Component) PasswordEncoder(org.springframework.security.crypto.password.PasswordEncoder) USER(io.gravitee.repository.management.model.Audit.AuditProperties.USER) io.gravitee.management.service(io.gravitee.management.service) User(io.gravitee.repository.management.model.User) io.gravitee.common.utils(io.gravitee.common.utils) DatatypeConverter(javax.xml.bind.DatatypeConverter) UserNotFoundException(io.gravitee.management.service.exceptions.UserNotFoundException) User(io.gravitee.repository.management.model.User) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) TechnicalManagementException(io.gravitee.management.service.exceptions.TechnicalManagementException)

Aggregations

JWTSigner (com.auth0.jwt.JWTSigner)2 JWTVerifier (com.auth0.jwt.JWTVerifier)2 io.gravitee.common.utils (io.gravitee.common.utils)2 UUID (io.gravitee.common.utils.UUID)2 io.gravitee.management.model (io.gravitee.management.model)2 io.gravitee.management.service (io.gravitee.management.service)2 EmailNotificationBuilder (io.gravitee.management.service.builder.EmailNotificationBuilder)2 Claims (io.gravitee.management.service.common.JWTHelper.Claims)2 DEFAULT_JWT_EMAIL_REGISTRATION_EXPIRE_AFTER (io.gravitee.management.service.common.JWTHelper.DefaultValues.DEFAULT_JWT_EMAIL_REGISTRATION_EXPIRE_AFTER)2 DEFAULT_JWT_ISSUER (io.gravitee.management.service.common.JWTHelper.DefaultValues.DEFAULT_JWT_ISSUER)2 DefaultRoleNotFoundException (io.gravitee.management.service.exceptions.DefaultRoleNotFoundException)2 TechnicalManagementException (io.gravitee.management.service.exceptions.TechnicalManagementException)2 UserNotFoundException (io.gravitee.management.service.exceptions.UserNotFoundException)2 UsernameAlreadyExistsException (io.gravitee.management.service.exceptions.UsernameAlreadyExistsException)2 NotificationParamsBuilder (io.gravitee.management.service.notification.NotificationParamsBuilder)2 PortalHook (io.gravitee.management.service.notification.PortalHook)2 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)2 UserRepository (io.gravitee.repository.management.api.UserRepository)2 USER (io.gravitee.repository.management.model.Audit.AuditProperties.USER)2 MembershipDefaultReferenceId (io.gravitee.repository.management.model.MembershipDefaultReferenceId)2