Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0020659Openbravo ERPA. Platformpublic2012-06-01 10:052012-06-07 12:37
mtaal 
AugustoMauch 
normalminorhave not tried
closedfixed 
5
 
3.0MP133.0MP13 
Core
No
0020659: OrganizationStructureProvider throws NPE if passed org id does not belong to the client
The OrganizationStructureProvider class throws an NPE in this line (271):
    return new HashSet<String>(childByOrganizationID.get(orgId));

this because childByOrganizationID.get(orgId) returns null and the HashSet constructor can't handle that.

It is nicer to either throw a more meaningfull exception (organization not valid for client or something) or return an empty result.
Get the organization structure provider from the context:
      Set<String> orgChildTree = OBContext.getOBContext().getOrganizationStructureProvider()
          .getChildTree(strOrg, true);

the strOrg should be a non-existing id
a NPE will be thrown

it is nice to check this issue through a junit testcase
No tags attached.
Issue History
2012-06-01 10:05mtaalNew Issue
2012-06-01 10:05mtaalAssigned To => marvintm
2012-06-01 10:05mtaalModules => Core
2012-06-04 12:13marvintmAssigned Tomarvintm => AugustoMauch
2012-06-05 15:09hgbotCheckin
2012-06-05 15:09hgbotNote Added: 0049619
2012-06-05 15:09hgbotStatusnew => resolved
2012-06-05 15:09hgbotResolutionopen => fixed
2012-06-05 15:09hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/b9a5fed6dd96ef644fcf8c6e31260a4f93ccf340 [^]
2012-06-07 12:37guilleaerNote Added: 0049667
2012-06-07 12:37guilleaerStatusresolved => closed
2012-06-07 12:37guilleaerFixed in Version => 3.0MP13

Notes
(0049619)
hgbot   
2012-06-05 15:09   
Repository: erp/devel/pi
Changeset: b9a5fed6dd96ef644fcf8c6e31260a4f93ccf340
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Tue Jun 05 15:08:23 2012 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/b9a5fed6dd96ef644fcf8c6e31260a4f93ccf340 [^]

Fixes issue 20659: An empty set is returned when an invalid orgid is provided

The method getChildOrg of OrganizationStructureProvider now returns and empty set instead of null if an invalid orgid is provided.

A test has been added to test this behaviour.: Enter commit message. Lines beginning with 'HG:' are removed.

---
M src-test/org/openbravo/test/dal/IssuesTest.java
M src/org/openbravo/dal/security/OrganizationStructureProvider.java
---
(0049667)
guilleaer   
2012-06-07 12:37   
code reviewed and tested in pi@0bc61ab27f73