while (criteriasForThisLevel.size() > ((MenuLevelDynamic)requestedObjectType).getCriteriaDepth()) {
criteriasForThisLevel.remove(0);
}
}
TitleFormat parser = null;
if(((MenuLevelDynamic)requestedObjectType).getFormat()!=null) {
parser = new TitleFormat(((MenuLevelDynamic)requestedObjectType).getFormat());
}
// Lookup and call browse service
BrowseService browseService = browseServiceManager.getBrowseService(requestedMainObjectType);
browseResult = browseService.findChildren(criteriasForThisLevel, new ArrayList<String>(), firstItem, maxItems, counts);
if (maxItems == null || maxItems >0) {
// Iterate through browse service result and create appropriate items
Collection<ResultItem> browseResultItems = browseResult.getItems();
for (ResultItem item : browseResultItems) {
String id;
if (item.getItem() instanceof SMDIdentity) {
id = requestedObjectType.getType() + ":" + ((SMDIdentity) item.getItem()).getId();
} else {
id = requestedObjectType.getType() + ":" + item.getItem().toString();
}
item.setId(id);
item.setType(requestedMainObjectType);
if(parser != null) {
item.setName(requestedObjectType.getDisplayName()+parser.format(item.getItem()));
}else {
item.setName(requestedObjectType.getDisplayName()+item.getItem().toString());
}
item.setPlayable(requestedObjectType.isPlayable());
item.setLeaf(requestedObjectType.getChildLevels() == null);