use of org.commonjava.maven.galley.model.Location in project galley by Commonjava.
the class GridFileSystemCacheProvider method createAlias.
@Override
public void createAlias(final ConcreteResource from, final ConcreteResource to) throws IOException {
// if the download landed in a different repository, copy it to the current one for
// completeness...
final Location fromKey = from.getLocation();
final Location toKey = to.getLocation();
final String fromPath = from.getPath();
final String toPath = to.getPath();
if (fromKey != null && toKey != null && !fromKey.equals(toKey) && fromPath != null && toPath != null && !fromPath.equals(toPath)) {
copy(from, to);
}
}
use of org.commonjava.maven.galley.model.Location in project galley by Commonjava.
the class RoutingCacheProviderWrapperTest method test.
@Test
public void test() throws Exception {
final RoutingCacheProviderWrapper router = (RoutingCacheProviderWrapper) new RoutingCacheProviderFactory(selector, fastLocalFac, partylineFac).create(pathgen, decorator, events);
final CacheProvider partyline = partylineFac.create(pathgen, decorator, events);
final CacheProvider fastLocal = fastLocalFac.create(pathgen, decorator, events);
final String fname = "/path/to/my/file.txt";
Location loc = new SimpleLocation("remote:foo/com");
ConcreteResource resource = new ConcreteResource(loc, fname);
CacheProvider get = router.getRoutedProvider(resource);
assertThat(get, equalTo(partyline));
loc = new SimpleLocation("hosted:foo/com");
resource = new ConcreteResource(loc, fname);
get = router.getRoutedProvider(resource);
assertThat(get, equalTo(fastLocal));
loc = new SimpleLocation("group:foo/com");
resource = new ConcreteResource(loc, fname);
get = router.getRoutedProvider(resource);
assertThat(get, equalTo(partyline));
loc = new SimpleLocation("http://foo.com");
resource = new ConcreteResource(loc, fname);
get = router.getRoutedProvider(resource);
assertThat(get, equalTo(partyline));
resource = new ConcreteResource(null, null);
get = router.getRoutedProvider(resource);
assertThat(get, equalTo(partyline));
get = router.getRoutedProvider(null);
assertThat(get, equalTo(partyline));
resource = new ConcreteResource(loc, fname);
try {
router.asAdminView().getDetachedFile(resource);
fail("Should have thrown exception");
} catch (UnsupportedOperationException ex) {
// Pass
}
}
use of org.commonjava.maven.galley.model.Location in project galley by Commonjava.
the class PartyLineCacheProvider method createAlias.
@Override
public void createAlias(final ConcreteResource from, final ConcreteResource to) throws IOException {
// if the download landed in a different repository, copy it to the current one for
// completeness...
final Location fromKey = from.getLocation();
final Location toKey = to.getLocation();
final String fromPath = from.getPath();
final String toPath = to.getPath();
if (fromKey != null && toKey != null && !fromKey.equals(toKey) && fromPath != null && toPath != null && !fromPath.equals(toPath)) {
copy(from, to);
}
}
use of org.commonjava.maven.galley.model.Location in project galley by Commonjava.
the class CacheProviderTCK method lockThenWriteViaTransferSucceedsInSameThread.
@Test
public void lockThenWriteViaTransferSucceedsInSameThread() throws Exception {
final Location loc = new SimpleLocation("http://foo.com");
final String path = "my/path.txt";
final ConcreteResource res = new ConcreteResource(loc, path);
final CacheProvider cache = getCacheProvider();
cache.lockWrite(res);
final Transfer txfr = new Transfer(res, cache, new TestFileEventManager(), new TestTransferDecorator());
OutputStream out = null;
try {
out = txfr.openOutputStream(TransferOperation.UPLOAD);
IOUtils.write("this is a test", out);
} finally {
IOUtils.closeQuietly(out);
}
}
use of org.commonjava.maven.galley.model.Location in project galley by Commonjava.
the class CacheProviderTCK method writeDeleteAndVerifyNonExistence.
@Test
public void writeDeleteAndVerifyNonExistence() throws Exception {
final String content = "This is a test";
final Location loc = new SimpleLocation("http://foo.com");
final String fname = "/path/to/my/file.txt";
final CacheProvider provider = getCacheProvider();
final OutputStream out = provider.openOutputStream(new ConcreteResource(loc, fname));
out.write(content.getBytes("UTF-8"));
out.close();
assertThat(provider.exists(new ConcreteResource(loc, fname)), equalTo(true));
provider.delete(new ConcreteResource(loc, fname));
assertThat(provider.exists(new ConcreteResource(loc, fname)), equalTo(false));
}
Aggregations