repository));
// this will force remote check for newer files
repository.expireCaches(new ResourceStoreRequest(PUBLISHING_PATH_PREFIX));
IndexUpdateRequest updateRequest = new IndexUpdateRequest(context, new ResourceFetcher()
{
public void connect(String id, String url)
throws IOException
{
}
public void disconnect()
throws IOException
{
}
public InputStream retrieve(String name)
throws IOException
{
TaskUtil.checkInterruption();
ResourceStoreRequest req = new ResourceStoreRequest(PUBLISHING_PATH_PREFIX + "/" + name);
try {
StorageFileItem item = null;
// XXX: ensure it goes to remote only and throws FileNotFoundException if nothing found on remote
// kinda turn off transparent proxying for this method
// We need to use ProxyRepository and get it's RemoteStorage stuff to completely
// avoid "transparent" proxying, and even the slightest possibility to return
// some stale file from cache to the updater.
if (ISPROXY(repository) && REMOTEACCESSALLOWED(repository)) {
item =
(StorageFileItem) repository.getRemoteStorage()
.retrieveItem(repository, req, repository.getRemoteUrl());
}
else {
throw new ItemNotFoundException(req, repository);
}
return item.getInputStream();
}
catch (ItemNotFoundException ex) {
final FileNotFoundException fne = new FileNotFoundException(name + " (remote item not found)");
fne.initCause(ex);
throw fne;
}
}
});
//Set request for either full or incremental-only update
if (forceFullUpdate) {
updateRequest.setForceFullUpdate(true);
updateRequest.setIncrementalOnly(false);
}
else {
updateRequest.setForceFullUpdate(false);
updateRequest.setIncrementalOnly(true);
}
updateRequest.setFSDirectoryFactory(luceneDirectoryFactory);
if (repository instanceof MavenRepository) {
MavenRepository mrepository = (MavenRepository) repository;
updateRequest.setDocumentFilter(getFilterFor(mrepository.getRepositoryPolicy()));
}
try {
IndexUpdateResult result = indexUpdater.fetchAndUpdateIndex(updateRequest);