Package it.unipd.netmus.server.persistent

Examples of it.unipd.netmus.server.persistent.UserAccount


     */
    @Override
    public boolean deleteSong(String user, String artist, String title,
            String album) {

        UserAccount useraccount = UserAccount.load(user);
        return useraccount.getMusicLibrary().removeSong(artist, title, album);

    }
View Full Code Here


     * Datastore ritorna il valore double che rappresenta la nuova media tra
     * tutte le votazione effettuate su quella canzone.
     */
    @Override
    public double rateSong(String user, SongSummaryDTO song, int rating) {
        UserAccount userAccount = UserAccount.load(user);
        MusicLibrary library = userAccount.getMusicLibrary();
        library.rateSong(Song.loadFromDTO(song), rating);
        return Song.loadFromDTO(song).getRatingDouble();
    }
View Full Code Here

        String passwordHash = BCrypt.hashpw(login.getPassword(),
                BCrypt.gensalt());

        // create new user in the database
        try {
            new UserAccount(login.getUser(), passwordHash);
        } catch (Exception e) {
            throw new RegistrationException();
        }

        return login;
View Full Code Here

            if (user == null || session_id == null)
                // non deve fare niente sui cookie, non esistono
                throw new LoginException();

            // restart old session by Cookies (se soddisfa)
            UserAccount userAccount = UserAccount.load(user);
            if (userAccount == null)
                throw new LoginException();
            String session_id_old = userAccount.getLastSessionId();

            if (session_id_old.equals(session_id)) {
                // caricare attributi in nuova session
                session.setAttribute("userLoggedIn", user);

                // aggiornare il campo lastSessionId
                userAccount.setLastSessionId(session_id_new);

                // deve aggionare i cookie pero' (refresh)
                return session_id_new;

            } else {
View Full Code Here

     */
    @Override
    public String startLogin(LoginDTO login) throws LoginException {

        // find user in the database
        UserAccount userAccount = verifyLogin(login);

        HttpSession session = getThreadLocalRequest().getSession();
        String session_id = session.getId();

        // set session parameter - userID
        LoginHelper.setSession(session, login.getUser());
        // set in DB userAccount the new SessionID
        userAccount.setLastSessionId(session_id);

        return session_id;
    }
View Full Code Here

        // find user in the database
        String username = login.getUser();
        if (username == null || username.equals(""))
            throw new LoginException("User empty");
        UserAccount userAccount = UserAccount.load(login.getUser());

        if (userAccount == null) {
            // user not found in the database
            throw new LoginException("User don't exists");
        } else {
            if (BCrypt.checkpw(login.getPassword(), userAccount.getPassword())) {
                // correct password
                return userAccount;
            } else
                throw new LoginException();
        }
View Full Code Here

     * login. Le canzoni che facevano parte del catalogo non vengono cancellate.
     */
    @Override
    public boolean deleteProfile(String user) {
        try {
            UserAccount current_user = UserAccount.load(user);
            UserAccount.deleteUser(current_user);

            return true;
        } catch (Exception e) {
            return false;
View Full Code Here

     */
    @Override
    public boolean editProfile(String user, UserCompleteDTO new_info_user) {

        try {
            UserAccount current_user = UserAccount.load(user);

            if (!new_info_user.getNewPassword().equals("")) {
                String passwordHash = BCrypt.hashpw(
                        new_info_user.getNewPassword(), BCrypt.gensalt());
                current_user.setPassword(passwordHash);
            }

            current_user.setNickName(new_info_user.getNickName());
            current_user.setFirstName(new_info_user.getFirstName());
            current_user.setLastName(new_info_user.getLastName());
            current_user.setGender(new_info_user.getGender());
            current_user.setNationality(new_info_user.getNationality());
            current_user.setAboutMe(new_info_user.getAboutMe());
            current_user.update();
            return true;

        } catch (Exception e) {
            return false;
        }
View Full Code Here

     * dall’artista più ricorrente.
     */
    @Override
    public List<String> findRelatedUsers(String user) {

        UserAccount user_account = UserAccount.load(user);

        return user_account.findRelatedUsers();
    }
View Full Code Here

     * richiesto il caricamento devono essere presenti nel Datastore.
     */
    @Override
    public UserCompleteDTO loadProfile(String user) {

        UserAccount user_account = UserAccount.load(user);

        if (user_account != null) {
            return user_account.toUserCompleteDTO();
        } else {
            return null;
        }

    }
View Full Code Here

TOP

Related Classes of it.unipd.netmus.server.persistent.UserAccount

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.