use of javax.faces.application.FacesMessage 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();
}
use of javax.faces.application.FacesMessage 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()));
}
use of javax.faces.application.FacesMessage in project opentheso by miledrousset.
the class SelectedThesaurus method editerTheso.
/**
* Modification d'un thésaurus
*/
public void editerTheso() {
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 {
new ThesaurusHelper().UpdateThesaurus(connect.getPoolConnexion(), editTheso);
vue.setEdit(false);
}
}
use of javax.faces.application.FacesMessage in project acs-community-packaging by Alfresco.
the class BaseDetailsBean method takeOwnership.
/**
* Action Handler to take Ownership of the current node
*/
public void takeOwnership(final ActionEvent event) {
final FacesContext fc = FacesContext.getCurrentInstance();
try {
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>() {
public Object execute() throws Throwable {
getOwnableService().takeOwnership(getNode().getNodeRef());
String msg = Application.getMessage(fc, MSG_SUCCESS_OWNERSHIP);
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
String formId = Utils.getParentForm(fc, event.getComponent()).getClientId(fc);
fc.addMessage(formId + ':' + getPropertiesPanelId(), facesMsg);
getNode().reset();
return null;
}
};
txnHelper.doInTransaction(callback);
} catch (Throwable e) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(fc, Repository.ERROR_GENERIC), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
}
use of javax.faces.application.FacesMessage in project acs-community-packaging by Alfresco.
the class AdminNodeBrowseBean method submitSearch.
/**
* Action to submit search
*
* @return next action
*/
public String submitSearch() {
long start = System.currentTimeMillis();
RetryingTransactionCallback<String> searchCallback = new RetryingTransactionCallback<String>() {
public String execute() throws Throwable {
if (queryLanguage.equals("noderef")) {
// ensure node exists
NodeRef nodeRef = new NodeRef(query);
boolean exists = getNodeService().exists(nodeRef);
if (!exists) {
throw new AlfrescoRuntimeException("Node " + nodeRef + " does not exist.");
}
setNodeRef(nodeRef);
return "node";
} else if (queryLanguage.equals("selectnodes")) {
List<NodeRef> nodes = getSearchService().selectNodes(getNodeRef(), query, null, getNamespaceService(), false);
searchResults = new SearchResults(nodes);
return "search";
}
// perform search
searchResults = new SearchResults(getSearchService().query(getNodeRef().getStoreRef(), queryLanguage, query));
return "search";
}
};
try {
String result = getTransactionService().getRetryingTransactionHelper().doInTransaction(searchCallback, true);
this.searchElapsedTime = System.currentTimeMillis() - start;
return result;
} catch (Throwable e) {
FacesContext context = FacesContext.getCurrentInstance();
FacesMessage message = new FacesMessage();
message.setSeverity(FacesMessage.SEVERITY_ERROR);
message.setDetail("Search failed due to: " + e.toString());
context.addMessage("searchForm:query", message);
return "error";
}
}
Aggregations