use of org.sonatype.nexus.index.updater.IndexUpdateRequest in project intellij-community by JetBrains.
the class NexusIndexerTest method _testDownloading.
public void _testDownloading() throws Exception {
String id = "remote";
String url = "file:///" + myRepositoryHelper.getTestDataPath("remote");
IndexingContext c = addContext(id, myIndexDir, null, url);
IndexUpdateRequest request = new IndexUpdateRequest(c);
request.setResourceFetcher(new Maven2ServerIndexFetcher(id, url, myEmbedder.getComponent(WagonManager.class), new NullTransferListener()));
myUpdater.fetchAndUpdateIndex(request);
assertSearchWorks();
}
use of org.sonatype.nexus.index.updater.IndexUpdateRequest in project intellij-community by JetBrains.
the class Maven2ServerIndexerImpl method updateIndex.
public void updateIndex(int id, MavenServerSettings settings, MavenServerProgressIndicator indicator) throws MavenServerIndexerException, MavenServerProcessCanceledException, RemoteException {
IndexingContext index = getIndex(id);
try {
if (isLocal(index)) {
File repository = index.getRepository();
if (repository != null && repository.exists()) {
indicator.setIndeterminate(true);
try {
myIndexer.scan(index, new MyScanningListener(indicator), false);
} finally {
indicator.setIndeterminate(false);
}
}
} else {
IndexUpdateRequest request = new IndexUpdateRequest(index);
Maven2ServerEmbedderImpl embedder = Maven2ServerEmbedderImpl.create(settings);
try {
request.setResourceFetcher(new Maven2ServerIndexFetcher(index.getRepositoryId(), index.getRepositoryUrl(), embedder.getComponent(WagonManager.class), new TransferListenerAdapter(indicator) {
@Override
protected void downloadProgress(long downloaded, long total) {
super.downloadProgress(downloaded, total);
try {
myIndicator.setFraction(((double) downloaded) / total);
} catch (RemoteException e) {
throw new RuntimeRemoteException(e);
}
}
@Override
public void transferCompleted(TransferEvent event) {
super.transferCompleted(event);
try {
myIndicator.setText2("Processing indices...");
} catch (RemoteException e) {
throw new RuntimeRemoteException(e);
}
}
}));
myUpdater.fetchAndUpdateIndex(request);
} finally {
embedder.release();
}
}
} catch (RuntimeRemoteException e) {
throw e.getCause();
} catch (ProcessCanceledException e) {
throw new MavenServerProcessCanceledException();
} catch (Exception e) {
throw new MavenServerIndexerException(wrapException(e));
}
}
use of org.sonatype.nexus.index.updater.IndexUpdateRequest in project intellij-community by JetBrains.
the class Maven3ServerIndexerImpl method updateIndex.
@Override
public void updateIndex(int id, MavenServerSettings settings, final MavenServerProgressIndicator indicator) throws RemoteException, MavenServerIndexerException, MavenServerProcessCanceledException {
final IndexingContext index = getIndex(id);
try {
File repository = index.getRepository();
if (repository != null) {
// is local repository
if (repository.exists()) {
indicator.setIndeterminate(true);
try {
myIndexer.scan(index, new MyScanningListener(indicator), false);
} finally {
indicator.setIndeterminate(false);
}
}
} else {
final Maven3ServerEmbedder embedder = createEmbedder(settings);
MavenExecutionRequest r = embedder.createRequest(null, Collections.<String>emptyList(), Collections.<String>emptyList(), Collections.<String>emptyList());
final IndexUpdateRequest request = new IndexUpdateRequest(index);
try {
embedder.executeWithMavenSession(r, new Runnable() {
@Override
public void run() {
request.setResourceFetcher(new Maven3ServerIndexFetcher(index.getRepositoryId(), index.getRepositoryUrl(), embedder.getComponent(WagonManager.class), embedder.getComponent(RepositorySystem.class), new WagonTransferListenerAdapter(indicator) {
@Override
protected void downloadProgress(long downloaded, long total) {
super.downloadProgress(downloaded, total);
try {
myIndicator.setFraction(((double) downloaded) / total);
} catch (RemoteException e) {
throw new RuntimeRemoteException(e);
}
}
@Override
public void transferCompleted(TransferEvent event) {
super.transferCompleted(event);
try {
myIndicator.setText2("Processing indices...");
} catch (RemoteException e) {
throw new RuntimeRemoteException(e);
}
}
}));
try {
myUpdater.fetchAndUpdateIndex(request);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
});
} finally {
embedder.release();
}
}
} catch (RuntimeRemoteException e) {
throw e.getCause();
} catch (ProcessCanceledException e) {
throw new MavenServerProcessCanceledException();
} catch (Exception e) {
throw new MavenServerIndexerException(wrapException(e));
}
}
Aggregations