aegif / CmisSync

Synchronize content between a CMIS repository and your desktop. Like Dropbox for Enterprise Content Management!
http://CmisSync.com
164 stars 123 forks source link

Test CmisSync in multi-parents repository #533

Open nicolas-raoul opened 9 years ago

nicolas-raoul commented 9 years ago

From the forum:

Alfresco is able to handle multiple parents: http://blogs.alfresco.com/wp/rfernandes/2013/09/25/alfresco-parents-and-children/ section "Multiple Parents". It is currently not available to end users on the web frontend by default. But this feature is used by Alfresco's Add-on Records Management. And IIRC there is also an extension that offers that feature on the web frontend even without Records Management.

bas commented 9 years ago

This is currently listed as an enhancement, but it might also be a bug.

When I browse a folder in CMIS Workbench with documents including some that have the folder as a secondary parent, I can see all files including the once that have a secondary parent. screen shot 2015-04-22 at 06 44 30

When I sync a folder using CmisSync the documents that have the folder as a secondary parent are not synced. screen shot 2015-04-22 at 06 44 12

To reproduce you can either use the Link to action in Alfresco RM or execute a document.addNode(childNode);

I ran a code example using DotCMIS.dll (assuming it is used as CMIS library) and that returns the secondary parent nodes (being the doc and docx documents):

Listing records for customer John Smith...
Invoice 01 (2015-1429645065088).pdf
Invoice 02 (2015-1429645065662).pdf
Invoice 03 (2015-1429645065931).pdf
Invoice - Alf e183k (2015-1426890305211).doc
Background Check Policy (2015-1427796103168).docx

Code snippet:

   private void getCustomerRecords(ISession session) {
        System.Console.WriteLine("Listing records for customer John Smith...");
        IFolder filePlan = (IFolder)session.GetObjectByPath("/Sites/rm/documentLibrary/Customers/John Smith");
        foreach (ICmisObject cmisObject in filePlan.GetChildren())
        {
            System.Console.WriteLine(cmisObject.Name);
        }
        System.Console.WriteLine();
    }

Also updating a document retrieved from the secondary parent location works using DotCMIS.

nicolas-raoul commented 9 years ago

Thanks a lot for the investigation!

Here are the commands that CmisSync uses:

It looks exactly like your code, right? So I wonder what is the difference... Actually CmisSync uses this slightly modified version of DotCMIS: https://github.com/aegif/chemistry-dotcmis Might it be the reason? Sorry for the trouble but would you mind replacing the DotCMIS with this one and let us know whether it is different? Thank you very much!

nicolas-raoul commented 9 years ago

Sorry for the newbie question, but are there cases where a folder is filed in one of its children? Such a case might cause an infinite loop in CmisSync.

bas commented 9 years ago

I tested the same code but now with the DotCMIS.dll used by CmisSync and it also lists the documents with secondary parents and updates a document properly.

The error in CmisSync cient is recorded in the log as follows:

2015-04-23 00:46:53,049 [8] INFO CmisSync.Lib.Sync.CmisRepo+SynchronizedFolder [(null)] - Downloading: InvoiceAdmin.doc
2015-04-23 00:46:53,096 [8] ERROR CmisSync.Lib.Sync.CmisRepo+SynchronizedFolder [(null)] - Could not download file: \Sites\test\documentLibrary\Documents\InvoiceAdmin.doc
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Sites\test\documentLibrary\Documents\InvoiceAdmin.doc.sync'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.IO.File.OpenWrite(String path)
at CmisSync.Lib.Sync.CmisRepo.SynchronizedFolder.DownloadStream(IContentStream contentStream, String filePath)
at CmisSync.Lib.Sync.CmisRepo.SynchronizedFolder.DownloadFile(IDocument remoteDocument, String localFolder)

Looks like it tries to sync using its primary path rather than the secondary path. The primary path is Documents and the secondary path is admin in my test cases. So it might be related to how metadata is stored in the local database?

nicolas-raoul commented 9 years ago

@bpeters09 Could you please let me know what Alfresco add-on or setting you use to create secondary paths? I am beginning to investigate the matter and I trying to figure out what is the easiest way to create such nodes now that Alfresco Explorer is gone :-) Thanks a lot for your help!

cdwi commented 9 years ago

@nicolas-raoul I usually use the JavaScript Console (js-console) to enter the JS code - see code behind the link in the first posting in this thread. But you should also be able to write the JS code, upload it to the data dictionary and execute it there (but not that handy...).

bas commented 9 years ago

@nicolas-raoul the JavaScript call

space.addNode(childNode);

adds the childNode as a secondary parent to space. In the RM module the link to capability using secondary parents is exposed in the Share UI. Most of the time I use a simple rule to automatically add documents as a secondary parent to some other folder to have some sample content.