/*
 * TODO: enable support for propertie
 *      [Parameter(Position = 3, Mandatory = false)]
 *      public Hashtable Properties { get; set; }
 */

        protected override void EndProcessing()
        {
            var path = new CmisPath(Path);

            if (LocalFile != null && path.HasTrailingSlash())
            {
                path = path.Combine(System.IO.Path.GetFileName(LocalFile));
            }
            var nav = new CmisNavigation(CmisSession, WorkingFolder);
//            var props = Utilities.HashtableToDict(Properties);
            var stream = GetContentStream();

            try
            {
//                WriteObject(nav.CreateDocument(path, stream, props));
                WriteObject(nav.CreateDocument(path, stream, null));
            }
            catch (CmisBaseException e)
            {
                ThrowTerminatingError(new ErrorRecord(e, "CreateDocumentFailed",
                                                      ErrorCategory.WriteError, path));
            }
            finally
            {
                if (stream != null)
                {
                    stream.Stream.Close();
                }
            }
        }
Exemplo n.º 2
0
        public IDocument CreateTempDocument(CmisPath path, ContentStream stream,
                                            IDictionary <string, object> properties)
        {
            var doc = _cmisNav.CreateDocument(path, stream, properties);

            _createdObjects.Add(doc);
            return(doc);
        }
Exemplo n.º 3
0
        public IDocument CreateTempDocument(CmisPath path, string content, string mimeType)
        {
            var bytes         = Encoding.UTF8.GetBytes(content);
            var contentStream = new ContentStream();

            contentStream.MimeType = mimeType;
            contentStream.Length   = bytes.Length;
            using (var memoryStream = new MemoryStream(bytes))
            {
                contentStream.Stream = memoryStream;
                return(CreateTempDocument(path, contentStream, null));
            }
        }
Exemplo n.º 4
0
        protected override void ProcessRecord()
        {
            var         cmisPath   = new CmisPath(Path);
            var         navigation = new CmisNavigation(CmisSession, WorkingFolder);
            ICmisObject obj        = null;

            try
            {
                obj = navigation.Get(cmisPath);
            }
            catch (CmisBaseException e)
            {
                ThrowTerminatingError(new ErrorRecord(e, "GetObjectFailed",
                                                      ErrorCategory.ResourceUnavailable, Path));
                return;
            }

            var nameIsEmpty = String.IsNullOrEmpty(Name);

            if (!(obj is IFolder) ||
                (!cmisPath.HasTrailingSlash() && nameIsEmpty && RecursionDepth < 1))
            {
                WriteObject(obj);
                return;
            }

            WildcardPattern wildcard = new WildcardPattern("*");

            if (!nameIsEmpty)
            {
                wildcard = Exact.IsPresent ? new WildcardPattern(Name)
                                      : new WildcardPattern(Name + "*", WildcardOptions.IgnoreCase);
            }
            int depth = RecursionDepth == 0 ? 1 : RecursionDepth;

            //otherwise we want the descendants of the folder
            var folder = obj as IFolder;
            IList <ITree <IFileableCmisObject> > descendants;

            try
            {
                descendants = folder.GetDescendants(depth);
            }
            catch (CmisBaseException e)
            {
                ThrowTerminatingError(new ErrorRecord(e, "GetDescendatnsFailed",
                                                      ErrorCategory.ResourceUnavailable, Path));
                return;
            }
            WriteTreeList(descendants, wildcard);
        }
Exemplo n.º 5
0
        public IFolder CreateTempFolder(CmisPath path, bool recursive,
                                        IDictionary <string, object> properties)
        {
            path = path.WithoutTrailingSlash();
            if (recursive)
            {
                try
                {
                    return(_cmisNav.GetFolder(path));
                }
                catch (CmisBaseException) {}
            }
            var comps = path.GetComponents();

            if (recursive)
            {
                CreateTempFolder(comps[0], true, null);
            }
            var folder = _cmisNav.CreateFolder(path, false, properties);

            _createdObjects.Add(folder);
            return(folder);
        }
Exemplo n.º 6
0
 protected void SetWorkingFolder(CmisPath path)
 {
     _workingFolder = path;
     SessionState.PSVariable.Set(DIRECTORY_VAR_NAME, path.ToString());
 }
Exemplo n.º 7
0
 public IFolder CreateTempFolder(CmisPath path, bool recursive)
 {
     return(CreateTempFolder(path, recursive, null));
 }
Exemplo n.º 8
0
 public IFolder CreateTempFolder(CmisPath path)
 {
     return(CreateTempFolder(path, false));
 }
Exemplo n.º 9
0
 public IDocument CreateTempDocument(CmisPath path, ContentStream stream)
 {
     return(CreateTempDocument(path, stream, null));
 }
Exemplo n.º 10
0
 public IDocument CreateTempDocument(CmisPath path)
 {
     return(CreateTempDocument(path, null));
 }
Exemplo n.º 11
0
 public ICmisObject Get(CmisPath path)
 {
     return(_cmisNav.Get(path));
 }