use of org.apache.sling.distribution.transport.impl.HttpConfiguration in project sling by apache.
the class RemoteDistributionPackageImporterTest method testDummyImport.
@Test
public void testDummyImport() throws Exception {
DistributionTransportSecretProvider distributionTransportSecretProvider = mock(DistributionTransportSecretProvider.class);
Map<String, String> endpoints = new HashMap<String, String>();
RemoteDistributionPackageImporter remotedistributionPackageImporter = new RemoteDistributionPackageImporter(mock(DefaultDistributionLog.class), distributionTransportSecretProvider, endpoints, new HttpConfiguration(10000));
endpoints.put("default", "http://endpoint");
ResourceResolver resourceResolver = mock(ResourceResolver.class);
DistributionPackage distributionPackage = mock(DistributionPackage.class);
DistributionPackageInfo info = new DistributionPackageInfo("/foo");
when(distributionPackage.getInfo()).thenReturn(info);
remotedistributionPackageImporter.importPackage(resourceResolver, distributionPackage);
}
use of org.apache.sling.distribution.transport.impl.HttpConfiguration in project sling by apache.
the class ReverseDistributionAgentFactory method createAgent.
@Override
protected SimpleDistributionAgent createAgent(String agentName, BundleContext context, Map<String, Object> config, DefaultDistributionLog distributionLog) {
String serviceName = SettingsUtils.removeEmptyEntry(PropertiesUtil.toString(config.get(SERVICE_NAME), null));
boolean queueProcessingEnabled = PropertiesUtil.toBoolean(config.get(QUEUE_PROCESSING_ENABLED), true);
String[] exporterEndpoints = PropertiesUtil.toStringArray(config.get(EXPORTER_ENDPOINTS), new String[0]);
exporterEndpoints = SettingsUtils.removeEmptyEntries(exporterEndpoints);
int pullItems = PropertiesUtil.toInteger(config.get(PULL_ITEMS), Integer.MAX_VALUE);
Integer timeout = PropertiesUtil.toInteger(HTTP, 10) * 1000;
HttpConfiguration httpConfiguration = new HttpConfiguration(timeout);
DistributionPackageExporter packageExporter = new RemoteDistributionPackageExporter(distributionLog, packageBuilder, transportSecretProvider, exporterEndpoints, pullItems, httpConfiguration);
DistributionPackageImporter packageImporter = new LocalDistributionPackageImporter(agentName, distributionEventFactory, packageBuilder);
DistributionQueueProvider queueProvider = new MonitoringDistributionQueueProvider(new JobHandlingDistributionQueueProvider(agentName, jobManager, context), context);
DistributionQueueDispatchingStrategy exportQueueStrategy = new SingleQueueDispatchingStrategy();
DistributionQueueDispatchingStrategy importQueueStrategy = null;
DistributionRequestType[] allowedRequests = new DistributionRequestType[] { DistributionRequestType.PULL };
Set<String> processingQueues = new HashSet<String>();
processingQueues.addAll(exportQueueStrategy.getQueueNames());
return new SimpleDistributionAgent(agentName, queueProcessingEnabled, processingQueues, serviceName, packageImporter, packageExporter, requestAuthorizationStrategy, queueProvider, exportQueueStrategy, importQueueStrategy, distributionEventFactory, resourceResolverFactory, slingRepository, distributionLog, allowedRequests, null, 0);
}
use of org.apache.sling.distribution.transport.impl.HttpConfiguration in project sling by apache.
the class RemoteDistributionPackageImporterFactory method activate.
@Activate
protected void activate(Map<String, Object> config) {
Map<String, String> endpoints = SettingsUtils.toUriMap(config.get(ENDPOINTS));
String importerName = PropertiesUtil.toString(config.get(NAME), null);
DefaultDistributionLog distributionLog = new DefaultDistributionLog(DistributionComponentKind.IMPORTER, importerName, RemoteDistributionPackageImporter.class, DefaultDistributionLog.LogLevel.ERROR);
// default to 10s, we can expose it if needed
HttpConfiguration httpConfiguration = new HttpConfiguration(10000);
importer = new RemoteDistributionPackageImporter(distributionLog, transportSecretProvider, endpoints, httpConfiguration);
}
Aggregations