use of javax.faces.application.FacesMessage in project opentheso by miledrousset.
the class CurrentUser method renamePseudo.
public void renamePseudo() {
if (pseudo == null || pseudo.isEmpty()) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error6")));
} else if (new UserHelper().isPseudoExist(connect.getPoolConnexion(), pseudo)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error5")));
} else {
new UserHelper().updatePseudo(connect.getPoolConnexion(), user.getId(), pseudo);
user.setName(pseudo);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info5")));
}
name = pseudo;
pseudo = "";
}
use of javax.faces.application.FacesMessage in project opentheso by miledrousset.
the class CurrentUser method editAllPref.
public void editAllPref() {
// nodePreference.setAlertCdt(alertCdtEdit);
nodePreference.setSourceLang(langSourceEdit);
if (!new PreferencesHelper().updateAllPreferenceUser(connect.getPoolConnexion(), nodePreference, idTheso)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
return;
}
initUserNodePref(idTheso);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info6")));
}
use of javax.faces.application.FacesMessage in project opentheso by miledrousset.
the class CurrentUser method addUser.
public void addUser() throws SQLException {
if (pwdEdit1 == null || pwdEdit1.equals("") || pwdEdit2 == null || pwdEdit2.equals("") || nameEdit == null || nameEdit.equals("") || mailEdit.equals("") || mailEdit == null) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error2")));
} else if (!pwdEdit1.equals(pwdEdit2)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error3")));
} else if (new UserHelper().isUserLoginExist(connect.getPoolConnexion(), nameEdit)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error5")));
} else {
UserHelper userHelper = new UserHelper();
Connection conn;
conn = connect.getPoolConnexion().getConnection();
conn.setAutoCommit(false);
int idUser = -1;
if (userHelper.isUserMailExist(conn, mailEdit)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.info7")));
} else {
try {
// Cas de création de SuperAdmin
if (user.getIdRole() == 1) {
// ajout de l'utilisateur
if (!userHelper.addUser(conn, nameEdit, mailEdit, MD5Password.getEncodedPassword(pwdEdit1), roleEdit)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
conn.rollback();
conn.close();
return;
}
// récupération de l'Id du User
idUser = userHelper.getIdUser(conn, nameEdit);
if (idUser == -1) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
conn.rollback();
conn.close();
return;
}
// ajout du role
if (!userHelper.addRole(conn, idUser, roleEdit, idTheso, "")) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
conn.rollback();
conn.close();
return;
}
}
// Cas de création d'admin (par thésaurus)
if (user.getIdRole() == 2) {
// ajout de l'utilisateur
if (!userHelper.addUser(conn, nameEdit, mailEdit, MD5Password.getEncodedPassword(pwdEdit1), roleEdit)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
conn.rollback();
conn.close();
return;
}
// récupération de l'Id du User
idUser = userHelper.getIdUser(conn, nameEdit);
if (idUser == -1) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
conn.rollback();
conn.close();
return;
}
// ajout du role
if (!userHelper.addRole(conn, idUser, roleEdit, idTheso, "")) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
conn.rollback();
conn.close();
return;
}
}
// mise à jour des alerts mails pour l'utilisateur
if (alertmail) {
if (idUser != -1)
if (!userHelper.setAlertMailForUser(conn, idUser, true)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
conn.rollback();
conn.close();
return;
}
}
userHelper.updateAddUserHistorique(conn, nameEdit);
conn.commit();
conn.close();
} catch (SQLException ex) {
Logger.getLogger(CurrentUser.class.getName()).log(Level.SEVERE, null, ex);
}
mailEdit = "";
pwdEdit1 = "";
pwdEdit2 = "";
nameEdit = "";
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info3")));
}
}
}
use of javax.faces.application.FacesMessage in project opentheso by miledrousset.
the class Soap method openConnexionPool.
private HikariDataSource openConnexionPool(Properties properties) {
HikariConfig config = new HikariConfig();
config.setMinimumIdle(Integer.parseInt(properties.getProperty("minimumIdle")));
config.setMaximumPoolSize(Integer.parseInt(properties.getProperty("setMaximumPoolSize")));
config.setAutoCommit(true);
config.setIdleTimeout(Integer.parseInt(properties.getProperty("idleTimeout")));
config.setConnectionTimeout(Integer.parseInt(properties.getProperty("connectionTimeout")));
config.setConnectionTestQuery(properties.getProperty("connectionTestQuery"));
config.setDataSourceClassName(properties.getProperty("dataSourceClassName"));
config.addDataSourceProperty("user", properties.getProperty("dataSource.user"));
config.addDataSourceProperty("password", properties.getProperty("dataSource.password"));
config.addDataSourceProperty("databaseName", properties.getProperty("dataSource.databaseName"));
config.addDataSourceProperty("serverName", properties.getProperty("dataSource.serverName"));
config.addDataSourceProperty("portNumber", properties.getProperty("dataSource.serverPort"));
HikariDataSource poolConnexion1 = new HikariDataSource(config);
try {
Connection conn = poolConnexion1.getConnection();
if (conn == null)
return null;
conn.close();
} catch (SQLException ex) {
Logger.getLogger(Connexion.class.getName()).log(Level.SEVERE, null, ex);
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_FATAL, ex.getClass().getName(), ex.getMessage());
FacesContext.getCurrentInstance().addMessage(null, message);
poolConnexion1.close();
return null;
}
return poolConnexion1;
}
use of javax.faces.application.FacesMessage in project opentheso by miledrousset.
the class Connexion method openConnexionPool.
private HikariDataSource openConnexionPool() {
HikariConfig config = new HikariConfig();
ResourceBundle resourceBundle = getBundlePool();
if (resourceBundle == null) {
// retour pour installation
return null;
}
config.setMinimumIdle(Integer.parseInt(resourceBundle.getString("minimumIdle")));
config.setMaximumPoolSize(Integer.parseInt(resourceBundle.getString("setMaximumPoolSize")));
config.setAutoCommit(true);
// config.setIdleTimeout(Integer.parseInt(getBundlePool().getString("idleTimeout")));
// config.setConnectionTimeout(Integer.parseInt(getBundlePool().getString("connectionTimeout")));
// config.setJdbc4ConnectionTest(false);
config.setConnectionTestQuery(resourceBundle.getString("connectionTestQuery"));
config.setDataSourceClassName(resourceBundle.getString("dataSourceClassName"));
config.addDataSourceProperty("user", resourceBundle.getString("dataSource.user"));
config.addDataSourceProperty("password", resourceBundle.getString("dataSource.password"));
config.addDataSourceProperty("databaseName", resourceBundle.getString("dataSource.databaseName"));
config.addDataSourceProperty("serverName", resourceBundle.getString("dataSource.serverName"));
config.addDataSourceProperty("portNumber", resourceBundle.getString("dataSource.serverPort"));
HikariDataSource poolConnexion1 = new HikariDataSource(config);
try {
poolConnexion1.getConnection();
} catch (SQLException ex) {
Logger.getLogger(Connexion.class.getName()).log(Level.SEVERE, null, ex);
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_FATAL, ex.getClass().getName(), ex.getMessage());
FacesContext.getCurrentInstance().addMessage(null, message);
poolConnexion1.close();
return null;
}
return poolConnexion1;
}
Aggregations