Ejemplo n.º 1
0
        /// <inheritdoc/>
        public void Put(ICmisObject cmisObject, string cacheKey)
        {
            // no object, no id, no cache key - no cache
            if (cmisObject == null || cmisObject.Id == null || cacheKey == null)
            {
                return;
            }

            lock (cacheLock)
            {
                IDictionary <string, ICmisObject> cacheKeyDict = objectCache.Get(cmisObject.Id);
                if (cacheKeyDict == null)
                {
                    cacheKeyDict = new Dictionary <string, ICmisObject>();
                    objectCache.Add(cmisObject.Id, cacheKeyDict);
                }

                cacheKeyDict[cacheKey] = cmisObject;

                // folders may have a path, use it!
                string path = cmisObject.GetPropertyValue(PropertyIds.Path) as string;
                if (path != null)
                {
                    pathToIdCache.Add(path, cmisObject.Id);
                }
            }
        }
Ejemplo n.º 2
0
        private Uri CreateDownloadLink(TimeSpan?expirationIn = null, string password = null, string mailAddress = null, params string[] objectIds)
        {
            IDictionary <string, object> properties = new Dictionary <string, object>();

            properties.Add(PropertyIds.ObjectTypeId, "cmis:item");
            List <string> idsSecondary = new List <string>();

            idsSecondary.Add("cmis:rm_clientMgtRetention");
            idsSecondary.Add("gds:downloadLink");
            properties.Add(PropertyIds.SecondaryObjectTypeIds, idsSecondary);

            properties.Add("cmis:rm_expirationDate", DateTime.UtcNow + (TimeSpan)(expirationIn ?? new TimeSpan(24, 0, 0)));

            List <string> idsObject = new List <string>();

            foreach (var objectId in objectIds)
            {
                idsObject.Add(objectId);
            }

            properties.Add("gds:objectIds", idsObject);
            properties.Add("gds:comment", "Create download link comment");
            properties.Add("gds:subject", "Create download link subject");
            properties.Add("gds:message", "Create download link message");
            if (mailAddress != null)
            {
                properties.Add("gds:emailAddress", mailAddress);
            }

            if (password != null)
            {
                properties.Add("gds:password", password);
            }

            var         id   = this.session.CreateItem(properties, this.session.GetObject(this.session.RepositoryInfo.RootFolderId));
            ICmisObject cmis = this.session.GetObject(id);
            var         url  = cmis.GetPropertyValue("gds:url") as string;

            return(url == null ? null : new Uri(url));
        }
Ejemplo n.º 3
0
        public void Put(ICmisObject cmisObject, string cacheKey)
        {
            // no object, no id, no cache key - no cache
            if (cmisObject == null || cmisObject.Id == null || cacheKey == null)
            {
                return;
            }

            Lock();
            try
            {
                IDictionary<string, ICmisObject> cacheKeyDict = objectCache.Get(cmisObject.Id);
                if (cacheKeyDict == null)
                {
                    cacheKeyDict = new Dictionary<string, ICmisObject>();
                    objectCache.Add(cmisObject.Id, cacheKeyDict);
                }

                cacheKeyDict[cacheKey] = cmisObject;

                // folders may have a path, use it!
                string path = cmisObject.GetPropertyValue(PropertyIds.Path) as string;
                if (path != null)
                {
                    pathToIdCache.Add(path, cmisObject.Id);
                }
            }
            finally
            {
                Unlock();
            }
        }