GetNodeByBinaryName() static private method

static private GetNodeByBinaryName ( Node parentNode, string fileName, string &binaryPropertyName ) : Node
parentNode Node
fileName string
binaryPropertyName string
return Node
示例#1
0
        internal void ProcessCurrent()
        {
            if (_handler.Path == string.Empty)
            {
                ProcessRoot();
                return;
            }

            var node = Node.LoadNode(_handler.GlobalPath);

            if (node == null)
            {
                var parentPath  = RepositoryPath.GetParentPath(_handler.GlobalPath);
                var currentName = RepositoryPath.GetFileName(_handler.GlobalPath);

                node = Node.LoadNode(parentPath);

                var binaryPropertyName = string.Empty;
                var foundNode          = WebDavHandler.GetNodeByBinaryName(node, currentName, out binaryPropertyName);

                if (foundNode != null)
                {
                    node = foundNode;
                }
                else
                {
                    //content type check
                    //LATER: CTD handling
                    //var parentIsContentType = (node != null && node is ContentType);

                    //if (!parentIsContentType)
                    //{

                    // desktop.ini, thumbs.db, and other files that are not present are mocked instead of returning 404
                    if ((Config.MockExistingFiles != null) && (Config.MockExistingFiles.Contains(currentName)))
                    {
                        _writer = Common.GetXmlWriter();
                        _writer.WriteStartElement(XmlNS.DAV_Prefix, "multistatus", XmlNS.DAV);
                        _writer.WriteEndElement(); // multistatus

                        _handler.Context.Response.Flush();
                        return;
                    }
                    _handler.Context.Response.StatusCode = 404;
                    _handler.Context.Response.Flush();
                    return;
                    //}

                    // parent is contenttype, continue operation on parent (foldernode's name is valid CTD name)
                }
            }

            _writer = Common.GetXmlWriter();
            _writer.WriteStartElement(XmlNS.DAV_Prefix, "multistatus", XmlNS.DAV);

            WriteItem(node);

            _writer.WriteEndElement(); // multistatus
        }
示例#2
0
        public void HandleMethod()
        {
            var node = Node.LoadNode(_handler.GlobalPath);
            var binaryPropertyName = "Binary";

            if (node == null)
            {
                var parentPath  = RepositoryPath.GetParentPath(_handler.GlobalPath);
                var currentName = RepositoryPath.GetFileName(_handler.GlobalPath);

                node = Node.LoadNode(parentPath);

                var foundNode = WebDavHandler.GetNodeByBinaryName(node, currentName, out binaryPropertyName);

                if (foundNode != null)
                {
                    node = foundNode;
                }
                else
                {
                    binaryPropertyName = "Binary";

                    // check if parent is contenttype
                    // (contenttypes are listed under their own folder, so the node exists only virtually)
                    var parentIsContentType = (node != null && node is ContentType);

                    if (!parentIsContentType)
                    {
                        _handler.Context.Response.StatusCode = 404;
                        _handler.Context.Response.Flush();
                    }

                    // parent is contenttype, continue operation on parent (foldernode's name is valid CTD name)
                }
            }

            // load specific version
            if (node != null && !string.IsNullOrEmpty(PortalContext.Current.VersionRequest))
            {
                VersionNumber version;
                if (VersionNumber.TryParse(PortalContext.Current.VersionRequest, out version))
                {
                    var nodeVersion = Node.LoadNode(node.Id, version);
                    if (nodeVersion != null && nodeVersion.SavingState == ContentSavingState.Finalized)
                    {
                        node = nodeVersion;
                    }
                }
            }

            ConverterPattern.DoTransform(node, _handler, binaryPropertyName);
            _handler.Context.Response.Flush();

            return;
        }
示例#3
0
文件: Get.cs 项目: vlslavik/SenseNet
        public void HandleMethod()
        {
            var node = Node.LoadNode(_handler.GlobalPath);
            var binaryPropertyName = "Binary";

            if (node == null)
            {
                var parentPath  = RepositoryPath.GetParentPath(_handler.GlobalPath);
                var currentName = RepositoryPath.GetFileName(_handler.GlobalPath);

                node = Node.LoadNode(parentPath);

                var foundNode = WebDavHandler.GetNodeByBinaryName(node, currentName, out binaryPropertyName);

                if (foundNode != null)
                {
                    node = foundNode;
                }
                else
                {
                    binaryPropertyName = "Binary";

                    // check if parent is contenttype
                    //(contenttypes are listed under their own folder, so the node exists only virtually)
                    var parentIsContentType = (node != null && node is ContentType);

                    if (!parentIsContentType)
                    {
                        _handler.Context.Response.StatusCode = 404;
                        _handler.Context.Response.Flush();
                    }

                    // parent is contenttype, continue operation on parent (foldernode's name is valid CTD name)
                }
            }

            ConverterPattern.DoTransform(node, _handler, binaryPropertyName);
            _handler.Context.Response.Flush();

            return;
        }