DomainOptions Impl
This commit is contained in:
parent
9453174b83
commit
93a4c560ab
@ -139,26 +139,32 @@ public class DomainModuleImpl extends AbstractModuleImpl {
|
||||
|
||||
@Override
|
||||
public AbstractEntity update(AbstractEntity existingEntity) throws HSAdminException {
|
||||
Domain dom = (Domain) existingEntity;
|
||||
UnixUser loginUser = getTransaction().getLoginUser();
|
||||
if (dom.isPacDomain() && !loginUser.hasHostmasterRole()) {
|
||||
throw new AuthorisationException(loginUser, "update", existingEntity);
|
||||
}
|
||||
if (dom.getName() == null || dom.getName().length() == 0) {
|
||||
Domain updatedDom = (Domain) existingEntity;
|
||||
if (updatedDom.getName() == null || updatedDom.getName().length() == 0) {
|
||||
throw new HSAdminException("domain name required");
|
||||
}
|
||||
UnixUser admin = dom.getUser();
|
||||
UnixUser loginUser = getTransaction().getLoginUser();
|
||||
EntityManager em = getTransaction().getEntityManager();
|
||||
Domain oldDom = em.find(Domain.class, updatedDom.getId());
|
||||
UnixUser admin = updatedDom.getUser();
|
||||
if (admin == null || admin.getName() == null || admin.getName().length() == 0) {
|
||||
throw new HSAdminException("domain admin required");
|
||||
}
|
||||
if (admin.getPac() == null) {
|
||||
EntityManager em = getTransaction().getEntityManager();
|
||||
Query query = em.createQuery("SELECT u FROM UnixUsers u WHERE u.name = :adminName");
|
||||
query.setParameter("adminName", admin.getName());
|
||||
dom.setUser((UnixUser) query.getSingleResult());
|
||||
if (!admin.getName().equals(oldDom.getUser().getName())) {
|
||||
throw new AuthorisationException(loginUser, "update", existingEntity);
|
||||
}
|
||||
Query q = em.createQuery("SELECT opt FROM " +
|
||||
DomainOption.class.getAnnotation(javax.persistence.Entity.class).name() +
|
||||
" opt WHERE opt.name=:optName");
|
||||
for (DomainOption opt : updatedDom.getDomainOptions()) {
|
||||
q.setParameter("optName", opt.getName());
|
||||
List<?> list = q.getResultList();
|
||||
if (list.size() != 1) {
|
||||
throw new HSAdminException("invalid domain option: " + opt.getName());
|
||||
}
|
||||
}
|
||||
needsWriteAccessOn(existingEntity, "update");
|
||||
throw new AuthorisationException(loginUser, "update", existingEntity);
|
||||
return super.update(existingEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,11 +2,16 @@ package de.hsadmin.remote;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.mods.dom.Domain;
|
||||
import de.hsadmin.mods.dom.DomainOption;
|
||||
import de.hsadmin.mods.user.UnixUser;
|
||||
|
||||
public class DomainRemote extends AbstractRemote {
|
||||
@ -36,6 +41,11 @@ public class DomainRemote extends AbstractRemote {
|
||||
String since = df.format(sDate);
|
||||
resultMap.put("since", since);
|
||||
}
|
||||
List<String> domainOptionsList = new ArrayList<String>();
|
||||
resultMap.put("domainoptions", domainOptionsList);
|
||||
for (DomainOption opt : dom.getDomainOptions()) {
|
||||
domainOptionsList.add(opt.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,6 +61,15 @@ public class DomainRemote extends AbstractRemote {
|
||||
u.setName(user);
|
||||
dom.setUser(u);
|
||||
}
|
||||
Set<DomainOption> domainOptionsSet = new TreeSet<DomainOption>();
|
||||
Object domOptsObj = setParams.get("domainoptions");
|
||||
if (domOptsObj != null && domOptsObj instanceof List<?>) {
|
||||
List<String> domOptions = (List<String>) domOptsObj;
|
||||
for (String optString : domOptions) {
|
||||
domOptions.add(optString);
|
||||
}
|
||||
}
|
||||
dom.setDomainOptions(domainOptionsSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,13 +53,7 @@ public class EMailAddressRemote extends AbstractRemote {
|
||||
adr.setSubdomain(subdomain);
|
||||
}
|
||||
Object l = map.get("target");
|
||||
if (l instanceof String) {
|
||||
String target = (String) l;
|
||||
if (assertNotNull(target)) {
|
||||
adr.setTarget(target);
|
||||
}
|
||||
}
|
||||
if (l instanceof List<?>) {
|
||||
if (l != null && l instanceof List<?>) {
|
||||
StringBuffer tBuff = new StringBuffer();
|
||||
for (Object o : (List<?>) l) {
|
||||
if (o instanceof String) {
|
||||
|
Loading…
Reference in New Issue
Block a user