Package usecase.user
Class UserService
- java.lang.Object
-
- usecase.user.UserService
-
@ApplicationScoped public class UserService extends Object
Classe che fornisce i servizi relativi agli utenti.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedUserService()protectedUserService(GenericRepository genericRepository, MediaRepository mediaRepository, Pbkdf2PasswordHash passwordHash, CurrentUser currentUser)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete(int id)Elimina un utente dato un idvoidedit(@Valid UserEditPage edit, int id)Modifica i dati di un utente dato un idUserProfilegetUser(int id)Ritorna un entita UserProfile dato un idUserProfilegetUser(@NotBlank String name)Ritorna un entita UserProfile dato un nomeStringgetUsernameById(int id)Ritorna un lo username di un utente dato un idintnewUser(String email, String username, String password)Crea un nuovo utente e ne restituisce l'idList<UserProfile>showUsers()Ritorna un lista di UserProfile relativa agli utenti registrativoidtoggleAdmin(int id)Inverte lo stato di admin di un utente dato un id
-
-
-
Constructor Detail
-
UserService
protected UserService()
-
UserService
@Inject protected UserService(GenericRepository genericRepository, MediaRepository mediaRepository, Pbkdf2PasswordHash passwordHash, CurrentUser currentUser)
-
-
Method Detail
-
toggleAdmin
@AdminsOnly public void toggleAdmin(@UserExists int id)
Inverte lo stato di admin di un utente dato un id- Parameters:
id- id di un utente esistente
-
getUser
public UserProfile getUser(@NotBlank @UserExists @NotBlank String name)
Ritorna un entita UserProfile dato un nome- Parameters:
name- di un utente esistente- Returns:
- entita UserProfile
-
getUser
public UserProfile getUser(@UserExists int id)
Ritorna un entita UserProfile dato un id- Parameters:
id- di un utente esistente- Returns:
- entita UserProfile
-
getUsernameById
public String getUsernameById(@UserExists int id)
Ritorna un lo username di un utente dato un id- Parameters:
id- di un utente esistente- Returns:
- nome dell'utente
-
showUsers
public List<UserProfile> showUsers()
Ritorna un lista di UserProfile relativa agli utenti registrati- Returns:
- lista di entita UserIdentityDTO
-
delete
@AdminsOnly public void delete(@UserExists int id)
Elimina un utente dato un id- Parameters:
id- di un utente esistente
-
edit
@AuthenticationRequired public void edit(@Valid @Valid UserEditPage edit, @UserExists int id)
Modifica i dati di un utente dato un id- Parameters:
edit- nuovi dati dell'utenteid- di un utente esistente
-
newUser
public int newUser(@NotNull @EmailFormat @UniqueEmail String email, @NotNull @UsernameFormat @UniqueUsername String username, @NotNull @PasswordFormat String password)
Crea un nuovo utente e ne restituisce l'id- Parameters:
email- stringa non vuota, unica e in formato emailusername- stringa non vuota e unicapassword- Stringa non vuota con minimo: 3 e massimo: 255 caratteri- Returns:
- identificativo dell'utente creato
-
-