@Test public void testFileImportAliasOverwite() throws OperationException { DocumentModel file; try (OperationContext ctx = new OperationContext(session)) { ctx.setInput(textBlob); ctx.put("currentDocument", "/"); file = (DocumentModel) service.run(ctx, FileManagerImport.ID); } try (OperationContext ctx = new OperationContext(session)) { ctx.setInput(textBlob); ctx.put("currentDocument", "/"); Map<String, Serializable> params = Map.of("overwite", true); DocumentModel doc = (DocumentModel) service.run(ctx, FileManagerImport.ID, params); assertEquals(file.getId(), doc.getId()); } }
@OperationMethod public DocumentModel run(Blob blob) throws OperationException, IOException { TransactionHelper.commitOrRollbackTransaction(); TransactionHelper.startTransaction(IMPORT_TX_TIMEOUT_SEC); DocumentModel currentDocument = getCurrentDocument(); String path = currentDocument.getPathAsString(); FileImporterContext fileCreationContext = FileImporterContext.builder(session, blob, path) .overwrite(overwrite) .mimeTypeCheck(!noMimeTypeCheck) .build(); DocumentModel doc = fileManager.createOrUpdateDocument(fileCreationContext); TransactionHelper.commitOrRollbackTransaction(); TransactionHelper.startTransaction(); return doc; }
FileManagerImport { @OperationMethod public DocumentModel run(Blob blob) throws OperationException, IOException { TransactionHelper.commitOrRollbackTransaction(); TransactionHelper.startTransaction(IMPORT_TX_TIMEOUT_SEC); DocumentModel currentDocument = getCurrentDocument(); String path = currentDocument.getPathAsString(); FileImporterContext fileCreationContext = FileImporterContext.builder(session, blob, path) .overwrite(overwrite) .mimeTypeCheck(!noMimeTypeCheck) .build(); DocumentModel doc = fileManager.createOrUpdateDocument(fileCreationContext); TransactionHelper.commitOrRollbackTransaction(); TransactionHelper.startTransaction(); return doc; } }
FileManagerImport { @OperationMethod public DocumentModel run(Blob blob) throws OperationException, IOException { TransactionHelper.commitOrRollbackTransaction(); TransactionHelper.startTransaction(IMPORT_TX_TIMEOUT_SEC); DocumentModel currentDocument = getCurrentDocument(); String path = currentDocument.getPathAsString(); FileImporterContext fileCreationContext = FileImporterContext.builder(session, blob, path) .overwrite(overwrite) .mimeTypeCheck(!noMimeTypeCheck) .build(); DocumentModel doc = fileManager.createOrUpdateDocument(fileCreationContext); TransactionHelper.commitOrRollbackTransaction(); TransactionHelper.startTransaction(); return doc; }  }
FileManagerImport { @OperationMethod public DocumentModel run(Blob blob) throws OperationException, IOException { TransactionHelper.commitOrRollbackTransaction(); TransactionHelper.startTransaction(IMPORT_TX_TIMEOUT_SEC); DocumentModel currentDocument = getCurrentDocument(); String path = currentDocument.getPathAsString(); FileImporterContext fileCreationContext = FileImporterContext.builder(session, blob, path) .overwrite(overwrite) .mimeTypeCheck(!noMimeTypeCheck) .build(); DocumentModel doc = fileManager.createOrUpdateDocument(fileCreationContext); TransactionHelper.commitOrRollbackTransaction(); TransactionHelper.startTransaction(); return doc; }  @OperationMethod DocumentModel run(Blob blob); @OperationMethod DocumentModelList run(BlobList blobs); }
FileManagerImport { @OperationMethod public DocumentModel run(Blob blob) throws OperationException, IOException { TransactionHelper.commitOrRollbackTransaction(); TransactionHelper.startTransaction(IMPORT_TX_TIMEOUT_SEC); DocumentModel currentDocument = getCurrentDocument(); String path = currentDocument.getPathAsString(); FileImporterContext fileCreationContext = FileImporterContext.builder(session, blob, path) .overwrite(overwrite) .mimeTypeCheck(!noMimeTypeCheck) .build(); DocumentModel doc = fileManager.createOrUpdateDocument(fileCreationContext); TransactionHelper.commitOrRollbackTransaction(); TransactionHelper.startTransaction(); return doc; }  @OperationMethod DocumentModel run(Blob blob); @OperationMethod DocumentModelList run(BlobList blobs); static final String ID; }