@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentRef doc) { return session.getChild(doc, name); }
@Override public void validateImportedSnapshot(CoreSession session, String name, String version, String pathSegment, String title) { DocumentModel container = persister.getDistributionRoot(session); DocumentRef tmpRef = new PathRef(container.getPathAsString(), IMPORT_TMP); DocumentModel tmp; if (session.exists(tmpRef)) { tmp = session.getChild(container.getRef(), IMPORT_TMP); DocumentModel snapDoc = session.getChildren(tmp.getRef()).get(0); snapDoc.setPropertyValue("nxdistribution:name", name); snapDoc.setPropertyValue("nxdistribution:version", version); snapDoc.setPropertyValue("nxdistribution:key", name + "-" + version); snapDoc.setPropertyValue("dc:title", title); snapDoc = session.saveDocument(snapDoc); DocumentModel targetContainer = session.getParentDocument(tmp.getRef()); session.move(snapDoc.getRef(), targetContainer.getRef(), pathSegment); session.removeDocument(tmp.getRef()); } }
@Override public DocumentModel importTmpSnapshot(CoreSession session, InputStream is) throws IOException { DocumentModel container = persister.getDistributionRoot(session); DocumentRef tmpRef = new PathRef(container.getPathAsString(), IMPORT_TMP); DocumentModel tmp; if (session.exists(tmpRef)) { tmp = session.getChild(container.getRef(), IMPORT_TMP); session.removeChildren(tmp.getRef()); } else { tmp = session.createDocumentModel(container.getPathAsString(), IMPORT_TMP, "Workspace"); tmp.setPropertyValue("dc:title", "tmpImport"); tmp = session.createDocument(tmp); session.save(); } DocumentReader reader = new NuxeoArchiveReader(is); DocumentWriter writer = new SnapshotWriter(session, tmp.getPathAsString()); DocumentPipe pipe = new DocumentPipeImpl(10); pipe.setReader(reader); pipe.setWriter(writer); pipe.run(); reader.close(); writer.close(); return session.getChildren(tmp.getRef()).get(0); }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { return session.getChild(doc.getRef(), name); }
String name = Framework.getService(PathSegmentService.class).generatePathSegment(title); documentManager.copy(new IdRef(selectedTemplateId), currentDocRef, name); DocumentModel created = documentManager.getChild(currentDocRef, name);