use of org.commonjava.maven.galley.model.ListingResult in project galley by Commonjava.
the class TransferManagerImpl method listAll.
@Override
public List<ListingResult> listAll(final VirtualResource virt, final EventMetadata metadata) throws TransferException {
final Map<ConcreteResource, Future<ListingResult>> futureList = new HashMap<>();
for (final ConcreteResource res : virt) {
final Future<ListingResult> listingFuture = executorService.submit(new Callable<ListingResult>() {
@Override
public ListingResult call() throws TransferException {
return doList(res, true, metadata);
}
});
futureList.put(res, listingFuture);
}
final List<ListingResult> results = new ArrayList<>();
for (Map.Entry<ConcreteResource, Future<ListingResult>> entry : futureList.entrySet()) {
Future<ListingResult> listingFuture = entry.getValue();
ConcreteResource res = entry.getKey();
ListingResult listing;
try {
listing = listingFuture.get();
} catch (InterruptedException ex) {
throw new TransferException("Listing of %s was interrupted", ex, res);
} catch (ExecutionException ex) {
throw new TransferException("Listing of %s threw an error: %s", ex, res, ex);
}
if (listing != null) {
results.add(listing);
}
}
return results;
}
use of org.commonjava.maven.galley.model.ListingResult in project galley by Commonjava.
the class HttpListTest method simpleCentralListing_Error.
@Test
public void simpleCentralListing_Error() throws Exception {
final String dir = "central-error/";
final String fname = dir + "index.html";
final String listingFname = dir + ".listing.txt";
final String url = fixture.formatUrl(fname);
final SimpleHttpLocation location = new SimpleHttpLocation("test", url, true, true, true, true, null);
fixture.registerException(fixture.getUrlPath(url), "Test Error");
final Transfer transfer = fixture.getTransfer(new ConcreteResource(location, listingFname));
final HttpListing listing = new HttpListing(url, new ConcreteResource(location, fname), fixture.getHttp());
final ListingResult result = listing.call();
assertThat(result, nullValue());
assertThat(listing.getError(), notNullValue());
assertTrue(listing.getError().getMessage().contains("Test Error"));
}
use of org.commonjava.maven.galley.model.ListingResult in project galley by Commonjava.
the class HttpListTest method simpleCentralListing.
@Test
public void simpleCentralListing() throws Exception {
final String dir = "central-btm/";
final String fname = dir + "index.html";
final String listingFname = dir + ".listing.txt";
final String url = fixture.formatUrl(fname);
final String body = getBody(fname);
fixture.getServer().expect(url, 200, body);
final SimpleHttpLocation location = new SimpleHttpLocation("test", url, true, true, true, true, null);
final Transfer transfer = fixture.getTransfer(new ConcreteResource(location, listingFname));
final HttpListing listing = new HttpListing(url, new ConcreteResource(location, fname), fixture.getHttp());
final ListingResult result = listing.call();
assertThat(listing.getError(), nullValue());
assertThat(result, notNullValue());
assertThat(result.getListing(), notNullValue());
System.out.println("Got listing\n\n " + StringUtils.join(result.getListing(), "\n ") + "\n\n");
assertTrue(Arrays.equals(centralbtm, result.getListing()));
}
use of org.commonjava.maven.galley.model.ListingResult in project galley by Commonjava.
the class HttpListTest method simpleNexusListing_Missing.
@Test
public void simpleNexusListing_Missing() throws Exception {
final String dir = "nexus-missing/";
final String fname = dir + "index.html";
final String listingFname = dir + ".listing.txt";
final String url = fixture.formatUrl(fname);
final SimpleHttpLocation location = new SimpleHttpLocation("test", url, true, true, true, true, null);
final Transfer transfer = fixture.getTransfer(new ConcreteResource(location, listingFname));
final HttpListing listing = new HttpListing(url, new ConcreteResource(location, fname), fixture.getHttp());
final ListingResult result = listing.call();
assertThat(listing.getError(), nullValue());
assertThat(result, nullValue());
}
use of org.commonjava.maven.galley.model.ListingResult in project galley by Commonjava.
the class HttpListTest method simpleNexusListing_Error.
@Test
public void simpleNexusListing_Error() throws Exception {
final String dir = "nexus-error/";
final String fname = dir + "index.html";
final String listingFname = dir + ".listing.txt";
final String url = fixture.formatUrl(fname);
final SimpleHttpLocation location = new SimpleHttpLocation("test", url, true, true, true, true, null);
fixture.registerException(fixture.getUrlPath(url), "Test Error");
final Transfer transfer = fixture.getTransfer(new ConcreteResource(location, listingFname));
final HttpListing listing = new HttpListing(url, new ConcreteResource(location, fname), fixture.getHttp());
final ListingResult result = listing.call();
assertThat(result, nullValue());
assertThat(listing.getError(), notNullValue());
assertTrue(listing.getError().getMessage().contains("Test Error"));
}
Aggregations