diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandGetSpaces.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandGetSpaces.java index 7d3503e..67d50be 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandGetSpaces.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/command/AccountingCommandGetSpaces.java @@ -12,14 +12,12 @@ import org.slf4j.LoggerFactory; /** * - * @author Giancarlo Panichi + * @author Giancarlo Panichi * * */ -public class AccountingCommandGetSpaces implements - AccountingCommand { - private static final Logger logger = LoggerFactory - .getLogger(AccountingCommandGetSpaces.class); +public class AccountingCommandGetSpaces implements AccountingCommand { + private static final Logger logger = LoggerFactory.getLogger(AccountingCommandGetSpaces.class); public AccountingCommandGetSpaces() { } @@ -29,21 +27,20 @@ public class AccountingCommandGetSpaces implements try { logger.debug("getSpaces()"); SortedSet keys = null; - AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory - .getInstance(); - + AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance(); + keys = apq.getSpaceProvidersIds(); logger.debug("AccountingPersistenceQuery.getSpaces: " + keys); - if (keys == null || keys.isEmpty()) { - return null; - } - ArrayList spaceList = new ArrayList<>(); - for (String key : keys) { - if (key != null && !key.isEmpty()) { - spaceList.add(key); + if (keys == null || keys.isEmpty()) { + logger.error("Spaces have not keys: {}", keys); + } else { + for (String key : keys) { + if (key != null && !key.isEmpty()) { + spaceList.add(key); + } } } Spaces categories = new Spaces(spaceList); @@ -52,9 +49,7 @@ public class AccountingCommandGetSpaces implements return categories; } catch (Throwable e) { - logger.error("Error in AccountingCommandGetSpaces(): " - + e.getLocalizedMessage()); - e.printStackTrace(); + logger.error("Error in AccountingCommandGetSpaces(): {}", e.getLocalizedMessage(), e); throw new ServiceException("No spaces available!"); }