Search in sources :

Example 36 with UserHelper2

use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.

the class CurrentUser2 method addUser.

/**
 * permet de créer un nouvel utilisateur avec le role et dans le groupe en
 * cours
 *
 * @param idGroup
 * @return
 */
public boolean addUser(String idGroup) {
    UserHelper2 userHelper = new UserHelper2();
    if (pwdAdded1 == null || pwdAdded1.equals("") || pwdAdded2 == null || pwdAdded2.equals("") || pseudoAdded == null || pseudoAdded.equals("") || mailAdded.equals("") || mailAdded == null) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error2")));
        return false;
    }
    if (!pwdAdded1.equals(pwdAdded2)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error3")));
        return false;
    }
    if (userHelper.isPseudoExist(connect.getPoolConnexion(), pseudoAdded)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error5")));
        return false;
    }
    if (userHelper.isMailExist(connect.getPoolConnexion(), mailAdded)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.info7")));
        return false;
    }
    int idUser;
    int idGroupTemp = -1;
    boolean isSuperAdmin = false;
    if (idGroup != null) {
        if (!idGroup.isEmpty()) {
            idGroupTemp = Integer.parseInt(idGroup);
        } else
            idGroupTemp = -1;
    }
    if (roleAdded == 1)
        isSuperAdmin = true;
    if (!userHelper.addUser(connect.getPoolConnexion(), pseudoAdded, mailAdded, MD5Password.getEncodedPassword(pwdAdded1), isSuperAdmin, alertmail)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
        return false;
    }
    idUser = userHelper.getIdUser(connect.getPoolConnexion(), pseudoAdded, MD5Password.getEncodedPassword(pwdAdded1));
    if (idUser == -1) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
        return false;
    }
    // / si idGroupTemp = -1 : création d'utilisateur sans groupe
    if (!isSuperAdmin && idGroupTemp != -1) {
        // on ajoute l'utilisateur au groupe séléctionné par l'utilisateur
        if (!userHelper.addUserRoleOnGroup(connect.getPoolConnexion(), idUser, roleAdded, idGroupTemp)) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
            return false;
        }
    }
    mailAdded = "";
    pwdAdded1 = "";
    pwdAdded2 = "";
    pseudoAdded = "";
    roleAdded = -1;
    groupAdded = "";
    listUsersByGroup();
    if (isSuperAdmin)
        listSuperAdmin();
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info3")));
    return true;
}
Also used : UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2) FacesMessage(javax.faces.application.FacesMessage)

Example 37 with UserHelper2

use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.

the class CurrentUser2 method listAllGroupUser.

private void listAllGroupUser() {
    UserHelper2 userHelper = new UserHelper2();
    listeAllGroupUser = userHelper.getAllGroupUser(connect.getPoolConnexion(), connect.getWorkLanguage());
    // les users sans groupe en ignorant les superAdmin
    ArrayList<NodeUserGroupUser> nodeUserGroupUser_wtihoutGroup = userHelper.getAllGroupUserWithoutGroup(connect.getPoolConnexion(), connect.getWorkLanguage());
    if (nodeUserGroupUser_wtihoutGroup != null)
        if (!nodeUserGroupUser_wtihoutGroup.isEmpty())
            listeAllGroupUser.addAll(nodeUserGroupUser_wtihoutGroup);
}
Also used : UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2) NodeUserGroupUser(mom.trd.opentheso.bdd.helper.nodes.NodeUserGroupUser)

Example 38 with UserHelper2

use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.

the class CurrentUser2 method initPassword.

public void initPassword() {
    if (password5 == null) {
        return;
    }
    UserHelper2 userHelper2 = new UserHelper2();
    if (!userHelper2.updatePwd(connect.getPoolConnexion(), userEdit.getIdUser(), MD5Password.getEncodedPassword(password5))) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("BDD" + " :", "Error"));
    }
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info1")));
}
Also used : UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2) FacesMessage(javax.faces.application.FacesMessage)

Example 39 with UserHelper2

use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.

the class CurrentUser2 method updatePassword.

/**
 * Permet de modifier le mot de passe de l'utilisateur
 */
public void updatePassword() {
    if (pwdAdded1 == null || pwdAdded1.equals("") || pwdAdded2 == null || pwdAdded2.equals("") || pwdAdded3 == null || pwdAdded3.equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error2")));
    } else if (!pwdAdded2.equals(pwdAdded3)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error3")));
    } else if (!new UserHelper2().isUserExist(connect.getPoolConnexion(), user.getName(), MD5Password.getEncodedPassword(pwdAdded1))) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error4")));
    } else {
        new UserHelper2().updatePwd(connect.getPoolConnexion(), user.getIdUser(), MD5Password.getEncodedPassword(pwdAdded2));
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info1")));
    }
    pwdAdded1 = "";
    pwdAdded2 = "";
    pwdAdded3 = "";
}
Also used : UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2) FacesMessage(javax.faces.application.FacesMessage)

Example 40 with UserHelper2

use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.

the class CurrentUser2 method getSelectedGroupName.

public String getSelectedGroupName() {
    UserHelper2 userHelper = new UserHelper2();
    if (selectedGroup != null)
        if (!selectedGroup.isEmpty())
            selectedGroupName = userHelper.getGroupName(connect.getPoolConnexion(), Integer.parseInt(selectedGroup));
        else
            selectedGroupName = selectedGroup;
    return selectedGroupName;
}
Also used : UserHelper2(mom.trd.opentheso.bdd.helper.UserHelper2)

Aggregations

UserHelper2 (mom.trd.opentheso.bdd.helper.UserHelper2)48 FacesMessage (javax.faces.application.FacesMessage)19 Connection (java.sql.Connection)9 SQLException (java.sql.SQLException)8 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)6 HikariDataSource (com.zaxxer.hikari.HikariDataSource)5 ConnexionTest (connexion.ConnexionTest)5 Thesaurus (mom.trd.opentheso.bdd.datas.Thesaurus)5 Test (org.junit.Test)5 AccessThesaurusHelper (mom.trd.opentheso.bdd.helper.AccessThesaurusHelper)3 PreferencesHelper (mom.trd.opentheso.bdd.helper.PreferencesHelper)3 LinkedHashMap (java.util.LinkedHashMap)2 CandidateHelper (mom.trd.opentheso.bdd.helper.CandidateHelper)2 NodePreference (mom.trd.opentheso.bdd.helper.nodes.NodePreference)2 NodeUserRoleGroup (mom.trd.opentheso.bdd.helper.nodes.NodeUserRoleGroup)2 PrimeFaces (org.primefaces.PrimeFaces)2 HashMap (java.util.HashMap)1 PostConstruct (javax.annotation.PostConstruct)1 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)1 NodeUser2 (mom.trd.opentheso.bdd.helper.nodes.NodeUser2)1