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
|
public class AccountingCommandGetSpaces implements AccountingCommand<Spaces> {
|
||||||
AccountingCommand<Spaces> {
|
private static final Logger logger = LoggerFactory.getLogger(AccountingCommandGetSpaces.class);
|
||||||
private static final Logger logger = LoggerFactory
|
|
||||||
.getLogger(AccountingCommandGetSpaces.class);
|
|
||||||
|
|
||||||
public AccountingCommandGetSpaces() {
|
public AccountingCommandGetSpaces() {
|
||||||
}
|
}
|
||||||
|
@ -29,21 +27,20 @@ public class AccountingCommandGetSpaces implements
|
||||||
try {
|
try {
|
||||||
logger.debug("getSpaces()");
|
logger.debug("getSpaces()");
|
||||||
SortedSet<String> keys = null;
|
SortedSet<String> keys = null;
|
||||||
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory
|
AccountingPersistenceQuery apq = AccountingPersistenceQueryFactory.getInstance();
|
||||||
.getInstance();
|
|
||||||
|
|
||||||
keys = apq.getSpaceProvidersIds();
|
keys = apq.getSpaceProvidersIds();
|
||||||
|
|
||||||
logger.debug("AccountingPersistenceQuery.getSpaces: " + keys);
|
logger.debug("AccountingPersistenceQuery.getSpaces: " + keys);
|
||||||
if (keys == null || keys.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<String> spaceList = new ArrayList<>();
|
ArrayList<String> spaceList = new ArrayList<>();
|
||||||
|
|
||||||
for (String key : keys) {
|
if (keys == null || keys.isEmpty()) {
|
||||||
if (key != null && !key.isEmpty()) {
|
logger.error("Spaces have not keys: {}", keys);
|
||||||
spaceList.add(key);
|
} else {
|
||||||
|
for (String key : keys) {
|
||||||
|
if (key != null && !key.isEmpty()) {
|
||||||
|
spaceList.add(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Spaces categories = new Spaces(spaceList);
|
Spaces categories = new Spaces(spaceList);
|
||||||
|
@ -52,9 +49,7 @@ public class AccountingCommandGetSpaces implements
|
||||||
|
|
||||||
return categories;
|
return categories;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.error("Error in AccountingCommandGetSpaces(): "
|
logger.error("Error in AccountingCommandGetSpaces(): {}", e.getLocalizedMessage(), e);
|
||||||
+ e.getLocalizedMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new ServiceException("No spaces available!");
|
throw new ServiceException("No spaces available!");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue