List of usage examples for org.hibernate Session merge
Object merge(Object object);
From source file:de.fhdo.collaboration.desktop.AttachmentDetails.java
License:Apache License
public void onOkClicked() { try {//from w w w. j a v a 2 s . com if (logger.isDebugEnabled()) logger.debug("Daten speichern"); //if(link.getAttachment() != null) // logger.debug("Tech type: " + getAttachment().getAttachment().getTechnicalTypeCd()); if (selectedTechnicalType != null) { //link.setTechnicalTypeCd(selectedTechnicalType.getDomainCode()); String code = selectedTechnicalType.getCode(); if (code != null && code.length() > 0) { link.setLinkType(Integer.parseInt(code)); } } Session hb_session = HibernateUtil.getSessionFactory().openSession(); hb_session.getTransaction().begin(); try { if (bearbeiten) { hb_session.merge(link); if (file != null) { file.setLinkId(link.getId()); hb_session.merge(file); } } else { // Neuer Eintrag link.setInsertTs(new Date()); hb_session.save(link); if (file != null) { logger.debug("Speicher neue Datei mit Link-ID: " + link.getId()); file.setLinkId(link.getId()); hb_session.save(file); } } //Benachrichtigung Benutzer ArrayList<Collaborationuser> completeUserList = new ArrayList<Collaborationuser>(); //Lade alle Benutzer mit Privilegien auf Proposal String hqlPrivilegeUsers = "from Collaborationuser cu join fetch cu.privileges pri join fetch pri.proposal pro join fetch cu.organisation o where pro.id=:id"; Query qPrivilegeUsers = hb_session.createQuery(hqlPrivilegeUsers); qPrivilegeUsers.setParameter("id", proposal.getId()); List<Collaborationuser> privUserList = qPrivilegeUsers.list(); for (Collaborationuser cu : privUserList) { completeUserList.add(cu); } //Lade alle Diskussionsgruppen mit Privilegien auf Proposal String hqlPrivilegeGroups = "from Collaborationuser cu join fetch cu.discussiongroups dg join fetch dg.privileges pri join fetch pri.proposal pro where pro.id=:id"; Query qPrivilegeGroups = hb_session.createQuery(hqlPrivilegeGroups); qPrivilegeGroups.setParameter("id", proposal.getId()); List<Collaborationuser> privGroupList = qPrivilegeGroups.list(); for (Collaborationuser cu : privGroupList) { boolean doubleEntry = false; for (Collaborationuser cuI : completeUserList) { if (cu.getId().equals(cuI.getId())) { doubleEntry = true; } } if (!doubleEntry) { completeUserList.add(cu); } } ArrayList<String> mailAdr = new ArrayList<String>(); for (Collaborationuser u : completeUserList) { if (u.getSendMail() != null && u.getSendMail()) mailAdr.add(u.getEmail()); } String[] adr = new String[mailAdr.size()]; for (int i = 0; i < adr.length; i++) { adr[i] = mailAdr.get(i); } Mail.sendMailAUT(adr, M_AUT.PROPOSAL_LINK_SUBJECT, M_AUT.getInstance().getProposalLinkChangeText(proposal.getVocabularyName(), proposal.getContentType(), proposal.getDescription(), selectedTechnicalType.getDisplayText(), link.getDescription())); hb_session.getTransaction().commit(); // Collaborationuser lesen und speichern in link, damit dieser in der Liste angezeigt werden kann link.setCollaborationuser((Collaborationuser) hb_sessionS.get(Collaborationuser.class, SessionHelper.getCollaborationUserID())); } catch (Exception e) { LoggingOutput.outputException(e, this); hb_session.getTransaction().rollback(); // TODO Fehlermeldung anzeigen } finally { hb_session.close(); if (getUpdateListInterface() != null) getUpdateListInterface().update(link, bearbeiten); } } catch (Exception e) { // Fehlermeldung ausgeben logger.error("Fehler in onOkClicked(): " + e.getMessage()); hb_sessionS.close(); } this.setVisible(false); this.detach(); hb_sessionS.close(); //de.fhdo.gui.patientrecord.modules.masterdata.CommunicationDetails cannot be cast to de.fhdo.gui.patientrecord.modules.masterdata.Mast //Executions.getCurrent().setAttribute("contactPerson_controller", null); }
From source file:de.fhdo.collaboration.discgroup.DiscGroupDetails.java
License:Apache License
public void onOkClicked() { if (!showOnly) { boolean run = true; dgd.getGroup().setName(((Textbox) getFellow("tb_DiscussiongroupName")).getText()); if (dgd.getGroup().getName() == null || dgd.getGroup().getName().length() == 0) { Messagebox.show("Sie mssen einen Namen fr die Diskussionsgruppe und Teilnehmer angeben!", "Information", Messagebox.OK, Messagebox.EXCLAMATION); run = false;//from w w w .j ava 2 s.co m } if (dlbu.getChosenDataList().isEmpty()) { Messagebox.show("Eine Diskussionsgruppe muss mindestens einen Teilnehmer haben!", "Information", Messagebox.OK, Messagebox.EXCLAMATION); run = false; } if (run) { try { if (logger.isDebugEnabled()) logger.debug("Daten speichern"); Session hb_session = HibernateUtil.getSessionFactory().openSession(); hb_session.getTransaction().begin(); try { if (newEntry) { // prfen, ob Gruppe bereits existiert String hql = "from Discussiongroup where name=:group"; Query q = hb_session.createQuery(hql); q.setParameter("group", dgd.getGroup().getName()); List dGroupList = q.list(); if (dGroupList != null && dGroupList.size() > 0) { hb_session.close(); run = false; Messagebox.show( "Diskussionsgruppe existiert bereits. Bitte whlen Sie einen anderen Namen!", "Information", Messagebox.OK, Messagebox.EXCLAMATION); } if (run) { if (logger.isDebugEnabled()) logger.debug("Neuer Eintrag, fge hinzu!"); Discussiongroup group = new Discussiongroup(dgd.getGroup().getName()); for (DiscussionGroupUserInfo user : dlbu.getChosenDataList()) { Collaborationuser cu = (Collaborationuser) hb_session.get( de.fhdo.collaboration.db.classes.Collaborationuser.class, user.getCollaborationuserId()); group.getCollaborationusers().add(cu); } group.setHead(SessionHelper.getCollaborationUserID()); hb_session.save(group); dgd.setGroup(group); // prfen, ob Gruppe bereits existiert String hqlU = "from Collaborationuser where id=:p_id"; Query qU = hb_session.createQuery(hqlU); qU.setParameter("p_id", SessionHelper.getCollaborationUserID()); List<Collaborationuser> userList = qU.list(); if (userList.size() == 1) { dgd.setHeadOfGroup(userList.get(0)); } hb_session.getTransaction().commit(); } } else { dgd.getGroup().getCollaborationusers().clear(); for (DiscussionGroupUserInfo user : dlbu.getChosenDataList()) { Collaborationuser cu = (Collaborationuser) hb_session.get( de.fhdo.collaboration.db.classes.Collaborationuser.class, user.getCollaborationuserId()); dgd.getGroup().getCollaborationusers().add(cu); } hb_session.merge(dgd.getGroup()); hb_session.getTransaction().commit(); } } catch (Exception e) { hb_session.getTransaction().rollback(); logger.error("Fehler in DiskussionsgruppenDetails.java (onOkClicked()): " + e.getMessage()); } if (run) { hb_session.close(); this.setVisible(false); this.detach(); if (updateListInterface != null) { updateListInterface.update(dgd, !newEntry); } } } catch (Exception e) { // Fehlermeldung ausgeben logger.error("Fehler in DiskussionsgruppenDetails.java: " + e.getMessage()); e.printStackTrace(); } } } else { Boolean run = false; if (((Checkbox) getFellow("cb_cbAbmelden")).isChecked()) { Session hb_session = HibernateUtil.getSessionFactory().openSession(); hb_session.getTransaction().begin(); try { Discussiongroup dg = (Discussiongroup) hb_session.get(Discussiongroup.class, dgd.getGroup().getId()); for (Collaborationuser u : dg.getCollaborationusers()) { if (u.getId().equals(SessionHelper.getCollaborationUserID())) { dg.getCollaborationusers().remove(u); break; } } hb_session.update(dg); hb_session.getTransaction().commit(); run = true; } catch (Exception e) { hb_session.getTransaction().rollback(); logger.error("Fehler in DiskussionsgruppenDetails.java (onOkClicked()): " + e.getMessage()); } finally { hb_session.close(); } } this.setVisible(false); this.detach(); if (run) { if (updateListInterface != null) { updateListInterface.update(run, false); //ResetList } } } }
From source file:de.fhdo.collaboration.discussion.DiscussionEntryDetails.java
License:Apache License
public void onOkClicked() { try {// w ww. j a v a 2 s.c o m if (logger.isDebugEnabled()) logger.debug("Daten speichern"); Quote quote = null; Session hb_session = HibernateUtil.getSessionFactory().openSession(); hb_session.getTransaction().begin(); try { //CKeditor edit = (CKeditor)getFellow("editor"); //discussion.setLongDescription(edit.getValue()); if (bearbeiten) { discussion.setChanged(new Date()); hb_session.merge(discussion); /*if(file != null) { file.setLinkId(link.getId()); hb_session.merge(file); }*/ } else { // Neuer Eintrag discussion.setDate(new Date()); // Diskussionsnummer berechnen String SQL_QUERY = "select max(d.postNumber) from Discussion d where d.proposal.id=" + discussion.getProposal().getId(); Query query = hb_session.createQuery(SQL_QUERY); List list = query.list(); Integer maxNumber = null; if (!list.isEmpty()) { maxNumber = (Integer) list.get(0); } if (maxNumber == null || maxNumber < 0) maxNumber = 0; discussion.setPostNumber(maxNumber + 1); // Speichern hb_session.save(discussion); if (discussionQuoted != null) { logger.debug("Zitat speichern, mit Disk-ID " + discussion.getId() + " und " + discussionQuoted.getId()); // Zitat speichern quote = new Quote(); quote.setDiscussionByDiscussionId(new Discussion()); quote.setDiscussionByDiscussionIdQuoted(new Discussion()); quote.getDiscussionByDiscussionId().setId(discussion.getId()); quote.getDiscussionByDiscussionIdQuoted().setId(discussionQuoted.getId()); // TODO nur bestimmten Text als Zitat speichern // quote.setText() hb_session.save(quote); } /*if(file != null) { logger.debug("Speicher neue Datei mit Link-ID: " + link.getId()); file.setLinkId(link.getId()); hb_session.save(file); }*/ } hb_session.getTransaction().commit(); if (bearbeiten == false) { // Zur Anzeige in der Liste discussion.setCollaborationuser((Collaborationuser) hb_sessionS.get(Collaborationuser.class, discussion.getCollaborationuser().getId())); if (quote != null) { quote.setDiscussionByDiscussionIdQuoted(discussionQuoted); discussion.setQuotesForDiscussionId(new HashSet<Quote>()); discussion.getQuotesForDiscussionId().add(quote); } logger.debug("Neu geladen mit user-ID: " + discussion.getCollaborationuser().getId() + " und name: " + discussion.getCollaborationuser().getName()); } ArrayList<Collaborationuser> completeUserList = new ArrayList<Collaborationuser>(); Proposal prop = (Proposal) hb_session.get(Proposal.class, discussion.getProposal().getId()); //Lade alle Benutzer mit Privilegien auf Proposal String hqlPrivilegeUsers = "from Collaborationuser cu join fetch cu.privileges pri join fetch pri.proposal pro join fetch cu.organisation o where pro.id=:id"; Query qPrivilegeUsers = hb_session.createQuery(hqlPrivilegeUsers); qPrivilegeUsers.setParameter("id", prop.getId()); List<Collaborationuser> privUserList = qPrivilegeUsers.list(); for (Collaborationuser cu : privUserList) { completeUserList.add(cu); } //Lade alle Diskussionsgruppen mit Privilegien auf Proposal String hqlPrivilegeGroups = "from Collaborationuser cu join fetch cu.discussiongroups dg join fetch dg.privileges pri join fetch pri.proposal pro where pro.id=:id"; Query qPrivilegeGroups = hb_session.createQuery(hqlPrivilegeGroups); qPrivilegeGroups.setParameter("id", prop.getId()); List<Collaborationuser> privGroupList = qPrivilegeGroups.list(); for (Collaborationuser cu : privGroupList) { boolean doubleEntry = false; for (Collaborationuser cuI : completeUserList) { if (cu.getId().equals(cuI.getId())) { doubleEntry = true; } } if (!doubleEntry) { completeUserList.add(cu); } } ArrayList<String> mailAdr = new ArrayList<String>(); for (Collaborationuser u : completeUserList) { if (u.getSendMail() != null && u.getSendMail()) mailAdr.add(u.getEmail()); } String[] adr = new String[mailAdr.size()]; for (int i = 0; i < adr.length; i++) { adr[i] = mailAdr.get(i); } Mail.sendMailAUT(adr, M_AUT.PROPOSAL_DISCUSSION_SUBJECT, M_AUT.getInstance().getProposalDiscussionEntryText(prop.getVocabularyName(), prop.getContentType(), prop.getDescription(), discussion.getLongDescription(), discussion.getCollaborationuser().getFirstName() + " " + discussion.getCollaborationuser().getName())); } catch (Exception e) { LoggingOutput.outputException(e, this); hb_session.getTransaction().rollback(); // TODO Fehlermeldung anzeigen } finally { hb_session.close(); if (updateInterface != null) updateInterface.update(discussion, bearbeiten); } } catch (Exception e) { // Fehlermeldung ausgeben logger.error("Fehler in onOkClicked(): " + e.getMessage()); hb_sessionS.close(); } this.setVisible(false); this.detach(); if (hb_sessionS != null) hb_sessionS.close(); //de.fhdo.gui.patientrecord.modules.masterdata.CommunicationDetails cannot be cast to de.fhdo.gui.patientrecord.modules.masterdata.Mast //Executions.getCurrent().setAttribute("contactPerson_controller", null); }
From source file:de.fhdo.collaboration.helper.LoginHelper.java
License:Apache License
public boolean activate(String hash) { Session hb_session = HibernateUtil.getSessionFactory().openSession(); hb_session.getTransaction().begin(); org.hibernate.Query q = hb_session.createQuery("from Collaborationuser WHERE activation_md5=:p_hash"); q.setString("p_hash", hash); java.util.List<Collaborationuser> userList = (java.util.List<Collaborationuser>) q.list(); if (userList.size() == 1) { Collaborationuser user = userList.get(0); DateTime now = DateTime.now();// w w w . j av a 2 s. c o m DateTime origin = new DateTime(user.getActivationTime()); Seconds seconds = Seconds.secondsBetween(origin, now); int sec = seconds.getSeconds(); if (seconds.getSeconds() < activationTimespan) { user.setEnabled(true); user.setActivated(true); user.setActivationMd5(""); hb_session.merge(user); hb_session.getTransaction().commit(); hb_session.close(); return true; } else { return false; } } hb_session.close(); return false; }
From source file:de.fhdo.collaboration.helper.LoginHelper.java
License:Apache License
public static boolean resendPassword(boolean New, String Username) { boolean erfolg = false; if (logger.isDebugEnabled()) logger.debug("Neues Passwort fuer Benutzer " + Username); Session hb_session = HibernateUtil.getSessionFactory().openSession(); hb_session.getTransaction().begin(); try {//from w w w .ja v a 2 s . c o m List list = hb_session.createQuery("from Collaborationuser where username=:p_user") .setString("p_user", Username).list(); if (list.size() > 0) { Collaborationuser user = (Collaborationuser) list.get(0); // Neues Passwort generieren String neuesPW = Password.generateRandomPassword(8); // Email-Adresse lesen String mail = user.getEmail(); // TODO Neues Passwort per Email versenden String[] adr = new String[1]; adr[0] = mail; String result = Mail.sendNewPasswordCollaboration(Username, neuesPW, adr); if (result.length() == 0) erfolg = true; if (erfolg) { // Neues Passwort in der Datenbank speichern String salt = Password.generateRandomSalt(); user.setPassword(Password.getSaltedPassword(neuesPW, salt, Username)); user.setSalt(salt); hb_session.merge(user); } } hb_session.getTransaction().commit(); } catch (Exception e) { hb_session.getTransaction().rollback(); logger.error("Fehler bei resendPassword(): " + e.getLocalizedMessage()); } finally { hb_session.close(); } return erfolg; }
From source file:de.fhdo.collaboration.UserDetails.java
License:Apache License
public void onOkClicked() { // speichern mit Hibernate try {/*from ww w. java 2 s. c om*/ if (logger.isDebugEnabled()) logger.debug("Daten speichern"); Session hb_session = HibernateUtil.getSessionFactory().openSession(); hb_session.getTransaction().begin(); try { hb_session.merge(user); hb_session.getTransaction().commit(); } catch (Exception e) { hb_session.getTransaction().rollback(); LoggingOutput.outputException(e, this); } hb_session.close(); this.setVisible(false); this.detach(); if (updateListInterface != null) updateListInterface.update(user, true); } catch (Exception e) { // Fehlermeldung ausgeben LoggingOutput.outputException(e, this); hb_sessionS.close(); } hb_sessionS.close(); }
From source file:de.fhdo.gui.admin.modules.collaboration.BenutzerDetails.java
License:Apache License
public void onOkClicked() { String mailResponse = ""; // speichern mit Hibernate try {/*www . j a v a 2s . com*/ if (logger.isDebugEnabled()) logger.debug("Daten speichern"); Session hb_session = HibernateUtil.getSessionFactory().openSession(); hb_session.getTransaction().begin(); try { if (newEntry) { // Pflichtfelder prfen if (user.getUsername() == null || user.getUsername().length() == 0 || user.getEmail() == null || user.getEmail().length() == 0 || user.getEmail().contains("@") == false || cbUserRole.getSelectedItem() == null || user.getOrganisation().getOrganisation() == null || user.getOrganisation().getOrganisation().equals("")) { Messagebox.show( "Sie mssen einen Benutzernamen, eine gltige Email-Adresse, Benutzerrolle und Organisation angeben."); hb_session.close(); return; } // prfen, ob Benutzer bereits existiert String hql = "from Collaborationuser where username=:user"; Query q = hb_session.createQuery(hql); q.setParameter("user", user.getUsername()); List userList = q.list(); if (userList != null && userList.size() > 0) { Messagebox .show("Benutzer existiert bereits. Bitte whlen Sie einen anderen Benutzernamen."); hb_session.close(); return; } if (logger.isDebugEnabled()) logger.debug("Neuer Eintrag, fuege hinzu!"); // Passwort und Salt generieren String neuesPW = Password.generateRandomPassword(8); String salt = Password.generateRandomSalt(); user.setPassword(Password.getSaltedPassword(neuesPW, salt, user.getUsername(), 1000)); user.setSalt(salt); user.setActivated(false); user.setActivationMd5(MD5.getMD5(Password.generateRandomPassword(6))); user.setActivationTime(new Date()); Role r = (Role) hb_session.get(Role.class, CollabUserRoleHelper .getCollabUserRoleIdByName(cbUserRole.getSelectedItem().getLabel())); user.getRoles().clear(); user.getRoles().add(r); // Benutzer speichern hb_session.save(user); user.getOrganisation().getCollaborationusers().clear(); user.getOrganisation().getCollaborationusers().add(user); hb_session.save(user.getOrganisation()); // Benachrichtigung senden mailResponse = Mail.sendMailCollaborationNewUser(user.getUsername(), neuesPW, user.getEmail(), user.getActivationMd5()); if (mailResponse.length() == 0) { hb_session.getTransaction().commit(); Messagebox.show("Benutzer wurde erfolgreich angelegt und Aktivierungs-Email verschickt."); } else { Messagebox.show("Fehler beim Anlegen eines Benutzers: " + mailResponse); hb_session.getTransaction().rollback(); } neuesPW = " "; } else { Role r = (Role) hb_session.get(Role.class, CollabUserRoleHelper .getCollabUserRoleIdByName(cbUserRole.getSelectedItem().getLabel())); user.getRoles().clear(); user.getRoles().add(r); hb_session.merge(user); hb_session.getTransaction().commit(); } } catch (Exception e) { hb_session.getTransaction().rollback(); logger.error("Fehler in DomainDetails.java (onOkClicked()): " + e.getMessage()); } hb_session.close(); this.setVisible(false); this.detach(); if (updateListInterface != null) updateListInterface.update(user, !newEntry); } catch (Exception e) { // Fehlermeldung ausgeben logger.error("Fehler in BenutzerDetails.java: " + e.getMessage()); hb_sessionS.close(); } if (hb_sessionS != null) hb_sessionS.close(); }
From source file:de.fhdo.gui.admin.modules.collaboration.DomainDetails.java
License:Apache License
public void onOkClicked() { // speichern mit Hibernate try {// w ww . j a v a2 s. co m if (logger.isDebugEnabled()) logger.debug("Daten speichern"); if (getSelectedSortType() != null) domain.setDomainValueByDisplayOrder(getSelectedSortType()); Session hb_session = HibernateUtil.getSessionFactory().openSession(); hb_session.getTransaction().begin(); try { if (newEntry) { if (logger.isDebugEnabled()) logger.debug("Neuer Eintrag, fuege der Domain hinzu!"); //Domain d = (Domain) hb_session.get(Domain.class, domainId); //d.setDomain(domain); hb_session.save(domain); } else { hb_session.merge(domain); } } catch (Exception e) { logger.error("Fehler in DomainDetails.java (onOkClicked()): " + e.getMessage()); } hb_session.getTransaction().commit(); hb_session.close(); this.setVisible(false); this.detach(); if (getUpdateListInterface() != null) getUpdateListInterface().update(getDomain(), !newEntry); } catch (Exception e) { // Fehlermeldung ausgeben logger.error("Fehler in DomainDetails.java: " + e.getMessage()); if (hb_sessionS != null) hb_sessionS.close(); } if (hb_sessionS != null) hb_sessionS.close(); }
From source file:de.fhdo.gui.admin.modules.collaboration.DomainValueDetails.java
License:Apache License
public void onOkClicked() { // speichern mit Hibernate try {/*w w w .ja va 2s .c o m*/ if (domainValue.getCode() == null || domainValue.getCode().length() == 0) { Messagebox.show("Geben Sie bitte einen Code an."); return; } if (domainValue.getDisplayText() == null || domainValue.getDisplayText().length() == 0) { Messagebox.show("Geben Sie bitte einen Anzeige-Text an."); return; } if (logger.isDebugEnabled()) logger.debug("Daten speichern"); Session hb_session = HibernateUtil.getSessionFactory().openSession(); hb_session.getTransaction().begin(); try { if (newEntry) { if (logger.isDebugEnabled()) logger.debug("Neuer Eintrag, fuege der Domain hinzu!"); Domain domain = (Domain) hb_session.get(Domain.class, domainId); domainValue.setDomain(domain); DomainValue val = (DomainValue) hb_session .get(de.fhdo.collaboration.db.classes.DomainValue.class, 1358l); domainValue.setDomainValue(val); hb_session.save(domainValue); } else { hb_session.merge(domainValue); } } catch (Exception e) { logger.error("Fehler in DomainValueDetails.java in onOkClicked(): " + e.getMessage()); e.printStackTrace(); } hb_session.getTransaction().commit(); hb_session.close(); // Verbindungen speichern Textbox tb = (Textbox) getFellow("ueberID"); String ueberIDs = tb.getValue(); if (ueberIDs.length() > 0) { String[] ids = ueberIDs.split(";"); for (int i = 0; i < ids.length; ++i) { long id = 0; if (ids[i].length() > 0) { id = Long.parseLong(ids[i]); DomainHelper.getInstance().saveUpperDomainID(domainValue.getId(), id); } } } //hb_session.close(); this.setVisible(false); this.detach(); if (updateListInterface != null) updateListInterface.update(domainValue, !newEntry); } catch (Exception e) { // Fehlermeldung ausgeben logger.error("Fehler in DomainValueDetails.java: " + e.getMessage()); e.printStackTrace(); } }
From source file:de.fhdo.gui.admin.modules.collaboration.EnquiryDetails.java
License:Apache License
public void onOkClicked() { String mailResponse = ""; if (!enquiry.getClosedFlag()) { try {//from www.j a va 2s .c om if (logger.isDebugEnabled()) logger.debug("Daten speichern"); if ((userExt.getUsername() != null && userExt.getUsername().length() != 0) || (userExt.getFirstName() != null && userExt.getFirstName().length() != 0) || (userExt.getName() != null && userExt.getName().length() != 0) || (userExt.getOrganisation().getOrganisation() != null && userExt.getOrganisation().getOrganisation().length() != 0) || (userExt.getEmail() != null && userExt.getEmail().length() != 0) || (userExt.getPhone() != null && userExt.getPhone().length() != 0)) { if (userExt.getUsername() == null || userExt.getUsername().length() == 0 || userExt.getFirstName() == null || userExt.getFirstName().length() == 0 || userExt.getName() == null || userExt.getName().length() == 0 || userExt.getOrganisation().getOrganisation() == null || userExt.getOrganisation().getOrganisation().length() == 0 || userExt.getEmail() == null || userExt.getEmail().length() == 0 || userExt.getEmail().contains("@") == false || userExt.getPhone() == null || userExt.getPhone().length() == 0) { Messagebox.show( "Wenn Sie den Inhaltsverwalter extra angeben, \n dann bitte alle Felder ausfllen!", "Fehler", Messagebox.OK, Messagebox.INFORMATION); return; } else { enquiry.setCollaborationuserExtPerson(userExt); } } Session hb_session = HibernateUtil.getSessionFactory().openSession(); hb_session.getTransaction().begin(); try { if (userTransfer.isChecked()) { enquiry.getCollaborationuser().setEnabled(true); enquiry.getCollaborationuser().setHidden(false); activateUser = true; closedIssue.setChecked(true); } else if (enquiry.getCollaborationuserExtPerson() != null && userExTransfer.isChecked()) { enquiry.getCollaborationuserExtPerson().setEnabled(true); enquiry.getCollaborationuserExtPerson().setHidden(false); enquiry.getCollaborationuser().setEnabled(false); enquiry.getCollaborationuser().setHidden(true); activateUserEx = true; closedIssue.setChecked(true); } else if (enquiry.getCollaborationuserExtPerson() != null && !userExTransfer.isChecked()) { enquiry.getCollaborationuserExtPerson().setEnabled(false); enquiry.getCollaborationuserExtPerson().setHidden(true); enquiry.getCollaborationuser().setEnabled(false); enquiry.getCollaborationuser().setHidden(true); } else { enquiry.getCollaborationuser().setEnabled(false); enquiry.getCollaborationuser().setHidden(true); } enquiry.setClosedFlag(closedIssue.isChecked()); if (enquiry.getCollaborationuserExtPerson() != null) { if (enquiry.getCollaborationuserExtPerson().getOrganisation() != null) { hb_session.merge(enquiry.getCollaborationuserExtPerson().getOrganisation()); } if (activateUserEx) { neuesPW = Password.generateRandomPassword(8); String salt = Password.generateRandomSalt(); enquiry.getCollaborationuserExtPerson().setPassword(Password.getSaltedPassword(neuesPW, salt, enquiry.getCollaborationuserExtPerson().getUsername(), 1000)); enquiry.getCollaborationuserExtPerson().setSalt(salt); enquiry.getCollaborationuserExtPerson().setActivated(false); enquiry.getCollaborationuserExtPerson() .setActivationMd5(MD5.getMD5(Password.generateRandomPassword(6))); enquiry.getCollaborationuserExtPerson().setActivationTime(new Date()); } hb_session.merge(enquiry.getCollaborationuserExtPerson()); } if (activateUser) { neuesPW = Password.generateRandomPassword(8); String salt = Password.generateRandomSalt(); enquiry.getCollaborationuser().setPassword(Password.getSaltedPassword(neuesPW, salt, enquiry.getCollaborationuser().getUsername(), 1000)); enquiry.getCollaborationuser().setSalt(salt); enquiry.getCollaborationuser().setActivated(false); enquiry.getCollaborationuser() .setActivationMd5(MD5.getMD5(Password.generateRandomPassword(6))); enquiry.getCollaborationuser().setActivationTime(new Date()); } hb_session.merge(enquiry.getCollaborationuser().getOrganisation()); hb_session.merge(enquiry.getCollaborationuser()); hb_session.merge(enquiry); if (activateUser || activateUserEx) { Collaborationuser user = null; if (activateUser) user = enquiry.getCollaborationuser(); if (activateUserEx) user = enquiry.getCollaborationuserExtPerson(); // Benachrichtigung senden mailResponse = Mail.sendMailCollaborationNewUser(user.getUsername(), neuesPW, user.getEmail(), user.getActivationMd5()); if (mailResponse.length() == 0) { hb_session.getTransaction().commit(); } else { throw new Exception("Mail konnte nicht versandt werden!"); } neuesPW = " "; } else { hb_session.getTransaction().commit(); } } catch (Exception e) { hb_session.getTransaction().rollback(); logger.error("Fehler in EnquiryDetails.java (onOkClicked()): " + e.getMessage()); } finally { hb_session.close(); } if ((activateUser && enquiry.getCollaborationuser().getRoles().iterator().next().getName() .equals(CODES.ROLE_INHALTSVERWALTER)) || (activateUserEx && enquiry.getCollaborationuserExtPerson() != null && enquiry.getCollaborationuserExtPerson().getRoles().iterator().next().getName() .equals(CODES.ROLE_INHALTSVERWALTER))) { Messagebox.show( "Der Benutzer wurde mit der Rolle Inhaltsverwalter \nin der Kollaboration angelegt!\n " + "Bitte legen sie nun den Benutzer manuell im Terminologiebereich an!", "ACHTUNG", Messagebox.OK, Messagebox.INFORMATION, new org.zkoss.zk.ui.event.EventListener() { public void onEvent(Event evt) throws InterruptedException { if (evt.getName().equals("onOK")) { EnquiryDetails.this.setVisible(false); EnquiryDetails.this.detach(); } } }); } else { this.setVisible(false); this.detach(); } if (updateListInterface != null) updateListInterface.update(enquiry, true); } catch (Exception e) { // Fehlermeldung ausgeben logger.error("Fehler in EnquiryDetails.java: " + e.getMessage()); } finally { if (hb_sessionS != null) hb_sessionS.close(); } } }