public IFolder CreateFolder(CmisPath path, bool recursive, IDictionary <string, object> properties) { path = path.WithoutTrailingSlash(); if (recursive) { // check if it already exists and proceed to create otherwise try { return(GetFolder(path)); } catch (CmisObjectNotFoundException) { } } var components = path.GetComponents(); var dirname = components[0]; var basename = components[1]; IFolder parent = recursive ? CreateFolder(dirname, true, null) : GetFolder(dirname); var allProps = new Dictionary <string, object>() { { PropertyIds.ObjectTypeId, "cmis:folder" }, { PropertyIds.Name, basename } }; Utilities.UpdateDictionary(allProps, properties); return(parent.CreateFolder(allProps)); }
/* 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(); } } }
public IFolder CreateFolder(CmisPath path, bool recursive, IDictionary<string, object> properties) { path = path.WithoutTrailingSlash(); if (recursive) { // check if it already exists and proceed to create otherwise try { return GetFolder(path); } catch (CmisObjectNotFoundException) { } } var components = path.GetComponents(); var dirname = components[0]; var basename = components[1]; IFolder parent = recursive ? CreateFolder(dirname, true, null) : GetFolder(dirname); var allProps = new Dictionary<string, object>() { { PropertyIds.ObjectTypeId, "cmis:folder" }, { PropertyIds.Name, basename } }; Utilities.UpdateDictionary(allProps, properties); return parent.CreateFolder(allProps); }
public CmisPath Combine(CmisPath other) { if (other.IsAbsolutePath()) { return other.Clone(); } return new CmisPath(_path + CorrectSlash + other.ToString()); }
public CmisPath Combine(CmisPath other) { if (other.IsAbsolutePath()) { return(other.Clone()); } return(new CmisPath(_path + CorrectSlash + other.ToString())); }
public IList <string> Delete(CmisPath cmisPath, bool recursive) { ICmisObject obj; if (!TryGet(cmisPath, out obj)) { // fail otherwise return(new string[] { _curDir.Combine(cmisPath).ToString() }); } return(Delete(obj, recursive)); }
public IDocument GetDocument(CmisPath cmisPath) { IDocument d = Get(cmisPath) as IDocument; if (d == null) { var path = _curDir.Combine(cmisPath).ToString(); var msg = String.Format("The object identified by '{0}' is not a document.", path); throw new CmisObjectNotFoundException(msg); } return(d); }
public IFolder GetFolder(CmisPath cmisPath) { IFolder f = Get(cmisPath) as IFolder; // we need to check if that object is a folder if (f == null) { var path = _curDir.Combine(cmisPath).ToString(); var msg = String.Format("The object identified by '{0}' is not a folder.", path); throw new CmisObjectNotFoundException(msg); } return(f); }
public ICmisObject Get(CmisPath cmisPath) { ICmisObject obj; if (!TryGet(cmisPath, out obj)) { // DotCMIS is not very generous when it comes to generating error messages // so we create a better one var msg = String.Format("The path '{0}' doesn't identify a CMIS object.", cmisPath.ToString()); throw new CmisObjectNotFoundException(msg); } return(obj); }
public bool TryGet(CmisPath cmisPath, out ICmisObject obj) { var path = _curDir.Combine(cmisPath).ToString(); obj = null; try { obj = _session.GetObjectByPath(path); } catch (CmisObjectNotFoundException) { return(false); } return(true); }
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); }
public IDocument CreateDocument(CmisPath path, ContentStream stream, IDictionary<string, object> properties) { var components = path.GetComponents(); var name = components[1]; if (name.Length == 0) { throw new CmisNameConstraintViolationException("The document name is empty."); } var folder = GetFolder(components[0]); var allProps = new Dictionary<string, object>() { { PropertyIds.ObjectTypeId, "cmis:document" }, { PropertyIds.Name, name } }; Utilities.UpdateDictionary(allProps, properties); return folder.CreateDocument(allProps, stream, VersioningState.Major); }
public IDocument CreateDocument(CmisPath path, ContentStream stream, IDictionary <string, object> properties) { var components = path.GetComponents(); var name = components[1]; if (name.Length == 0) { throw new CmisNameConstraintViolationException("The document name is empty."); } var folder = GetFolder(components[0]); var allProps = new Dictionary <string, object>() { { PropertyIds.ObjectTypeId, "cmis:document" }, { PropertyIds.Name, name } }; Utilities.UpdateDictionary(allProps, properties); return(folder.CreateDocument(allProps, stream, VersioningState.Major)); }
public ICmisObject Get(CmisPath cmisPath) { ICmisObject obj; if (!TryGet(cmisPath, out obj)) { // DotCMIS is not very generous when it comes to generating error messages // so we create a better one var msg = String.Format("The path '{0}' doesn't identify a CMIS object.", cmisPath.ToString()); throw new CmisObjectNotFoundException(msg); } return obj; }
public IFolder CreateFolder(CmisPath path, bool recursive) { return(CreateFolder(path, recursive, null)); }
public IFolder CreateTempFolder(CmisPath path, bool recursive) { return CreateTempFolder(path, recursive, null); }
public IDocument CreateTempDocument(CmisPath path, ContentStream stream, IDictionary<string, object> properties) { var doc = _cmisNav.CreateDocument(path, stream, properties); _createdObjects.Add(doc); return doc; }
public IDocument CreateTempDocument(CmisPath path, ContentStream stream) { return CreateTempDocument(path, stream, null); }
protected void SetWorkingFolder(CmisPath path) { _workingFolder = path; SessionState.PSVariable.Set(DIRECTORY_VAR_NAME, path.ToString()); }
public IFolder GetFolder(CmisPath cmisPath) { IFolder f = Get(cmisPath) as IFolder; // we need to check if that object is a folder if (f == null) { var path = _curDir.Combine(cmisPath).ToString(); var msg = String.Format("The object identified by '{0}' is not a folder.", path); throw new CmisObjectNotFoundException(msg); } return f; }
public bool TryGet(CmisPath cmisPath, out ICmisObject obj) { var path = _curDir.Combine(cmisPath).ToString(); obj = null; try { obj = _session.GetObjectByPath(path); } catch (CmisObjectNotFoundException) { return false; } return true; }
public IList<string> Delete(CmisPath cmisPath, bool recursive) { ICmisObject obj; if (!TryGet(cmisPath, out obj)) { // fail otherwise return new string[] { _curDir.Combine(cmisPath).ToString() }; } return Delete(obj, recursive); }
public ICmisObject Get(CmisPath path) { return _cmisNav.Get(path); }
public IDocument CreateTempDocument(CmisPath path) { return CreateTempDocument(path, null); }
public IDocument GetDocument(CmisPath cmisPath) { IDocument d = Get(cmisPath) as IDocument; if (d == null) { var path = _curDir.Combine(cmisPath).ToString(); var msg = String.Format("The object identified by '{0}' is not a document.", path); throw new CmisObjectNotFoundException(msg); } return d; }
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); } }
public CmisNavigation(ISession session, CmisPath path) { _session = session; _curDir = path; }
public IFolder CreateTempFolder(CmisPath path) { return CreateTempFolder(path, false); }
public IDocument CreateDocument(CmisPath path, ContentStream stream) { return(CreateDocument(path, stream, null)); }
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; }