@Subscribe
 public void onEvent(ModelArchiveDownloadedEvent e) throws IOException {
   if (!isRunning()) {
     log(INFO_SERVICE_NOT_RUNNING);
     return;
   }
   if (isIndex(e.model)) {
     File location = repository.getLocation(e.model, false).orNull();
     String remoteUri = e.model.getHint(HINT_REPOSITORY_URL).orNull();
     if (remoteUri != null) {
       Pair<File, IModelIndex> pair = openDelegates.get(remoteUri);
       if (pair == null) {
         File folder = createIndexLocation(remoteUri);
         folder.mkdir();
         Zips.unzip(location, folder);
         openDelegate(remoteUri, folder);
       } else {
         File folder = Files.createTempDir();
         Zips.unzip(location, folder);
         IModelIndex modelIndex = pair.getSecond();
         modelIndex.updateIndex(folder);
         bus.post(new ModelIndexOpenedEvent());
         FileUtils.deleteDirectory(folder);
       }
     }
   }
 }
  @Override
  public ImmutableSet<ModelCoordinate> getKnownModels(String modelType) {
    if (!isRunning()) {
      log(INFO_SERVICE_NOT_RUNNING);
      return ImmutableSet.of();
    }
    Set<ModelCoordinate> models = Sets.newHashSet();
    for (Entry<String, Pair<File, IModelIndex>> entry : openDelegates.entrySet()) {
      IModelIndex index = entry.getValue().getSecond();
      models.addAll(addRepositoryUrlHint(index.getKnownModels(modelType), entry.getKey()));
    }

    return ImmutableSet.copyOf(models);
  }
  @Override
  public ImmutableSet<ModelCoordinate> suggestCandidates(ProjectCoordinate pc, String modelType) {
    if (!isRunning()) {
      log(INFO_SERVICE_NOT_RUNNING);
      return ImmutableSet.of();
    }
    Set<ModelCoordinate> candidates = Sets.newHashSet();
    for (Entry<String, Pair<File, IModelIndex>> entry : openDelegates.entrySet()) {
      IModelIndex index = entry.getValue().getSecond();
      candidates.addAll(
          addRepositoryUrlHint(index.suggestCandidates(pc, modelType), entry.getKey()));
    }

    return ImmutableSet.copyOf(candidates);
  }
  @Override
  public Optional<ProjectCoordinate> suggestProjectCoordinateByArtifactId(String artifactId) {
    if (!isRunning()) {
      log(INFO_SERVICE_NOT_RUNNING);
      return absent();
    }
    for (Pair<File, IModelIndex> delegate : openDelegates.values()) {
      IModelIndex index = delegate.getSecond();
      Optional<ProjectCoordinate> suggest = index.suggestProjectCoordinateByArtifactId(artifactId);
      if (suggest.isPresent()) {
        return suggest;
      }
    }

    return absent();
  }
 private void openDelegate(String remoteUrl, File indexLocation) throws IOException {
   IModelIndex modelIndex = createModelIndex(indexLocation);
   modelIndex.open();
   storeDelegate(remoteUrl, Pair.newPair(indexLocation, modelIndex));
   bus.post(new ModelIndexOpenedEvent());
 }