Search in sources :

Example 6 with DistributionPackageBuilder

use of org.apache.sling.distribution.packaging.DistributionPackageBuilder in project sling by apache.

the class DistributionAgentQueueServlet method getPackage.

private DistributionPackage getPackage(ResourceResolver resourceResolver, DistributionQueueItem item) {
    DistributionPackageInfo info = DistributionPackageUtils.fromQueueItem(item);
    String type = info.getType();
    DistributionPackageBuilder packageBuilder = packageBuilderProvider.getPackageBuilder(type);
    if (packageBuilder != null) {
        try {
            return packageBuilder.getPackage(resourceResolver, item.getPackageId());
        } catch (DistributionException e) {
            log.error("cannot get package", e);
        }
    }
    return null;
}
Also used : DistributionPackageInfo(org.apache.sling.distribution.packaging.DistributionPackageInfo) DistributionPackageBuilder(org.apache.sling.distribution.packaging.DistributionPackageBuilder) DistributionException(org.apache.sling.distribution.common.DistributionException)

Example 7 with DistributionPackageBuilder

use of org.apache.sling.distribution.packaging.DistributionPackageBuilder in project sling by apache.

the class AvroContentSerializerTest method testBuildAndInstallOnSingleDeepPath.

@Test
public void testBuildAndInstallOnSingleDeepPath() throws Exception {
    String type = "avro";
    DistributionContentSerializer contentSerializer = new AvroContentSerializer(type);
    String tempFilesFolder = "target";
    String[] nodeFilters = new String[0];
    String[] propertyFilters = new String[0];
    DistributionPackageBuilder packageBuilder = new FileDistributionPackageBuilder(type, contentSerializer, tempFilesFolder, null, nodeFilters, propertyFilters);
    DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, true, "/libs");
    DistributionPackage distributionPackage = packageBuilder.createPackage(resourceResolver, request);
    Resource resource = resourceResolver.getResource("/libs/sub");
    resourceResolver.delete(resource);
    resourceResolver.commit();
    assertTrue(packageBuilder.installPackage(resourceResolver, distributionPackage));
    assertNotNull(resourceResolver.getResource("/libs"));
    assertNotNull(resourceResolver.getResource("/libs/sub"));
    assertNotNull(resourceResolver.getResource("/libs/sameLevel"));
}
Also used : FileDistributionPackageBuilder(org.apache.sling.distribution.packaging.impl.FileDistributionPackageBuilder) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionRequest(org.apache.sling.distribution.DistributionRequest) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionPackage(org.apache.sling.distribution.packaging.DistributionPackage) FileDistributionPackageBuilder(org.apache.sling.distribution.packaging.impl.FileDistributionPackageBuilder) DistributionPackageBuilder(org.apache.sling.distribution.packaging.DistributionPackageBuilder) Resource(org.apache.sling.api.resource.Resource) DistributionContentSerializer(org.apache.sling.distribution.serialization.DistributionContentSerializer) Test(org.junit.Test)

Example 8 with DistributionPackageBuilder

use of org.apache.sling.distribution.packaging.DistributionPackageBuilder in project sling by apache.

the class RemoteDistributionPackageExporterTest method testNothingExported.

@Test
public void testNothingExported() throws Exception {
    DistributionPackageBuilder packageBuilder = mock(DistributionPackageBuilder.class);
    DistributionTransportSecretProvider distributionTransportSecretProvider = mock(DistributionTransportSecretProvider.class);
    String[] endpoints = new String[0];
    RemoteDistributionPackageExporter remotedistributionPackageExporter = new RemoteDistributionPackageExporter(mock(DefaultDistributionLog.class), packageBuilder, distributionTransportSecretProvider, endpoints, 1, new HttpConfiguration(10000));
    ResourceResolver resourceResolver = mock(ResourceResolver.class);
    DistributionRequest distributionRequest = new SimpleDistributionRequest(DistributionRequestType.ADD, "/");
    final List<DistributionPackage> distributionPackages = new ArrayList<DistributionPackage>();
    remotedistributionPackageExporter.exportPackages(resourceResolver, distributionRequest, new DistributionPackageProcessor() {

        @Override
        public void process(DistributionPackage distributionPackage) {
            distributionPackages.add(distributionPackage);
        }

        @Override
        public List<DistributionResponse> getAllResponses() {
            return null;
        }

        @Override
        public int getPackagesCount() {
            return 0;
        }

        @Override
        public long getPackagesSize() {
            return 0;
        }
    });
    assertNotNull(distributionPackages);
    assertTrue(distributionPackages.isEmpty());
}
Also used : ArrayList(java.util.ArrayList) DistributionTransportSecretProvider(org.apache.sling.distribution.transport.DistributionTransportSecretProvider) DefaultDistributionLog(org.apache.sling.distribution.log.impl.DefaultDistributionLog) HttpConfiguration(org.apache.sling.distribution.transport.impl.HttpConfiguration) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionRequest(org.apache.sling.distribution.DistributionRequest) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionPackageProcessor(org.apache.sling.distribution.packaging.DistributionPackageProcessor) DistributionPackage(org.apache.sling.distribution.packaging.DistributionPackage) DistributionPackageBuilder(org.apache.sling.distribution.packaging.DistributionPackageBuilder) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 9 with DistributionPackageBuilder

use of org.apache.sling.distribution.packaging.DistributionPackageBuilder in project sling by apache.

the class LocalDistributionPackageExporterTest method testGetPackage.

@Test
public void testGetPackage() throws Exception {
    DistributionPackageBuilder packageBuilder = mock(DistributionPackageBuilder.class);
    when(packageBuilder.getPackage(any(ResourceResolver.class), any(String.class))).thenReturn(mock(DistributionPackage.class));
    LocalDistributionPackageExporter localdistributionPackageExporter = new LocalDistributionPackageExporter(packageBuilder);
    ResourceResolver resourceResolver = mock(ResourceResolver.class);
    DistributionPackage distributionPackage = localdistributionPackageExporter.getPackage(resourceResolver, "123");
    assertNotNull(distributionPackage);
}
Also used : DistributionPackage(org.apache.sling.distribution.packaging.DistributionPackage) DistributionPackageBuilder(org.apache.sling.distribution.packaging.DistributionPackageBuilder) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) Test(org.junit.Test)

Example 10 with DistributionPackageBuilder

use of org.apache.sling.distribution.packaging.DistributionPackageBuilder in project sling by apache.

the class AvroContentSerializerTest method testBuildAndInstallOnSingleShallowPath.

@Test
public void testBuildAndInstallOnSingleShallowPath() throws Exception {
    String type = "avro";
    DistributionContentSerializer contentSerializer = new AvroContentSerializer(type);
    String tempFilesFolder = "target";
    String[] nodeFilters = new String[0];
    String[] propertyFilters = new String[0];
    DistributionPackageBuilder packageBuilder = new FileDistributionPackageBuilder(type, contentSerializer, tempFilesFolder, null, nodeFilters, propertyFilters);
    DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, "/libs/sub");
    DistributionPackage distributionPackage = packageBuilder.createPackage(resourceResolver, request);
    Resource resource = resourceResolver.getResource("/libs/sub");
    resourceResolver.delete(resource);
    resourceResolver.commit();
    assertTrue(packageBuilder.installPackage(resourceResolver, distributionPackage));
    assertNotNull(resourceResolver.getResource("/libs"));
    assertNotNull(resourceResolver.getResource("/libs/sub"));
    assertNotNull(resourceResolver.getResource("/libs/sameLevel"));
}
Also used : FileDistributionPackageBuilder(org.apache.sling.distribution.packaging.impl.FileDistributionPackageBuilder) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionRequest(org.apache.sling.distribution.DistributionRequest) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionPackage(org.apache.sling.distribution.packaging.DistributionPackage) FileDistributionPackageBuilder(org.apache.sling.distribution.packaging.impl.FileDistributionPackageBuilder) DistributionPackageBuilder(org.apache.sling.distribution.packaging.DistributionPackageBuilder) Resource(org.apache.sling.api.resource.Resource) DistributionContentSerializer(org.apache.sling.distribution.serialization.DistributionContentSerializer) Test(org.junit.Test)

Aggregations

DistributionPackageBuilder (org.apache.sling.distribution.packaging.DistributionPackageBuilder)20 DistributionPackage (org.apache.sling.distribution.packaging.DistributionPackage)16 Test (org.junit.Test)15 SimpleDistributionRequest (org.apache.sling.distribution.SimpleDistributionRequest)12 DistributionRequest (org.apache.sling.distribution.DistributionRequest)11 FileDistributionPackageBuilder (org.apache.sling.distribution.packaging.impl.FileDistributionPackageBuilder)10 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)9 DistributionContentSerializer (org.apache.sling.distribution.serialization.DistributionContentSerializer)7 Resource (org.apache.sling.api.resource.Resource)6 DefaultDistributionLog (org.apache.sling.distribution.log.impl.DefaultDistributionLog)5 DistributionPackageInfo (org.apache.sling.distribution.packaging.DistributionPackageInfo)5 DistributionTransportSecretProvider (org.apache.sling.distribution.transport.DistributionTransportSecretProvider)5 InputStream (java.io.InputStream)3 URI (java.net.URI)3 HashMap (java.util.HashMap)3 HttpResponse (org.apache.http.HttpResponse)3 Executor (org.apache.http.client.fluent.Executor)3 Request (org.apache.http.client.fluent.Request)3 Response (org.apache.http.client.fluent.Response)3 DistributionException (org.apache.sling.distribution.common.DistributionException)3