package org.jboss.da.communication;

import org.commonjava.cartographer.CartoDataException;
import org.commonjava.cartographer.CartographerCore;
import org.commonjava.cartographer.CartographerCoreBuilder;
import org.commonjava.cartographer.spi.graph.discover.DiscoverySourceManager;
import org.commonjava.maven.atlas.graph.RelationshipGraphFactory;
import org.commonjava.maven.atlas.graph.spi.neo4j.FileNeo4jConnectionFactory;
import org.commonjava.maven.galley.cache.FileCacheProviderConfig;
import org.jboss.da.communication.pom.qualifier.DACartographerCore;
import javax.enterprise.inject.Produces;
import java.io.File;
import java.io.IOException;

/**
 * Class used to inject null to '@Injects' in cartographer
 */
public class CartographerProducer {

    @Produces
    @DACartographerCore
    public CartographerCore getCartographerCore() throws IOException, CartoDataException {

        // tempFile is not really used, but just needed to be passed to the constructor
        File tempFile = new File("random");

        return new CartographerCoreBuilder(tempFile, new FileNeo4jConnectionFactory(null, true))
                .withDefaultTransports().build();
    }

    @Produces
    public DiscoverySourceManager getDiscoverySourceManager() {
        return null;
    }

    @Produces
    public RelationshipGraphFactory getRelationshipGraphFactory() {
        return null;
    }

    @Produces
    public FileCacheProviderConfig getFileCacheProviderConfig() {
        FileCacheProviderConfig fcpc = new FileCacheProviderConfig(new File("random"));
        return fcpc;
    }
}

@@ -486,16 +486,282 @@
 Config;%0A
+import org.commonjava.maven.galley.cache.partyline.PartyLineCacheProvider;%0Aimport org.commonjava.maven.galley.event.NoOpFileEventManager;%0Aimport org.commonjava.maven.galley.io.HashedLocationPathGenerator;%0Aimport org.commonjava.maven.galley.io.NoOpTransferDecorator;%0A
 import o
@@ -816,24 +816,25 @@
 rapherCore;%0A
+%0A
 import javax
@@ -862,16 +862,17 @@
 oduces;%0A
+%0A
 import j
@@ -1280,16 +1280,218 @@
 dom%22);%0A%0A
+        PartyLineCacheProvider cache = new PartyLineCacheProvider(tempFile,%0A                new HashedLocationPathGenerator(), new NoOpFileEventManager(),%0A                new NoOpTransferDecorator());%0A%0A
         
@@ -1579,16 +1579,16 @@
  true))%0A
-
         
@@ -1620,16 +1620,33 @@
 ports().
+withCache(cache).
 build();

Use partyline as cahce for galley