protected DocumentModel doCreateLeafNode(DocumentModel parent, SourceNode node) throws IOException { if (!shouldImportDocument(node)) { return null; } Stopwatch stopwatch = SimonManager.getStopwatch("org.nuxeo.ecm.platform.importer.create_leaf"); Split split = stopwatch.start(); DocumentModel leaf = null; try { leaf = getFactory().createLeafNode(session, parent, node); } catch (IOException e) { String errMsg = "Unable to create leaf document for " + node.getSourcePath() + ":" + e + (e.getCause() != null ? e.getCause() : ""); fslog(errMsg, true); log.error(errMsg); // Process leaf node creation error and check if the global // import task should continue boolean shouldImportTaskContinue = getFactory().processLeafNodeCreationError(session, parent, node); if (!shouldImportTaskContinue) { throw new NuxeoException(e); } } finally { split.stop(); } BlobHolder bh = node.getBlobHolder(); if (leaf != null && bh != null) { Blob blob = bh.getBlob(); if (blob != null) { long fileSize = blob.getLength(); String fileName = blob.getFilename(); if (fileSize > 0) { long kbSize = fileSize / 1024; String parentPath = (parent == null) ? "null" : parent.getPathAsString(); fslog( "Created doc " + leaf.getName() + " at " + parentPath + " with file " + fileName + " of size " + kbSize + "KB", true); } uploadedKO += fileSize; } // save session if needed commit(); } return leaf; }
protected void recursiveCreateDocumentFromNode(DocumentModel parent, SourceNode node) throws IOException { if (getFactory().isTargetDocumentModelFolderish(node)) { DocumentModel folder; Boolean newThread = false; if (skipContainerCreation) { folder = parent; skipContainerCreation = false; newThread = true; } else { folder = doCreateFolderishNode(parent, node); if (folder == null) { return; } } // get a new TaskImporter if available to start // processing the sub-tree GenericThreadedImportTask task = null; if (!newThread) { task = createNewTaskIfNeeded(folder, node); } if (task != null) { // force comit before starting new thread commit(true); try { GenericMultiThreadedImporter.getExecutor().execute(task); } catch (RejectedExecutionException e) { log.error("Import task rejected", e); } } else { Stopwatch stopwatch = SimonManager.getStopwatch("org.nuxeo.ecm.platform.importer.node_get_children"); Split split = stopwatch.start(); List<SourceNode> nodes = node.getChildren(); split.stop(); if (nodes != null) { for (SourceNode child : nodes) { recursiveCreateDocumentFromNode(folder, child); } } } } else { doCreateLeafNode(parent, node); } }
protected DocumentModel doCreateFolderishNode(DocumentModel parent, SourceNode node) { if (!shouldImportDocument(node)) { return null; } Stopwatch stopwatch = SimonManager.getStopwatch("org.nuxeo.ecm.platform.importer.create_folder"); Split split = stopwatch.start(); DocumentModel folder = null; try { folder = getFactory().createFolderishNode(session, parent, node); } catch (IOException e) { String errorMsg = "Unable to create folderish document for " + node.getSourcePath() + ":" + e + (e.getCause() != null ? e.getCause() : ""); fslog(errorMsg, true); log.error(errorMsg); // Process folderish node creation error and check if the global // import task should continue boolean shouldImportTaskContinue = getFactory().processFolderishNodeCreationError(session, parent, node); if (!shouldImportTaskContinue) { throw new NuxeoException(e); } } finally { split.stop(); } if (folder != null) { String parentPath = (parent == null) ? "null" : parent.getPathAsString(); fslog("Created Folder " + folder.getName() + " at " + parentPath, true); // save session if needed commit(); } return folder; }
protected void commit() { commit(false); }