Package org.apache.sling.replication.communication

Examples of org.apache.sling.replication.communication.ReplicationRequest


            log.info("triggering replication from event {}", event);

            Object pathProperty = event.getProperty("path");
            if (pathProperty != null) {
                String replicatingPath = String.valueOf(pathProperty);
                requestHandler.handle(new ReplicationRequest(System.currentTimeMillis(), action, replicatingPath));
            }
        }
View Full Code Here


    }

    @Override
    protected ReplicationRequest processEvent(Event event) throws RepositoryException {
        log.info("triggering replication from jcr event {}", event);
        ReplicationRequest replicationRequest = null;
        Object pathProperty = event.getPath();
        if (pathProperty != null) {
            String replicatingPath = String.valueOf(pathProperty);
            int type = event.getType();
            if (Event.PROPERTY_REMOVED == type || Event.PROPERTY_CHANGED == type || Event.PROPERTY_ADDED == type) {
                replicatingPath = replicatingPath.substring(0, replicatingPath.lastIndexOf('/'));
            }
            replicationRequest = new ReplicationRequest(System.currentTimeMillis(), Event.NODE_REMOVED ==
                    type ? ReplicationActionType.DELETE : ReplicationActionType.ADD, replicatingPath);
            log.info("replicating {}", replicationRequest);
        }
        return replicationRequest;
    }
View Full Code Here

    @Override
    protected ReplicationRequest processEvent(Event event) throws RepositoryException {
        log.debug("processing event {}", event);

        ReplicationRequest replicationRequest = null;

        Session session = getSession();

        if (session != null && session.hasPermission(nuggetsPath, Privilege.JCR_ADD_CHILD_NODES)) {
            log.debug("persisting event under {}", nuggetsPath);
            Node nuggetsNode = session.getNode(nuggetsPath);
            if (nuggetsNode != null) {
                String nodeName = event.getIdentifier() != null ? event.getIdentifier() : String.valueOf(System.nanoTime());
                Node createdNode = nuggetsNode.addNode(nodeName);
                if (createdNode != null) {
                    String path = createdNode.getPath();
                    nuggetsNode.setProperty("path", event.getPath());
                    nuggetsNode.setProperty("date", event.getDate());
                    nuggetsNode.setProperty("type", event.getType());
                    nuggetsNode.setProperty("userData", event.getUserData());
                    nuggetsNode.setProperty("userID", event.getUserID());

                    Set<Map.Entry> set = event.getInfo().entrySet();
                    for (Map.Entry entry : set) {
                        nuggetsNode.setProperty("info." + entry.getKey(), String.valueOf(entry.getValue()));
                    }
                    session.save();
                    log.debug("event persisted at {}", path);
                    replicationRequest = new ReplicationRequest(System.currentTimeMillis(), ReplicationActionType.ADD, path);
                } else {
                    log.warn("could not create node {}", nuggetsPath + "/" + nodeName);
                }
            } else {
                log.warn("could not get node {} to persist event", nuggetsPath);
View Full Code Here

                for (String p : paths) {
                    if (p.startsWith(path)) {
                        log.info("triggering chain replication from event {}", event);

                        ReplicationActionType action = ReplicationActionType.valueOf(String.valueOf(actionProperty));
                        requestHandler.handle(new ReplicationRequest(System.currentTimeMillis(), action, paths));
                        break;
                    }
                }
            }
        }
View Full Code Here

        public void onEvent(EventIterator eventIterator) {
            while (eventIterator.hasNext()) {
                Event event = eventIterator.nextEvent();
                try {
                    if (ReplicationJcrUtils.isSafe(event)) {
                        ReplicationRequest request = processEvent(event);
                        if (request != null) {
                            requestHandler.handle(request);
                        }
                    }
                } catch (RepositoryException e) {
View Full Code Here

        ReplicationEventFactory eventFactory = mock(ReplicationEventFactory.class);

        FileVaultReplicationPackageBuilder fileVaultReplicationPackageBuilder = new FileVaultReplicationPackageBuilder(
                packaging, eventFactory);
        ReplicationRequest request = new ReplicationRequest(ReplicationActionType.ADD, new String[]{"/"});
        ReplicationPackage replicationPackage = fileVaultReplicationPackageBuilder.createPackageForAdd(resourceResolver, request);
        assertNotNull(replicationPackage);
    }
View Full Code Here

        final long start = System.currentTimeMillis();

        response.setContentType(ContentType.APPLICATION_OCTET_STREAM.toString());

        ReplicationRequest replicationRequest = RequestUtils.fromServletRequest(request);
        ResourceResolver resourceResolver = request.getResourceResolver();

        int consumed = 0;
        int fetched = 0;
        try {
View Full Code Here

        String[] paths = request.getParameterValues(PATH_PARAMETER);

        ReplicationActionType action = ReplicationActionType.fromName(a);


        ReplicationRequest replicationRequest = new ReplicationRequest(System.currentTimeMillis(),
                action, paths);

        ResourceResolver resourceResolver = request.getResourceResolver();

        boolean failed = false;
View Full Code Here

    protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
            throws ServletException, IOException {

        response.setContentType("application/json");

        ReplicationRequest replicationRequest = RequestUtils.fromServletRequest(request);

        ReplicationAgent agent = request.getResource().adaptTo(ReplicationAgent.class);

        ResourceResolver resourceResolver = request.getResourceResolver();
View Full Code Here

        }

        public void run() {
            log.debug("agent {}: scheduling {} replication of {}", new Object[]{requestHandler, replicationAction, path});

            requestHandler.handle(new ReplicationRequest(System.currentTimeMillis(), replicationAction, path));
        }
View Full Code Here

TOP

Related Classes of org.apache.sling.replication.communication.ReplicationRequest

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.