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);
}