* @return agents meta information of all agents: id, type, urls
* @throws Exception
*/
public List<Map<String, Object>> list(
@Name("type") @Required(false) String type) throws Exception {
ObjectDatastore datastore = new AnnotationObjectDatastore();
RootFindCommand<AgentMetaData> command = datastore.find()
.type(AgentMetaData.class);
if (type != null) {
command = command.addFilter("type", FilterOperator.EQUAL, type);
}
List<Map<String, Object>> info = new ArrayList<Map<String,Object>>();
QueryResultIterator<AgentMetaData> it = command.now();
while (it.hasNext()) {
AgentMetaData meta = it.next();
Map<String, Object> i = toInfo(meta);
if (i != null) {
info.add(i);
}
else {
// agent does not exist anymore. Delete meta information.
datastore.delete(meta);
}
}
return info;
}