fix NullPointer

greylisting seen more common
This commit is contained in:
Peter Hormanns 2012-07-25 16:24:12 +00:00
parent 3a386fb24e
commit 7b0315df1f
4 changed files with 9 additions and 9 deletions

View File

@ -155,6 +155,6 @@ INSERT INTO unixuser (name, comment, shell, homedir, locked, packet_id, userid)
-- table: domain_option
--
INSERT INTO domain_option (domain_option_name)
VALUES ('graylisting');
VALUES ('greylisting');
INSERT INTO domain_option (domain_option_name)
VALUES ('htdocsfallback');

View File

@ -159,9 +159,6 @@ public class DomainModuleImpl extends AbstractModuleImpl {
DomainOption.class.getAnnotation(javax.persistence.Entity.class).name() +
" opt WHERE opt.name=:optName");
Set<DomainOption> domainOptions = updatedDom.getDomainOptions();
// if (domainOptions == null) {
// updatedDom.setDomainOptions(oldDom.getDomainOptions());
// }
for (DomainOption opt : domainOptions) {
q.setParameter("optName", opt.getName());
List<?> list = q.getResultList();

View File

@ -43,8 +43,11 @@ public class DomainRemote extends AbstractRemote {
}
List<String> domainOptionsList = new ArrayList<String>();
resultMap.put("domainoptions", domainOptionsList);
for (DomainOption opt : dom.getDomainOptions()) {
domainOptionsList.add(opt.getName());
Set<DomainOption> domainOptions = dom.getDomainOptions();
if (domainOptions != null) {
for (DomainOption opt : domainOptions) {
domainOptionsList.add(opt.getName());
}
}
}

View File

@ -155,7 +155,7 @@ public class DomainTest {
Map<String, Object> setParams = new HashMap<String, Object>();
Map<String, String> whereParams = new HashMap<String, String>();
List<String> optionslist = new ArrayList<String>();
optionslist.add("graylisting");
optionslist.add("greylisting");
setParams.put("domainoptions", optionslist);
whereParams.put("name", "example01.org");
Object[] params = new Object[] { user,
@ -177,7 +177,7 @@ public class DomainTest {
Map<String, String> whereParams = new HashMap<String, String>();
List<String> optionslist = new ArrayList<String>();
optionslist.add("htdocsfallback");
optionslist.add("graylisting");
optionslist.add("greylisting");
setParams.put("domainoptions", optionslist);
whereParams.put("name", "example01.org");
Object[] params = new Object[] { user,
@ -244,7 +244,7 @@ public class DomainTest {
Object[] result = (Object[]) execute;
assertEquals(result.length, 1);
assertTrue(result[0] instanceof Map<?, ?>);
Map<String, ?> domainMap = (Map<String, ?>) result[0];
Map<?, ?> domainMap = (Map<?, ?>) result[0];
assertNotNull(domainMap);
Object[] optsList = (Object[])domainMap.get("domainoptions");
if (optsList == null) {