I am running into an issue trying to remove a file from a deployment. In my Preprocessor (there is only one) I am attempting the following:
WFMFile [] originalFileList = workflow.getFiles();
workflow.removeFiles(originalFileList);
for (WFMFile file : originalFiles) {
workflow.addFiles(getDependentFiles(file);
}
The issue is that when I run the run the remove files to clear the list, they aren't actually removed. When I add that original file back to the list I get a Modeler Exception that the file already exists -- shouldn't it be out of the list at this point? (If I remove the add of the original DCR and I log the list, I still only see the original file, so for now I have taken this line of code out).
Let's say one file is submitted, and it has 3 files which it depends upon. I wish for the list of files to look like this:
files[0] = dependentFileA; //JPG file
files[1] = dependentFileB; //Dependent DCR (inside DCR as a relative link)
files[2] = dependentFileC; //JPG file
files[3] = submittedFile; //Original DCR
Updated:
If I log the file list before adding the files I see only one file, after adding the files I also only see one file; however when I move to the next task and log the files I do in fact see all of the attached files, but the ordering is just slightly off.
In the above example let's assume that dependentFileB is a DCR, and I want to resubmit this DCR to ensure that the newest version is published prior to the new/updated content being published. Well the file list comes out as:
files[0] = dependentFileA;//JPG file
files[1] = dependentFileC;//JPG file
files[2] = submittedFile;//Originally submitted DCR
files[3] = dependentFileB;//Dependent DCR
So the non DCR files are in fact moving to the front of the list, but the dependent DCRs are bubbling all the way down to the bottom. In order to maintain data integrity, the dependent DCR needs to be published prior to the submitted file.