Beispiel #1
0
        public static void DoTransform(Node node, WebDavHandler handler, string binaryPropertyName)
        {
            var content  = Content.Load(node.Path);
            var nodeType = content.ContentHandler.GetType();

            var transformer = TransformerRules.Where(rule => nodeType.IsSubclassOf(rule.Key) ||
                                                     nodeType == rule.Key).Select(rule => rule.Value).FirstOrDefault();

            if (node is IFile)
            {
                switch (handler.WebdavType)
                {
                case WebdavType.Page:
                    transformer = NodeConverter.TransformFile;
                    break;

                case WebdavType.Content:
                    transformer = NodeConverter.TransformContent;
                    break;

                case WebdavType.ContentType:
                    transformer = NodeConverter.TransformContentType;
                    break;

                default:
                    transformer = NodeConverter.TransformFile;
                    break;
                }
            }

            if (transformer != null)
            {
                transformer(node, handler.Context, binaryPropertyName);
            }
        }
Beispiel #2
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
        }
Beispiel #3
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;
        }
Beispiel #4
0
        /// <summary>
        /// Checks an existing node whether it has a binary property with
        /// matching name and sets the binary value if needed
        /// </summary>
        /// <returns>True, if binary value was set</returns>
        private bool SetBinaryAttachment(Node existingNode, string binaryName)
        {
            bool foundBin = false;

            foreach (var propType in existingNode.PropertyTypes)
            {
                //TODO: BETTER FILENAME CHECK!
                if (propType.DataType == DataType.Binary)
                {
                    string tempBinaryName = WebDavHandler.GetAttachmentName(existingNode, propType.Name);

                    if (tempBinaryName.CompareTo(binaryName) == 0)
                    {
                        SetBinaryStream(existingNode, _handler.Context.Request.InputStream, propType.Name);
                        foundBin = true;
                        break;
                    }
                }
            }

            return(foundBin);
        }
Beispiel #5
0
 public Propfind(WebDavHandler handler)
 {
     _handler = handler;
 }
Beispiel #6
0
 public Move(WebDavHandler handler)
 {
     _handler = handler;
 }
Beispiel #7
0
 public MkCol(WebDavHandler handler)
 {
     _handler = handler;
 }
Beispiel #8
0
 public Delete(WebDavHandler handler)
 {
     _handler = handler;
 }
Beispiel #9
0
 public Put(WebDavHandler handler)
 {
     _handler = handler;
 }
Beispiel #10
0
 public Get(WebDavHandler handler)
 {
     _handler = handler;
 }
Beispiel #11
0
 public Proppatch(WebDavHandler handler)
 {
     _handler = handler;
 }
Beispiel #12
0
 public UnLock(WebDavHandler handler)
 {
     _handler = handler;
 }
Beispiel #13
0
 public Head(WebDavHandler handler)
 {
     _handler = handler;
 }