use of org.apache.archiva.indexer.UnsupportedBaseContextException in project archiva by apache.
the class MavenRepositorySearch method getRemoteIndexingContextIds.
@Override
public Set<String> getRemoteIndexingContextIds(String managedRepoId) throws RepositorySearchException {
Set<String> ids = new HashSet<>();
List<ProxyConnector> proxyConnectors = null;
try {
proxyConnectors = proxyConnectorAdmin.getProxyConnectorAsMap().get(managedRepoId);
} catch (RepositoryAdminException e) {
throw new RepositorySearchException(e.getMessage(), e);
}
if (proxyConnectors == null || proxyConnectors.isEmpty()) {
return ids;
}
for (ProxyConnector proxyConnector : proxyConnectors) {
String remoteId = "remote-" + proxyConnector.getTargetRepoId();
RemoteRepository repo = repositoryRegistry.getRemoteRepository(proxyConnector.getTargetRepoId());
if (repo.getType() == RepositoryType.MAVEN) {
try {
IndexingContext context = repo.getIndexingContext() != null ? repo.getIndexingContext().getBaseContext(IndexingContext.class) : null;
if (context != null && context.isSearchable()) {
ids.add(remoteId);
}
} catch (UnsupportedBaseContextException e) {
// Ignore this one
}
}
}
return ids;
}
use of org.apache.archiva.indexer.UnsupportedBaseContextException in project archiva by apache.
the class ArchivaIndexManagerMock method executeUpdateFunction.
/*
* This method is used to do some actions around the update execution code. And to make sure, that no other
* method is running on the same index.
*/
private void executeUpdateFunction(ArchivaIndexingContext context, IndexUpdateConsumer function) throws IndexUpdateFailedException {
IndexingContext indexingContext = null;
try {
indexingContext = getMvnContext(context);
} catch (UnsupportedBaseContextException e) {
throw new IndexUpdateFailedException("Maven index is not supported by this context", e);
}
final Path ctxPath = getIndexPath(context);
int loop = MAX_WAIT;
boolean active = false;
while (loop-- > 0 && !active) {
active = activeContexts.add(ctxPath);
try {
Thread.currentThread().sleep(WAIT_TIME);
} catch (InterruptedException e) {
// Ignore this
}
}
if (active) {
try {
function.accept(indexingContext);
} finally {
activeContexts.remove(ctxPath);
}
} else {
throw new IndexUpdateFailedException("Timeout while waiting for index release on context " + context.getId());
}
}
Aggregations