Search in sources :

Example 6 with DistributionExportOptions

use of org.apache.sling.distribution.serialization.DistributionExportOptions in project sling by apache.

the class KryoContentSerializerTest method testExtract.

@Test
public void testExtract() throws Exception {
    KryoContentSerializer kryoContentSerializer = new KryoContentSerializer("kryo");
    DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, "/libs");
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    NavigableMap<String, List<String>> nodeFilters = new TreeMap<String, List<String>>();
    NavigableMap<String, List<String>> propertyFilters = new TreeMap<String, List<String>>();
    try {
        DistributionExportFilter filter = DistributionExportFilter.createFilter(request, nodeFilters, propertyFilters);
        kryoContentSerializer.exportToStream(resourceResolver, new DistributionExportOptions(request, filter), outputStream);
        byte[] bytes = outputStream.toByteArray();
        assertNotNull(bytes);
        assertTrue(bytes.length > 0);
    } finally {
        outputStream.close();
    }
}
Also used : DistributionExportOptions(org.apache.sling.distribution.serialization.DistributionExportOptions) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionRequest(org.apache.sling.distribution.DistributionRequest) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) List(java.util.List) DistributionExportFilter(org.apache.sling.distribution.serialization.DistributionExportFilter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 7 with DistributionExportOptions

use of org.apache.sling.distribution.serialization.DistributionExportOptions in project sling by apache.

the class FileVaultContentSerializer method exportToStream.

@Override
public void exportToStream(ResourceResolver resourceResolver, DistributionExportOptions exportOptions, OutputStream outputStream) throws DistributionException {
    Session session = null;
    try {
        session = getSession(resourceResolver);
        String packageGroup = PACKAGE_GROUP;
        String packageName = TYPE + "_" + System.currentTimeMillis() + "_" + UUID.randomUUID();
        WorkspaceFilter filter = VltUtils.createFilter(exportOptions.getRequest(), nodeFilters, propertyFilters);
        ExportOptions opts = VltUtils.getExportOptions(filter, packageRoots, packageGroup, packageName, VERSION, useBinaryReferences);
        log.debug("assembling package {} user {}", packageGroup + '/' + packageName + "-" + VERSION, resourceResolver.getUserID());
        packaging.getPackageManager().assemble(session, opts, outputStream);
    } catch (Exception e) {
        throw new DistributionException(e);
    } finally {
        ungetSession(session);
    }
}
Also used : DistributionExportOptions(org.apache.sling.distribution.serialization.DistributionExportOptions) ExportOptions(org.apache.jackrabbit.vault.packaging.ExportOptions) WorkspaceFilter(org.apache.jackrabbit.vault.fs.api.WorkspaceFilter) DistributionException(org.apache.sling.distribution.common.DistributionException) DistributionException(org.apache.sling.distribution.common.DistributionException) RepositoryException(javax.jcr.RepositoryException) Session(javax.jcr.Session)

Aggregations

DistributionExportOptions (org.apache.sling.distribution.serialization.DistributionExportOptions)7 DistributionExportFilter (org.apache.sling.distribution.serialization.DistributionExportFilter)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 DistributionRequest (org.apache.sling.distribution.DistributionRequest)4 Test (org.junit.Test)4 List (java.util.List)3 TreeMap (java.util.TreeMap)3 SimpleDistributionRequest (org.apache.sling.distribution.SimpleDistributionRequest)3 OutputStream (java.io.OutputStream)2 Session (javax.jcr.Session)2 ExportOptions (org.apache.jackrabbit.vault.packaging.ExportOptions)2 DistributionException (org.apache.sling.distribution.common.DistributionException)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 DigestOutputStream (java.security.DigestOutputStream)1 RepositoryException (javax.jcr.RepositoryException)1 Workspace (javax.jcr.Workspace)1 ObservationManager (javax.jcr.observation.ObservationManager)1 ImportMode (org.apache.jackrabbit.vault.fs.api.ImportMode)1