Beispiel #1
0
        /// <summary>
        /// Get the sub-folders of a particular CMIS folder.
        /// </summary>
        /// <returns>Full path of each sub-folder, including leading slash.</returns>
        static public string[] GetSubfolders(string repositoryId, string path,
                                             string url, string user, string password)
        {
            List <string> result = new List <string>();

            // Connect to the CMIS repository.
            ISession session = Auth.Auth.GetCmisSession(url, user, password, repositoryId);

            // 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}", path), ex);
                return(result.ToArray());
            }

            // 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());

            // Get the folder's sub-folders.
            IItemEnumerable <ICmisObject> children = folder.GetChildren();

            // Return the full path of each of the sub-folders.
            foreach (var subfolder in children.OfType <IFolder>())
            {
                result.Add(subfolder.Path);
            }
            return(result.ToArray());
        }
Beispiel #2
0
        /// <summary>
        /// Get the sub-folders of a particular CMIS folder.
        /// </summary>
        /// <returns>Full path of each sub-folder, including leading slash.</returns>
        static public string[] GetSubfolders(CmisRepoCredentials credentials, string path)
        {
            List <string> result = new List <string>();

            // Connect to the CMIS repository.
            Dictionary <string, string> cmisParameters = GetCmisParameters(credentials);
            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)));
                return(result.ToArray());
            }

            // 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());

            // Get the folder's sub-folders.
            IItemEnumerable <ICmisObject> children = folder.GetChildren();

            // Return the full path of each of the sub-folders.
            foreach (var subfolder in children.OfType <IFolder>())
            {
                result.Add(subfolder.Path);
            }

            return(result.ToArray());
        }
Beispiel #3
0
        /// <summary>
        /// Get the sub-folders of a particular CMIS folder.
        /// </summary>
        /// <returns>Full path of each sub-folder, including leading slash.</returns>
        static public string[] GetSubfolders(string repositoryId, string path,
                                             string address, string user, string password)
        {
            List <string> result = new List <string>();

            // Connect to the CMIS repository.
            Dictionary <string, string> cmisParameters = new Dictionary <string, string>();

            cmisParameters[SessionParameter.BindingType]  = BindingType.AtomPub;
            cmisParameters[SessionParameter.AtomPubUrl]   = address;
            cmisParameters[SessionParameter.User]         = user;
            cmisParameters[SessionParameter.Password]     = password;
            cmisParameters[SessionParameter.RepositoryId] = repositoryId;
            SessionFactory factory = SessionFactory.NewInstance();
            ISession       session = factory.CreateSession(cmisParameters);

            // Get the folder.
            IFolder folder = (IFolder)session.GetObjectByPath(path);

            // 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());

            // Get the folder's sub-folders.
            IItemEnumerable <ICmisObject> children = folder.GetChildren();

            // Return the full path of each of the sub-folders.
            foreach (var subfolder in children.OfType <IFolder>())
            {
                result.Add(subfolder.Path);
            }
            return(result.ToArray());
        }
Beispiel #4
0
        static public string[] GetSubfolders(string repositoryId, string path,
                                             string address, string user, string password)
        {
            List <string> result = new List <string>();

            Dictionary <string, string> cmisParameters = new Dictionary <string, string>();

            cmisParameters[SessionParameter.BindingType]  = BindingType.AtomPub;
            cmisParameters[SessionParameter.AtomPubUrl]   = address;
            cmisParameters[SessionParameter.User]         = user;
            cmisParameters[SessionParameter.Password]     = password;
            cmisParameters[SessionParameter.RepositoryId] = repositoryId;

            SessionFactory factory = SessionFactory.NewInstance();
            ISession       session = factory.CreateSession(cmisParameters);

            IFolder folder = (IFolder)session.GetObjectByPath(path);

            Logger.Info("Sync | folder.Properties.Count:" + folder.Properties.Count);
            IItemEnumerable <ICmisObject> children = folder.GetChildren();

            foreach (var subfolder in children.OfType <IFolder>())
            {
                result.Add(subfolder.Path);
            }
            return(result.ToArray());
        }
Beispiel #5
0
        public void DotCmisToIBMConnections(string canonical_name, string localPath, string remoteFolderPath,
                                            string url, string user, string password, string repositoryId)
        {
            var cmisParameters = new Dictionary <string, string>();

            cmisParameters[SessionParameter.BindingType]  = BindingType.AtomPub;
            cmisParameters[SessionParameter.AtomPubUrl]   = url;
            cmisParameters[SessionParameter.User]         = user;
            cmisParameters[SessionParameter.Password]     = Crypto.Deobfuscate(password);
            cmisParameters[SessionParameter.RepositoryId] = repositoryId;

            SessionFactory factory = SessionFactory.NewInstance();
            ISession       session = factory.GetRepositories(cmisParameters)[0].CreateSession();

            Console.WriteLine("Depth: 1");
            IFolder root = session.GetRootFolder();
            IItemEnumerable <ICmisObject> children = root.GetChildren();

            foreach (var folder in children.OfType <IFolder>())
            {
                Console.WriteLine(folder.Path);
            }

            Console.WriteLine("Depth: 2");
            root     = session.GetRootFolder();
            children = root.GetChildren();
            foreach (var folder in children.OfType <IFolder>())
            {
                Console.WriteLine(folder.Path);
                IItemEnumerable <ICmisObject> subChildren = folder.GetChildren();
                foreach (var subFolder in subChildren.OfType <IFolder>()) // Exception happens here, see https://issues.apache.org/jira/browse/CMIS-593
                {
                    Console.WriteLine(subFolder.Path);
                }
            }
        }