Skip to content

Commit

Permalink
Fixed bug when creating an enterprise
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoeppke committed Nov 28, 2016
1 parent 38c0ce8 commit e797590
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ public void updateEnterpriseInformation() {

@Override
public void updateStoreInformation() throws NotInDatabaseException_Exception {
if (this.enterprises == null) {
updateEnterpriseInformation();
}
checkEnterprisesAvailable();

// This collection has a fixed size depending on the number of
// enterprises,
Expand All @@ -114,9 +112,7 @@ public void updateStoreInformation() throws NotInDatabaseException_Exception {

@Override
public EnterpriseViewData getEnterpriseByID(long enterpriseID) {
if (enterprises == null) {
updateEnterpriseInformation();
}
checkEnterprisesAvailable();

return enterprises.get(enterpriseID);
}
Expand Down Expand Up @@ -192,6 +188,8 @@ public boolean updateStore(@NotNull StoreViewData store) {

@Override
public boolean createEnterprise(@NotNull String name) {
checkEnterprisesAvailable();

EnterpriseTO enterpriseTO;

try {
Expand All @@ -201,6 +199,7 @@ public boolean createEnterprise(@NotNull String name) {
LOG.error(String.format("Exception while creating enterprise: %s\n%s", e.getMessage(), e.getStackTrace()));
return false;
}

enterprises.put(enterpriseTO.getId(), new EnterpriseViewData(enterpriseTO.getId(), enterpriseTO.getName()));

return true;
Expand Down Expand Up @@ -266,4 +265,10 @@ private boolean checkStoresAvailable() {
}
return true;
}

private void checkEnterprisesAvailable() {
if (enterprises == null) {
updateEnterpriseInformation();
}
}
}

0 comments on commit e797590

Please sign in to comment.