From 98b63c1415454dc6af61279a06db86abb1c20ed8 Mon Sep 17 00:00:00 2001 From: Elaine Tan Date: Thu, 21 Mar 2013 11:46:02 +0800 Subject: [PATCH] Handle NPE in warehouses when login using System Administrator role --- .../idempiere/webservices/AbstractService.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/org.idempiere.webservices/WEB-INF/src/org/idempiere/webservices/AbstractService.java b/org.idempiere.webservices/WEB-INF/src/org/idempiere/webservices/AbstractService.java index a1a3130c7a..18e9fdd1b0 100644 --- a/org.idempiere.webservices/WEB-INF/src/org/idempiere/webservices/AbstractService.java +++ b/org.idempiere.webservices/WEB-INF/src/org/idempiere/webservices/AbstractService.java @@ -142,15 +142,18 @@ public class AbstractService { return "Error logging in - org not allowed for this role"; KeyNamePair[] warehouses = login.getWarehouses(new KeyNamePair(loginRequest.getOrgID(), "")); - boolean okwh = false; - for (KeyNamePair warehouse : warehouses) { - if (warehouse.getKey() == loginRequest.getWarehouseID()) { - okwh = true; - break; + if (warehouses != null) + { + boolean okwh = false; + for (KeyNamePair warehouse : warehouses) { + if (warehouse.getKey() == loginRequest.getWarehouseID()) { + okwh = true; + break; + } } + if (!okwh) + return "Error logging in - warehouse not allowed for this org"; } - if (!okwh) - return "Error logging in - warehouse not allowed for this org"; String error = login.validateLogin(orglogin); if (error != null && error.length() > 0)