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
This commit is contained in:
Matt Ward
2017-05-26 15:55:40 +00:00
parent b2d5de0078
commit da418f7295
3 changed files with 92 additions and 54 deletions

View File

@@ -95,7 +95,16 @@
<td><label for="disableRules">Disable rules:</label></td><td><input type="checkbox" id="disableRules" name="disableRules" value="disableRules" unchecked/> (unchecked means rules are enabled during the import)</td><td></td> <td><label for="disableRules">Disable rules:</label></td><td><input type="checkbox" id="disableRules" name="disableRules" value="disableRules" unchecked/> (unchecked means rules are enabled during the import)</td><td></td>
</tr> </tr>
<tr> <tr>
<td><label for="replaceExisting">Replace existing files:</label></td><td><input type="checkbox" id="replaceExisting" name="replaceExisting" value="replaceExisting" unchecked/> (unchecked means skip files that already exist in the repository)</td><td></td> <td><label>Existing file mode:</label></td>
<td>
<br /><br />
When a file being imported already exists in the repository<br />
<label><input type="radio" name="existingFileMode" value="SKIP" checked/> skip (don't import) the file</label><br />
<label><input type="radio" name="existingFileMode" value="REPLACE" unchecked/> replace the file in the repository with the imported file</label><br />
<label><input type="radio" name="existingFileMode" value="ADD_VERSION" unchecked/> create a new version of the file with the imported content</label><br />
<br />
</td>
<td></td>
</tr> </tr>
<tr> <tr>
<td>Batch Size:</td> <td>Batch Size:</td>

View File

@@ -59,6 +59,7 @@ public class AbstractBulkFileSystemImportWebScript extends DeclarativeWebScript
// Web scripts parameters (common) // Web scripts parameters (common)
protected static final String PARAMETER_REPLACE_EXISTING = "replaceExisting"; 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_VALUE_REPLACE_EXISTING = "replaceExisting";
protected static final String PARAMETER_SOURCE_DIRECTORY = "sourceDirectory"; protected static final String PARAMETER_SOURCE_DIRECTORY = "sourceDirectory";
protected static final String PARAMETER_DISABLE_RULES = "disableRules"; protected static final String PARAMETER_DISABLE_RULES = "disableRules";

View File

@@ -73,7 +73,8 @@ public class BulkFilesystemImportWebScript extends AbstractBulkFileSystemImportW
String targetNodeRefStr = null; String targetNodeRefStr = null;
String targetPath = null; String targetPath = null;
String sourceDirectoryStr = null; String sourceDirectoryStr = null;
String replaceExistingStr = null; @Deprecated String replaceExistingStr = null;
String existingFileModeStr = null;
String batchSizeStr = null; String batchSizeStr = null;
String numThreadsStr = null; String numThreadsStr = null;
String disableRulesStr = null; String disableRulesStr = null;
@@ -87,6 +88,7 @@ public class BulkFilesystemImportWebScript extends AbstractBulkFileSystemImportW
NodeRef targetNodeRef = null; NodeRef targetNodeRef = null;
File sourceDirectory = null; File sourceDirectory = null;
boolean replaceExisting = false; boolean replaceExisting = false;
BulkImportParameters.ExistingFileMode existingFileMode = null;
int batchSize = bulkImporter.getDefaultBatchSize(); int batchSize = bulkImporter.getDefaultBatchSize();
int numThreads = bulkImporter.getDefaultNumThreads(); int numThreads = bulkImporter.getDefaultNumThreads();
boolean disableRules = false; boolean disableRules = false;
@@ -96,6 +98,8 @@ public class BulkFilesystemImportWebScript extends AbstractBulkFileSystemImportW
targetPath = request.getParameter(PARAMETER_TARGET_PATH); targetPath = request.getParameter(PARAMETER_TARGET_PATH);
sourceDirectoryStr = request.getParameter(PARAMETER_SOURCE_DIRECTORY); sourceDirectoryStr = request.getParameter(PARAMETER_SOURCE_DIRECTORY);
replaceExistingStr = request.getParameter(PARAMETER_REPLACE_EXISTING); replaceExistingStr = request.getParameter(PARAMETER_REPLACE_EXISTING);
existingFileModeStr = request.getParameter(PARAMETER_EXISTING_FILE_MODE);
batchSizeStr = request.getParameter(PARAMETER_BATCH_SIZE); batchSizeStr = request.getParameter(PARAMETER_BATCH_SIZE);
numThreadsStr = request.getParameter(PARAMETER_NUM_THREADS); numThreadsStr = request.getParameter(PARAMETER_NUM_THREADS);
disableRulesStr = request.getParameter(PARAMETER_DISABLE_RULES); disableRulesStr = request.getParameter(PARAMETER_DISABLE_RULES);
@@ -109,11 +113,26 @@ public class BulkFilesystemImportWebScript extends AbstractBulkFileSystemImportW
sourceDirectory = new File(sourceDirectoryStr.trim()); 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) if (replaceExistingStr != null && replaceExistingStr.trim().length() > 0)
{ {
replaceExisting = PARAMETER_VALUE_REPLACE_EXISTING.equals(replaceExistingStr); 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) if (disableRulesStr != null && disableRulesStr.trim().length() > 0)
{ {
disableRules = PARAMETER_VALUE_DISABLE_RULES.equals(disableRulesStr); disableRules = PARAMETER_VALUE_DISABLE_RULES.equals(disableRulesStr);
@@ -157,7 +176,16 @@ public class BulkFilesystemImportWebScript extends AbstractBulkFileSystemImportW
} }
} }
if (existingFileMode != null)
{
bulkImportParameters.setExistingFileMode(existingFileMode);
}
else
{
// Fall back to the old/deprecated way.
bulkImportParameters.setReplaceExisting(replaceExisting); bulkImportParameters.setReplaceExisting(replaceExisting);
}
bulkImportParameters.setTarget(targetNodeRef); bulkImportParameters.setTarget(targetNodeRef);
bulkImportParameters.setDisableRulesService(disableRules); bulkImportParameters.setDisableRulesService(disableRules);