Ejemplo n.º 1
0
 @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
 protected String getBasePath(UniqueMethodName key) {
   return Zips.path(key.getName(), DOT_JSON);
 }