Inside a custom developed timer job, we're doing a selective list migration between an internal and external farm based on list item attributes, e.g. only copy to external if "Is Public" is checked. Here's the rough code for how we're handling changes on each list:
SPChangeCollection changes = list.GetChanges(changeToken);
foreach (SPChange change in changes)
{
var itemChange = change as SPChangeItem;
if (change.ChangeType == SPChangeType.Add || change.ChangeType == SPChangeType.Update)
{
//Check "Is Public" field.
//If set, create and add new SPExportObject to settings.ExportObjects
}
else if (change.ChangeType == SPChangeType.Delete)
{
//WHAT DO WE DO HERE?
}
}
The problem we're having is with the handling of deleted items. If we add the deleted item to settings.ExportObjects
and run the export, we get an error:
The object of type ListItem with Id [GUID] that was configured as part of the Export Settings does not exist.
The only method I've found to add a deletion to an export file involves:
- Saving a list of the deleted items as we step through the changes.
- After exporting the changes, open up the CAB file, edit the manifest.xml, and add SPObject elements with the IsDeleted flag set to true for each item we want to remove.
Is there a way to "deploy" a deletion using the Content Deployment API? Is there an overall simpler way for us to attack this entire problem? Should we abandon the deployment API and switch to an alternative method of moving the items between farms?