Directory tree authority determination method, device, storage medium and electronic device

By generating a directed node graph of the directory tree and using the dichotomy method to adjust the node depth, the problem of low efficiency in permission inheritance calculation caused by a large amount of directory data in the directory tree is solved, and faster permission calculation speed is achieved.

CN115438047BActive Publication Date: 2025-09-12INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211071660.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-02
Publication Date
2025-09-12
Estimated Expiration
2042-09-02

AI Technical Summary

Technical Problem

When a large amount of directory data exists in the directory tree, the efficiency of permission inheritance calculation is low, resulting in query timeouts and affecting the normal use of business functions.

Method used

By generating directed node graph information of the directory tree, using the binary method to adjust the node depth to judge the node authority, determining the node authority inheritance relationship, using the binary method to adjust the node depth to make it the same, and when the adjusted node depth is less than the preset node depth, determining the node authority as the preset authority of the target root node.

Benefits of technology

It improves the efficiency of directory data permission inheritance calculation, reduces the time complexity of node permission calculation, and speeds up permission calculation in the directory tree.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115438047B_ABST
    Figure CN115438047B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, storage medium and electronic device for determining permissions of a directory tree. Relating to the field of big data technology, the method comprises: reading directory data in a directory tree, generating directed node graph information of the directory tree according to the directory data; when the node depth of the first node is the same as the node depth of the second node, and when the first node is different from the second node, adjusting the node depth of the first node and the node depth of the second node by the same number of steps respectively by bisection; if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth, determining that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node. Through the present application, the problem of low efficiency in calculating the permissions inheritance of directory data in the related art when there is a large amount of directory data in the directory tree is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of big data technology, and in particular to a method, device, storage medium, and electronic device for determining permissions of a directory tree. Background Art

[0002] All of our bank's back-end systems involve permission management. This is a crucial component of the system, with the primary purpose of controlling permissions across the entire back-end management system and avoiding risks arising from missing permission controls or improper operations.

[0003] A backend system typically has various functions, some of which involve metadata management. This metadata is typically categorized and organized using a directory tree. Users can create subdirectories or metadata within a directory within the tree, as well as modify or delete a directory or metadata. Some backend systems for publishing information online have particularly strict permission management. Different users have varying permissions for different directories under different functions, including permissions for adding, modifying, deleting, and various levels of approval and publishing. This ensures that published content is compiled and approved by dedicated personnel.

[0004] Different business functions may have directories ranging from a few to hundreds of thousands. Assigning permissions to each directory individually would be a tremendous amount of work. Therefore, it's common to want a user with permission qa on directory a to also have that permission on all its descendant directories. If permission qb is assigned to a descendant directory b under directory a, then it's desirable to grant permission qb to all descendant directories under b instead of qa.

[0005] It can be found that when there are many directories in the directory tree and the user grants many permissions to individual directories in the directory tree, if the traditional traversal method is used to calculate the permissions, the query will time out and the relevant business functions will be completely unusable.

[0006] Currently, no effective solution has been proposed to the above-mentioned problems in related technologies. Summary of the Invention

[0007] The main purpose of this application is to provide a method, device, storage medium and electronic device for determining the permissions of a directory tree to solve the problem in the related art that the efficiency of the calculation of the permissions inheritance of directory data is low when there is a large amount of directory data in the directory tree.

[0008] In order to achieve the above objectives, according to one aspect of the present application, a method for determining permissions of a directory tree is provided. The method includes: reading directory data in a directory tree, wherein the directory data includes at least: a sub-target serial number, a parent directory serial number, and a directory name; generating directed node graph information of the directory tree according to the directory data, wherein at least one target root node in the directed node graph information carries preset permissions; judging whether the node depth of a first node and the node depth of a second node in the directed node graph information are the same, wherein the node depth of the first node is the distance between the first node and the target root node corresponding to the first node, and the node depth of the second node is the distance between the second node and the target root node corresponding to the second node; when the node depth of the first node and the node depth of the second node are the same, and when the first node and the second node are different, adjusting the node depth of the first node and the node depth of the second node by the same number of steps by using a dichotomy method to obtain an adjusted first target node and an adjusted second target node; if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth, determining that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node.

[0009] Furthermore, generating directed node graph information of the directory tree according to the directory data includes: assigning preset permissions to the target directory serial number in the directory data; and generating directed node graph information of the directory tree according to the preset permissions.

[0010] Furthermore, after determining whether the node depth of the first node in the directed node graph information is the same as the node depth of the second node, the method also includes: if the node depth of the first node in the directed node graph information is different from the node depth of the second node, obtaining the node depth of the first node and the node depth of the second node; adjusting the node depth of the first node and / or the node depth of the second node by bisection so that the node depth of the first node is the same as the node depth of the second node.

[0011] Furthermore, when the node depth of the first node is greater than the node depth of the second node, adjusting the node depth of the first node by bisection so that the node depth of the first node is the same as the node depth of the second node includes: adjusting the node depth of the first node by bisection according to a preset number of steps to obtain an adjusted first node; judging whether the node depth of the adjusted first node is greater than the node depth of the second node; if the node depth of the adjusted first node is greater than the node depth of the second node, executing the step of adjusting the node depth of the adjusted first node by bisection according to a preset number of steps so that the node depth of the first node is the same as the node depth of the second node.

[0012] Further, if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth, determining that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node includes: if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth, then the target predecessor node of the adjusted first target node is the same as the target predecessor node of the adjusted second target node; at the same time, determining the target predecessor node as the target root node, and determining that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node.

[0013] Furthermore, after determining whether the node depth of the first node in the directed node graph information is the same as the node depth of the second node, the method also includes: if the node depth of the first node in the directed node graph information is the same as the node depth of the second node, and the first node is the same as the second node, the permissions carried by the second node are used as the adjusted permissions of the first node.

[0014] Furthermore, before determining whether the node depth of the first node in the directed node graph information is the same as the node depth of the second node, the method also includes: obtaining the predecessor node of the first node and the predecessor node of the second node; if the predecessor node of the first node and the predecessor node of the second node are respectively granted corresponding permissions, then determining that the permissions carried by the first node are the permissions carried by the predecessor node of the first node, and determining that the permissions carried by the second node are the permissions carried by the predecessor node of the second node.

[0015] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a device for determining the permissions of a directory tree is provided. The device includes: a reading unit for reading the directory data in the directory tree, wherein the directory data at least includes: a sub-target serial number, a parent directory serial number, and a directory name; a generating unit for generating directed node graph information of the directory tree according to the directory data, wherein at least one target root node in the directed node graph information carries a preset permission; a judging unit for judging whether the node depth of the first node in the directed node graph information is the same as the node depth of the second node, wherein the node depth of the first node is the distance between the first node and the target root node corresponding to the first node, and the node depth of the second node is the distance between the second node and the target root node corresponding to the second node. the distance between the target root nodes; a first adjustment unit, used to, when the node depth of the first node is the same as the node depth of the second node, and when the first node is different from the second node, adjust the node depth of the first node and the node depth of the second node by the same number of steps through bisection to obtain the adjusted first target node and the adjusted second target node; a first determination unit, used to determine that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth.

[0016] Through the present application, the following steps are adopted: reading directory data in a directory tree, wherein the directory data includes at least: a sub-target serial number, a parent directory serial number, and a directory name; generating directed node graph information of the directory tree according to the directory data, wherein there is at least one target root node in the directed node graph information carrying preset permissions; judging whether the node depth of the first node and the node depth of the second node in the directed node graph information are the same, wherein the node depth of the first node is the distance between the first node and the target root node corresponding to the first node, and the node depth of the second node is the distance between the second node and the target root node corresponding to the second node; when the node depth of the first node is the same as the node depth of the second node, and the first node is different from the second node, the node depth of the first node and the node depth of the second node are adjusted by the same number of steps through dichotomy to obtain an adjusted first target node and an adjusted second target node; if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth, determining that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node. Through this application, the problem of low efficiency in calculating the inheritance of permissions of directory data in the related art when there is a large amount of directory data in the directory tree is solved. By judging whether the node depth of the first node in the directed node graph information is the same as the node depth of the second node, it is determined that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node, thereby achieving the effect of improving the efficiency of calculating the inheritance of permissions of directory data. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The accompanying drawings, which constitute part of this application, are intended to provide a further understanding of this application. The exemplary embodiments and descriptions of this application are intended to explain this application and do not constitute an improper limitation on this application. In the accompanying drawings:

[0018] Figure 1 This is a flowchart of a method for determining permissions of a directory tree according to an embodiment of the present application;

[0019] Figure 2 Schematic diagram of a directed graph of a method for determining permissions of a directory tree according to an embodiment of the present application;

[0020] Figure 3 This is a weighted directed graph diagram of the directory tree authority determination method provided by the embodiment of the present application. Figure 1 ;

[0021] Figure 4 This is a weighted directed graph diagram of the directory tree authority determination method provided by the embodiment of the present application. Figure 2 ;

[0022] Figure 5This is a weighted directed graph diagram of the directory tree authority determination method provided by the embodiment of the present application. Figure 3 ;

[0023] Figure 6 This is a weighted directed graph diagram of the directory tree authority determination method provided by the embodiment of the present application. Figure 4 ;

[0024] Figure 7 This is a weighted directed graph diagram of the directory tree authority determination method provided by the embodiment of the present application. Figure 5 ;

[0025] Figure 8 This is a weighted directed graph diagram of the directory tree authority determination method provided by the embodiment of the present application. Figure 6 ;

[0026] Figure 9 This is a weighted directed graph diagram of the directory tree authority determination method provided by the embodiment of the present application. Figure 7 ;

[0027] Figure 10 This is a weighted directed graph diagram of the directory tree authority determination method provided by the embodiment of the present application. Figure 8 ;

[0028] Figure 11 This is a weighted directed graph diagram of the directory tree authority determination method provided by the embodiment of the present application. Figure 9 ;

[0029] Figure 12 This is a weighted directed graph diagram of the directory tree authority determination method provided by the embodiment of the present application. Figure 10 ;

[0030] Figure 13 Schematic diagram of a directory tree authority determination device provided according to an embodiment of the present application;

[0031] Figure 14 This is a schematic diagram of an electronic device for determining permissions of a directory tree provided in an embodiment of the present application. DETAILED DESCRIPTION

[0032] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0033] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.

[0034] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0035] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.

[0036] The present invention will be described below in conjunction with preferred implementation steps. Figure 1 Flowchart of the method for determining the permissions of a directory tree according to an embodiment of the present application. Figure 1 As shown, the method includes the following steps:

[0037] Step S101, read directory data in the directory tree, wherein the directory data at least includes: a sub-target serial number, a parent directory serial number, and a directory name.

[0038] For example, the table structure of directory data in a directory tree is designed as an adjacency list. For example, the table structure of an adjacency list (Table 1) that generally includes a parent-child relationship of nodes is designed as follows:

[0039] Table 1

[0040]

[0041] For example, in the design of the rights management function, it is necessary to assign different rights to different directories based on the user (Table 2). The table structure is usually designed as follows:

[0042] Table 2

[0043]

[0044]

[0045] Each record in the table above indicates that user user_id has permission role_id for directory dir_id. These three fields form a tuple (user_id, dir_id, role_id). Each tuple is unique to ensure data is unique.

[0046] Step S102: Generate directed node graph information of the directory tree according to the directory data, wherein at least one target root node in the directed node graph information carries a preset permission.

[0047] Specifically, when the program starts, it first reads all the data in Table 1, stores the data in the program memory, and then constructs a tree-shaped directed graph of a directory tree to obtain information of the directed graph.

[0048] Specifically, generally speaking, the nodes of a directed graph can be displayed as follows Figure 2 As shown in the figure, node 1 represents the root directory of the entire directory tree, under which there are three subdirectories: node 2, node 3, and node 4, and so on.

[0049] Optionally, in the directory tree permission determination method provided in an embodiment of the present application, generating directed node graph information of the directory tree based on directory data includes: granting preset permissions to the target directory serial number in the directory data; generating directed node graph information of the directory tree based on the preset permissions.

[0050] It should be noted that this application first generates a weighted graph of directories based on the rights assigned by a user to some directories in the entire tree, such as Figure 3 As shown, the user has permission qa for node 1 and permission qb for node 3. According to the understanding of business functions, the user should have permission qb for any node in the subtree with node 3 as the root node, and permission qa for all nodes in the subtree with node 1 as the root node, excluding node 3 as the root node. Figure 4 As shown, we will now study how to calculate the authority of any node on each root node.

[0051] Step S103, determine whether the node depth of the first node in the directed node graph information is the same as the node depth of the second node, wherein the node depth of the first node is the distance between the first node and the target root node corresponding to the first node, and the node depth of the second node is the distance between the second node and the target root node corresponding to the second node.

[0052] For example, Figure 5As shown, two nodes, Node 7 and Node 12, are selected to calculate the user's permissions on these two nodes. It is also determined whether the node depth of Node 7 is the same as the node depth of Node 12. The node depth of Node 7 can be the path from Node 7 to Node 4, and the node depth of Node 12 can be the path from Node 12 to Node 4 (i.e., the distance in this application).

[0053] Now, if we select any n nodes in the tree, we need to determine what permissions the user has for these nodes. The algorithm is derived as follows:

[0054] First, assume that LCA(x,y) represents the intersection of the path from node x to the root node and the path from node y to the root node. It is also the node with the smallest depth on the path between x and y. Assume that fa[x,k] represents the 2 k The predecessor node of the layer, that is, moving 2 from x to the root node k The node reached by the first step. If the node does not exist, set fa[x,k] = 0. fa[x,0] is the parent node of x. So we can get: fa[x,k] = fa[fa[x,k-1],k-1].

[0055] This is similar to a continuous dynamic programming process, where the stage represents the node depth. Therefore, we can perform a BFS (breadth-first traversal) on the tree in hierarchical order. Before adding the node to the queue, we calculate the corresponding value of the node in the fa array, calculate the LCA(x,y) based on the fa array, and finally determine the permissions of node x and node y based on the LCA(x,y).

[0056] Optionally, in the method for determining the permissions of a directory tree provided in an embodiment of the present application, after determining whether the node depth of the first node in the directed node graph information is the same as the node depth of the second node, the method also includes: if the node depth of the first node in the directed node graph information is different from the node depth of the second node, obtaining the node depth of the first node and the node depth of the second node; adjusting the node depth of the first node and / or the node depth of the second node by bisection so that the node depth of the first node is the same as the node depth of the second node.

[0057] For example, select two nodes from any n nodes, obtain the node depths of the two nodes, and adjust the node depths through bisection to ensure that the depths of the two nodes are the same. The specific steps are as follows:

[0058] Optionally, in the method for determining the permissions of a directory tree provided in an embodiment of the present application, when the node depth of a first node is greater than the node depth of a second node, adjusting the node depth of the first node by bisection so that the node depth of the first node is the same as the node depth of the second node includes: adjusting the node depth of the first node by bisection according to a preset number of steps to obtain an adjusted first node; judging whether the node depth of the adjusted first node is greater than the node depth of the second node; if the node depth of the adjusted first node is greater than the node depth of the second node, executing the step of adjusting the node depth of the adjusted first node by bisection according to a preset number of steps so that the node depth of the first node is the same as the node depth of the second node.

[0059] For example, let depth[x] represent the depth of x and depth[y] represent the depth of y, as Figure 6 As shown, given two nodes x and y, depth[x] ≥ depth[y], we can use the binary search idea to adjust x to the same depth as y. Specifically, we try to move x up k = 2 logn ,…2 1 ,2 0 Steps (corresponding to the preset number of steps in this application), that is, the depth of x is continuously adjusted. Each time it moves, check whether the node depth reached by x is deeper than y. If so, let x = fa[x, k], that is, after moving x to the predecessor node of x, continue to use the binary search method to adjust the node depth of x until Figure 7 As shown, the node depths of x and y are adjusted to be the same. This application uses the dichotomy method to adjust the node depths of the two nodes to be the same, which greatly facilitates subsequent node jumping and improves the subsequent calculation speed of node permissions.

[0060] Optionally, in the method for determining the permissions of a directory tree provided in an embodiment of the present application, after determining whether the node depth of the first node in the directed node graph information is the same as the node depth of the second node, the method also includes: if the node depth of the first node in the directed node graph information is the same as the node depth of the second node, and the first node is the same as the second node, the permissions carried by the second node are used as the adjusted permissions of the first node.

[0061] For example, if the node depth of node x is adjusted to the same as that of node y, and after the adjustment, node x and node y coincide, that is, node x = y, it means that LCA(x, y) has been found. At this time, LCA(x, y) = y, and the permissions carried by node y are used as the permissions of node x after the node depth is adjusted.

[0062] Step S104, when the node depth of the first node is the same as the node depth of the second node, and the first node is different from the second node, the node depth of the first node and the node depth of the second node are adjusted by the same number of steps through bisection to obtain the adjusted first target node and the adjusted second target node.

[0063] For example, if the node depth of point x is adjusted to the same as that of node y, and the first node is different from the second node, that is, when node x≠y, we still use the binary idea to adjust x and y upward at the same time, while keeping the depth consistent and preventing them from intersecting. Specifically, we move x and y upward by k=2 at the same time. logn ,…2 1 ,2 0 Step (corresponding to the same step number in this application), the specific node jump adjustment details can be as follows Figure 8 As shown, if the predecessor nodes are found to be the same, there are too many jumps, so the number is reduced by half and the jump is 2. k Node location; Figure 9 As shown, there are still too many predecessor nodes, so we continue to reduce them by half and jump to 2 k-1 Node location and 2 k-2 Node location, such as Figure 10 As shown, it is found that the predecessor nodes are different. k-3 Stop shrinking, such as Figure 11 As shown, move x,y to this position, now from 2 k-3 Start jumping. Repeat the jumps to jump to the predecessor node that is farthest from the initial x,y position and different from it. This application uses the bisection method to adjust the node depths of the two nodes to be the same, thereby improving the subsequent calculation speed of the node authority.

[0064] Step S105 , if the adjusted node depth of the first target node and the adjusted node depth of the second target node are less than the preset node depth, determine that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node.

[0065] In step S104, we can jump to the farthest and different predecessor node from the initial positions of x and y, that is, fa[x,k]≠fa[y,k], which means they have not yet intersected. Then let x=fa[x,k] and y=fa[y,k]. At this time, x and y must be only one step away from intersecting, and their parent node fa[x,0] is LCA(x,y).

[0066] Optionally, in the method for determining the permissions of the directory tree provided in an embodiment of the present application, if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth, determining that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node includes: if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth, then the target predecessor node of the adjusted first target node is the same as the target predecessor node of the adjusted second target node; at the same time, determining the target predecessor node as the target root node, and determining that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node.

[0067] For example, Figure 12 As shown, fa[x, k] = fa[y, k], that is, the target predecessor node of the adjusted first target node is the same as the target predecessor node of the adjusted second target node, that is, after the jump, the node x and the node y have the same target predecessor node, and the target predecessor node is also LCA(x, y), and the target predecessor node is used as the root node of the x and y nodes, that is, Figure 13 Middle 2 0 The node permissions at are the permissions of nodes x and y.

[0068] Optionally, in the method for determining the permissions of a directory tree provided in an embodiment of the present application, before determining whether the node depth of the first node in the directed node graph information is the same as the node depth of the second node, the method also includes: obtaining the predecessor node of the first node and the predecessor node of the second node; if the predecessor node of the first node and the predecessor node of the second node are respectively granted corresponding permissions, then determining that the permissions carried by the first node are the permissions carried by the predecessor node of the first node, and determining that the permissions carried by the second node are the permissions carried by the predecessor node of the second node.

[0069] It should be noted that if a node is found to have reached the authorized predecessor node during the entire node jumping process, the authority of the node can be obtained directly based on the authorized predecessor node, and then a remaining unprocessed node can be added for calculation until the authority of all nodes is calculated, further improving the calculation speed of node authority. The event processing complexity of this application can be O(klogn), where k is the number of nodes.

[0070] In summary, the method for determining the permissions of a directory tree provided in an embodiment of the present application reads the directory data in the directory tree, wherein the directory data includes at least: a sub-target serial number, a parent directory serial number, and a directory name; generates directed node graph information of the directory tree based on the directory data, wherein at least one target root node in the directed node graph information carries preset permissions; determines whether the node depth of the first node and the node depth of the second node in the directed node graph information are the same, wherein the node depth of the first node is the distance between the first node and the target root node corresponding to the first node, and the node depth of the second node is the distance between the second node and the target root node corresponding to the second node; when the node depth of the first node is the same as the node depth of the second node, and the first node is different from the second node, the node depth of the first node and the node depth of the second node are adjusted by the same number of steps through dichotomy to obtain an adjusted first target node and an adjusted second target node; if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth, it is determined that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node. Through this application, the problem of low efficiency in calculating the inheritance of permissions of directory data in the related art when there is a large amount of directory data in the directory tree is solved. By judging whether the node depth of the first node in the directed node graph information is the same as the node depth of the second node, it is determined that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node, thereby achieving the effect of improving the efficiency of calculating the inheritance of permissions of directory data.

[0071] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0072] The present application also provides a directory tree permission determination device. It should be noted that the directory tree permission determination device of the present application embodiment can be used to execute the directory tree permission determination method provided in the present application embodiment. The following introduces the directory tree permission determination device provided in the present application embodiment.

[0073] Figure 13 Schematic diagram of a directory tree authority determination device according to an embodiment of the present application. Figure 13 As shown, the device includes: a reading unit 1301, a generating unit 1302, a judging unit 1303, a first adjusting unit 1304, and a first determining unit 1305.

[0074] Specifically, the reading unit 1301 is used to read the directory data in the directory tree, wherein the directory data at least includes: a sub-target serial number, a parent directory serial number, and a directory name;

[0075] A generating unit 1302 is configured to generate directed node graph information of a directory tree according to the directory data, wherein at least one target root node in the directed node graph information carries a preset permission;

[0076] A determining unit 1303 is configured to determine whether a node depth of a first node and a node depth of a second node in the directed node graph information are the same, wherein the node depth of the first node is the distance between the first node and a target root node corresponding to the first node, and the node depth of the second node is the distance between the second node and the target root node corresponding to the second node;

[0077] A first adjustment unit 1304 is configured to, when the node depth of the first node is the same as the node depth of the second node, and when the first node is different from the second node, adjust the node depth of the first node and the node depth of the second node by the same number of steps using a bisection method to obtain an adjusted first target node and an adjusted second target node;

[0078] The first determining unit 1305 is used to determine that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node if the adjusted node depth of the first target node and the adjusted node depth of the second target node are less than the preset node depth.

[0079] In summary, the permission determination device for a directory tree provided in an embodiment of the present application is used to read directory data in a directory tree through a reading unit 1301, wherein the directory data includes at least: a sub-target serial number, a parent directory serial number, and a directory name; a generating unit 1302 is used to generate directed node graph information of a directory tree according to the directory data, wherein there is at least one target root node in the directed node graph information that carries preset permissions; a judging unit 1303 is used to judge whether the node depth of a first node and the node depth of a second node in the directed node graph information are the same, wherein the node depth of the first node is the distance between the first node and the target root node corresponding to the first node, and the node depth of the second node is the distance between the second node and the target root node corresponding to the second node; a first adjusting unit 1304 is used to, when the node depth of the first node is the same as the node depth of the second node, and the node depth of the first node and the second node are the same, When the nodes are different, the node depth of the first node and the node depth of the second node are adjusted according to the same number of steps through the binary search method to obtain the adjusted first target node and the adjusted second target node; the first determination unit 1305 is used to determine that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth, which solves the problem of low efficiency in calculating the inheritance of permissions of directory data in the relevant technology when there is a large amount of directory data in the directory tree. By judging whether the node depth of the first node and the node depth of the second node in the directed node graph information are the same, it is determined that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node, thereby achieving the effect of improving the efficiency of calculating the inheritance of permissions of directory data.

[0080] Optionally, in the directory tree permission determination device provided in an embodiment of the present application, the generation unit includes: a setting module for granting preset permissions to the target directory serial number in the directory data; and a generation module for generating directed node graph information of the directory tree according to the preset permissions.

[0081] Optionally, in the directory tree permission determination device provided in the embodiment of the present application, the device also includes: a first acquisition unit, used to, after determining whether the node depth of the first node in the directed node graph information is the same as the node depth of the second node, obtain the node depth of the first node and the node depth of the second node if the node depth of the first node in the directed node graph information is not the same as the node depth of the second node; a second adjustment unit, used to adjust the node depth of the first node and / or the node depth of the second node by bisection so that the node depth of the first node is the same as the node depth of the second node.

[0082] Optionally, in the permission determination device for the directory tree provided in an embodiment of the present application, when the node depth of the first node is greater than the node depth of the second node, the second adjustment unit includes: an adjustment module, used to adjust the node depth of the first node according to a preset number of steps through bisection to obtain the adjusted first node; a judgment module, used to judge whether the node depth of the adjusted first node is greater than the node depth of the second node; and an execution module, used to execute the step of adjusting the node depth of the adjusted first node according to a preset number of steps through bisection if the node depth of the adjusted first node is greater than the node depth of the second node, so that the node depth of the first node is the same as the node depth of the second node.

[0083] Optionally, in the permission determination device for the directory tree provided in an embodiment of the present application, the determination unit includes: a comparison module, which is used to determine that if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth, the target predecessor node of the adjusted first target node is the same as the target predecessor node of the adjusted second target node; at the same time, a determination module is used to determine that the target predecessor node is the target root node, and to determine that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node.

[0084] Optionally, in the directory tree permission determination device provided in the embodiment of the present application, the device also includes: a second determination unit, which is used to, after determining whether the node depth of the first node in the directed node graph information is the same as the node depth of the second node, if the node depth of the first node in the directed node graph information is the same as the node depth of the second node, and the first node is the same as the second node, use the permission carried by the second node as the adjusted permission of the first node.

[0085] Optionally, in the directory tree permission determination device provided in an embodiment of the present application, the device also includes: a second acquisition unit, used to obtain the predecessor node of the first node and the predecessor node of the second node before determining whether the node depth of the first node in the directed node graph information is the same; a third determination unit, used to determine that the permission carried by the first node is the permission carried by the predecessor node of the first node, and determine that the permission carried by the second node is the permission carried by the predecessor node of the second node if the predecessor node of the first node and the predecessor node of the second node are respectively granted corresponding permissions.

[0086] The permission determination device of the directory tree includes a processor and a memory. The above-mentioned reading unit 1301, generation unit 1302, judgment unit 1303, first adjustment unit 1304, first determination unit 1305, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize the corresponding functions.

[0087] The processor contains a kernel, which calls the corresponding program unit from the memory. One or more kernels can be set, and the permissions of the directory tree can be determined by adjusting the kernel parameters.

[0088] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0089] An embodiment of the present invention provides a computer-readable storage medium storing a program, which implements a method for determining permissions of a directory tree when executed by a processor.

[0090] An embodiment of the present invention provides a processor, which is used to run a program, wherein a method for determining permissions of a directory tree is executed when the program is running.

[0091] like Figure 14 As shown, an embodiment of the present invention provides an electronic device, the device includes a processor, a memory and a program stored in the memory and runnable on the processor, and the processor implements the following steps when executing the program: reading directory data in a directory tree, wherein the directory data includes at least: a sub-target serial number, a parent directory serial number, and a directory name; generating directed node graph information of the directory tree according to the directory data, wherein at least one target root node in the directed node graph information carries a preset authority; judging whether the node depth of a first node in the directed node graph information is the same as the node depth of a second node, wherein the node depth of the first node is the node depth of the first node and the target root node corresponding to the first node. The distance between the nodes, the node depth of the second node is the distance between the second node and the target root node corresponding to the second node; when the node depth of the first node is the same as the node depth of the second node, and the first node is different from the second node, the node depth of the first node and the node depth of the second node are adjusted by the same step number through bisection to obtain the adjusted first target node and the adjusted second target node; if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth, it is determined that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node.

[0092] When the processor executes the program, the following steps are also implemented: assigning preset permissions to the target directory serial number in the directory data; and generating directed node graph information of the directory tree according to the preset permissions.

[0093] When the processor executes the program, the following steps are also implemented: after determining whether the node depth of the first node in the directed node graph information is the same as the node depth of the second node, if the node depth of the first node in the directed node graph information is different from the node depth of the second node, the node depth of the first node and the node depth of the second node are obtained; the node depth of the first node and / or the node depth of the second node are adjusted by bisection so that the node depth of the first node is the same as the node depth of the second node.

[0094] When the processor executes the program, the following steps are also implemented: adjusting the node depth of the first node according to a preset number of steps through a binary search method to obtain an adjusted first node; judging whether the node depth of the adjusted first node is greater than the node depth of the second node; if the node depth of the adjusted first node is greater than the node depth of the second node, executing the step of adjusting the node depth of the adjusted first node according to a preset number of steps through a binary search method to make the node depth of the first node the same as the node depth of the second node.

[0095] When the processor executes the program, the following steps are also implemented: if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth, the target predecessor node of the adjusted first target node is the same as the target predecessor node of the adjusted second target node; at the same time, the target predecessor node is determined to be the target root node, and the permissions carried by the first node and the permissions carried by the second node are determined to be the preset permissions carried by the target root node.

[0096] When the processor executes the program, the following steps are also implemented: if the node depth of the first node in the directed node graph information is the same as the node depth of the second node, and the first node is the same as the second node, the permissions carried by the second node are used as the adjusted permissions of the first node.

[0097] When the processor executes the program, the following steps are also implemented: obtaining the predecessor node of the first node and the predecessor node of the second node; if the predecessor node of the first node and the predecessor node of the second node are respectively granted corresponding permissions, then determining that the permissions carried by the first node are the permissions carried by the predecessor node of the first node, and determining that the permissions carried by the second node are the permissions carried by the predecessor node of the second node.

[0098] The devices in this article can be servers, PCs, PADs, mobile phones, etc.

[0099] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program initialized with the following method steps: reading directory data in a directory tree, wherein the directory data at least includes: a sub-target serial number, a parent directory serial number, and a directory name; generating directed node graph information of the directory tree based on the directory data, wherein at least one target root node in the directed node graph information carries a preset authority; determining whether the node depth of a first node in the directed node graph information is the same as the node depth of a second node, wherein the node depth of the first node is the distance between the first node and the target root node corresponding to the first node, and the node depth of the second node is the same as the node depth of the first node. The node depth of the two nodes is the distance between the second node and the target root node corresponding to the second node; when the node depth of the first node is the same as the node depth of the second node, and the first node is different from the second node, the node depth of the first node and the node depth of the second node are adjusted by the same number of steps through bisection to obtain the adjusted first target node and the adjusted second target node; if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth, it is determined that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node.

[0100] When executed on a data processing device, it is also suitable for executing an initialization program having the following method steps: assigning preset permissions to the target directory serial number in the directory data; and generating directed node graph information of the directory tree according to the preset permissions.

[0101] When executed on a data processing device, it is also suitable for executing an initialized program having the following method steps: after determining whether the node depth of the first node in the directed node graph information is the same as the node depth of the second node, if the node depth of the first node in the directed node graph information is different from the node depth of the second node, obtaining the node depth of the first node and the node depth of the second node; adjusting the node depth of the first node and / or the node depth of the second node by bisection so that the node depth of the first node is the same as the node depth of the second node.

[0102] When executed on a data processing device, it is also suitable for executing an initialized program having the following method steps: adjusting the node depth of the first node according to a preset number of steps by bisection to obtain an adjusted first node; judging whether the node depth of the adjusted first node is greater than the node depth of the second node; if the node depth of the adjusted first node is greater than the node depth of the second node, executing the step of adjusting the node depth of the adjusted first node according to a preset number of steps by bisection to make the node depth of the first node the same as the node depth of the second node.

[0103] When executed on a data processing device, it is also suitable for executing an initialization program with the following method steps: if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth, then the target predecessor node of the adjusted first target node is the same as the target predecessor node of the adjusted second target node; at the same time, the target predecessor node is determined to be the target root node, and the permissions carried by the first node and the permissions carried by the second node are determined to be the preset permissions carried by the target root node.

[0104] When executed on a data processing device, it is also suitable for executing an initialized program having the following method steps: if the node depth of the first node in the directed node graph information is the same as the node depth of the second node, and the first node is the same as the second node, the permissions carried by the second node are used as the adjusted permissions of the first node.

[0105] When executed on a data processing device, it is also suitable for executing an initialized program having the following method steps: obtaining a predecessor node of a first node and a predecessor node of a second node; if the predecessor node of the first node and the predecessor node of the second node are respectively assigned corresponding permissions, then determining that the permissions carried by the first node are the permissions carried by the predecessor node of the first node, and determining that the permissions carried by the second node are the permissions carried by the predecessor node of the second node.

[0106] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0107] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0108] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0109] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0110] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0111] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0112] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0113] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0114] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0115] The above are merely embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A method for determining permissions of a directory tree, characterized in that: include: Read directory data in the directory tree, wherein the directory data at least includes: a sub-target serial number, a parent directory serial number, and a directory name; Generating directed node graph information of the directory tree according to the directory data, wherein at least one target root node in the directed node graph information carries a preset permission; Determining whether a node depth of a first node and a node depth of a second node in the directed node graph information are the same, wherein the node depth of the first node is the distance between the first node and the target root node corresponding to the first node, and the node depth of the second node is the distance between the second node and the target root node corresponding to the second node; When the node depth of the first node is the same as the node depth of the second node, and the first node is different from the second node, the node depth of the first node and the node depth of the second node are adjusted by the same number of steps through a bisection method to obtain an adjusted first target node and the adjusted second target node; If the adjusted node depth of the first target node and the adjusted node depth of the second target node are less than the preset node depth, it is determined that the authority carried by the first node and the authority carried by the second node are the preset authority carried by the target root node.

2. The method according to claim 1, characterized in that Generating directed node graph information of the directory tree according to the directory data includes: Assigning preset permissions to the target directory serial number in the directory data; Generate directed node graph information of the directory tree according to the preset authority.

3. The method according to claim 1, characterized in that After determining whether the node depth of the first node and the node depth of the second node in the directed node graph information are the same, the method further includes: If the node depth of the first node and the node depth of the second node in the directed node graph information are different, obtaining the node depth of the first node and the node depth of the second node; The node depth of the first node and / or the node depth of the second node are adjusted by a bisection method, so that the node depth of the first node is the same as the node depth of the second node.

4. The method according to claim 3, characterized in that When the node depth of the first node is greater than the node depth of the second node, adjusting the node depth of the first node by a dichotomy method so that the node depth of the first node is the same as the node depth of the second node includes: Adjusting the node depth of the first node according to a preset number of steps using the dichotomy method to obtain an adjusted first node; Determining whether the adjusted node depth of the first node is greater than the node depth of the second node; If the node depth of the adjusted first node is greater than the node depth of the second node, the step of adjusting the node depth of the adjusted first node according to a preset number of steps by the bisection method is performed so that the node depth of the first node is the same as the node depth of the second node.

5. The method according to claim 1, wherein If the adjusted node depth of the first target node and the adjusted node depth of the second target node are less than a preset node depth, determining that the authority carried by the first node and the authority carried by the second node are the preset authority carried by the target root node includes: If the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth, the target predecessor node of the adjusted first target node and the target predecessor node of the adjusted second target node are the same; at the same time, The target predecessor node is determined to be the target root node, and the authority carried by the first node and the authority carried by the second node are determined to be the preset authority carried by the target root node.

6. The method according to claim 1, characterized in that After determining whether the node depth of the first node and the node depth of the second node in the directed node graph information are the same, the method further includes: If the node depth of the first node in the directed node graph information is the same as the node depth of the second node, and the first node is the same as the second node, the authority carried by the second node is used as the authority of the adjusted first node.

7. The method according to claim 1, characterized in that Before determining whether the node depth of the first node and the node depth of the second node in the directed node graph information are the same, the method further includes: Obtain a predecessor node of the first node and a predecessor node of the second node; If the predecessor node of the first node and the predecessor node of the second node are respectively granted corresponding permissions, the permissions carried by the first node are determined to be the permissions carried by the predecessor node of the first node, and the permissions carried by the second node are determined to be the permissions carried by the predecessor node of the second node.

8. A device for determining permissions of a directory tree, characterized in that: include: A reading unit is used to read directory data in the directory tree, wherein the directory data at least includes: Sub-target number, parent directory number, directory name; A generating unit, configured to generate directed node graph information of the directory tree according to the directory data, wherein at least one target root node in the directed node graph information carries a preset permission; a judging unit, configured to judge whether a node depth of a first node and a node depth of a second node in the directed node graph information are the same, wherein the node depth of the first node is a distance between the first node and the target root node corresponding to the first node, and the node depth of the second node is a distance between the second node and the target root node corresponding to the second node; a first adjustment unit, configured to, when the node depth of the first node is the same as the node depth of the second node and the first node is different from the second node, adjust the node depth of the first node and the node depth of the second node by the same number of steps through a bisection method to obtain an adjusted first target node and the adjusted second target node; The first determination unit is used to determine that the permissions carried by the first node and the permissions carried by the second node are the preset permissions carried by the target root node if the node depth of the adjusted first target node and the node depth of the adjusted second target node are less than the preset node depth.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a program, wherein the program executes the method according to any one of claims 1 to 7.

10. An electronic device, characterized in that: The method comprises one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Information processing method, device and equipment

    CN113094737A

  • Directory authorization method and device, processor and electronic equipment

    CN114491455A