use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class AbstractDistributionPackageBuilder method readPackage.
@Nonnull
public DistributionPackage readPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull InputStream stream) throws DistributionException {
if (!stream.markSupported()) {
stream = new BufferedInputStream(stream);
}
Map<String, Object> headerInfo = new HashMap<String, Object>();
DistributionPackageUtils.readInfo(stream, headerInfo);
try {
stream.reset();
} catch (IOException e) {
// do nothing
}
DistributionPackage distributionPackage = SimpleDistributionPackage.fromStream(stream, type);
try {
stream.reset();
} catch (IOException e) {
// do nothing
}
// not a simple package
if (distributionPackage == null) {
distributionPackage = readPackageInternal(resourceResolver, stream);
}
distributionPackage.getInfo().putAll(headerInfo);
return distributionPackage;
}
use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class AbstractDistributionPackageBuilder method createPackage.
@Nonnull
public DistributionPackage createPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionRequest request) throws DistributionException {
DistributionPackage distributionPackage;
request = VltUtils.sanitizeRequest(request);
if (DistributionRequestType.ADD.equals(request.getRequestType())) {
distributionPackage = createPackageForAdd(resourceResolver, request);
} else if (DistributionRequestType.DELETE.equals(request.getRequestType())) {
distributionPackage = new SimpleDistributionPackage(request, type);
} else if (DistributionRequestType.PULL.equals(request.getRequestType())) {
distributionPackage = new SimpleDistributionPackage(request, type);
} else if (DistributionRequestType.TEST.equals(request.getRequestType())) {
distributionPackage = new SimpleDistributionPackage(request, type);
} else {
throw new DistributionException("unknown action type " + request.getRequestType());
}
DistributionPackageUtils.fillInfo(distributionPackage.getInfo(), request);
return distributionPackage;
}
use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class KryoContentSerializerTest method testBuildAndInstallOnSingleShallowPath.
@Test
public void testBuildAndInstallOnSingleShallowPath() throws Exception {
String type = "kryo";
DistributionContentSerializer contentSerializer = new KryoContentSerializer(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"));
}
use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class DistributionAgentQueueServlet method deleteItem.
private void deleteItem(ResourceResolver resourceResolver, DistributionQueue queue, DistributionQueueEntry entry) {
DistributionQueueItem item = entry.getItem();
String id = entry.getId();
queue.remove(id);
DistributionPackage distributionPackage = getPackage(resourceResolver, item);
DistributionPackageUtils.releaseOrDelete(distributionPackage, queue.getName());
}
use of org.apache.sling.distribution.packaging.DistributionPackage in project sling by apache.
the class KryoContentSerializerTest method testBuildAndInstallOnMultipleShallowPaths.
@Test
public void testBuildAndInstallOnMultipleShallowPaths() throws Exception {
String type = "kryo";
DistributionContentSerializer contentSerializer = new KryoContentSerializer(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", "/libs/sameLevel");
DistributionPackage distributionPackage = packageBuilder.createPackage(resourceResolver, request);
Resource resource = resourceResolver.getResource("/libs/sub");
resourceResolver.delete(resource);
resource = resourceResolver.getResource("/libs/sameLevel");
resourceResolver.delete(resource);
resourceResolver.commit();
assertTrue(packageBuilder.installPackage(resourceResolver, distributionPackage));
assertNotNull(resourceResolver.getResource("/libs"));
assertNotNull(resourceResolver.getResource("/libs/sub"));
assertNotNull(resourceResolver.getResource("/libs/sameLevel"));
}
Aggregations