Hello,
I am coding using AGASP SDK to perform synced-copy in a SharePoint workflow action.
The archiving is well done (by calling the method "CreateDocument"), the document is copied in the folder specified (with variable "targetPath").
If I call my method "SynchronizeDocument", changes on document are sent to the Content-Server in a correct way.
But if I go on the SharePoint interface of the document library, and go to the item menu / Syced copy / view status, I got the following error message:
Exception of type 'Opentext.SharePoint.Livelink.Pages.MissingSyncFileException' was thrown.
- The synchronized item'"/sites/PocDevTest/mydocs/azrsdfgfdg.txt" (48e32275-14eb-4de8-93f2-f78538824828)' cannot be found in Enterprise Library.
The interface try to find the archived (synced copy) document like if the archiving path was the like the URL of the document library, but the archiving path was totally different (like "testA/testB"). As the update of document work correctly (using correct path), I'm suprised that the user interface function looks for the in wrong location.
To make a sync copy, I use following code (based on code provided in documentation):
/// <summary>
/// make the first archiving
/// </summary>
/// <param name="targetPath">path to livelink folder, with "/" as folder separator</param>
/// <param name="localPath">Path to document on local filesystem </param>
/// <returns></returns>
public static LivelinkDocument CreateDocument(String targetPath, SPFile spFile)
{
//var fileInfo = CopyFileToTempLocalFolder(
spFile);
var webConfProvider = ConfigurationProviders.getWebConfigurationProvider(spFile.Web);
//Initialize la factory
ProviderFactory.Initialize(webConfProvider.ProviderConfig);
using (LivelinkConnection connection = Connections.Connect(webConfProvider))
{
try
{
LivelinkEnterpriseWorkspace workspace = connection.LivelinkService.GetLivelinkEnterpriseWorkspace();
//get the required Livelink folder reference
LivelinkDocumentContainer targetFolder = GetSubFolderNode(workspace, targetPath);
//Create the document in LiveLink
IDocumentCreator documentCreator = DocumentCreatorFactory.Create("DocumentCreator",
webConfProvider, connection);
LivelinkDocument archivedDocument = documentCreator.CreateDocument(spFile,
targetFolder, spFile.Name, spFile.CheckInComment);
//Archive all version of document in LiveLink
IVersionProvider versionProvider = AllVersionsProviderFactory.Create("AllVersionsProvider");
IMappedVersionCreator mappedVersionCreator = MappedVersionCreatorFactory.Create("MappedVersionCreator", webConfProvider);
IList<MappedVersionValue> mappedVersions = mappedVersionCreator.CreateVersions(versionProvider, spFile, archivedDocument);
//create the synced copy item, all new versions will be synced
IIncrementalVersionProvider incrementalVersionProvider = AllNewVersionsProviderFactory.Create("AllNewVersionsProvider");
MappedVersionsInfo mappedVersionsInfo = new MappedVersionsInfo(mappedVersions, incrementalVersionProvider);
SyncedCopyItemsParameters parameters = new SyncedCopyItemsParameters(mappedVersionsInfo, true, true);
ISyncedCopyItemsManager itemsManager = SyncedCopyItemsManagerFactory.Create("SyncedCopyItemsManager", webConfProvider);
Relationship relationship = itemsManager.MakeSyncedItems(spFile, archivedDocument, parameters);
return (archivedDocument);
}
finally
{
Connections.Disconnect(connection);
}
}
}
public static void SynchronizeDocument(SPFile spFile)
{
LivelinkConfigurationProvider webConfProvider = ConfigurationProviders.getWebConfigurationProvider(spFile.Web);
//Initialize la factory
ProviderFactory.Initialize(webConfProvider.ProviderConfig);
//Create rollbackExecutor used to rollback action if error occurs
using (IRollbackExecutor rollbackExecutor = RollbackExecutorFactory.Create("RollbackExecutor"))
{
try
{
//Create SyncedCopyOrderProcessor used to make the synchronization
using (ISyncedCopyOrderProcessor orderProcessor = SyncedCopyOrderProcessorFactory.Create("SyncedCopyOrder",
webConfProvider))
{
//Create SyncedCopyOrderList wich represent the list of item that are synchronizable
using (SyncedCopyOrderList orderList = (SyncedCopyOrderList)SyncedCopyOrderListFactory.Create("SyncedCopyOrderList",
spFile.Web, webConfProvider))
{
//get a reference on the sharePoint Item we want to update
ListItemReference itemRef = ListItemReference.Create(spFile.Item);
//get the SyncedcopyOrder require to process to synchronization
SyncedCopyOrder order = (SyncedCopyOrder)orderList[itemRef];
//Do the synchronization
orderProcessor.ProcessOrder(spFile.Web, orderList, order);
}
}
rollbackExecutor.ClearRollbacks();
}
catch (Exception)
{
rollbackExecutor.ExecuteRollbacks();
}
}
}
private static LivelinkDocumentContainer GetSubFolderNode(LivelinkEnterpriseWorkspace workspace, String targetPath)
{
LivelinkDocumentContainer currentFolder = (LivelinkDocumentContainer)workspace;
if (!String.IsNullOrEmpty(targetPath))
{
String[] folders = targetPath.Split('/');
foreach (String folder in folders)
{
currentFolder = currentFolder.GetChild(folder) as LivelinkDocumentContainer;
}
}
return currentFolder;
}
Did I miss anything?
Julien Dufour