/// <summary>
		/// Gets the ACL mask of the <paramref name="assetType"/>.
		/// </summary>
		/// <param name="assetType">The <see cref="AssetType"/> for which to generate the ACL mask.</param>
		/// <returns>Returns the mask code.</returns>
		protected static int GetACLMask(AssetType assetType)
		{
			// validate arguments
			if (assetType == null)
				throw new ArgumentNullException("assetType");
			return (int) (AccessControlRules.FolderView | AccessControlRules.FileView | AccessControlRules.FolderCreate | AccessControlRules.FileUpload);
		}
Пример #2
0
		/// <summary>
		/// Creates an <see cref="AssetFolder"/> instance from the <paramref name="node"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="assetType">The <see cref="AssetType"/>.</param>
		/// <param name="node">The <see cref="Node"/>.</param>
		/// <returns>Returns the constructed <see cref="AssetFolder"/> instance.</returns>
		public static AssetFolder Create(IMansionContext context, AssetType assetType, Node node)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (assetType == null)
				throw new ArgumentNullException("assetType");
			if (node == null)
				throw new ArgumentNullException("node");

			// create the folder
			return new AssetFolder
			       {
			       	AssetType = assetType,
			       	Path = "/" + node.Pointer.Name.ToLower() + "/",
			       	Label = node.Pointer.Name,
			       	Node = node,
			       	Url = AssetUtil.GetUrl(context, assetType.Node, node)
			       };
		}
Пример #3
0
		/// <summary>
		/// Parses the <paramref name="path"/> into a <see cref="AssetFolder"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="assetType">The <see cref="AssetType"/>.</param>
		/// <param name="path">The path which to parse.</param>
		/// <returns>Returns the <see cref="AssetFolder"/>.</returns>
		public AssetFolder ParseFolder(IMansionContext context, AssetType assetType, string path)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (assetType == null)
				throw new ArgumentNullException("assetType");
			if (string.IsNullOrEmpty(path))
				throw new ArgumentNullException("path");

			// if the asset type is unknown, return unknown folder
			if (assetType.Equals(AssetType.Unknown))
				return AssetFolder.Unknown;

			// get the path parts
			var parts = path.Split(Dispatcher.Constants.UrlPartTrimCharacters, StringSplitOptions.RemoveEmptyEntries);
			if (parts.Length == 0)
				return AssetFolder.Create(context, assetType, assetType.Node);

			// retrieve the folder node
			var folderNode = RetrieveFolderByNameNode(context, assetType.Node, parts);

			// create the folder
			return AssetFolder.Create(context, assetType, folderNode);
		}