From ce201f4ac0527cdb473d4975b52254e0c8c50c97 Mon Sep 17 00:00:00 2001 From: Ralph Soika Date: Sat, 5 Dec 2020 12:06:53 +0100 Subject: [PATCH] implementation, docu Issue #135 --- imixs-archive-api/README.md | 15 +++++++++++++++ .../imixs/archive/core/SnapshotService.java | 19 ++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/imixs-archive-api/README.md b/imixs-archive-api/README.md index dcb75f8c..73af9ad8 100644 --- a/imixs-archive-api/README.md +++ b/imixs-archive-api/README.md @@ -101,6 +101,21 @@ The synchronization between a Imixs-Archive Service and a Imixs-Workflow Instanc The Imixs-Archive Service polls the snapshot EventLog entries on a scheduled basis and pulls the snappshot data. +## Overwrite File File Data + +The environment variable SNAPSHOT_OVERWRITEFILECONTENT can be used to protect existing file data to be overwritten. If the environment variable is set to 'false', than in case a file with the same name already exits, will be 'archived' with a time-stamp-sufix: + + '.pdf' => '-1514410113556.pdf' + +This protects already archived file data and allows the 'versioning' of file content. + +If the environment variable SNAPSHOT_OVERWRITEFILECONTENT is not set then it default to 'false' which means existing file data is protected. + +### Temporary overwriting of File Data + +During the processing life cycle this mechanism can be overwritten by providing the temporarily item '$snapshot.overwriteFileContent' with a list of filenames to be overwritten even if the environment variable is set to false. The item will automatically be cleared during the processing life cycle. + + # How to Calculate the Size of a Imixs-Archive System? To calculate the size of an Imixs-Archive system, the following factors are crucial: diff --git a/imixs-archive-api/src/main/java/org/imixs/archive/core/SnapshotService.java b/imixs-archive-api/src/main/java/org/imixs/archive/core/SnapshotService.java index 96c3f698..f3af2794 100644 --- a/imixs-archive-api/src/main/java/org/imixs/archive/core/SnapshotService.java +++ b/imixs-archive-api/src/main/java/org/imixs/archive/core/SnapshotService.java @@ -129,6 +129,7 @@ public class SnapshotService { public final static String ITEM_FILEDATA_FILE_NAMES = "$file.names"; // list of files public final static String ITEM_FILEDATA_FILE_COUNT = "$file.count"; // count of files + public final static String ITEM_SNAPSHOT_OVERWRITEFILECONTENT = "$snapshot.overwriteFileContent"; // force overwriting file content public static final String PROPERTY_SNAPSHOT_WORKITEMLOB_SUPPORT = "snapshot.workitemlob_suport"; public static final String PROPERTY_SNAPSHOT_HISTORY = "snapshot.history"; @@ -319,11 +320,11 @@ public void onSave(@Observes DocumentEvent documentEvent) { } // 5.a. update fileData Meta information... - documentEvent.getDocument().replaceItemValue(ITEM_FILEDATA_FILE_COUNT, - documentEvent.getDocument().getFileNames().size()); - documentEvent.getDocument().replaceItemValue(ITEM_FILEDATA_FILE_NAMES, - documentEvent.getDocument().getFileNames()); // TODO : $file.count and $file.names is computed by ItemCollection and can be removed from here. +// documentEvent.getDocument().replaceItemValue(ITEM_FILEDATA_FILE_COUNT, +// documentEvent.getDocument().getFileNames().size()); +// documentEvent.getDocument().replaceItemValue(ITEM_FILEDATA_FILE_NAMES, +// documentEvent.getDocument().getFileNames()); // 6. store the snapshot uniqeId into the origin-workitem ($snapshotID) documentEvent.getDocument().replaceItemValue(SNAPSHOTID, snapshot.getUniqueID()); @@ -523,6 +524,8 @@ private void copyFilesFromItemCollection(ItemCollection source, ItemCollection t boolean debug = logger.isLoggable(Level.FINE); List files = target.getFileData(); + + List overwriteFileList=origin.getItemValueList(ITEM_SNAPSHOT_OVERWRITEFILECONTENT, String.class); for (FileData fileData : files) { String fileName = fileData.getName(); @@ -558,7 +561,10 @@ private void copyFilesFromItemCollection(ItemCollection source, ItemCollection t // in case 'overwriteFileContent' is set to 'false' we protect existing content // of // files with the same name, but extend the name of the old file with a suffix - if (!overwriteFileContent) { + // This feature can be skiped if $snapshot.overwriteFileContent contans the filename + + + if (!overwriteFileContent && !(overwriteFileList.contains(fileName))) { FileData oldFileData = source.getFileData(fileName); if (oldFileData != null) { // we need to suffix the last file with the same name here to protect the @@ -610,6 +616,9 @@ private void copyFilesFromItemCollection(ItemCollection source, ItemCollection t } } } + + // clean "$snapshot.overwriteFileContent" + origin.replaceItemValue(ITEM_SNAPSHOT_OVERWRITEFILECONTENT, ""); }