private static List < ObjectContent > retrievePropertiesAllObjects ( ConnectionResources connectionResources , List < PropertyFilterSpec > propertyFilterSpecList ) throws RuntimeFaultFaultMsg , InvalidPropertyFaultMsg { VimPortType vimPort = connectionResources . getVimPortType ( ) ; ManagedObjectReference serviceInstance = connectionResources . getServiceInstance ( ) ; ServiceContent serviceContent = vimPort . retrieveServiceContent ( serviceInstance ) ; ManagedObjectReference propertyCollectorReference = serviceContent . getPropertyCollector ( ) ; RetrieveOptions propertyObjectRetrieveOptions = new RetrieveOptions ( ) ; List < ObjectContent > objectContentList = new ArrayList <> ( ) ; RetrieveResult results = vimPort . retrievePropertiesEx ( propertyCollectorReference , propertyFilterSpecList , propertyObjectRetrieveOptions ) ; if ( results != null && results . getObjects ( ) != null && ! results . getObjects ( ) . isEmpty ( ) ) { objectContentList . addAll ( results . getObjects ( ) ) ; } String token = null ; if ( results != null && results . getToken ( ) != null ) { token = results . getToken ( ) ; } while ( token != null && ! token . isEmpty ( ) ) { results = vimPort . continueRetrievePropertiesEx ( propertyCollectorReference , token ) ; token = null ; if ( results != null ) { token = results . getToken ( ) ; if ( results . getObjects ( ) != null && ! results . getObjects ( ) . isEmpty ( ) ) { objectContentList . addAll ( results . getObjects ( ) ) ; } } } return objectContentList ; }
Uses the new RetrievePropertiesEx method to emulate the now deprecated RetrieveProperties method