Skip to content

Commit

Permalink
implementation, docu
Browse files Browse the repository at this point in the history
Issue #135
  • Loading branch information
rsoika committed Dec 5, 2020
1 parent 11f445d commit ce201f4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
15 changes: 15 additions & 0 deletions imixs-archive-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

'<FILE_NAME>.pdf' => '<FILE_NAME>-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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -523,6 +524,8 @@ private void copyFilesFromItemCollection(ItemCollection source, ItemCollection t
boolean debug = logger.isLoggable(Level.FINE);

List<FileData> files = target.getFileData();

List<String> overwriteFileList=origin.getItemValueList(ITEM_SNAPSHOT_OVERWRITEFILECONTENT, String.class);

for (FileData fileData : files) {
String fileName = fileData.getName();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -610,6 +616,9 @@ private void copyFilesFromItemCollection(ItemCollection source, ItemCollection t
}
}
}

// clean "$snapshot.overwriteFileContent"
origin.replaceItemValue(ITEM_SNAPSHOT_OVERWRITEFILECONTENT, "");

}

Expand Down

0 comments on commit ce201f4

Please sign in to comment.