From da418f72954920dadce64887ed1ed2bad90ebf3e Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Fri, 26 May 2017 15:55:40 +0000 Subject: [PATCH] MNT-17703: Allow Bulk Import versioning without appending a version number to docs git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@136971 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../bulkfilesystemimport/ui.get.html.ftl | 11 ++- ...AbstractBulkFileSystemImportWebScript.java | 51 +++++------ .../copy/BulkFilesystemImportWebScript.java | 84 ++++++++++++------- 3 files changed, 92 insertions(+), 54 deletions(-) diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/bulkfilesystemimport/ui.get.html.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/bulkfilesystemimport/ui.get.html.ftl index 2ccfbb1777..a021027aa0 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/bulkfilesystemimport/ui.get.html.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/bulkfilesystemimport/ui.get.html.ftl @@ -95,7 +95,16 @@ (unchecked means rules are enabled during the import) - (unchecked means skip files that already exist in the repository) + + +

+ When a file being imported already exists in the repository
+
+
+
+
+ + Batch Size: diff --git a/source/java/org/alfresco/repo/web/scripts/bulkimport/AbstractBulkFileSystemImportWebScript.java b/source/java/org/alfresco/repo/web/scripts/bulkimport/AbstractBulkFileSystemImportWebScript.java index 592982c728..3e98a9d142 100644 --- a/source/java/org/alfresco/repo/web/scripts/bulkimport/AbstractBulkFileSystemImportWebScript.java +++ b/source/java/org/alfresco/repo/web/scripts/bulkimport/AbstractBulkFileSystemImportWebScript.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Remote API + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.web.scripts.bulkimport; @@ -59,6 +59,7 @@ public class AbstractBulkFileSystemImportWebScript extends DeclarativeWebScript // Web scripts parameters (common) protected static final String PARAMETER_REPLACE_EXISTING = "replaceExisting"; + protected static final String PARAMETER_EXISTING_FILE_MODE = "existingFileMode"; protected static final String PARAMETER_VALUE_REPLACE_EXISTING = "replaceExisting"; protected static final String PARAMETER_SOURCE_DIRECTORY = "sourceDirectory"; protected static final String PARAMETER_DISABLE_RULES = "disableRules"; diff --git a/source/java/org/alfresco/repo/web/scripts/bulkimport/copy/BulkFilesystemImportWebScript.java b/source/java/org/alfresco/repo/web/scripts/bulkimport/copy/BulkFilesystemImportWebScript.java index b20794bf81..ef7461193d 100644 --- a/source/java/org/alfresco/repo/web/scripts/bulkimport/copy/BulkFilesystemImportWebScript.java +++ b/source/java/org/alfresco/repo/web/scripts/bulkimport/copy/BulkFilesystemImportWebScript.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Remote API - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Remote API + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.web.scripts.bulkimport.copy; @@ -73,7 +73,8 @@ public class BulkFilesystemImportWebScript extends AbstractBulkFileSystemImportW String targetNodeRefStr = null; String targetPath = null; String sourceDirectoryStr = null; - String replaceExistingStr = null; + @Deprecated String replaceExistingStr = null; + String existingFileModeStr = null; String batchSizeStr = null; String numThreadsStr = null; String disableRulesStr = null; @@ -87,6 +88,7 @@ public class BulkFilesystemImportWebScript extends AbstractBulkFileSystemImportW NodeRef targetNodeRef = null; File sourceDirectory = null; boolean replaceExisting = false; + BulkImportParameters.ExistingFileMode existingFileMode = null; int batchSize = bulkImporter.getDefaultBatchSize(); int numThreads = bulkImporter.getDefaultNumThreads(); boolean disableRules = false; @@ -96,6 +98,8 @@ public class BulkFilesystemImportWebScript extends AbstractBulkFileSystemImportW targetPath = request.getParameter(PARAMETER_TARGET_PATH); sourceDirectoryStr = request.getParameter(PARAMETER_SOURCE_DIRECTORY); replaceExistingStr = request.getParameter(PARAMETER_REPLACE_EXISTING); + existingFileModeStr = request.getParameter(PARAMETER_EXISTING_FILE_MODE); + batchSizeStr = request.getParameter(PARAMETER_BATCH_SIZE); numThreadsStr = request.getParameter(PARAMETER_NUM_THREADS); disableRulesStr = request.getParameter(PARAMETER_DISABLE_RULES); @@ -108,12 +112,27 @@ public class BulkFilesystemImportWebScript extends AbstractBulkFileSystemImportW } sourceDirectory = new File(sourceDirectoryStr.trim()); - + + if (replaceExistingStr != null && existingFileModeStr != null) + { + // Check that we haven't had both the deprecated and new (existingFileMode) + // parameters supplied. + throw new IllegalStateException( + String.format("Only one of these parameters may be used, not both: %s, %s", + PARAMETER_REPLACE_EXISTING, + PARAMETER_EXISTING_FILE_MODE)); + } + if (replaceExistingStr != null && replaceExistingStr.trim().length() > 0) { replaceExisting = PARAMETER_VALUE_REPLACE_EXISTING.equals(replaceExistingStr); } + if (existingFileModeStr != null && existingFileModeStr.trim().length() > 0) + { + existingFileMode = BulkImportParameters.ExistingFileMode.valueOf(existingFileModeStr); + } + if (disableRulesStr != null && disableRulesStr.trim().length() > 0) { disableRules = PARAMETER_VALUE_DISABLE_RULES.equals(disableRulesStr); @@ -157,7 +176,16 @@ public class BulkFilesystemImportWebScript extends AbstractBulkFileSystemImportW } } - bulkImportParameters.setReplaceExisting(replaceExisting); + if (existingFileMode != null) + { + bulkImportParameters.setExistingFileMode(existingFileMode); + } + else + { + // Fall back to the old/deprecated way. + bulkImportParameters.setReplaceExisting(replaceExisting); + } + bulkImportParameters.setTarget(targetNodeRef); bulkImportParameters.setDisableRulesService(disableRules);