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();
}
}
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);
}
}
Aggregations