Package org.apache.sling.replication.packaging

Examples of org.apache.sling.replication.packaging.ReplicationPackage


    @Override
    protected ReplicationPackage readPackageInternal(ResourceResolver resourceResolver, final InputStream stream)
            throws ReplicationPackageReadingException {
        log.debug("reading a stream");
        ReplicationPackage pkg = null;
        try {
            File tmpFile = File.createTempFile("rp-vlt-read-" + System.nanoTime(), ".zip");
            FileOutputStream fileStream = new FileOutputStream(tmpFile);
            IOUtils.copy(stream, fileStream);
            IOUtils.closeQuietly(fileStream);
View Full Code Here


    }


    @Override
    protected ReplicationPackage getPackageInternal(ResourceResolver resourceResolver, String id) {
        ReplicationPackage replicationPackage = null;
        try {
            File file = new File(id);
            if (file.exists()) {
                VaultPackage pkg = packaging.getPackageManager().open(file);
                replicationPackage = new FileVaultReplicationPackage(pkg);
View Full Code Here

        return success;
    }

    public ReplicationPackage importStream(@Nonnull ResourceResolver resourceResolver, @Nonnull InputStream stream) throws ReplicationPackageImportException {
        try {
            ReplicationPackage replicationPackage = packageBuilder.readPackage(resourceResolver, stream);
            if (importPackage(resourceResolver, replicationPackage)) {
                return replicationPackage;
            } else {
                throw new ReplicationPackageImportException("could not import the package " + replicationPackage);
            }
View Full Code Here

        response.setCharacterEncoding("utf-8");

        InputStream stream = request.getInputStream();
        ResourceResolver resourceResolver = request.getResourceResolver();
        try {
            ReplicationPackage replicationPackage = replicationPackageImporter.importStream(resourceResolver, stream);
            if (replicationPackage != null) {
                replicationPackage.delete();
            } else {
                log.warn("cannot import replication package from request {}", request);
                response.setStatus(400);
                response.getWriter().print("error: could not import a package from the request stream");
            }
View Full Code Here

        this.replicationPackageBuilder = replicationPackageExporter;
    }

    @CheckForNull
    public ReplicationPackage createPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull ReplicationRequest request) throws ReplicationPackageBuildingException {
        ReplicationPackage replicationPackage = replicationPackageBuilder.createPackage(resourceResolver, request);

        if (replicationPackage == null) {
            return null;
        }
View Full Code Here

        }
    }

    @CheckForNull
    public ReplicationPackage readPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull InputStream stream) throws ReplicationPackageReadingException {
        ReplicationPackage replicationPackage = replicationPackageBuilder.readPackage(resourceResolver, stream);

        if (replicationPackage == null) {
            return null;
        }
View Full Code Here

        }
    }

    public ReplicationPackage getPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull String replicationPackageId) {
        String originalPackageId = retrieveIdFromPath(resourceResolver, replicationPackageId);
        ReplicationPackage replicationPackage = replicationPackageBuilder.getPackage(resourceResolver, originalPackageId);

        if (replicationPackage == null) {
            return null;
        }
View Full Code Here

            return false;
        }

        ResourceSharedReplicationPackage sharedReplicationPackage = (ResourceSharedReplicationPackage) replicationPackage;

        ReplicationPackage originalPackage = sharedReplicationPackage.getPackage();
        return replicationPackageBuilder.installPackage(resourceResolver, originalPackage);
    }
View Full Code Here

                while ((httpResponse = executor.execute(req).returnResponse())
                        .getStatusLine().getStatusCode() == 200
                        && polls < maxNumberOfPackages) {
                    HttpEntity entity = httpResponse.getEntity();
                    if (entity != null) {
                        final ReplicationPackage responsePackage = packageBuilder.readPackage(resourceResolver, entity.getContent());
                        if (responsePackage != null) {
                            String origin = getHostAndPort(replicationURI);
                            responsePackage.getInfo().setOrigin(origin);
                            result.add(responsePackage);
                        }
                        else {
                            log.warn("responsePackage is null");
                        }
View Full Code Here

    }

    @CheckForNull
    public ReplicationPackage createPackage(@Nonnull ResourceResolver resourceResolver, @Nonnull ReplicationRequest request)
            throws ReplicationPackageBuildingException {
        ReplicationPackage replicationPackage;
        if (ReplicationActionType.ADD.equals(request.getAction())) {
            replicationPackage = createPackageForAdd(resourceResolver, request);
        } else if (ReplicationActionType.DELETE.equals(request.getAction())) {
            replicationPackage = new VoidReplicationPackage(request, type);
        } else if (ReplicationActionType.POLL.equals(request.getAction())) {
            replicationPackage = new VoidReplicationPackage(request, type);
        } else {
            throw new ReplicationPackageBuildingException("unknown action type "
                    + request.getAction());
        }
        if (replicationPackage != null && replicationEventFactory != null) {
            Dictionary<String, Object> dictionary = new Hashtable<String, Object>();
            dictionary.put("replication.action", replicationPackage.getAction());
            dictionary.put("replication.path", replicationPackage.getPaths());
            replicationEventFactory.generateEvent(ReplicationEventType.PACKAGE_CREATED, dictionary);
        }
        return replicationPackage;
    }
View Full Code Here

TOP

Related Classes of org.apache.sling.replication.packaging.ReplicationPackage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.