private static List<IInstallableUnit> querySourceIus(
     Collection<IUDescription> sourceIUs,
     IMetadataRepository repository,
     RepositoryReferences sources)
     throws FacadeException {
   if (sourceIUs == null || sourceIUs.isEmpty()) {
     return null;
   }
   List<IInstallableUnit> result = new ArrayList<IInstallableUnit>();
   for (IUDescription iu : sourceIUs) {
     IQuery<IInstallableUnit> iuQuery = createQuery(iu);
     Iterator<IInstallableUnit> queryResult = repository.query(iuQuery, null).iterator();
     if (!queryResult.hasNext()) {
       throw new FacadeException(
           "Could not find IU "
               + iu.toString()
               + " in any of the source repositories "
               + sources.getMetadataRepositories(),
           null);
     }
     while (queryResult.hasNext()) {
       result.add(queryResult.next());
     }
   }
   return result;
 }
 private IQuery<IInstallableUnit> createQuery(IUDescription iu) {
   String id = iu.getId();
   String version = iu.getVersion();
   if (version == null || version.length() == 0) {
     return QueryUtil.createLatestQuery(QueryUtil.createIUQuery(id));
   } else {
     return QueryUtil.createIUQuery(id, Version.parseVersion(version));
   }
 }
 private static IQuery<IInstallableUnit> createQuery(IUDescription iu) {
   String id = iu.getId();
   String version = iu.getVersion();
   if (iu.getQueryMatchExpression() != null) {
     return QueryUtil.createMatchQuery(
         iu.getQueryMatchExpression(), (Object[]) iu.getQueryParameters());
   } else {
     if (version == null || version.length() == 0) {
       return QueryUtil.createLatestQuery(QueryUtil.createIUQuery(id));
     } else {
       return QueryUtil.createIUQuery(id, Version.parseVersion(version));
     }
   }
 }