Refs #21013: Migrate accounting-manager to postgresql persistence
Updated GetSpaces
This commit is contained in:
parent
ef12d844c1
commit
72ea4d1314
|
@ -12,14 +12,12 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class AccountingCommandGetSpaces implements
|
||||
AccountingCommand<Spaces> {
|
||||
private static final Logger logger = LoggerFactory
|
||||
.getLogger(AccountingCommandGetSpaces.class);
|
||||
public class AccountingCommandGetSpaces implements AccountingCommand<Spaces> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(AccountingCommandGetSpaces.class);
|
||||
|
||||
public AccountingCommandGetSpaces() {
|
||||
}
|
||||
|
@ -29,21 +27,20 @@ public class AccountingCommandGetSpaces implements
|
|||
try {
|
||||
logger.debug("getSpaces()");
|
||||
SortedSet<String> 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<String> 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!");
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue