Package org.apache.sling.replication.packaging

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


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

        ReplicationPackageExporter replicationPackageExporter = request
                .getResource()
                .adaptTo(ReplicationPackageExporter.class);

        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 {
            // get all items
            List<ReplicationPackage> replicationPackages = replicationPackageExporter.exportPackages(resourceResolver, replicationRequest);
            fetched = replicationPackages.size();

            if (replicationPackages.size() > 0) {
                log.info("{} package(s) available for fetching", replicationPackages.size());
View Full Code Here


        String factory = PropertiesUtil.toString(properties.get(COMPONENT_TYPE), ReplicationComponentFactory.AGENT_SIMPLE);

        if (ReplicationComponentFactory.AGENT_SIMPLE.equals(factory)) {

            Map<String, Object> exporterProperties = extractMap(COMPONENT_PACKAGE_EXPORTER, properties);
            ReplicationPackageExporter packageExporter = createExporter(exporterProperties, componentProvider);

            Map<String, Object> importerProperties = extractMap(COMPONENT_PACKAGE_IMPORTER, properties);
            ReplicationPackageImporter packageImporter = createImporter(importerProperties, componentProvider);

            Map<String, Object> authorizationStrategyProperties = extractMap(COMPONENT_REQUEST_AUTHORIZATION_STRATEGY, properties);
View Full Code Here

        DefaultReplicationComponentFactory defaultReplicationComponentFactory = new DefaultReplicationComponentFactory();
        String name = "sample-exporter";
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("name", name);
        ReplicationComponentProvider provider = mock(ReplicationComponentProvider.class);
        ReplicationPackageExporter exporter = mock(ReplicationPackageExporter.class);
        when(provider.getComponent(ReplicationPackageExporter.class, name)).thenReturn(exporter);
        ReplicationPackageExporter component = defaultReplicationComponentFactory.createComponent(ReplicationPackageExporter.class, properties, provider);
        assertNotNull(component);
    }
View Full Code Here

    @Test
    public void testReplicationWithFailingDistributionStrategy() throws Exception {
        String name = "sample-agent";
        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
        ReplicationRequestAuthorizationStrategy packageExporterStrategy = mock(ReplicationRequestAuthorizationStrategy.class);
        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
        when(distributionHandler.add(any(String.class), any(ReplicationPackage.class), any(ReplicationQueueProvider.class))).thenReturn(false);
        ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
        ResourceResolverFactory resolverFactory = mock(ResourceResolverFactory.class);

        SimpleReplicationAgent agent = new SimpleReplicationAgent(name,
                false, "serviceName", packageImporter,
                packageExporter, packageExporterStrategy,
                queueProvider, distributionHandler,
                replicationEventFactory, resolverFactory,  null);
        ReplicationRequest request = new ReplicationRequest(System.nanoTime(),
                ReplicationActionType.ADD, "/");
        ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
        ResourceResolver resourceResolver = mock(ResourceResolver.class);

        when(replicationPackage.getPaths()).thenReturn(new String[]{"/"});
        when(packageExporter.exportPackages(any(ResourceResolver.class), any(ReplicationRequest.class)))
                .thenReturn(Arrays.asList(replicationPackage));
        when(queueProvider.getDefaultQueue(name)).thenReturn(
                new SimpleReplicationQueue(name, "name"));
        ReplicationResponse response = agent.execute(resourceResolver, request);
        assertNotNull(response);
View Full Code Here

    @Test
    public void testReplicationWithWorkingDistributionStrategy() throws Exception {
        String name = "sample-agent";
        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
        ReplicationRequestAuthorizationStrategy packageExporterStrategy = mock(ReplicationRequestAuthorizationStrategy.class);
        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
        ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
        ResourceResolverFactory resolverFactory = mock(ResourceResolverFactory.class);
        SimpleReplicationAgent agent = new SimpleReplicationAgent(name,
                false, "subServiceName", packageImporter,
                packageExporter, packageExporterStrategy,
                queueProvider,
                distributionHandler, replicationEventFactory, resolverFactory, null);
        ReplicationRequest request = new ReplicationRequest(System.nanoTime(),
                ReplicationActionType.ADD, "/");
        ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
        ResourceResolver resourceResolver = mock(ResourceResolver.class);

        when(replicationPackage.getPaths()).thenReturn(new String[]{"/"});
        when(distributionHandler.add(any(String.class), any(ReplicationPackage.class), eq(queueProvider))).thenReturn(true);
        when(packageExporter.exportPackages(any(ResourceResolver.class), any(ReplicationRequest.class)))
                .thenReturn(Arrays.asList(replicationPackage));
        when(queueProvider.getDefaultQueue(name)).thenReturn(
                new SimpleReplicationQueue(name, "name"));
        ReplicationResponse response = agent.execute(resourceResolver, request);
        assertNotNull(response);
View Full Code Here

    @Test
    public void testReplication() throws Exception {
        String name = "sample-agent";
        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
        ReplicationRequestAuthorizationStrategy packageExporterStrategy = mock(ReplicationRequestAuthorizationStrategy.class);
        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
        ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
        ResourceResolverFactory resolverFactory = mock(ResourceResolverFactory.class);

        SimpleReplicationAgent agent = new SimpleReplicationAgent(name,
                false, "serviceName", packageImporter,
                packageExporter, packageExporterStrategy,
                queueProvider, distributionHandler,
                replicationEventFactory, resolverFactory, null);
        ReplicationRequest request = new ReplicationRequest(System.nanoTime(),
                ReplicationActionType.ADD, "/");
        ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
        ResourceResolver resourceResolver = mock(ResourceResolver.class);

        when(replicationPackage.getPaths()).thenReturn(new String[]{"/"});
        when(packageExporter.exportPackages(resourceResolver, request)).thenReturn(Arrays.asList(replicationPackage));
        when(queueProvider.getDefaultQueue(name)).thenReturn(
                new SimpleReplicationQueue(name, "name"));

        agent.execute(resourceResolver, request);
    }
View Full Code Here

    @Test
    public void testGetDefaultQueue() throws Exception {
        String name = "sample-agent";
        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
        ReplicationRequestAuthorizationStrategy packageExporterStrategy = mock(ReplicationRequestAuthorizationStrategy.class);

        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
        ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
View Full Code Here

    @Test
    public void testGetExistingNamedQueue() throws Exception {
        String name = "sample-agent";
        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
        ReplicationRequestAuthorizationStrategy packageExporterStrategy = mock(ReplicationRequestAuthorizationStrategy.class);

        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
        ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
View Full Code Here

    @Test
    public void testGetNonExistingNamedQueue() throws Exception {
        String name = "sample-agent";
        ReplicationPackageImporter packageImporter = mock(ReplicationPackageImporter.class);
        ReplicationPackageExporter packageExporter = mock(ReplicationPackageExporter.class);
        ReplicationRequestAuthorizationStrategy packageExporterStrategy = mock(ReplicationRequestAuthorizationStrategy.class);

        ReplicationQueueProvider queueProvider = mock(ReplicationQueueProvider.class);
        ReplicationQueueDistributionStrategy distributionHandler = mock(ReplicationQueueDistributionStrategy.class);
        ReplicationEventFactory replicationEventFactory = mock(ReplicationEventFactory.class);
View Full Code Here

TOP

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

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.