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 -- table: domain_option
-- --
INSERT INTO domain_option (domain_option_name) INSERT INTO domain_option (domain_option_name)
VALUES ('graylisting'); VALUES ('greylisting');
INSERT INTO domain_option (domain_option_name) INSERT INTO domain_option (domain_option_name)
VALUES ('htdocsfallback'); VALUES ('htdocsfallback');

View File

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

View File

@ -43,10 +43,13 @@ public class DomainRemote extends AbstractRemote {
} }
List<String> domainOptionsList = new ArrayList<String>(); List<String> domainOptionsList = new ArrayList<String>();
resultMap.put("domainoptions", domainOptionsList); resultMap.put("domainoptions", domainOptionsList);
for (DomainOption opt : dom.getDomainOptions()) { Set<DomainOption> domainOptions = dom.getDomainOptions();
if (domainOptions != null) {
for (DomainOption opt : domainOptions) {
domainOptionsList.add(opt.getName()); domainOptionsList.add(opt.getName());
} }
} }
}
@Override @Override
protected void map2entity(Map<String, Object> setParams, AbstractEntity entity) { protected void map2entity(Map<String, Object> setParams, AbstractEntity entity) {

View File

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