Inheritance: PropertySet
Example #1
0
        private static IEnumerable<string> GetAvailablePathsByTypeAndPath(string contextNodePath, NodeType nodeType, string appFolderName, string appName, HierarchyOption option)
        {
            contextNodePath = contextNodePath.TrimEnd('/');

            var assocName = appName ?? String.Empty;
            if (assocName.Length > 0)
                assocName = String.Concat("/", assocName);

            string[] parts = contextNodePath.Split('/');

            var probs = new List<string>();

            while (nodeType != null)
            {
                probs.Add(String.Concat("/{0}/", nodeType.Name, assocName));
                nodeType = nodeType.Parent;
            }

            var paths = new List<string>();

            paths.Add(String.Concat(contextNodePath, "/", appFolderName, "/This", assocName));

            var position = parts.Length + 1;
            string partpath;
            while (position-- > 2)
            {
                partpath = string.Join("/", parts, 0, position);
                foreach (var prob in probs)
                    paths.Add(String.Concat(partpath, string.Format(prob, appFolderName)));
            }
            return paths;
        }
Example #2
0
		public TypeExpression(NodeType nodeType)
		{
			if (nodeType == null)
				throw new ArgumentNullException("nodeType");
			_nodeType = nodeType;
			//_exactMatch = false;
		}
Example #3
0
		public TypeExpression(NodeType nodeType, bool exactMatch)
		{
			if (nodeType == null)
				throw new ArgumentNullException("nodeType");
			_nodeType = nodeType;
			_exactMatch = exactMatch;
		}
Example #4
0
 public IEnumerable<NodeHead> ResolveApplications(string appName, string contextNodePath, NodeType nodeType)
 {
     var paths = ApplicationResolver.GetAvailablePaths(contextNodePath, nodeType, this.AppFolderName, appName, Option);
     if (ResolveAll)
         return ResolveAllByPaths(paths, ResolveChildren);
     else
         return new NodeHead[] { ResolveFirstByPaths(paths) };
 }
Example #5
0
 internal static IEnumerable<string> GetAvailablePaths(string contextNodePath, NodeType nodeType, string appFolderName, string appName, HierarchyOption hierarchyOption)
 {
     switch (hierarchyOption)
     {
         case HierarchyOption.Type:
             return GetAvailablePathsByType(contextNodePath, nodeType, appFolderName, appName, hierarchyOption);
         case HierarchyOption.Path:
             return GetAvailablePathsByPath(contextNodePath, nodeType, appFolderName, appName, hierarchyOption);
         case HierarchyOption.TypeAndPath:
             return GetAvailablePathsByTypeAndPath(contextNodePath, nodeType, appFolderName, appName, hierarchyOption);
         case HierarchyOption.PathAndType:
             return GetAvailablePathsByPathAndType(contextNodePath, nodeType, appFolderName, appName, hierarchyOption);
         default:
             throw new NotImplementedException(hierarchyOption.ToString());
     }
 }
Example #6
0
		//================================================================================ Construction

		internal NodeType(int id, string name, ISchemaRoot schemaRoot, string className, NodeType parent) : base(id, name, schemaRoot)
		{
			_declaredPropertyTypes = new TypeCollection<PropertyType>(this.SchemaRoot);
			_parent = parent;
			_children = new TypeCollection<NodeType>(this.SchemaRoot);
			_className = className;
			_nodeTypePath = name;

			if (parent != null)
			{
				parent._children.Add(this);
				//-- Inherit PropertyTypes
				foreach (PropertyType propType in parent.PropertyTypes)
					this.PropertyTypes.Add(propType);
				_nodeTypePath = String.Concat(parent._nodeTypePath, "/", _nodeTypePath);
			}
		}
Example #7
0
        private static IEnumerable<string> GetAvailablePathsByType(string contextNodePath, NodeType nodeType, string appFolderName, string appName, HierarchyOption option)
        {
            contextNodePath = contextNodePath.TrimEnd('/');

            var assocName = appName ?? String.Empty;
            if (assocName.Length > 0)
                assocName = String.Concat("/", assocName);

            var pathBase = String.Concat(contextNodePath, "/", appFolderName);
            var paths = new List<string>();

            paths.Add(String.Concat(pathBase, "/This", assocName));

            while (nodeType != null)
            {
                paths.Add(String.Concat(pathBase, "/", nodeType.Name, assocName));
                nodeType = nodeType.Parent;
            }

            return paths;
        }
Example #8
0
        public bool ParseBinary(BinaryData binaryData)
        {
            if(binaryData == null)
                throw new ArgumentNullException("binaryData");

            // TODO: Resolve correct File subtype by the SenseNet.ContentRepository.Storage.MimeTable
            _nodeType = ActiveSchema.NodeTypes[typeof(File).Name];
            if(_nodeType == null)
            {
                // Unknown type
                _fileNameExtension = null;
                _contentType = null;
                return false;
            }
            else
            {
                // Fix extension and/or contenttype values by config matching
                _fileNameExtension = binaryData.FileName.Extension;
                _contentType = binaryData.ContentType;
                return true;
            }
        }
Example #9
0
        private static IEnumerable<string> GetAvailablePathsByPath(string contextNodePath, NodeType nodeType, string appFolderName, string appName, HierarchyOption option)
        {
            contextNodePath = contextNodePath.TrimEnd('/');

            var assocName = appName ?? String.Empty;
            if (assocName.Length > 0)
                assocName = String.Concat("/", assocName);

            string[] parts = contextNodePath.Split('/');

            var paths = new List<string>();

            paths.Add(String.Concat(contextNodePath, "/", appFolderName, "/This", assocName));

            var position = parts.Length + 1;
            string partpath;
            while (position-- > 2)
            {
                partpath = string.Join("/", parts, 0, position);
                paths.Add(String.Concat(partpath, "/", appFolderName, assocName));
            }
            return paths;
        }
 public abstract void UpdatePropertyTypeDeclarationState(PropertyType propertyType, NodeType owner, bool isDeclared);
Example #11
0
 public NodeType CreateNodeType(NodeType parent, string name)
 {
     return(CreateNodeType(parent, name, null));
 }
Example #12
0
		public abstract void UpdatePropertyTypeDeclarationState(PropertyType propertyType, NodeType owner, bool isDeclared);
Example #13
0
		public abstract void ModifyNodeType(NodeType nodeType, NodeType parent, string className);
Example #14
0
 private static bool MustCache(NodeType nodeType)
 {
     if (RepositoryConfiguration.CacheContentAfterSaveMode != RepositoryConfiguration.CacheContentAfterSaveOption.Containers)
         return RepositoryConfiguration.CacheContentAfterSaveMode == RepositoryConfiguration.CacheContentAfterSaveOption.All ? true : false;
     //return nodeType.IsInstaceOfOrDerivedFrom("Folder");
     var type = TypeHandler.GetType(nodeType.ClassName);
     return typeof(IFolder).IsAssignableFrom(type);
 }
Example #15
0
		public override void UpdatePropertyTypeDeclarationState(PropertyType propertyType, NodeType owner, bool isDeclared)
		{
			StringBuilder sb = new StringBuilder();
			if (propertyType == null)
				throw new ArgumentNullException("propertyType");
			if (owner == null)
				throw new ArgumentNullException("owner");
			WriteUpdateScript(sb, "SchemaPropertySetsPropertyTypes",
				String.Concat("PropertySetId = ", owner.Id, " AND PropertyTypeId = ", propertyType.Id),
				CreateCommentLine("Update PropertyType declaration: ", owner.Name, ".", propertyType.Name, ". Set IsDeclared = ", isDeclared ? "true" : "false"),
				"IsDeclared", isDeclared ? 1 : 0);
			AddScript(sb);
		}
Example #16
0
			public void DeleteNodeType(NodeType nodeType)
			{
				_target.GetType().GetMethod("DeleteNodeType").Invoke(_target, new object[] { nodeType });
			}
Example #17
0
			public void CreateNodeType(NodeType parent, string name, string className)
			{
				_target.GetType().GetMethod("CreateNodeType").Invoke(_target, new object[] { parent, name, className });
			}
Example #18
0
        public bool IsInstaceOfOrDerivedFrom(NodeType nodeType)
        {
            if (nodeType == null)
                throw new ArgumentNullException("nodeType");

            return IsInstaceOfOrDerivedFrom(nodeType.Name);
        }
Example #19
0
		internal void MoveTo(NodeType parent)
		{
			if (this.Parent == parent)
				return;

			if(_parent != null)
				_parent.Children.Remove(this);
			_parent = parent;
			parent._children.Add(this);
			UpdateNodeTypePath();

			//==== Remove unwanted properties
			//-- #1 Unwanted properties are old inherited properties thats are own properties excepting the declared properties
			List<PropertyType> unwantedProps = new List<PropertyType>(this.PropertyTypes);
			foreach (PropertyType declaredProperty in this.DeclaredPropertyTypes)
				unwantedProps.Remove(declaredProperty);

			//-- #2 Remove old inherited properties excepting the new inherited properties
			foreach (PropertyType unwantedProp in unwantedProps)
				if (!_parent.PropertyTypes.Contains(unwantedProp))
					RemovePropertyType(unwantedProp);

			//==== Inherit from new parent: add non-existent properties
			foreach (PropertyType newProp in _parent.PropertyTypes)
				if (!this.PropertyTypes.Contains(newProp))
					AddPropertyType(newProp);
		}
Example #20
0
 public static ADObjectType GetADObjectType(NodeType nodeType)
 {
     switch (nodeType.Name)
     {
         case "User":
             return ADObjectType.User;
         case "Group":
             return ADObjectType.Group;
         case "OrganizationalUnit":
             return ADObjectType.OrgUnit;
         case "Domain":
             return ADObjectType.Domain;
         case "ADFolder":
             return ADObjectType.Container;
         default:
             return ADObjectType.None;
     }
 }
Example #21
0
		private NodeType CreateNodeType(SchemaEditor editor, NodeType parent, string name, string className, int id)
		{
			NodeType nt = editor.CreateNodeType(parent, name, className);
			SetSchemaItemId(nt, id);
			return nt;
		}
Example #22
0
 public NodeType CreateNodeType(NodeType parent, string name, string className)
 {
     return(CreateNodeType(0, parent, name, className));
 }
Example #23
0
			public void ModifyNodeType(NodeType nodeType, NodeType parent, string className)
			{
				_target.GetType().GetMethod("ModifyNodeType").Invoke(_target, new object[] { nodeType, parent, className });
			}
Example #24
0
        public static bool CheckManageListPermission(NodeType nodeType, Node targetNode)
        {
            //silent error handling
            if (nodeType == null || targetNode == null)
                return true;

            return (!nodeType.IsInstaceOfOrDerivedFrom("ContentList") && !nodeType.IsInstaceOfOrDerivedFrom("Workspace")) || targetNode.Security.HasPermission(PermissionType.ManageListsAndWorkspaces);
        }
Example #25
0
			public void UpdatePropertyTypeDeclarationState(PropertyType propertyType, NodeType owner, bool isDeclared)
			{
				_target.GetType().GetMethod("UpdatePropertyTypeDeclarationState").Invoke(_target, new object[] { propertyType, owner, isDeclared });
			}
Example #26
0
        private void Initialize(HttpContext context, PortalContextInitInfo initInfo)
        {
            _ownerHttpContext = context;
            // use absolute uri to clone. requesturi.tostring messes up encoded parts, like backurl
            _originalUri = new Uri(initInfo.RequestUri.AbsoluteUri.ToString()); // clone
            _isWebdavRequest = initInfo.IsWebdavRequest;
            _isOfficeProtocolRequest = initInfo.IsOfficeProtocolRequest;
            _basicAuthHeaders = initInfo.BasicAuthHeaders;

            _site = initInfo.RequestedSite;
            _siteUrl = initInfo.SiteUrl;
            _siteRelativePath = initInfo.SiteRelativePath;
            _repositoryPath = initInfo.RepositoryPath;

            _actionName = initInfo.ActionName;
            _appNodePath = initInfo.AppNodePath;
            _contextNodePath = initInfo.ContextNodePath;
            _versionRequest = initInfo.VersionRequest;

            _deviceName = initInfo.DeviceName;

            if (_contextNodePath == null)
            {
                _contextNodeHead = initInfo.RequestedNodeHead;
            }
            else
            {
                _contextNodeHead = NodeHead.Get(initInfo.ContextNodePath);
                _appNodePath = initInfo.RequestedNodeHead.Path;
            }

            //if (_siteUrl != null)
            //    _authenticationMode = _site.UrlList[siteUrl];
            _authenticationMode = GetCurrentAuthenticationMode();

            if (_contextNodeHead != null /*_isRequestedResourceExistInRepository*/)
            {
                _nodeType = initInfo.RequestedNodeHead.GetNodeType();
                _nodeId = initInfo.RequestedNodeHead.Id;
            }

            //_queryStringNodePropertyName = HttpContext.Current.Request.QueryString[QUERYSTRING_NODEPROPERTY_KEY];
            _queryStringNodePropertyName = context.Request.QueryString[QUERYSTRING_NODEPROPERTY_KEY];
            if (_queryStringNodePropertyName != null)
                _queryStringNodePropertyName = _queryStringNodePropertyName.Replace('$', '#');

            BinaryHandlerRequestedNodeHead = initInfo.BinaryHandlerRequestedNodeHead;
        }
Example #27
0
        //---- when create new
        internal static NodeData CreateNewNodeData(Node parent, NodeType nodeType, ContentListType listType, int listId)
        {
            var listTypeId = listType == null ? 0 : listType.Id;
            var parentId = parent == null ? 0 : parent.Id;
            var userId = AccessProvider.Current.GetOriginalUser().Id;
            var name = String.Concat(nodeType.Name, "-", DateTime.Now.ToString("yyyyMMddHHmmss")); //Guid.NewGuid().ToString();
            var path = (parent == null) ? "/" + name : RepositoryPath.Combine(parent.Path, name);
            var now = DateTime.Now;
            var versionNumber = new VersionNumber(1, 0, VersionStatus.Approved);
            //---- when create new
            var privateData = new NodeData(nodeType, listType)
            {
                IsShared = false,
                SharedData = null,

                Id = 0,
                NodeTypeId = nodeType.Id,
                ContentListTypeId = listTypeId,
                ContentListId = listId,

                ParentId = parentId,
                Name = name,
                Path = path,
                Index = 0,
                IsDeleted = false,
                IsInherited = true,

                NodeCreationDate = now,
                NodeModificationDate = now,
                NodeCreatedById = userId,
                NodeModifiedById = userId,

                VersionId = 0,
                Version = versionNumber,
                CreationDate = now,
                ModificationDate = now,
                CreatedById = userId,
                ModifiedById = userId,

                Locked = false,
                LockedById = 0,
                ETag = null,
                LockType = 0,
                LockTimeout = 0,
                LockDate = DataProvider.Current.DateTimeMinValue,
                LockToken = null,
                LastLockUpdate = DataProvider.Current.DateTimeMinValue,
            };
            privateData.ModificationDateChanged = false;
            privateData.ModifiedByIdChanged = false;
            privateData.NodeModificationDateChanged = false;
            privateData.NodeModifiedByIdChanged = false;
            return privateData;
        }
Example #28
0
        private string GetPresenterViewLocations(string nodePath, NodeType nodeType)
        {
            var action = HttpContext.Current.Request.Params[ActionParamName] ?? String.Empty;
            if (action.Length > 0)
                action = String.Concat("/", action, PresenterPagePostfix);

            string[] parts = nodePath.Split('/');

            var probs = new List<string>();

            var nt = nodeType;
            while (nt != null)
            {
                probs.Add(String.Concat("/{0}/", nt.Name, "{1}", action));
                nt = nt.Parent;
            }

            StringBuilder sb = new StringBuilder();
            sb.Append("<r>");
            sb.Append("<p>").Append(nodePath).Append("/").Append(PresenterFolderName).Append("/This").Append(PresenterPagePostfix).Append(action).Append("</p>");

            var position = parts.Length + 1;
            string partpath;
            while (position-- > 2)
            {
                partpath = string.Join("/", parts, 0, position);
                foreach (var prob in probs)
                    sb.AppendFormat("<p>{0}{1}</p>", partpath, string.Format(prob, PresenterFolderName, PresenterPagePostfix));
            }
            partpath = "/Root/System";
            foreach (var prob in probs)
                sb.AppendFormat("<p>{0}{1}</p>", partpath, string.Format(prob, PresenterFolderName, PresenterPagePostfix));

            sb.Append("</r>");
            return sb.ToString();
        }
Example #29
0
		//============================ NodeType

		public abstract void CreateNodeType(NodeType parent, string name, string className);
Example #30
0
        public static bool IsApplicationNodeType(NodeType nodeType)
        {
            if (nodeType.IsInstaceOfOrDerivedFrom("Page"))
                return true;

            Type appType = TypeHandler.GetType(nodeType.ClassName);
            return typeof(IHttpHandler).IsAssignableFrom(appType);
        }
Example #31
0
		/// <summary>
		/// When overridden in a derived class, deletes the passed NodeType.
		/// Before NodeType deleting removes all PropertyTypes from the passed NodeType but does not reset the 
		/// property values because all nodes instatiated by passed NodeType had been deleted.
		/// </summary>
		/// <param name="nodeType">NodeType to delete</param>
		public abstract void DeleteNodeType(NodeType nodeType);
        // ============================ NodeType

        public abstract void CreateNodeType(NodeType parent, string name, string className);
Example #33
0
		public void TypeCollection_CopyTo_1()
		{
			SchemaEditor ed = new SchemaEditor();
			var nodeTypes = TypeCollectionAccessor<NodeType>.Create(ed);
			ed.Load();
			nodeTypes.Add(ed.NodeTypes[0]);
			nodeTypes.Add(ed.NodeTypes[1]);
			nodeTypes.Add(ed.NodeTypes[2]);
			NodeType[] copy = new NodeType[4];
			nodeTypes.CopyTo(copy, 1);
			Assert.IsTrue(copy[1] == ed.NodeTypes[0] && copy[2] == ed.NodeTypes[1] && copy[3] == ed.NodeTypes[2]);
		}
 public abstract void ModifyNodeType(NodeType nodeType, NodeType parent, string className);
Example #35
0
 public IEnumerable<string> GetAvailablePaths(string appName, string contextNodePath, NodeType nodeType)
 {
     return ApplicationResolver.GetAvailablePaths(contextNodePath, nodeType, this.AppFolderName, appName, Option);
 }
 /// <summary>
 /// When overridden in a derived class, deletes the passed NodeType.
 /// Before NodeType deleting removes all PropertyTypes from the passed NodeType but does not reset the
 /// property values because all nodes instantiated by passed NodeType had been deleted.
 /// </summary>
 /// <param name="nodeType">NodeType to delete</param>
 public abstract void DeleteNodeType(NodeType nodeType);