Search in sources :

Example 41 with Location

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);
    }
}
Also used : Location(org.commonjava.maven.galley.model.Location)

Example 42 with Location

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
    }
}
Also used : ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) CacheProvider(org.commonjava.maven.galley.spi.cache.CacheProvider) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) Location(org.commonjava.maven.galley.model.Location) Test(org.junit.Test)

Example 43 with Location

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);
    }
}
Also used : Location(org.commonjava.maven.galley.model.Location)

Example 44 with Location

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);
    }
}
Also used : TestTransferDecorator(org.commonjava.maven.galley.cache.testutil.TestTransferDecorator) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) Transfer(org.commonjava.maven.galley.model.Transfer) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) CacheProvider(org.commonjava.maven.galley.spi.cache.CacheProvider) TestFileEventManager(org.commonjava.maven.galley.cache.testutil.TestFileEventManager) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) Location(org.commonjava.maven.galley.model.Location) Test(org.junit.Test)

Example 45 with Location

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));
}
Also used : OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) CacheProvider(org.commonjava.maven.galley.spi.cache.CacheProvider) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) Location(org.commonjava.maven.galley.model.Location) Test(org.junit.Test)

Aggregations

Location (org.commonjava.maven.galley.model.Location)58 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)28 SimpleLocation (org.commonjava.maven.galley.model.SimpleLocation)26 Test (org.junit.Test)25 Transfer (org.commonjava.maven.galley.model.Transfer)14 ArrayList (java.util.ArrayList)13 KeyedLocation (org.commonjava.indy.model.galley.KeyedLocation)11 CacheProvider (org.commonjava.maven.galley.spi.cache.CacheProvider)11 JoinString (org.commonjava.maven.atlas.ident.util.JoinString)10 OutputStream (java.io.OutputStream)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 TestDownload (org.commonjava.maven.galley.testing.core.transport.job.TestDownload)7 URI (java.net.URI)6 RepositoryLocation (org.commonjava.indy.model.galley.RepositoryLocation)6 TransferException (org.commonjava.maven.galley.TransferException)6 GalleyMavenException (org.commonjava.maven.galley.maven.GalleyMavenException)6 MavenPomView (org.commonjava.maven.galley.maven.model.view.MavenPomView)6 CountDownLatch (java.util.concurrent.CountDownLatch)5 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)5 ProjectVersionRefLocation (org.commonjava.maven.galley.maven.model.ProjectVersionRefLocation)5