@Test public void testPublishRendition() throws OperationException { try (OperationContext ctx = new OperationContext(session); CapturingEventListener listener = new CapturingEventListener(DocumentEventTypes.DOCUMENT_PUBLISHED)) { ctx.setInput(fileToPublish); Map<String, Object> params = new HashMap<>(); params.put("renditionName", "xmlExport"); params.put("target", section); DocumentModel publishedDoc = (DocumentModel) service.run(ctx, PublishRendition.ID, params); assertEquals(section.getId(), session.getDocument(publishedDoc.getParentRef()).getId()); assertEquals(1, session.getChildren(section.getRef()).size()); assertEquals("xmlExport", publishedDoc.getPropertyValue("rend:renditionName")); List<Event> events = listener.getCapturedEvents(); assertEquals(2, events.size()); assertEquals(fileToPublish, ((DocumentEventContext) events.get(0).getContext()).getSourceDocument()); assertEquals(publishedDoc, ((DocumentEventContext) events.get(1).getContext()).getSourceDocument()); } }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { DocumentModel proxy; if (!defaultRendition && StringUtils.isEmpty(renditionName)) { proxy = session.publishDocument(doc, target, override); } else { RenditionService rs = Framework.getService(RenditionService.class); proxy = rs.publishRendition(doc, target, renditionName, override); } notifyPublishedEvent(doc); notifyPublishedEvent(proxy); return proxy; }
PublishRendition { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { DocumentModel proxy; if (!defaultRendition && StringUtils.isEmpty(renditionName)) { proxy = session.publishDocument(doc, target, override); } else { RenditionService rs = Framework.getService(RenditionService.class); proxy = rs.publishRendition(doc, target, renditionName, override); } notifyPublishedEvent(doc); notifyPublishedEvent(proxy); return proxy; } }
PublishRendition { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { DocumentModel proxy; if (!defaultRendition && StringUtils.isEmpty(renditionName)) { proxy = session.publishDocument(doc, target, override); } else { RenditionService rs = Framework.getService(RenditionService.class); proxy = rs.publishRendition(doc, target, renditionName, override); } notifyPublishedEvent(doc); notifyPublishedEvent(proxy); return proxy; }  }
PublishRendition { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { DocumentModel proxy; if (!defaultRendition && StringUtils.isEmpty(renditionName)) { proxy = session.publishDocument(doc, target, override); } else { RenditionService rs = Framework.getService(RenditionService.class); proxy = rs.publishRendition(doc, target, renditionName, override); } notifyPublishedEvent(doc); notifyPublishedEvent(proxy); return proxy; }  @OperationMethod(collector = DocumentModelCollector.class) DocumentModel run(DocumentModel doc); @OperationMethod DocumentModelList run(DocumentModelList docs); }
PublishRendition { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { DocumentModel proxy; if (!defaultRendition && StringUtils.isEmpty(renditionName)) { proxy = session.publishDocument(doc, target, override); } else { RenditionService rs = Framework.getService(RenditionService.class); proxy = rs.publishRendition(doc, target, renditionName, override); } notifyPublishedEvent(doc); notifyPublishedEvent(proxy); return proxy; }  @OperationMethod(collector = DocumentModelCollector.class) DocumentModel run(DocumentModel doc); @OperationMethod DocumentModelList run(DocumentModelList docs); static final String ID; }