Package org.apache.sling.replication.agent

Examples of org.apache.sling.replication.agent.ReplicationAgent


        response.setContentType("application/json");

        ReplicationRequest replicationRequest = RequestUtils.fromServletRequest(request);

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

        ResourceResolver resourceResolver = request.getResourceResolver();

        if (agent != null) {
            try {
                ReplicationResponse replicationResponse = agent.execute(resourceResolver, replicationRequest);
                if (replicationResponse.isSuccessful()) {
                    if (ItemState.SUCCEEDED.toString().equals(replicationResponse.getStatus())) {
                        response.setStatus(200);
                    }
                    if (ItemState.QUEUED.toString().equals(replicationResponse.getStatus())
View Full Code Here


            return new RemoteReplicationPackageExporter(packageBuilder, authenticationProvider, endpoints, endpointStrategyName, pollItems);
        } else if (PACKAGE_EXPORTER_AGENT.equals(factory)) {
            Map<String, Object> builderProperties = extractMap(COMPONENT_PACKAGE_BUILDER, properties);
            ReplicationPackageBuilder packageBuilder = createBuilder(builderProperties);
            ReplicationAgent agent = componentProvider.getComponent(ReplicationAgent.class, null);

            return new AgentReplicationPackageExporter(properties, agent, packageBuilder);
        }

View Full Code Here

            throws ServletException, IOException {
        response.setContentType("application/json");

        String queueName = request.getParameter(ReplicationParameter.QUEUE.toString());

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

        if (agent != null) {
            try {
                ReplicationQueue queue = agent.getQueue(queueName);
                response.getWriter().write(toJSoN(queue)); // TODO : use json writer
                response.setStatus(200);
            } catch (Exception e) {
                response.setStatus(400);
                response.getWriter().write("{\"status\" : \"error\",\"message\":\"error reading from the queue\",\"reason\":\""
View Full Code Here

                String componentClass = null;
                Object componentObject = null;

                if (ReplicationComponentFactory.COMPONENT_AGENT.equals(componentType)) {
                    ReplicationAgent agent = componentFactory.createComponent(ReplicationAgent.class, properties, this);
                    componentClass = ReplicationAgent.class.getName();
                    componentObject = agent;

                } else if (ReplicationComponentFactory.COMPONENT_TRIGGER.equals(componentType)) {
View Full Code Here

                packageExporterProperties = packageExporterPropertiesList.toArray(new String[packageExporterPropertiesList.size()]);
                properties.put(PACKAGE_EXPORTER, packageExporterProperties);

                properties.put("trigger0", new String[]{"type=scheduledEvent"});

                ReplicationAgent agent = componentFactory.createComponent(ReplicationAgent.class, properties, this);

                log.debug("activated agent {}", name);

                if (agent != null) {
View Full Code Here

            String name = PropertiesUtil
                    .toString(config.get(NAME), String.valueOf(new Random().nextInt(1000)));
            props.put(NAME, name);

            if (componentReg == null && componentFactory != null) {
                ReplicationAgent agent = componentFactory.createComponent(ReplicationAgent.class, config, this);

                log.debug("activated agent {}", name);

                if (agent != null) {
View Full Code Here

        DefaultReplicationComponentFactory defaultReplicationComponentFactory = new DefaultReplicationComponentFactory();
        String name = "sample-agent";
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("name", name);
        ReplicationComponentProvider provider = mock(ReplicationComponentProvider.class);
        ReplicationAgent agent = mock(ReplicationAgent.class);
        when(provider.getComponent(ReplicationAgent.class, name)).thenReturn(agent);
        ReplicationAgent component = defaultReplicationComponentFactory.createComponent(ReplicationAgent.class, properties, provider);
        assertNull(component); // agents cannot be referenced by service name using the factory
    }
View Full Code Here

                "endpoints[0]=http://localhost:101/libs/sling/replication/services/importers/default",
                "endpoints[1]=http://localhost:102/libs/sling/replication/services/importers/default",
                "endpoints[2]=http://localhost:103/libs/sling/replication/services/importers/default",
                "endpoints.strategy=All"});
        ReplicationComponentFactory replicationComponentFactory = mock(ReplicationComponentFactory.class);
        ReplicationAgent replicationAgent = mock(ReplicationAgent.class);
        CoordinatingReplicationAgentFactory coordinatingReplicationAgentFactory = new CoordinatingReplicationAgentFactory();
        when(replicationComponentFactory.createComponent(ReplicationAgent.class, config, coordinatingReplicationAgentFactory)).
                thenReturn(replicationAgent);

        Field componentFactory = coordinatingReplicationAgentFactory.getClass().getDeclaredField("componentFactory");
View Full Code Here

TOP

Related Classes of org.apache.sling.replication.agent.ReplicationAgent

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.