Пример #1
0
        public void CreateNonCachingAndPathIncludingContext()
        {
            var result  = Mock.Of <IOperationContext>();
            var session = this.CreateSessionMock(result);

            var context = OperationContextFactory.CreateNonCachingPathIncludingContext(session.Object);

            session.VerifyThatAllDefaultValuesAreSet();
            session.VerifyThatFilterContainsPath();
            session.VerifyThatCachingIsDisabled();
            Assert.That(context, Is.EqualTo(result));
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RemoteObjectFetcher"/> class.
        /// Fetches remote CMIS Objects and adds them to the handled events.
        /// </summary>
        /// <param name="session">Session to be used.</param>
        /// <param name="storage">Storage to look for mapped objects.</param>
        public RemoteObjectFetcher(ISession session, IMetaDataStorage storage)
        {
            if (session == null)
            {
                throw new ArgumentNullException("Session instance is needed , but was null");
            }

            if (storage == null)
            {
                throw new ArgumentNullException("MetaDataStorage instance is needed, but was null");
            }

            this.session          = session;
            this.storage          = storage;
            this.operationContext = OperationContextFactory.CreateNonCachingPathIncludingContext(this.session);
        }
Пример #3
0
        public void EnsureFileNameStaysEqualWhileUploading(
            string canonical_name,
            string localPath,
            string remoteFolderPath,
            string url,
            string user,
            string password,
            string repositoryId,
            string binding)
        {
            ISession session = DotCMISSessionTests.CreateSession(user, password, url, repositoryId, binding);

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

            string filename = "testfile.txt";
            Dictionary <string, object> properties = new Dictionary <string, object>();

            properties.Add(PropertyIds.Name, filename);
            properties.Add(PropertyIds.ObjectTypeId, BaseTypeId.CmisDocument.GetCmisValue());
            try {
                IDocument doc = session.GetObjectByPath(remoteFolderPath.TrimEnd('/') + "/" + filename) as IDocument;
                if (doc != null)
                {
                    doc.Delete(true);
                }
            } catch (CmisObjectNotFoundException) {
            }

            IDocument emptyDoc = folder.CreateDocument(properties, null, null);
            int       length   = 1024 * 1024;

            byte[]        content       = new byte[length];
            ContentStream contentStream = new ContentStream();

            contentStream.FileName = filename;
            contentStream.MimeType = MimeType.GetMIMEType(filename);
            contentStream.Length   = content.Length;
            Action assert = delegate {
                Assert.That((session.GetObject(emptyDoc.Id, OperationContextFactory.CreateNonCachingPathIncludingContext(session)) as IDocument).Name, Is.EqualTo(filename));
            };

            using (var memstream = new AssertingStream(new MemoryStream(content), assert)) {
                contentStream.Stream = memstream;
                emptyDoc.SetContentStream(contentStream, true, true);
            }
        }
Пример #4
0
 /// <summary>
 /// Updates the object.
 /// </summary>
 /// <param name='session'>
 /// Session from where the object should be requested.
 /// </param>
 public void UpdateObject(ISession session)
 {
     this.CmisObject = session.GetObject(this.ObjectId, OperationContextFactory.CreateNonCachingPathIncludingContext(session));
 }