Search in sources :

Example 6 with UserHelper

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

the class SelectedThesaurus method ajouterTheso.

/**
 * Création d'un nouveau thésaurus avec le role
 *
 * @param idUser
 * @param idRole
 */
public void ajouterTheso(int idUser, int idRole) {
    if (editTheso.getTitle() == null || editTheso.getTitle().trim().equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error1")));
    } else {
        ThesaurusHelper th = new ThesaurusHelper();
        th.setIdentifierType(identifierType);
        try {
            Connection conn = connect.getPoolConnexion().getConnection();
            conn.setAutoCommit(false);
            String idThesaurus = th.addThesaurusRollBack(conn, null, arkActive);
            if (idThesaurus == null) {
                FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("theso.error1")));
                conn.rollback();
                conn.close();
                return;
            }
            if (editTheso.getTitle().isEmpty()) {
                thesaurus.setTitle("theso_" + idThesaurus);
            }
            if (editTheso.getLanguage() == null) {
                editTheso.setLanguage(workLanguage);
            }
            editTheso.setId_thesaurus(idThesaurus);
            if (!th.addThesaurusTraductionRollBack(conn, editTheso)) {
                conn.rollback();
                conn.close();
                return;
            }
            // ajout de role pour le thésaurus à l'utilisateur en cours
            UserHelper userHelper = new UserHelper();
            if (!userHelper.addRole(conn, idUser, idRole, idThesaurus, "")) {
                FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
                conn.rollback();
                conn.close();
                return;
            }
            conn.commit();
            conn.close();
        } catch (SQLException ex) {
            Logger.getLogger(CurrentUser.class.getName()).log(Level.SEVERE, null, ex);
        }
        maj();
        arrayTheso = new ArrayList<>(th.getListThesaurus(connect.getPoolConnexion(), langueSource).entrySet());
        tree.getSelectedTerme().getUser().updateAuthorizedTheso();
        vue.setCreat(false);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("theso.info1.1") + " " + editTheso.getTitle() + " " + langueBean.getMsg("theso.info1.2")));
    // editTheso = new Thesaurus();
    }
// tree.getSelectedTerme().getUser().getUser().getId();
}
Also used : UserHelper(mom.trd.opentheso.bdd.helper.UserHelper) SQLException(java.sql.SQLException) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) Connection(java.sql.Connection) FacesMessage(javax.faces.application.FacesMessage)

Example 7 with UserHelper

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

the class SelectedThesaurus method supprimerTheso.

/**
 * Suppréssion d'un thésaurus
 *
 * @param id
 */
public void supprimerTheso(String id) {
    ThesaurusHelper th = new ThesaurusHelper();
    // on vérifie si l'utilisateur n'a plus aucun thésaurus, on garde son dernier role sans thésaurus
    // cette action est temporaire le temps de mettre en place une gestion complète des users et des groupes
    UserHelper userHelper = new UserHelper();
    Connection conn;
    try {
        conn = connect.getPoolConnexion().getConnection();
        conn.setAutoCommit(false);
        if (userHelper.isLastThesoOfUser(connect.getPoolConnexion(), tree.getSelectedTerme().getUser().getUser().getId())) {
            if (!userHelper.deleteOnlyTheThesoFromRole(conn, id)) {
                conn.rollback();
                conn.close();
                return;
            }
        } else {
            if (!userHelper.deleteThisRoleForThisThesaurus(conn, tree.getSelectedTerme().getUser().getUser().getId(), id)) {
                conn.rollback();
                conn.close();
                return;
            }
        }
        conn.commit();
        conn.close();
    } catch (SQLException ex) {
        Logger.getLogger(SelectedThesaurus.class.getName()).log(Level.SEVERE, null, ex);
    }
    ConceptHelper conceptHelper = new ConceptHelper();
    conceptHelper.setNodePreference(nodePreference);
    conceptHelper.deleteAllIdHandle(connect.getPoolConnexion(), id);
    th.deleteThesaurus(connect.getPoolConnexion(), id);
    arrayTheso = new ArrayList<>(th.getListThesaurus(connect.getPoolConnexion(), langueSource).entrySet());
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, langueBean.getMsg("info") + " :", conceptHelper.getMessage()));
}
Also used : ConceptHelper(mom.trd.opentheso.bdd.helper.ConceptHelper) UserHelper(mom.trd.opentheso.bdd.helper.UserHelper) SQLException(java.sql.SQLException) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) Connection(java.sql.Connection) FacesMessage(javax.faces.application.FacesMessage)

Example 8 with UserHelper

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

the class CurrentUser method changeMail.

public void changeMail() {
    if (mailEdit == null || mailEdit.equals("")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error6")));
    } else if (!mailEdit.contains("@") || mailEdit.lastIndexOf(".") < mailEdit.indexOf("@")) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error7")));
    } else if (new UserHelper().isUserMailExist(connect.getPoolConnexion(), mailEdit)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error8")));
    } else {
        new UserHelper().updateMail(connect.getPoolConnexion(), user.getId(), mailEdit);
        user.setMail(mailEdit);
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info5")));
    }
    mailEdit = "";
}
Also used : UserHelper(mom.trd.opentheso.bdd.helper.UserHelper) FacesMessage(javax.faces.application.FacesMessage)

Example 9 with UserHelper

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

the class CurrentUser method connect.

/**
 * Connect l'utilisateur si le compte existe
 *
 * @return le lien de l'index si le compte existe, un message d'erreur sinon
 * init c'est une parametre que viens du "isUserExist" ou return une 1 si on
 * fait le login normal (usuaire, pass), une 2 si on fait le login avec le
 * motpasstemp (et nous sommes dirigées a la page web de changer le
 * motpasstemp)
 */
public String connect() {
    UserHelper userHelper = new UserHelper();
    if (userHelper.isUserExist(connect.getPoolConnexion(), name, MD5Password.getEncodedPassword(pwd))) {
        try {
            // on vérifie si l'utilisateur est SuperAdmin, on lui donne tout les droits
            if (userHelper.isAdminUser(connect.getPoolConnexion(), name)) {
                user = userHelper.getInfoAdmin(connect.getPoolConnexion(), name);
                if (user == null) {
                    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.roleError")));
                    return "";
                }
                user.setIdThesaurus(idTheso);
                authorizedTheso = new ThesaurusHelper().getAllIdOfThesaurus(connect.getPoolConnexion());
                FacesContext context = FacesContext.getCurrentInstance();
                String version_Opentheso = context.getExternalContext().getInitParameter("version");
                BaseDeDoneesHelper baseDeDonnesHelper = new BaseDeDoneesHelper();
                baseDeDonnesHelper.updateVersionOpentheso(connect.getPoolConnexion(), version_Opentheso);
            } else // on récupère ses droits par rapport au thésaurus en cours
            {
                NodeUser nodeUserTemp = userHelper.getInfoUser(connect.getPoolConnexion(), name, idTheso);
                if (nodeUserTemp == null) {
                    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("info") + " :", langueBean.getMsg("user.roleErrorAll")));
                    nodeUserTemp = userHelper.getInfoUser(connect.getPoolConnexion(), name);
                    if (nodeUserTemp == null) {
                        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error1")));
                        return "";
                    }
                } else {
                    user = userHelper.getInfoUser(connect.getPoolConnexion(), name, idTheso);
                }
                authorizedTheso = userHelper.getAuthorizedThesaurus(connect.getPoolConnexion(), user.getId());
            }
            isLogged = true;
            if (userEdit != null) {
                isActive = userEdit.isIsActive();
            }
            if (userHelper.isChangeToPass(connect.getPoolConnexion(), name)) {
                // nouvelle pass web pour changer le motpasstemp
                return "changePass.xhtml?faces-redirect=true";
            }
            name = null;
            pwd = null;
            return "index.xhtml?faces-redirect=true";
        } catch (SQLException ex) {
            Logger.getLogger(CurrentUser.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    // utilisateur ou mot de passe n'existent pas
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error1")));
    return "";
}
Also used : FacesContext(javax.faces.context.FacesContext) UserHelper(mom.trd.opentheso.bdd.helper.UserHelper) SQLException(java.sql.SQLException) ThesaurusHelper(mom.trd.opentheso.bdd.helper.ThesaurusHelper) BaseDeDoneesHelper(mom.trd.opentheso.bdd.helper.BaseDeDoneesHelper) NodeUser(mom.trd.opentheso.bdd.helper.nodes.NodeUser) FacesMessage(javax.faces.application.FacesMessage)

Example 10 with UserHelper

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

the class CurrentUser method delUser.

public void delUser(int idUser) {
    new UserHelper().deleteUser(connect.getPoolConnexion(), idUser);
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info2")));
}
Also used : UserHelper(mom.trd.opentheso.bdd.helper.UserHelper) FacesMessage(javax.faces.application.FacesMessage)

Aggregations

UserHelper (mom.trd.opentheso.bdd.helper.UserHelper)19 FacesMessage (javax.faces.application.FacesMessage)10 Connection (java.sql.Connection)8 SQLException (java.sql.SQLException)8 ThesaurusHelper (mom.trd.opentheso.bdd.helper.ThesaurusHelper)6 Thesaurus (mom.trd.opentheso.bdd.datas.Thesaurus)2 BaseDeDoneesHelper (mom.trd.opentheso.bdd.helper.BaseDeDoneesHelper)2 CandidateHelper (mom.trd.opentheso.bdd.helper.CandidateHelper)2 NodeUser (mom.trd.opentheso.bdd.helper.nodes.NodeUser)2 FacesContext (javax.faces.context.FacesContext)1 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)1 PreferencesHelper (mom.trd.opentheso.bdd.helper.PreferencesHelper)1 SKOSCreator (mom.trd.opentheso.skosapi.SKOSCreator)1 SKOSLabel (mom.trd.opentheso.skosapi.SKOSLabel)1 SKOSRelation (mom.trd.opentheso.skosapi.SKOSRelation)1 SKOSResource (mom.trd.opentheso.skosapi.SKOSResource)1 SKOSConceptScheme (skos.SKOSConceptScheme)1 SKOSLabel (skos.SKOSLabel)1 SKOSResource (skos.SKOSResource)1 SKOSTopConcept (skos.SKOSTopConcept)1