Search in sources :

Example 6 with DistributionRequestType

use of org.apache.sling.distribution.DistributionRequestType in project sling by apache.

the class SimpleDistributionPackage method fromIdString.

public static SimpleDistributionPackage fromIdString(String id, String type) {
    if (!id.startsWith(PACKAGE_START)) {
        return null;
    }
    id = id.substring(PACKAGE_START.length());
    String[] parts = id.split(Pattern.quote(DELIM));
    if (parts.length < 1 || parts.length > 2) {
        return null;
    }
    String actionString = parts[0];
    String pathsString = parts.length < 2 ? null : parts[1];
    DistributionRequestType distributionRequestType = DistributionRequestType.fromName(actionString);
    SimpleDistributionPackage distributionPackage = null;
    if (distributionRequestType != null) {
        String[] paths = pathsString == null ? new String[0] : pathsString.split(PATH_DELIM);
        DistributionRequest request = new SimpleDistributionRequest(distributionRequestType, paths);
        distributionPackage = new SimpleDistributionPackage(request, type);
    }
    return distributionPackage;
}
Also used : SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionRequest(org.apache.sling.distribution.DistributionRequest) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionRequestType(org.apache.sling.distribution.DistributionRequestType)

Example 7 with DistributionRequestType

use of org.apache.sling.distribution.DistributionRequestType in project sling by apache.

the class AbstractDistributionPackageBuilder method installPackage.

public boolean installPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull DistributionPackage distributionPackage) throws DistributionException {
    DistributionRequestType actionType = distributionPackage.getInfo().getRequestType();
    if (!type.equals(distributionPackage.getType())) {
        throw new DistributionException("not supported package type" + distributionPackage.getType());
    }
    boolean installed = false;
    if (DistributionRequestType.DELETE.equals(actionType)) {
        installed = installDeletePackage(resourceResolver, distributionPackage);
    } else if (DistributionRequestType.TEST.equals(actionType)) {
        // do nothing for test packages
        installed = true;
    } else if (DistributionRequestType.ADD.equals(actionType)) {
        installed = installAddPackage(resourceResolver, distributionPackage);
    }
    return installed;
}
Also used : DistributionRequestType(org.apache.sling.distribution.DistributionRequestType) DistributionException(org.apache.sling.distribution.common.DistributionException)

Example 8 with DistributionRequestType

use of org.apache.sling.distribution.DistributionRequestType in project sling by apache.

the class VltUtils method sanitizeRequest.

public static DistributionRequest sanitizeRequest(DistributionRequest request) {
    DistributionRequestType requestType = request.getRequestType();
    if (!DistributionRequestType.ADD.equals(requestType) && !DistributionRequestType.DELETE.equals(requestType)) {
        return request;
    }
    Set<String> deepPaths = new HashSet<String>();
    List<String> paths = new ArrayList<String>();
    Map<String, String[]> filters = new HashMap<String, String[]>();
    for (String path : request.getPaths()) {
        if (VltUtils.findParent(path, "rep:policy") != null) {
            if (DistributionRequestType.DELETE.equals(requestType)) {
                // vlt cannot properly install delete of rep:policy subnodes
                throw new IllegalArgumentException("cannot distribute DELETE node " + path);
            } else if (DistributionRequestType.ADD.equals(requestType)) {
                String newPath = VltUtils.findParent(path, "rep:policy") + "/rep:policy";
                paths.add(newPath);
                deepPaths.add(newPath);
                log.debug("changed distribution path {} to deep path {}", path, newPath);
            }
        } else if (request.isDeep(path)) {
            paths.add(path);
            deepPaths.add(path);
        } else {
            paths.add(path);
        }
        filters.put(path, request.getFilters(path));
    }
    return new SimpleDistributionRequest(requestType, paths.toArray(new String[paths.size()]), deepPaths, filters);
}
Also used : SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionRequestType(org.apache.sling.distribution.DistributionRequestType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Aggregations

DistributionRequestType (org.apache.sling.distribution.DistributionRequestType)8 MonitoringDistributionQueueProvider (org.apache.sling.distribution.monitor.impl.MonitoringDistributionQueueProvider)4 DistributionPackageExporter (org.apache.sling.distribution.packaging.DistributionPackageExporter)4 DistributionQueueProvider (org.apache.sling.distribution.queue.DistributionQueueProvider)4 DistributionQueueDispatchingStrategy (org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy)4 JobHandlingDistributionQueueProvider (org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider)4 HashSet (java.util.HashSet)3 DistributionPackageImporter (org.apache.sling.distribution.packaging.DistributionPackageImporter)3 HttpConfiguration (org.apache.sling.distribution.transport.impl.HttpConfiguration)3 HashMap (java.util.HashMap)2 SimpleDistributionRequest (org.apache.sling.distribution.SimpleDistributionRequest)2 LocalDistributionPackageExporter (org.apache.sling.distribution.packaging.impl.exporter.LocalDistributionPackageExporter)2 RemoteDistributionPackageExporter (org.apache.sling.distribution.packaging.impl.exporter.RemoteDistributionPackageExporter)2 RemoteDistributionPackageImporter (org.apache.sling.distribution.packaging.impl.importer.RemoteDistributionPackageImporter)2 ErrorQueueDispatchingStrategy (org.apache.sling.distribution.queue.impl.ErrorQueueDispatchingStrategy)2 MultipleQueueDispatchingStrategy (org.apache.sling.distribution.queue.impl.MultipleQueueDispatchingStrategy)2 PriorityQueueDispatchingStrategy (org.apache.sling.distribution.queue.impl.PriorityQueueDispatchingStrategy)2 SingleQueueDispatchingStrategy (org.apache.sling.distribution.queue.impl.SingleQueueDispatchingStrategy)2 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1