Host templateHost = hostAPI.findParentHost(template, user, false);
//Getting the host that can be assigned to the template
List<Host> hosts = APILocator.getHostAPI().findAll(user, false);
hosts.remove(APILocator.getHostAPI().findSystemHost(user, false));
hosts = perAPI.filterCollection(hosts, PermissionAPI.PERMISSION_CAN_ADD_CHILDREN, false, user);
if(templateHost != null && !hosts.contains(templateHost)) {
hosts.add(templateHost);
}
req.setAttribute(WebKeys.TEMPLATE_HOSTS, hosts);