@Test public void testPublish() throws PublicationException { EventAdmin eventAdmin = Mockito.mock(EventAdmin.class); Distributor distributor = Mockito.mock(Distributor.class); DistributionResponse response = Mockito.mock(DistributionResponse.class); Mockito.when(response.isSuccessful()).thenReturn(true); Mockito.when(distributor.distribute(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(response); PublicationManager pman = new ContentDistributionPublicationManager(distributor, new String[] { "testagent" }, eventAdmin); pman.publish(context.currentResource().adaptTo(Page.class)); Mockito.verify(eventAdmin).postEvent(Mockito.any()); Mockito.verify(distributor).distribute(Mockito.eq("testagent"), Mockito.any(ResourceResolver.class), Mockito.any()); ValueMap properties = context.currentResource().getChild("jcr:content").getValueMap(); assertEquals(true, properties.get(CMSConstants.PN_PUBLISHED, Boolean.class)); assertEquals("ADD", properties.get(CMSConstants.PN_LAST_PUBLICATION_TYPE, String.class)); }
@Override public void publish(PublishableResource resource) throws PublicationException { log.info("Publishing: {}", resource.getPath()); DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, new String[] { resource.getPath(), resource.getContentResource().getPath() }, Collections.singleton(resource.getContentResource().getPath())); List<DistributionResponse> failedResponses = this .distributeRequest(resource.getResource().getResourceResolver(), request); if (!failedResponses.isEmpty()) { throw new PublicationException("Failed to publish: " + collectFailures(failedResponses)); } else { log.debug("Content Distribution successful, updating publication information"); super.publish(resource); } }
ContentDistributionPublicationManager extends StandalonePublicationManager { @Override public void publish(PublishableResource resource) throws PublicationException { log.info("Publishing: {}", resource.getPath()); DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, new String[] { resource.getPath(), resource.getContentResource().getPath() }, Collections.singleton(resource.getContentResource().getPath())); List<DistributionResponse> failedResponses = this .distributeRequest(resource.getResource().getResourceResolver(), request); if (!failedResponses.isEmpty()) { throw new PublicationException("Failed to publish: " + collectFailures(failedResponses)); } else { log.debug("Content Distribution successful, updating publication information"); super.publish(resource); } } }
ContentDistributionPublicationManager extends StandalonePublicationManager { @Override public void publish(PublishableResource resource) throws PublicationException { log.info("Publishing: {}", resource.getPath()); DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, new String[] { resource.getPath(), resource.getContentResource().getPath() }, Collections.singleton(resource.getContentResource().getPath())); List<DistributionResponse> failedResponses = this .distributeRequest(resource.getResource().getResourceResolver(), request); if (!failedResponses.isEmpty()) { throw new PublicationException("Failed to publish: " + collectFailures(failedResponses)); } else { log.debug("Content Distribution successful, updating publication information"); super.publish(resource); } } ContentDistributionPublicationManager(Distributor distributor, String[] agents, EventAdmin eventAdmin); }
ContentDistributionPublicationManager extends StandalonePublicationManager { @Override public void publish(PublishableResource resource) throws PublicationException { log.info("Publishing: {}", resource.getPath()); DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, new String[] { resource.getPath(), resource.getContentResource().getPath() }, Collections.singleton(resource.getContentResource().getPath())); List<DistributionResponse> failedResponses = this .distributeRequest(resource.getResource().getResourceResolver(), request); if (!failedResponses.isEmpty()) { throw new PublicationException("Failed to publish: " + collectFailures(failedResponses)); } else { log.debug("Content Distribution successful, updating publication information"); super.publish(resource); } } ContentDistributionPublicationManager(Distributor distributor, String[] agents, EventAdmin eventAdmin); @Override void publish(PublishableResource resource); @Override void unpublish(PublishableResource resource); @Override PUBLICATION_MODE getPublicationMode(); }
ContentDistributionPublicationManager extends StandalonePublicationManager { @Override public void publish(PublishableResource resource) throws PublicationException { log.info("Publishing: {}", resource.getPath()); DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, new String[] { resource.getPath(), resource.getContentResource().getPath() }, Collections.singleton(resource.getContentResource().getPath())); List<DistributionResponse> failedResponses = this .distributeRequest(resource.getResource().getResourceResolver(), request); if (!failedResponses.isEmpty()) { throw new PublicationException("Failed to publish: " + collectFailures(failedResponses)); } else { log.debug("Content Distribution successful, updating publication information"); super.publish(resource); } } ContentDistributionPublicationManager(Distributor distributor, String[] agents, EventAdmin eventAdmin); @Override void publish(PublishableResource resource); @Override void unpublish(PublishableResource resource); @Override PUBLICATION_MODE getPublicationMode();  }