static public NodeTree GetSubfolderTree(Credentials.CmisRepoCredentials credentials, string path, int depth)
{
// Connect to the CMIS repository.
Dictionary<string, string> cmisParameters = new Dictionary<string, string>();
cmisParameters[SessionParameter.BindingType] = BindingType.AtomPub;
cmisParameters[SessionParameter.AtomPubUrl] = credentials.Address.ToString();
cmisParameters[SessionParameter.User] = credentials.UserName;
cmisParameters[SessionParameter.Password] = credentials.Password.ToString();
cmisParameters[SessionParameter.RepositoryId] = credentials.RepoId;
SessionFactory factory = SessionFactory.NewInstance();
ISession session = factory.CreateSession(cmisParameters);
// Get the folder.
IFolder folder;
try
{
folder = (IFolder)session.GetObjectByPath(path);
}
catch (Exception ex)
{
Logger.Warn(string.Format("CmisUtils | exception when session GetObjectByPath for {0}: {1}", path, Utils.ToLogString(ex)));
throw;
}
// Debug the properties count, which allows to check whether a particular CMIS implementation is compliant or not.
// For instance, IBM Connections is known to send an illegal count.
Logger.Info("CmisUtils | folder.Properties.Count:" + folder.Properties.Count.ToString());
try
{
IList<ITree<IFileableCmisObject>> trees = folder.GetFolderTree(depth);
return new NodeTree(trees, folder, depth);
}
catch (Exception e)
{
Logger.Info("CmisUtils getSubFolderTree | Exception " + e.Message, e);
throw;
}
}