/** * insert user and the mail server configuration * * @param msa MailServerAccount * @return int * @throws EntityException */ public int insertUser(MailServerAccount msa) throws EntityException { int result = 0; try { if (msa.getMailServer().getMailServerId() == null || msa.getMailServer().getMailServerId().equals("")) { msa.getMailServer().setMailServerId("" + this.idMailServerSpace.next()); } else { String msId = msa.getMailServer().getMailServerId(); if (msa.getMailServer().getIsPublic()) { MailServer msFromDB = cdao.getPubMailServer(msId); MailServer ms = msa.getMailServer(); // replace the imput info with the db info msa.getMailServer().setMailServerId(msId); msa.getMailServer().setMailServerType(msFromDB.getMailServerType()); msa.getMailServer().setDescription(msFromDB.getDescription()); msa.getMailServer().setIsSoftDelete(msFromDB.getIsSoftDelete()); msa.getMailServer().setIsPublic(msFromDB.getIsPublic()); msa.getMailServer().setProtocol(msFromDB.getProtocol()); msa.getMailServer().setOutServer(msFromDB.getOutServer()); msa.getMailServer().setOutPort(msFromDB.getOutPort()); msa.getMailServer().setOutAuth(msFromDB.getOutAuth()); msa.getMailServer().setInServer(msFromDB.getInServer()); msa.getMailServer().setInPort(msFromDB.getInPort()); msa.getMailServer().setIsSSLIn(msFromDB.getIsSSLIn()); msa.getMailServer().setIsSSLOut(msFromDB.getIsSSLOut()); msa.getMailServer() .setInboxPath(getValueOrDefault(ms.getInboxPath(), msFromDB.getInboxPath())); msa.getMailServer().setInboxActivation(msFromDB.getInboxActivation()); msa.getMailServer() .setOutboxPath(getValueOrDefault(ms.getOutboxPath(), msFromDB.getOutboxPath())); msa.getMailServer().setOutboxActivation(msFromDB.getOutboxActivation()); msa.getMailServer() .setSentPath(getValueOrDefault(ms.getSentPath(), msFromDB.getSentPath())); msa.getMailServer().setSentActivation(msFromDB.getSentActivation()); msa.getMailServer() .setDraftsPath(getValueOrDefault(ms.getDraftsPath(), msFromDB.getDraftsPath())); msa.getMailServer().setDraftsActivation(msFromDB.getDraftsActivation()); msa.getMailServer() .setTrashPath(getValueOrDefault(ms.getTrashPath(), msFromDB.getTrashPath())); msa.getMailServer().setTrashActivation(msFromDB.getTrashActivation()); } } // from UI we get the minutes but in the DB we save the seconds msa.setPeriod(Utility.setMillis(msa.getPeriod())); // check serverType checkMailServerInfo(msa); // check folder names checkFoldersName(msa); // set the push listener framework properties msa.setTaskBeanFile(Def.DEFAULT_INBOX_LISTENER_BEAN_FILE); msa.setStatus(RegistryEntryStatus.NEW); msa.setLastUpdate(System.currentTimeMillis()); // insert the account result = cdao.insertUser(msa); } catch (DBIDGeneratorException ee) { throw new EntityException("Error handling ID ", ee); } catch (EntityException ee) { throw new EntityException("Error addind Account", ee); } catch (Exception ee) { throw new EntityException("Error checking input values of the Account", ee); } return result; }