Example #1
0
        public IRepositoryInfo GetRepositoryInfo(string repositoryId, IExtensionsData extension)
        {
            IRepositoryInfo result       = null;
            bool            hasExtension = (extension != null) && (extension.Extensions != null) && (extension.Extensions.Count > 0);

            RepositoryInfoCache cache = session.GetRepositoryInfoCache();

            // if extension is not set, check the cache first
            if (!hasExtension)
            {
                result = cache.Get(repositoryId);
                if (result != null)
                {
                    return(result);
                }
            }

            // it was not in the cache -> get the SPI and fetch the repository info
            ICmisSpi spi = session.GetSpi();

            result = spi.GetRepositoryService().GetRepositoryInfo(repositoryId, extension);

            // put it into the cache
            if (!hasExtension)
            {
                cache.Put(result);
            }

            return(result);
        }
Example #2
0
        /// <summary>
        /// Copy Constructor.
        /// </summary>
        public RepositoryInfo(IRepositoryInfo source)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            Id                   = source.Id;
            Name                 = source.Name;
            Description          = source.Description;
            VendorName           = source.VendorName;
            ProductName          = source.ProductName;
            ProductVersion       = source.ProductVersion;
            RootFolderId         = source.RootFolderId;
            Capabilities         = source.Capabilities;
            AclCapabilities      = source.AclCapabilities;
            LatestChangeLogToken = source.LatestChangeLogToken;
            CmisVersionSupported = source.CmisVersionSupported;
            ThinClientUri        = source.ThinClientUri;
            ChangesIncomplete    = source.ChangesIncomplete;
            ChangesOnType        = source.ChangesOnType;
            PrincipalIdAnonymous = source.PrincipalIdAnonymous;
            PrincipalIdAnyone    = source.PrincipalIdAnyone;
            ExtensionFeatures    = source.ExtensionFeatures;
            Extensions           = source.Extensions;
        }
Example #3
0
        public void Put(IRepositoryInfo repositoryInfo)
        {
            if ((repositoryInfo == null) || (repositoryInfo.Id == null))
            {
                return;
            }

            cache.Put(new string[] { repositoryInfo.Id }, repositoryInfo);
        }
Example #4
0
        public Repository(IRepositoryInfo info, IDictionary <string, string> parameters, SessionFactory sessionFactory, IObjectFactory objectFactory, AbstractAuthenticationProvider authenticationProvider, ICache cache)
            : base(info)
        {
            this.parameters = new Dictionary <string, string>(parameters);
            this.parameters[SessionParameter.RepositoryId] = Id;

            this.sessionFactory         = sessionFactory;
            this.objectFactory          = objectFactory;
            this.authenticationProvider = authenticationProvider;
            this.cache = cache;
        }
Example #5
0
 public RepositoryInfo(IRepositoryInfo source)
 {
     Id                   = source.Id;
     Name                 = source.Name;
     Description          = source.Description;
     VendorName           = source.VendorName;
     ProductName          = source.ProductName;
     ProductVersion       = source.ProductVersion;
     RootFolderId         = source.RootFolderId;
     Capabilities         = source.Capabilities;
     AclCapabilities      = source.AclCapabilities;
     LatestChangeLogToken = source.LatestChangeLogToken;
     CmisVersionSupported = source.CmisVersionSupported;
     ThinClientUri        = source.ThinClientUri;
     ChangesIncomplete    = source.ChangesIncomplete;
     ChangesOnType        = source.ChangesOnType;
     PrincipalIdAnonymous = source.PrincipalIdAnonymous;
     PrincipalIdAnyone    = source.PrincipalIdAnyone;
 }
Example #6
0
        public string Save(IRepositoryInfo repository)
        {
            Console.WriteLine("");
            Console.WriteLine("Saving repository...");
            Console.WriteLine("");

            if (String.IsNullOrEmpty(repository.Path))
            {
                throw new ArgumentException("The repository.Path property must be set.", "repository.Path");
            }

            if (String.IsNullOrEmpty(repository.FilePath))
            {
                repository.FilePath = FileNamer.CreateFilePath(repository.Name, repository.Path);
            }

            Console.WriteLine("File path:");
            Console.WriteLine(repository.FilePath);

            Console.WriteLine("Path:");
            Console.WriteLine(repository.Path);

            if (!Directory.Exists(repository.Path))
            {
                Directory.CreateDirectory(repository.Path);
            }

            using (StreamWriter writer = File.CreateText(repository.FilePath))
            {
                var extraTypes = new Type[] {
                    typeof(PackageInfo)
                };

                var serializer = new XmlSerializer(repository.GetType(), extraTypes);
                serializer.Serialize(writer, repository);
            }

            return(repository.FilePath);
        }
Example #7
0
        /// <summary>
        /// Creates a string containing all needed properties of a repository info from remote. If passed repoInfo is null, an empty string is returned.
        /// </summary>
        /// <returns>The log string.</returns>
        /// <param name="repoInfo">Remote repository information.</param>
        public static string ToLogString(this IRepositoryInfo repoInfo)
        {
            if (repoInfo == null)
            {
                return(string.Empty);
            }

            return(string.Format(
                       "Name: \"{1}\" Id: \"{2}\"{0}" +
                       "Description: \"{3}\"{0}" +
                       "ProductName: \"{4}\"{0}" +
                       "ProductVersion: \"{5}\"{0}" +
                       "Vendor: \"{6}\"{0}" +
                       "Supported Cmis Versions: \"{7}\"{0}",
                       Environment.NewLine,
                       repoInfo.Name,
                       repoInfo.Id,
                       repoInfo.Description,
                       repoInfo.ProductName,
                       repoInfo.ProductVersion,
                       repoInfo.VendorName,
                       repoInfo.CmisVersionSupported));
        }
Example #8
0
        public Repository(IRepositoryInfo info, IDictionary<string, string> parameters, SessionFactory sessionFactory, IObjectFactory objectFactory, AbstractAuthenticationProvider authenticationProvider, ICache cache)
            : base(info)
        {
            this.parameters = new Dictionary<string, string>(parameters);
            this.parameters[SessionParameter.RepositoryId] = Id;

            this.sessionFactory = sessionFactory;
            this.objectFactory = objectFactory;
            this.authenticationProvider = authenticationProvider;
            this.cache = cache;
        }
Example #9
0
        public void Put(IRepositoryInfo repositoryInfo)
        {
            if ((repositoryInfo == null) || (repositoryInfo.Id == null))
            {
                return;
            }

            cache.Put(new string[] { repositoryInfo.Id }, repositoryInfo);
        }
 public void Save(IRepositoryInfo repository)
 {
     Saver.Save(repository);
 }