Search in sources :

Example 1 with HttpImpl

use of org.commonjava.maven.galley.transport.htcli.HttpImpl in project galley by Commonjava.

the class DownloadHandlerConcurrencyTest method before.

@Before
public void before() throws IOException {
    executor = Executors.newCachedThreadPool();
    cacheProvider = new FileCacheProvider(temp.newFolder(), new HashedLocationPathGenerator(), new NoOpFileEventManager(), new NoOpTransferDecorator(), false);
    transport = new HttpClientTransport(new HttpImpl(new MemoryPasswordManager()), new ObjectMapper(), new GlobalHttpConfiguration());
}
Also used : FileCacheProvider(org.commonjava.maven.galley.cache.FileCacheProvider) NoOpFileEventManager(org.commonjava.maven.galley.event.NoOpFileEventManager) NoOpTransferDecorator(org.commonjava.maven.galley.io.NoOpTransferDecorator) HttpClientTransport(org.commonjava.maven.galley.transport.htcli.HttpClientTransport) HashedLocationPathGenerator(org.commonjava.maven.galley.io.HashedLocationPathGenerator) GlobalHttpConfiguration(org.commonjava.maven.galley.transport.htcli.conf.GlobalHttpConfiguration) MemoryPasswordManager(org.commonjava.maven.galley.auth.MemoryPasswordManager) HttpImpl(org.commonjava.maven.galley.transport.htcli.HttpImpl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 2 with HttpImpl

use of org.commonjava.maven.galley.transport.htcli.HttpImpl in project pom-manipulation-ext by release-engineering.

the class GalleyInfrastructure method init.

private void init(final File targetDirectory, final List<ArtifactRepository> remoteRepositories, final ArtifactRepository localRepository, final Settings settings, final List<String> activeProfiles, final Location customLocation, final Transport customTransport, File cacheDir_) throws ManipulationException {
    LocationExpander locationExpander;
    try {
        final List<Location> custom = customLocation == null ? Collections.<Location>emptyList() : Collections.singletonList(customLocation);
        locationExpander = new MavenLocationExpander(custom, remoteRepositories, localRepository, mirrorSelector, settings, activeProfiles);
    } catch (final MalformedURLException e) {
        throw new ManipulationException("Failed to setup Maven-specific LocationExpander: %s", e, e.getMessage());
    }
    xml = new XMLInfrastructure();
    xpaths = new XPathManager();
    final TransportManager transports;
    if (customTransport != null) {
        transports = new TransportManagerImpl(customTransport);
    } else {
        transports = new TransportManagerImpl(new HttpClientTransport(new HttpImpl(new MemoryPasswordManager())), new FileTransport(), new ZipJarTransport());
    }
    cacheDir = cacheDir_;
    if (cacheDir == null) {
        cacheDir = new File(targetDirectory, "manipulator-cache");
    }
    final FileEventManager fileEvents = new NoOpFileEventManager();
    final CacheProvider cache = new FileCacheProvider(cacheDir, new HashedLocationPathGenerator(), fileEvents, new NoOpTransferDecorator());
    final NotFoundCache nfc = new MemoryNotFoundCache();
    executor = Executors.newCachedThreadPool();
    final TransportManagerConfig config = new TransportManagerConfig();
    final TransferManager transfers = new TransferManagerImpl(transports, cache, nfc, fileEvents, new DownloadHandler(nfc, config, executor), new UploadHandler(nfc, config, executor), new ListingHandler(nfc), new ExistenceHandler(nfc), new SpecialPathManagerImpl(), executor);
    final TypeMapper types = new StandardTypeMapper();
    final ArtifactMetadataManager metadataManager = new ArtifactMetadataManagerImpl(transfers, locationExpander);
    final VersionResolver versionResolver = new VersionResolverImpl(new MavenMetadataReader(xml, locationExpander, metadataManager, xpaths));
    artifactManager = new ArtifactManagerImpl(transfers, locationExpander, types, versionResolver);
    // TODO: auto-adjust this to the current Maven runtime!
    final MavenPluginDefaults pluginDefaults = new StandardMaven304PluginDefaults();
    final MavenPluginImplications pluginImplications = new StandardMavenPluginImplications(xml);
    pomReader = new MavenPomReader(xml, locationExpander, artifactManager, xpaths, pluginDefaults, pluginImplications);
    metadataReader = new MavenMetadataReader(xml, locationExpander, metadataManager, xpaths);
}
Also used : StandardTypeMapper(org.commonjava.maven.galley.maven.internal.type.StandardTypeMapper) TypeMapper(org.commonjava.maven.galley.maven.spi.type.TypeMapper) MalformedURLException(java.net.MalformedURLException) NoOpTransferDecorator(org.commonjava.maven.galley.io.NoOpTransferDecorator) TransferManagerImpl(org.commonjava.maven.galley.internal.TransferManagerImpl) VersionResolverImpl(org.commonjava.maven.galley.maven.internal.version.VersionResolverImpl) MavenPluginDefaults(org.commonjava.maven.galley.maven.spi.defaults.MavenPluginDefaults) XPathManager(org.commonjava.maven.galley.maven.model.view.XPathManager) HttpImpl(org.commonjava.maven.galley.transport.htcli.HttpImpl) SpecialPathManagerImpl(org.commonjava.maven.galley.io.SpecialPathManagerImpl) LocationExpander(org.commonjava.maven.galley.spi.transport.LocationExpander) StandardMavenPluginImplications(org.commonjava.maven.galley.maven.internal.defaults.StandardMavenPluginImplications) MavenPluginImplications(org.commonjava.maven.galley.maven.spi.defaults.MavenPluginImplications) ArtifactMetadataManager(org.commonjava.maven.galley.maven.ArtifactMetadataManager) MavenMetadataReader(org.commonjava.maven.galley.maven.parse.MavenMetadataReader) MemoryNotFoundCache(org.commonjava.maven.galley.nfc.MemoryNotFoundCache) NotFoundCache(org.commonjava.maven.galley.spi.nfc.NotFoundCache) UploadHandler(org.commonjava.maven.galley.internal.xfer.UploadHandler) StandardTypeMapper(org.commonjava.maven.galley.maven.internal.type.StandardTypeMapper) ExistenceHandler(org.commonjava.maven.galley.internal.xfer.ExistenceHandler) FileCacheProvider(org.commonjava.maven.galley.cache.FileCacheProvider) TransferManager(org.commonjava.maven.galley.TransferManager) ListingHandler(org.commonjava.maven.galley.internal.xfer.ListingHandler) TransportManagerImpl(org.commonjava.maven.galley.transport.TransportManagerImpl) HashedLocationPathGenerator(org.commonjava.maven.galley.io.HashedLocationPathGenerator) DownloadHandler(org.commonjava.maven.galley.internal.xfer.DownloadHandler) TransportManagerConfig(org.commonjava.maven.galley.config.TransportManagerConfig) MemoryNotFoundCache(org.commonjava.maven.galley.nfc.MemoryNotFoundCache) MemoryPasswordManager(org.commonjava.maven.galley.auth.MemoryPasswordManager) CacheProvider(org.commonjava.maven.galley.spi.cache.CacheProvider) FileCacheProvider(org.commonjava.maven.galley.cache.FileCacheProvider) StandardMavenPluginImplications(org.commonjava.maven.galley.maven.internal.defaults.StandardMavenPluginImplications) ArtifactMetadataManagerImpl(org.commonjava.maven.galley.maven.internal.ArtifactMetadataManagerImpl) NoOpFileEventManager(org.commonjava.maven.galley.event.NoOpFileEventManager) StandardMaven304PluginDefaults(org.commonjava.maven.galley.maven.internal.defaults.StandardMaven304PluginDefaults) HttpClientTransport(org.commonjava.maven.galley.transport.htcli.HttpClientTransport) NoOpFileEventManager(org.commonjava.maven.galley.event.NoOpFileEventManager) FileEventManager(org.commonjava.maven.galley.spi.event.FileEventManager) VersionResolver(org.commonjava.maven.galley.maven.spi.version.VersionResolver) FileTransport(org.commonjava.maven.galley.filearc.FileTransport) ZipJarTransport(org.commonjava.maven.galley.filearc.ZipJarTransport) ManipulationException(org.commonjava.maven.ext.common.ManipulationException) XMLInfrastructure(org.commonjava.maven.galley.maven.parse.XMLInfrastructure) ArtifactManagerImpl(org.commonjava.maven.galley.maven.internal.ArtifactManagerImpl) TransportManager(org.commonjava.maven.galley.spi.transport.TransportManager) MavenPomReader(org.commonjava.maven.galley.maven.parse.MavenPomReader) File(java.io.File) Location(org.commonjava.maven.galley.model.Location)

Example 3 with HttpImpl

use of org.commonjava.maven.galley.transport.htcli.HttpImpl in project indy by Commonjava.

the class HttpProxyTest method setup.

@Before
public void setup() throws Exception {
    contentMetadata.clear();
    core.initGalley();
    final TransportManager transports = new TransportManagerImpl(new HttpClientTransport(new HttpImpl(new MemoryPasswordManager())));
    core.withTransportManager(transports);
    core.initMissingComponents();
    final HttproxConfig config = new HttproxConfig();
    config.setEnabled(true);
    proxyPort = config.getPort();
    final BootOptions bootOpts = new BootOptions();
    bootOpts.setBind(HOST);
    storeManager = new MemoryStoreDataManager(true);
    final IndyObjectMapper mapper = new IndyObjectMapper(true);
    final DefaultIndyConfiguration indyConfig = new DefaultIndyConfiguration();
    indyConfig.setNotFoundCacheTimeoutSeconds(1);
    final ExpiringMemoryNotFoundCache nfc = new ExpiringMemoryNotFoundCache(indyConfig);
    WeftExecutorService rescanService = new PoolWeftExecutorService("test-rescan-executor", (ThreadPoolExecutor) Executors.newCachedThreadPool(), 2, 10f, false, null, null);
    final DownloadManager downloadManager = new DefaultDownloadManager(storeManager, core.getTransferManager(), core.getLocationExpander(), new MockInstance<>(new MockContentAdvisor()), nfc, rescanService);
    WeftExecutorService contentAccessService = new PoolWeftExecutorService("test-content-access-executor", (ThreadPoolExecutor) Executors.newCachedThreadPool(), 2, 10f, false, null, null);
    DirectContentAccess dca = new DefaultDirectContentAccess(downloadManager, contentAccessService);
    ContentDigester contentDigester = new DefaultContentDigester(dca, new CacheHandle<>("content-metadata", contentMetadata));
    final ContentManager contentManager = new DefaultContentManager(storeManager, downloadManager, mapper, new SpecialPathManagerImpl(), new MemoryNotFoundCache(), contentDigester, new ContentGeneratorManager());
    DataFileManager dfm = new DataFileManager(temp.newFolder(), new DataFileEventManager());
    final TemplatingEngine templates = new TemplatingEngine(new GStringTemplateEngine(), dfm);
    final ContentController contentController = new ContentController(storeManager, contentManager, templates, mapper, new MimeTyper());
    KeycloakConfig kcConfig = new KeycloakConfig();
    kcConfig.setEnabled(false);
    final KeycloakProxyAuthenticator auth = new KeycloakProxyAuthenticator(kcConfig, config);
    ScriptEngine scriptEngine = new ScriptEngine(dfm);
    WeftExecutorService transferService = new PoolWeftExecutorService("test-mitm-transfers", (ThreadPoolExecutor) Executors.newCachedThreadPool(), 2, 10f, false, null, null);
    ProxyTransfersExecutor handler = new ProxyTransfersExecutor(transferService);
    IndyTraceConfiguration itc = new IndyTraceConfiguration();
    TraceManager tm = new TraceManager(new OtelTracePlugin(itc, itc), new SpanFieldsDecorator(Collections.emptyList()), itc);
    proxy = new HttpProxy(config, bootOpts, new ProxyAcceptHandler(config, storeManager, contentController, auth, core.getCache(), scriptEngine, new MDCManager(), null, null, new CacheProducer(null, cacheManager, null), handler, tm));
    proxy.start();
}
Also used : PoolWeftExecutorService(org.commonjava.cdi.util.weft.PoolWeftExecutorService) DefaultContentManager(org.commonjava.indy.core.content.DefaultContentManager) SpanFieldsDecorator(org.commonjava.o11yphant.trace.SpanFieldsDecorator) DownloadManager(org.commonjava.indy.content.DownloadManager) DefaultDownloadManager(org.commonjava.indy.core.content.DefaultDownloadManager) TraceManager(org.commonjava.o11yphant.trace.TraceManager) HttpImpl(org.commonjava.maven.galley.transport.htcli.HttpImpl) SpecialPathManagerImpl(org.commonjava.maven.galley.io.SpecialPathManagerImpl) HttproxConfig(org.commonjava.indy.httprox.conf.HttproxConfig) DirectContentAccess(org.commonjava.indy.content.DirectContentAccess) DefaultDirectContentAccess(org.commonjava.indy.core.content.DefaultDirectContentAccess) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) MemoryStoreDataManager(org.commonjava.indy.mem.data.MemoryStoreDataManager) KeycloakProxyAuthenticator(org.commonjava.indy.httprox.keycloak.KeycloakProxyAuthenticator) OtelTracePlugin(org.commonjava.o11yphant.otel.OtelTracePlugin) ProxyTransfersExecutor(org.commonjava.indy.httprox.handler.ProxyTransfersExecutor) DefaultDownloadManager(org.commonjava.indy.core.content.DefaultDownloadManager) DefaultIndyConfiguration(org.commonjava.indy.conf.DefaultIndyConfiguration) ContentDigester(org.commonjava.indy.content.ContentDigester) DefaultContentDigester(org.commonjava.indy.core.content.DefaultContentDigester) TransportManagerImpl(org.commonjava.maven.galley.transport.TransportManagerImpl) DefaultContentDigester(org.commonjava.indy.core.content.DefaultContentDigester) ContentController(org.commonjava.indy.core.ctl.ContentController) DataFileEventManager(org.commonjava.indy.subsys.datafile.change.DataFileEventManager) DefaultContentManager(org.commonjava.indy.core.content.DefaultContentManager) ContentManager(org.commonjava.indy.content.ContentManager) ExpiringMemoryNotFoundCache(org.commonjava.indy.core.inject.ExpiringMemoryNotFoundCache) MemoryNotFoundCache(org.commonjava.maven.galley.nfc.MemoryNotFoundCache) ExpiringMemoryNotFoundCache(org.commonjava.indy.core.inject.ExpiringMemoryNotFoundCache) GStringTemplateEngine(groovy.text.GStringTemplateEngine) MemoryPasswordManager(org.commonjava.maven.galley.auth.MemoryPasswordManager) BootOptions(org.commonjava.propulsor.boot.BootOptions) MimeTyper(org.commonjava.indy.util.MimeTyper) ScriptEngine(org.commonjava.indy.subsys.template.ScriptEngine) WeftExecutorService(org.commonjava.cdi.util.weft.WeftExecutorService) PoolWeftExecutorService(org.commonjava.cdi.util.weft.PoolWeftExecutorService) CacheProducer(org.commonjava.indy.subsys.infinispan.CacheProducer) HttpClientTransport(org.commonjava.maven.galley.transport.htcli.HttpClientTransport) MDCManager(org.commonjava.indy.bind.jaxrs.MDCManager) DataFileManager(org.commonjava.indy.subsys.datafile.DataFileManager) TemplatingEngine(org.commonjava.indy.subsys.template.TemplatingEngine) MockContentAdvisor(org.commonjava.indy.test.fixture.core.MockContentAdvisor) IndyTraceConfiguration(org.commonjava.indy.subsys.honeycomb.config.IndyTraceConfiguration) TransportManager(org.commonjava.maven.galley.spi.transport.TransportManager) ContentGeneratorManager(org.commonjava.indy.core.content.ContentGeneratorManager) ProxyAcceptHandler(org.commonjava.indy.httprox.handler.ProxyAcceptHandler) DefaultDirectContentAccess(org.commonjava.indy.core.content.DefaultDirectContentAccess) KeycloakConfig(org.commonjava.indy.subsys.keycloak.conf.KeycloakConfig) Before(org.junit.Before)

Example 4 with HttpImpl

use of org.commonjava.maven.galley.transport.htcli.HttpImpl in project indy by Commonjava.

the class AutoProxDataManagerDecoratorTest method setup.

@Before
public final void setup() throws Exception {
    rootDir = temp.newFolder("indy.root");
    autoproxDataDir = new File(rootDir, "data/autoprox");
    autoproxDataDir.mkdirs();
    File cacheDir = temp.newFolder();
    FileCacheProvider cache = new FileCacheProvider(cacheDir, new HashedLocationPathGenerator(), new NoOpFileEventManager(), new NoOpTransferDecorator());
    galley = new GalleyMavenBuilder(cache).withEnabledTransports(new HttpClientTransport(new HttpImpl(new MemoryPasswordManager()))).build();
    final DataFileManager dataFiles = new DataFileManager(rootDir, new DataFileEventManager());
    ruleParser = new ScriptRuleParser(new ScriptEngine(dataFiles));
    final AutoProxConfig indyConfig = new AutoProxConfig(autoproxDataDir.getName(), true);
    catalog = new AutoProxCatalogManager(dataFiles, indyConfig, ruleParser);
    storeDataManager = new TestAutoProxyDataManager(catalog, galley.getTransferManager());
    storeDataManager.install();
    storeDataManager.clear(summary);
    storeQuery = storeDataManager.query().packageType(MAVEN_PKG_KEY);
    System.setProperty("baseUrl", http.getBaseUri());
}
Also used : FileCacheProvider(org.commonjava.maven.galley.cache.FileCacheProvider) NoOpTransferDecorator(org.commonjava.maven.galley.io.NoOpTransferDecorator) HashedLocationPathGenerator(org.commonjava.maven.galley.io.HashedLocationPathGenerator) AutoProxConfig(org.commonjava.indy.autoprox.conf.AutoProxConfig) DataFileEventManager(org.commonjava.indy.subsys.datafile.change.DataFileEventManager) MemoryPasswordManager(org.commonjava.maven.galley.auth.MemoryPasswordManager) HttpImpl(org.commonjava.maven.galley.transport.htcli.HttpImpl) ScriptEngine(org.commonjava.indy.subsys.template.ScriptEngine) NoOpFileEventManager(org.commonjava.maven.galley.event.NoOpFileEventManager) GalleyMavenBuilder(org.commonjava.maven.galley.maven.GalleyMavenBuilder) HttpClientTransport(org.commonjava.maven.galley.transport.htcli.HttpClientTransport) ScriptRuleParser(org.commonjava.indy.autoprox.util.ScriptRuleParser) DataFileManager(org.commonjava.indy.subsys.datafile.DataFileManager) TestAutoProxyDataManager(org.commonjava.indy.autoprox.fixture.TestAutoProxyDataManager) File(java.io.File) Before(org.junit.Before)

Example 5 with HttpImpl

use of org.commonjava.maven.galley.transport.htcli.HttpImpl in project galley by Commonjava.

the class EmbeddableCDIProducer method postConstruct.

@PostConstruct
public void postConstruct() {
    fileEventManager = new NoOpFileEventManager();
    transferDecorator = new NoOpTransferDecorator();
    pathGenerator = new HashedLocationPathGenerator();
    nfc = new MemoryNotFoundCache();
    // locationExpander = new NoOpLocationExpander();
    // locationResolver = new SimpleUrlLocationResolver( locationExpander, transportManager );
    transportManagerConfig = new TransportManagerConfig();
    passwordManager = new MemoryPasswordManager();
    http = new HttpImpl(passwordManager);
    objectMapper = new ObjectMapper();
    objectMapper.registerModules(new ProjectVersionRefSerializerModule());
    pluginDefaults = new StandardMaven350PluginDefaults();
    pluginImplications = new StandardMavenPluginImplications(xml);
}
Also used : NoOpFileEventManager(org.commonjava.maven.galley.event.NoOpFileEventManager) NoOpTransferDecorator(org.commonjava.maven.galley.io.NoOpTransferDecorator) HashedLocationPathGenerator(org.commonjava.maven.galley.io.HashedLocationPathGenerator) TransportManagerConfig(org.commonjava.maven.galley.config.TransportManagerConfig) MemoryNotFoundCache(org.commonjava.maven.galley.nfc.MemoryNotFoundCache) MemoryPasswordManager(org.commonjava.maven.galley.auth.MemoryPasswordManager) StandardMavenPluginImplications(org.commonjava.maven.galley.maven.internal.defaults.StandardMavenPluginImplications) HttpImpl(org.commonjava.maven.galley.transport.htcli.HttpImpl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ProjectVersionRefSerializerModule(org.commonjava.maven.atlas.ident.jackson.ProjectVersionRefSerializerModule) StandardMaven350PluginDefaults(org.commonjava.maven.galley.maven.internal.defaults.StandardMaven350PluginDefaults) PostConstruct(javax.annotation.PostConstruct)

Aggregations

HttpImpl (org.commonjava.maven.galley.transport.htcli.HttpImpl)9 MemoryPasswordManager (org.commonjava.maven.galley.auth.MemoryPasswordManager)7 HttpClientTransport (org.commonjava.maven.galley.transport.htcli.HttpClientTransport)7 Before (org.junit.Before)5 NoOpFileEventManager (org.commonjava.maven.galley.event.NoOpFileEventManager)4 HashedLocationPathGenerator (org.commonjava.maven.galley.io.HashedLocationPathGenerator)4 NoOpTransferDecorator (org.commonjava.maven.galley.io.NoOpTransferDecorator)4 File (java.io.File)3 MemoryStoreDataManager (org.commonjava.indy.mem.data.MemoryStoreDataManager)3 IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)3 DataFileManager (org.commonjava.indy.subsys.datafile.DataFileManager)3 DataFileEventManager (org.commonjava.indy.subsys.datafile.change.DataFileEventManager)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 PostConstruct (javax.annotation.PostConstruct)2 PoolWeftExecutorService (org.commonjava.cdi.util.weft.PoolWeftExecutorService)2 WeftExecutorService (org.commonjava.cdi.util.weft.WeftExecutorService)2 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)2 ContentDigester (org.commonjava.indy.content.ContentDigester)2 DirectContentAccess (org.commonjava.indy.content.DirectContentAccess)2 DownloadManager (org.commonjava.indy.content.DownloadManager)2