Ejemplo n.º 1
0
        private void MoveFolderAndAllSubFolders(AssetFolder source, AssetFolder destination, string destinationParent, string destinationName, ref Dictionary<string, HttpStatusCode> multiStatus)
        {
            string srcPath = source.ParentPath + source.Name;
            if (!(source is AssetFolderItem)) srcPath += "/";

            //check "permissions"
            if (IsProtectedPath(srcPath))
            {
                //this is one of the default paths. this can't be deleted because it might result some problems
                if (multiStatus == null)
                    multiStatus = new Dictionary<string, HttpStatusCode>();
                multiStatus.Add(srcPath, HttpStatusCode.Forbidden);
                return;
            }

            //TODO: Lock check

            //first move resource
            if (destination == null)
            {
                if (!m_assetFolderStrg.RemoveItem(source)) { SetMultiStatusPrecoditionFailedError(destinationParent + destinationName, ref multiStatus); return; }
                source.Name = destinationName;
                source.ParentPath = destinationParent;
                m_assetFolderStrg.Save(source);

                IWebDAVResource resProp = m_propertyMngr.GetResource(srcPath);
                if (!m_propertyMngr.Remove(resProp)) { SetMultiStatusPrecoditionFailedError(destinationParent + destinationName, ref multiStatus); return; }
                string newPath = destinationParent + destinationName;
                if (!(source is AssetFolderItem)) newPath += "/";
                resProp.Path = newPath;
                if (!m_propertyMngr.SaveResource(resProp)) { SetMultiStatusPrecoditionFailedError(destinationParent + destinationName, ref multiStatus); return; }
            }
            else
            {
                //just delete the source
                if (!m_assetFolderStrg.RemoveItem(source)) { SetMultiStatusPrecoditionFailedError(destinationParent + destinationName, ref multiStatus); return; }
                if (!m_propertyMngr.Remove(srcPath)) { SetMultiStatusPrecoditionFailedError(destinationParent + destinationName, ref multiStatus); return; }
            }

            //then move sub resources
            if (!(source is AssetFolderItem))
            {
                IList<AssetFolder> subitems = m_assetFolderStrg.GetSubItems(srcPath);
                foreach (AssetFolder item in subitems)
                {
                    AssetFolder subDst = m_assetFolderStrg.GetItem(destinationParent + destinationName + "/", item.Name);
                    MoveFolderAndAllSubFolders(item, subDst, destinationParent + destinationName + "/", item.Name, ref multiStatus);
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Save or update object to database
 /// </summary>
 /// <param name="obj">Object to save or update</param>
 public void Save(AssetFolder obj)
 {
     try
     {
         AssetFolder old = (AssetFolder)manager.Get(typeof(AssetFolder), obj.Id);
         if (old != null)
         {
             m_log.InfoFormat("[NHIBERNATE] updating RexAssetFolder {0} {1}", obj.ParentPath, obj.Name);
             manager.Update(obj);
         }
         else
         {
             m_log.InfoFormat("[NHIBERNATE] saving RexAssetFolder {0} {1}", obj.ParentPath, obj.Name);
             manager.Insert(obj);
         }
     }
     catch (Exception e)
     {
         m_log.Error("[NHIBERNATE]: Can't save: ", e);
     }
 }
Ejemplo n.º 3
0
        HttpStatusCode MkcolHandler(string path, string username)
        {
            if (path.EndsWith("/"))
                path = path.TrimEnd('/');
            string[] pathParts = path.Split('/');
            string parentPath = String.Empty;
            for (int i = 0; i < pathParts.Length - 1; i++)
            {
                parentPath += pathParts[i];
                parentPath += "/";
            }

            AssetFolder parent = GetAssetFolder(parentPath);
            if (parent == null)
            {
                return HttpStatusCode.Conflict;
            }
            if (parent is AssetFolderItem)
            {
                return HttpStatusCode.Conflict;
            }

            AssetFolder folder = GetAssetFolder(path);
            if (folder != null)
            {
                return HttpStatusCode.MethodNotAllowed;
            }
            else
            {
                folder = new AssetFolder(parentPath, pathParts[pathParts.Length - 1]);
                m_assetFolderStrg.Save(folder);
                if (!path.EndsWith("/"))
                    path += "/";
                m_propertyMngr.SaveResource(new WebDAVFolder(path, DateTime.Now, DateTime.Now, DateTime.Now, false));
                m_log.DebugFormat("[WORLDINVENTORY]: Created folder {0} to {1}", folder.Name, folder.ParentPath);
                return HttpStatusCode.Created;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Removes the item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns>True if deleted properly, false if not</returns>
 public bool RemoveItem(AssetFolder item)
 {
     if (item != null)
     {
         return manager.Delete(item);
     }
     else
     {
         return false;
     }
 }