public Map searchManagedEntities()

in src/main/java/com/vmware/vim25/mo/InventoryNavigator.java [150:188]


    public Map<String, ManagedEntity> searchManagedEntities(String type, Collection<String> names) throws RemoteException {
        if (names == null || names.size() == 0) {
            return Collections.emptyMap();
        }
        final Map<String, ManagedEntity> retval = new HashMap<String, ManagedEntity>();

        final Map<String, String> lcNamesMap = new HashMap<String, String>();
        for (String name : names) {
            lcNamesMap.put(name.toLowerCase(), name);
        }

        if (type == null) {
            type = "ManagedEntity";
        }

        String[][] typeinfo = new String[][]{new String[]{type, "name",},};

        ObjectContent[] ocs = retrieveObjectContents(typeinfo, true);

        if (ocs == null || ocs.length == 0) {
            return null;
        }

        for (int i = 0; i < ocs.length; i++) {
            DynamicProperty[] propSet = ocs[i].getPropSet();

            if (propSet.length > 0) {
                String nameInPropSet = (String) propSet[0].getVal();
                if (nameInPropSet == null)
                    continue;
                String vmNameLC = nameInPropSet.toLowerCase();
                if (lcNamesMap.containsKey(vmNameLC)) {
                    ManagedObjectReference mor = ocs[i].getObj();
                    retval.put(lcNamesMap.get(vmNameLC), MorUtil.createExactManagedEntity(rootEntity.getServerConnection(), mor));
                }
            }
        }
        return retval;
    }