| | |
| | | import de.hsadmin.core.model.HSAdminException; |
| | | import de.hsadmin.core.model.Transaction; |
| | | import de.hsadmin.core.util.TextUtil; |
| | | import de.hsadmin.mods.dom.Domain; |
| | | import de.hsadmin.mods.email.EMailAddress; |
| | | import de.hsadmin.mods.email.EMailAlias; |
| | | import de.hsadmin.mods.pac.Pac; |
| | | import de.hsadmin.mods.user.UnixUser; |
| | | |
| | |
| | | } |
| | | Customer newCustomer = (Customer) newEntity; |
| | | assertNotNull("membercode", newCustomer.getName()); |
| | | assertValidMemberCode("membercode", newCustomer.getName()); |
| | | assertNotNull("password", newCustomer.getPassword()); |
| | | Contact contact = newCustomer.getContacts().iterator().next(); |
| | | assertNotNull("contact_lastname", contact.getLastName()); |
| | | assertNotNull("contact_email", contact.getEmail()); |
| | | String custComment = contact.getLastName(); |
| | | if (contact.getFirstName() != null && contact.getFirstName().length() > 0) { |
| | | custComment = contact.getFirstName() + " " + contact.getLastName(); |
| | |
| | | newCustomer.setBankAccount(bankAccount); |
| | | } |
| | | GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction()); |
| | | |
| | | UnixUser custAccount = new UnixUser(); |
| | | custAccount.setComment(TextUtil.replaceUmlautCharacters(custComment)); |
| | | custAccount.setName(newCustomer.getName()); |
| | |
| | | custAccount.setQuotaSoftlimit(8); |
| | | custAccount.setQuotaHardlimit(12); |
| | | helperModule.add(custAccount); |
| | | |
| | | EMailAlias custAlias = new EMailAlias(); |
| | | custAlias.setName(newCustomer.getName()); |
| | | custAlias.setTarget(contact.getEmail()); |
| | | helperModule.add(custAlias); |
| | | |
| | | String memberCode = newCustomer.getName(); |
| | | EMailAddress custEMail1 = new EMailAddress(); |
| | | custEMail1.setLocalpart(memberCode.substring(6)); |
| | | Domain dom = (Domain) helperModule.findByString(Domain.class, "hostsharing.net"); |
| | | custEMail1.setDomain(dom); |
| | | custEMail1.setTarget(memberCode); |
| | | helperModule.add(custEMail1); |
| | | |
| | | if (contact.getFirstName() != null && contact.getFirstName().length() > 0) { |
| | | custComment = TextUtil.replaceUmlautCharacters(contact.getFirstName().toLowerCase()) |
| | | + "." + TextUtil.replaceUmlautCharacters(contact.getLastName().toLowerCase()); |
| | | EMailAddress custEMail2 = new EMailAddress(); |
| | | custEMail2.setLocalpart(custComment.replace(' ', '-')); |
| | | custEMail2.setDomain(dom); |
| | | custEMail2.setTarget(memberCode); |
| | | helperModule.add(custEMail2); |
| | | } |
| | | |
| | | return super.add(newEntity); |
| | | } |
| | | |
| | |
| | | GenericModuleImpl helper = new GenericModuleImpl(getTransaction()); |
| | | AbstractEntity custAccount = helper.findByString(UnixUser.class, cust.getName()); |
| | | helper.delete(custAccount); |
| | | AbstractEntity custAlias = helper.findByString(EMailAlias.class, cust.getName()); |
| | | helper.delete(custAlias); |
| | | List<AbstractEntity> custEMailsList = helper.search(EMailAddress.class, "target='" + cust.getName() + "'", null); |
| | | for (AbstractEntity email : custEMailsList) { |
| | | helper.delete(email); |
| | | } |
| | | super.delete(existingEntity); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private void assertValidMemberCode(String name, String value) throws HSAdminException { |
| | | if (value == null || value.length() != 9 || !value.startsWith("hsh00-")) { |
| | | throw new HSAdminException("field '" + name + "' has to be like 'hsh00-xyz'"); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |