CN113361236A - Method and device for editing document - Google Patents
Method and device for editing document Download PDFInfo
- Publication number
- CN113361236A CN113361236A CN202010152533.7A CN202010152533A CN113361236A CN 113361236 A CN113361236 A CN 113361236A CN 202010152533 A CN202010152533 A CN 202010152533A CN 113361236 A CN113361236 A CN 113361236A
- Authority
- CN
- China
- Prior art keywords
- document
- editing
- target
- block chain
- locking
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 45
- 238000004590 computer program Methods 0.000 claims description 9
- 238000010586 diagram Methods 0.000 description 13
- 230000006870 function Effects 0.000 description 13
- 238000004891 communication Methods 0.000 description 8
- 230000000694 effects Effects 0.000 description 6
- 230000004048 modification Effects 0.000 description 6
- 238000012986 modification Methods 0.000 description 6
- 230000008569 process Effects 0.000 description 6
- 238000005516 engineering process Methods 0.000 description 5
- 238000012545 processing Methods 0.000 description 5
- 230000003287 optical effect Effects 0.000 description 4
- 238000013459 approach Methods 0.000 description 2
- 230000008901 benefit Effects 0.000 description 2
- 238000012217 deletion Methods 0.000 description 2
- 230000037430 deletion Effects 0.000 description 2
- 239000000835 fiber Substances 0.000 description 2
- 230000007246 mechanism Effects 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/62—Protecting access to data via a platform, e.g. using keys or access control rules
- G06F21/6218—Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
- G06F21/6227—Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database where protection concerns the structure of data, e.g. records, types, queries
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Bioethics (AREA)
- General Health & Medical Sciences (AREA)
- Computer Hardware Design (AREA)
- Health & Medical Sciences (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Document Processing Apparatus (AREA)
Abstract
The invention discloses a method and a device for editing a document, and relates to the technical field of computers. One embodiment of the method comprises: acquiring a document name and editing information from the editing request; locking the target document according to the document name; when the locking is successful, editing the target document based on the editing information; when the locking fails, the current content of the target document is read. The implementation mode can reduce the condition of document conflict and effectively ensure the authenticity and the correctness of document editing.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for editing a document.
Background
At present, when a plurality of people edit the same document, two implementation methods are generally available, one is editing in an off-line mode, and then merging is carried out when the document is submitted to a server, wherein a typical example is git; the other is real-time updating, such as google docs, when a plurality of people edit a document, the results edited by other people are displayed in the browser of the all people in real time.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
when different users edit the same part of content respectively, document conflict is easily caused.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for editing a document, which can reduce document conflict and effectively ensure authenticity and correctness of document editing.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method of editing a document.
The method for editing the document comprises the following steps:
acquiring a document name and editing information from the editing request;
locking the target document according to the document name;
when the locking is successful, editing the target document based on the editing information;
and when the locking fails, reading the current content of the target document.
Optionally, the editing information includes an editing position, an editing type, and editing content; and
acquiring a document name and editing information from the editing request, wherein the acquiring comprises the following steps:
receiving an editing request sent by a user;
and analyzing the editing request according to the sequence of the received editing request to obtain the document name, the editing position, the editing type and the editing content.
Optionally, locking the target document according to the document name includes:
inquiring a target block chain corresponding to the document name in a block chain network by using an intelligent contract; wherein the target blockchain is used for storing the target document;
if the document name is not inquired, creating a target block chain corresponding to the document name in the block chain network according to the document name, and locking the target block chain;
and if the document name is inquired, locking a target block chain corresponding to the document name in the block chain network.
Optionally, the edit type includes add, delete, and replace; and
editing the target document based on the editing information, including:
acquiring the target document from the latest sub-document block of the target block chain by using the intelligent contract; and
newly adding the edited content in the target document based on the editing position; and/or deleting the edited content from the target document based on the editing position; and/or, replacing the edited content in the target document based on the editing position;
caching the edited target document into a document cache;
and newly adding a sub file block in the target block chain to store the edited target document, and unlocking the target block chain.
Optionally, reading the current content of the target document includes:
reading the edited target document from the document cache according to the document name;
and displaying the edited target document to a user.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided an apparatus for editing a document.
The device for editing the document of the embodiment of the invention comprises:
the obtaining module is used for obtaining the document name and the editing information from the editing request;
the locking module is used for locking the target document according to the document name;
the editing module is used for editing the target document based on the editing information when the locking is successful;
and the reading module is used for reading the current content of the target document when the locking fails.
Optionally, the editing information includes an editing position, an editing type, and editing content; and
the acquisition module is further configured to:
receiving an editing request sent by a user;
and analyzing the editing request according to the sequence of the received editing request to obtain the document name, the editing position, the editing type and the editing content.
Optionally, the locking module is further configured to:
inquiring a target block chain corresponding to the document name in a block chain network by using an intelligent contract; wherein the target blockchain is used for storing the target document;
if the document name is not inquired, creating a target block chain corresponding to the document name in the block chain network according to the document name, and locking the target block chain;
and if the document name is inquired, locking a target block chain corresponding to the document name in the block chain network.
Optionally, the edit type includes add, delete, and replace; and
the editing module is further configured to:
acquiring the target document from the latest sub-document block of the target block chain by using the intelligent contract; and
newly adding the edited content in the target document based on the editing position; and/or deleting the edited content from the target document based on the editing position; and/or, replacing the edited content in the target document based on the editing position;
caching the edited target document into a document cache;
and newly adding a sub file block in the target block chain to store the edited target document, and unlocking the target block chain.
Optionally, the reading module is further configured to:
reading the edited target document from the document cache according to the document name;
and displaying the edited target document to a user.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided an electronic device for editing a document.
An electronic device for editing a document according to an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement a method of editing a document according to an embodiment of the present invention.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided a computer-readable storage medium.
A computer-readable storage medium of an embodiment of the present invention has stored thereon a computer program that, when executed by a processor, implements a method of editing a document of an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: because the document name and the editing information are obtained from the editing request; locking the target document according to the document name; when the locking is successful, editing the target document based on the editing information; when the locking fails, the technical means of reading the current content of the target document overcomes the technical problem that document conflict is easily caused when different users respectively edit the same part of content, thereby achieving the technical effects of reducing document conflict and effectively ensuring the authenticity and correctness of document editing.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a method of editing a document according to an embodiment of the present invention;
FIG. 2 is a diagram showing a main flow of a method of editing a document according to one referential embodiment of the present invention;
FIG. 3 is a schematic diagram of an application of a method of editing a document according to an embodiment of the invention;
FIG. 4 is a schematic diagram of the main modules of an apparatus for editing a document according to an embodiment of the present invention;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 6 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that the embodiments of the present invention and the technical features of the embodiments may be combined with each other without conflict.
Currently, when multiple people edit the same document, there are generally two implementation ways:
one is an off-line approach, such as git, where different users edit the same document locally, and when they are submitted to the server, they compare the document with the contents of the server to find out the differences, and then merge the differences. Although the method has low dependence on the server, does not need real-time online, and only needs to connect the server when submitting modification, the method is easy to generate conflict, when different users respectively edit the same part of content, the conflict can be generated, and git can require the users to solve the conflict, generally the users who submit modification later to solve the conflict;
the other is real-time updating, for example, Google docs has one or a group of servers, the server stores the document content being edited, Google docs sends the content edited by each user in real time, all users are connected with the server, and when any user modifies the document, the server sends a request to update the document content, and the latest document is displayed on the page. The document contents are downloaded from the server to the local by each user through respective client (e.g. browser), and displayed on the client for the user to edit. The google docs takes the whole document as a streaming media (stream), when a user edits the document, the current position is an offset from the beginning of the document, then the content input by the user is recorded, usually, the currently modified content is sent to the server within 1-5 seconds after the user modifies the content, after the modified content is sent to the server, the client can continue to record the next modified content of the user and continue to send the modified content to the server, and if the user continuously inputs the content, the client needs to frequently send data to the server.
When the two modes realize multi-user real-time editing, document conflicts are easily caused, for example:
the current document content of a shared document is as follows: "123456123456";
at a certain time, the user A and the user B edit the document at the same time, the user A adds the character string "abc" at the position of the offset 3, and the user B adds the character string "def" at the position of the offset 6, at this time, the document content of the user A is "123 abc 456123456", and the document content of the user B is "123456 def 123456";
after editing is finished, the user a and the user B respectively send the edited document content to the server, and ideally, the edited document content of the shared document is "123 abc456def 123456";
if the server receives the document content of the user A first, the edited document content of the shared document is '123 abc 456123456', and then receives the document content of the user B, the edited document content of the shared document is '123 adcdef 456123456', and the final document content is different from the expected (i.e. ideal situation);
if the server receives the document content of user B first, the edited document content of the shared document is "123456 def 123456", and then receives the document content of user A, the edited document content of the shared document is "123 abc456def 123456", and the final document content is the same as the expected content.
Document conflicts can arise when multiple people edit simultaneously online because the sequence in which the server executes the commands is not controllable.
Therefore, the method for editing the document of the embodiment of the invention adopts a locking mechanism, the document is locked before the user edits the document, the editing operation is executed after the locking is successful, and the locking is unlocked, and the failure of the locking indicates that the user edits the document at present and can not execute the editing operation, thereby reducing the situation that the document conflicts occur when a plurality of users edit the same document. Meanwhile, a block chain technology is adopted, and a method for editing a document in real time on line by multiple persons is provided by utilizing the decentralized anti-tampering characteristic of the block chain technology, so that the authenticity and the correctness of document editing can be effectively guaranteed.
Fig. 1 is a schematic diagram of main steps of a method of editing a document according to an embodiment of the present invention.
As shown in fig. 1, the method for editing a document according to the embodiment of the present invention mainly includes the following steps:
step S101: and acquiring the document name and the editing information from the editing request.
For a scene in which a plurality of people edit the same document, the online real-time editing system stores the shared document, and a user in communication connection with the online real-time editing system through a client (such as a browser) can edit the shared document. After the user finishes editing, the user can send the editing request to the online real-time editing system to edit a certain document.
The editing information may include an editing position, an editing type, and editing content, where the editing position refers to which part of the document is edited at this time, the editing type refers to which operation is performed on the document, main editing types include addition, deletion, and replacement, and the editing content refers to which modification is performed on the document.
In the embodiment of the present invention, step S101 may be implemented by: receiving an editing request sent by a user; and analyzing the editing request according to the sequence of the received editing requests to obtain the document name, the editing position, the editing type and the editing content.
When a plurality of people edit the same document, the user can send the document editing through the editing request, and the editing requests sent by the users are analyzed in sequence, so that the editing requests are processed in order.
Step S102: and locking the target document according to the document name.
And after the document name is analyzed from the editing request, the target document can be determined, and in order to reduce the problem of document conflict, the target document can be locked, if the locking is successful, the step S103 is continuously executed, and if the locking is failed, the step S104 is continuously executed. In addition, locking refers to that a target document can only be edited by a user corresponding to an editing request which triggers a locking operation, and it is ensured that the target document can only be edited by one user at the same time.
In the embodiment of the present invention, step S102 may be implemented by: inquiring a target block chain corresponding to the document name in a block chain network by using an intelligent contract; if the document name is not inquired, creating a target block chain corresponding to the document name in the block chain network according to the document name, and locking the target block chain; and if the document name is inquired, locking a target block chain corresponding to the document name in the block chain network.
The method for editing the document in the embodiment of the present invention may store the shared document by using a block chain network, that is, the document contents edited by multiple persons are stored in the block chain network, which may be a block chain platform such as a super book, wherein each document block chain in the block chain network is used to store a target document, and each document block chain may further include a plurality of sub-document blocks connected in time sequence, and each document editing uses one sub-document block for storage. When a target document is locked, the document name can be searched in a block chain network by using an intelligent contract, namely a target block chain corresponding to the document name is found from each document block chain, the target block chain stores the target document, in the process, if the document name is not inquired (namely the target block chain is not found), the target document corresponding to the editing request does not exist, a block chain can be newly built as the target block chain, and the target block chain is locked after being found.
The method for editing the document, provided by the embodiment of the invention, provides a reliable storage scheme for multiple people to edit the shared document online in real time based on the block chain technology, and simultaneously combines the block chain technology with a locking mechanism, so that the problem of document conflict caused by uncontrollable sequence of commands executed by a server when multiple people edit online simultaneously is solved.
Block chain in narrow sense, the block chain is a chain data structure formed by combining data blocks in a sequential connection mode according to a time sequence, and a distributed account book which is guaranteed in a cryptographic mode and cannot be tampered and forged is guaranteed. Broadly, the blockchain technique is a completely new distributed infrastructure and computing approach that utilizes blockchain data structures to verify and store data, utilizes distributed node consensus algorithms to generate and update data, utilizes cryptography to secure data transmission and access, and utilizes intelligent contracts composed of automated script code to program and manipulate data. In order to ensure the transaction performance, the block chain requests are performed in a serial mode and are completely serial, the requests are sequenced firstly, and then the intelligent contract is executed by using a single thread, so that transaction confusion, data conflict and the like caused by out-of-order execution are avoided. Due to the tamper resistance of the block chain, the document content can be traced, the latest total document content can be uniformly inquired for each user, and the data inconsistency is avoided. Intelligent contract: the intelligent contracts are only certain code of a block chain encryption currency network running on a computer (or other nodes), and once the node executes the code, the contracts update a general ledger (hedger). A developer may write code for an intelligent contract. The intelligent contract may be used for any exchange activity between two/more parties. The code contains conditions that trigger the automatic execution of the contract. When the trigger condition of the intelligent contract is reached, the corresponding affair is executed, and the corresponding result is returned; when the query method in the executed intelligent contract returns a corresponding result, and when the newly added write method in the executed intelligent contract, the latest result is placed in the latest block.
Step S103: and editing the target document based on the editing information.
If the locking is successful, the user can edit the target document, and the editing operation on the target document is completed based on the editing information.
In the embodiment of the present invention, step S103 may be implemented by: acquiring a target document from the latest sub-document block of the target block chain by using an intelligent contract; newly adding the editing content in the target document based on the editing position; and/or deleting the edited content from the target document based on the editing position; and/or, replacing the edited content in the target document based on the editing position; caching the edited target document into a document cache; and newly adding a sub file block in the target block chain to store the edited target document, and unlocking the target block chain.
When the target document is edited based on the editing information, the target document is obtained from the latest sub-document block, namely the latest sub-document block in the target block chain, the target document with the latest content is stored in the latest sub-document block, the target document is edited such as adding, deleting and replacing according to the editing information, the edited target document is stored in two ways of caching the edited target document in a document cache and storing the newly added sub-document block respectively, and finally the target block chain is unlocked. The document cache is a system cache of an online real-time editing system, and is used for enabling other users to obtain the latest content of a target document during locking, so that the other users can edit the target document conveniently, for example, Redis is used as the system cache, and Redis is a high-performance key-value database.
Step S104: and reading and displaying the current content of the target document.
If the locking fails, it indicates that the user cannot edit the target document, and at this time, the current content of the target document (i.e., the basic content of the next editing) may be presented to the user.
In the embodiment of the present invention, step S104 may be implemented by: reading the edited target document from the document cache according to the document name; and displaying the edited target document to a user.
The edited target document stored in the document cache, that is, the latest content of the target document, on the basis of which the user can adjust editing information and the like.
As a preferred implementation manner, as shown in fig. 2, the method for editing a document according to the embodiment of the present invention can be implemented by referring to the following flow:
step S201: receiving an editing request sent by a user;
step S202: analyzing the editing request according to the sequence of the received editing request to obtain a document name, an editing position, an editing type and editing content;
step S203: inquiring a target block chain corresponding to the document name in the block chain network by using an intelligent contract, and locking the target block chain:
if the document name is not inquired, creating a target block chain corresponding to the document name in the block chain network according to the document name, and locking the newly-created target block chain; if the document name is inquired, directly locking the target block chain;
when the locking is successful, executing step S204; when the locking fails, executing step S208;
step S204: acquiring a target document from the latest sub-document block of the target block chain by using an intelligent contract;
step S205: editing the target document by using the intelligent contract:
newly adding edited content in the target document based on the editing position; and/or deleting the edited content from the target document based on the editing position; and/or, replacing the edited content in the target document based on the editing position;
step S206: caching the edited target document into a document cache;
step S207: newly adding a sub-file block in the target block chain to store the edited target document, and unlocking the target block chain;
step S208: reading the edited target document from the document cache according to the document name;
step S209: and displaying the edited target document to a user.
According to the method for editing the document, the document name and the editing information are obtained from the editing request; locking the target document according to the document name; when the locking is successful, editing the target document based on the editing information; when the locking fails, the technical means of reading the current content of the target document overcomes the technical problem that document conflict is easily caused when different users respectively edit the same part of content, thereby achieving the technical effects of reducing document conflict and effectively ensuring the authenticity and correctness of document editing.
In order to further illustrate the technical idea of the present invention, the technical solution of the present invention will now be described with reference to specific application scenarios.
As shown in fig. 3, it is assumed that user 1 accesses the online real-time editing system through machine a and user 2 through machine B, and machine a and machine B are clients for implementing editing operations, respectively, and the online real-time editing system may also have other machines. When the method for editing a document according to the embodiment of the present invention is applied, the following processes may be referred to:
1. after receiving the editing request of the user 1, the machine A executes distributed locking on a shared document (namely a target document) corresponding to the editing request, if the locking fails, the document content of the shared document is read from a cache, the edited document is returned after the editing failure, and if the editing failure does not occur, the 'zero' (namely a null value) is returned; if the locking is successful, triggering an execution function of the intelligent contract, acquiring a corresponding shared document (namely a target block chain) corresponding to the editing request from the block chain network, if the shared document does not exist at first, initializing the document content to be "" i.e. newly creating the shared document and locking, and then executing the editing request of the user 1 (namely executing the step 2);
it should be noted that, executing the distributed locking on the shared document is performed in a single machine (for example, machine a and machine B), and after the locking is successful, an editing request is initiated on the target block chain, and the target block chain receives the editing request and triggers an execution function of the intelligent contract. The execution function is a code written by a developer in advance, and the execution function has entry references, wherein the entry references are a document name, an editing position, an executed operation (namely an editing type) and an executed character string (namely an editing content) carried by an editing request in the embodiment of the invention;
2. an executing function of the intelligent contract initiates a request for editing a shared document, namely adding a character string 'abc' (namely new editing content) at a position (namely an editing position) of an offset 0, writing the latest document content 'abc' (namely an edited target document) into a redis cache, storing the document content in the redis cache by using a document name as a key, storing the current shared document 'abc' into a newly-built block A (namely a newly-added sub-document block), unlocking a target block chain, and returning the edited target document and the successful editing to a user 1;
3. after receiving the editing request of the user 2, the machine B also executes distributed locking on the shared document corresponding to the editing request in the machine B, if the locking fails, the editing request of the user 1 is not processed, at this time, the document content of the shared document is read from the cache, the edited document of the editing failure person is returned, and at this time, if the query fails, the "" is returned (namely, a null value); if the locking is successful, triggering an execution function of the intelligent contract, acquiring a shared document (namely a target block chain, at the moment, only including a block A) corresponding to the editing request from the block chain network, and acquiring the shared document 'abc' (namely the target document) from the block A (namely the latest sub-document block);
4. after the locking is successful, an execution function of the intelligent contract initiates a request for editing the shared document "abc", namely, a character string "edf" (namely, newly-added editing content) is added at the position of the offset 3 (namely, the editing position), the latest document content "abcedf" is written into a redis cache, the current document content "abcedf" is stored into the latest block B (namely, a newly-added sub-document block), then, a target block chain is unlocked, and the edited target document and the editing success are returned to the user 2, wherein the target block chain comprises a block A and a block B at this time;
the above steps 3-4 are repeated in a loop, so that the editing process of the shared document by multiple users can be completed, for example, a user can delete the character string "ce" (i.e. delete the edited content) at the position of the offset 2 (i.e. the editing position) by the way of steps 3-4, and the final target block chain includes the block a and the block B … … block N, so that the data change history of the shared document is recorded in a non-falsification manner.
Fig. 4 is a schematic diagram of main blocks of an apparatus for editing a document according to an embodiment of the present invention.
As shown in fig. 4, an apparatus 400 for editing a document according to an embodiment of the present invention includes: an acquisition module 401, a locking module 402, an editing module 403, and a reading module 404.
Wherein,
an obtaining module 401, configured to obtain a document name and editing information from the editing request;
a locking module 402, configured to lock the target document according to the document name;
an editing module 403, configured to edit the target document based on the editing information when the locking is successful;
and the reading module 404 is configured to read the current content of the target document when the locking fails.
Further, the edit information may include an edit position, an edit type, and an edit content.
In this embodiment of the present invention, the obtaining module 401 may further be configured to:
receiving an editing request sent by a user;
and analyzing the editing request according to the sequence of the received editing request to obtain the document name, the editing position, the editing type and the editing content.
In this embodiment of the present invention, the locking module 402 may further be configured to:
inquiring a target block chain corresponding to the document name in a block chain network by using an intelligent contract; wherein the target blockchain is used for storing the target document;
if the document name is not inquired, creating a target block chain corresponding to the document name in the block chain network according to the document name, and locking the target block chain;
and if the document name is inquired, locking a target block chain corresponding to the document name in the block chain network.
In addition, the edit type may include addition, deletion, and replacement.
In this embodiment of the present invention, the editing module 403 may further be configured to:
acquiring the target document from the latest sub-document block of the target block chain by using the intelligent contract; and
newly adding the edited content in the target document based on the editing position; and/or deleting the edited content from the target document based on the editing position; and/or, replacing the edited content in the target document based on the editing position;
caching the edited target document into a document cache;
and newly adding a sub file block in the target block chain to store the edited target document, and unlocking the target block chain.
In this embodiment of the present invention, the reading module 404 may further be configured to:
reading the edited target document from the document cache according to the document name;
and displaying the edited target document to a user.
According to the device for editing the document, the document name and the editing information are obtained from the editing request; locking the target document according to the document name; when the locking is successful, editing the target document based on the editing information; when the locking fails, the technical means of reading the current content of the target document overcomes the technical problem that document conflict is easily caused when different users respectively edit the same part of content, thereby achieving the technical effects of reducing document conflict and effectively ensuring the authenticity and correctness of document editing.
Fig. 5 illustrates an exemplary system architecture 500 of a method of editing a document or an apparatus for editing a document to which an embodiment of the present invention may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 serves to provide a medium for communication links between the terminal devices 501, 502, 503 and the server 505. Network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 501, 502, 503 to interact with a server 505 over a network 504 to receive or send messages or the like. The terminal devices 501, 502, 503 may have various communication client applications installed thereon, such as a shopping application, a web browser application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal devices 501, 502, 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 505 may be a server that provides various services, such as a background management server that supports shopping websites browsed by users using the terminal devices 501, 502, 503. The background management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (e.g., target push information and product information) to the terminal device.
It should be noted that the method for editing a document provided by the embodiment of the present invention is generally executed by the server 505, and accordingly, an apparatus for editing a document is generally disposed in the server 505.
It should be understood that the number of terminal devices, networks, and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 6, a block diagram of a computer system 600 suitable for use with a terminal device implementing an embodiment of the invention is shown. The terminal device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU)601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 601.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes an acquisition module, a locking module, an editing module, and a reading module. The names of these modules do not in some cases constitute a limitation to the module itself, and for example, the acquiring module may also be described as a "module that acquires a document name and editing information from an editing request".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: step S101: acquiring a document name and editing information from the editing request; step S102: locking the target document according to the document name; step S103: editing the target document based on the editing information; step S104: and reading and displaying the current content of the target document.
According to the technical scheme of the embodiment of the invention, the document name and the editing information are obtained from the editing request; locking the target document according to the document name; when the locking is successful, editing the target document based on the editing information; when the locking fails, the technical means of reading the current content of the target document overcomes the technical problem that document conflict is easily caused when different users respectively edit the same part of content, thereby achieving the technical effects of reducing document conflict and effectively ensuring the authenticity and correctness of document editing.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (12)
1. A method of editing a document, comprising:
acquiring a document name and editing information from the editing request;
locking the target document according to the document name;
when the locking is successful, editing the target document based on the editing information;
and when the locking fails, reading the current content of the target document.
2. The method according to claim 1, wherein the editing information includes an editing location, an editing type, and an editing content; and
acquiring a document name and editing information from the editing request, wherein the acquiring comprises the following steps:
receiving an editing request sent by a user;
and analyzing the editing request according to the sequence of the received editing request to obtain the document name, the editing position, the editing type and the editing content.
3. The method of claim 2, wherein locking the target document according to the document name comprises:
inquiring a target block chain corresponding to the document name in a block chain network by using an intelligent contract; wherein the target blockchain is used for storing the target document;
if the document name is not inquired, creating a target block chain corresponding to the document name in the block chain network according to the document name, and locking the target block chain;
and if the document name is inquired, locking a target block chain corresponding to the document name in the block chain network.
4. The method of claim 3, wherein the edit types include add, delete, and replace; and
editing the target document based on the editing information, including:
acquiring the target document from the latest sub-document block of the target block chain by using the intelligent contract; and
newly adding the edited content in the target document based on the editing position; and/or deleting the edited content from the target document based on the editing position; and/or, replacing the edited content in the target document based on the editing position;
caching the edited target document into a document cache;
and newly adding a sub file block in the target block chain to store the edited target document, and unlocking the target block chain.
5. The method of claim 4, wherein reading the current content of the target document comprises:
reading the edited target document from the document cache according to the document name;
and displaying the edited target document to a user.
6. An apparatus for editing a document, comprising:
the obtaining module is used for obtaining the document name and the editing information from the editing request;
the locking module is used for locking the target document according to the document name;
the editing module is used for editing the target document based on the editing information when the locking is successful;
and the reading module is used for reading the current content of the target document when the locking fails.
7. The apparatus according to claim 6, wherein the editing information includes an editing location, an editing type, and an editing content; and
the acquisition module is further configured to:
receiving an editing request sent by a user;
and analyzing the editing request according to the sequence of the received editing request to obtain the document name, the editing position, the editing type and the editing content.
8. The apparatus of claim 7, wherein the locking module is further configured to:
inquiring a target block chain corresponding to the document name in a block chain network by using an intelligent contract; wherein the target blockchain is used for storing the target document;
if the document name is not inquired, creating a target block chain corresponding to the document name in the block chain network according to the document name, and locking the target block chain;
and if the document name is inquired, locking a target block chain corresponding to the document name in the block chain network.
9. The apparatus of claim 8, wherein the edit types include add, delete, and replace; and
the editing module is further configured to:
acquiring the target document from the latest sub-document block of the target block chain by using the intelligent contract; and
newly adding the edited content in the target document based on the editing position; and/or deleting the edited content from the target document based on the editing position; and/or, replacing the edited content in the target document based on the editing position;
caching the edited target document into a document cache;
and newly adding a sub file block in the target block chain to store the edited target document, and unlocking the target block chain.
10. The apparatus of claim 9, wherein the reading module is further configured to:
reading the edited target document from the document cache according to the document name;
and displaying the edited target document to a user.
11. An electronic device for editing a document, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-5.
12. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010152533.7A CN113361236A (en) | 2020-03-06 | 2020-03-06 | Method and device for editing document |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010152533.7A CN113361236A (en) | 2020-03-06 | 2020-03-06 | Method and device for editing document |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113361236A true CN113361236A (en) | 2021-09-07 |
Family
ID=77524136
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010152533.7A Pending CN113361236A (en) | 2020-03-06 | 2020-03-06 | Method and device for editing document |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113361236A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115081404A (en) * | 2022-08-22 | 2022-09-20 | 佳瑛科技有限公司 | Block chain-based shared document editing management method and device |
CN116170527A (en) * | 2023-02-16 | 2023-05-26 | 南京金阵微电子技术有限公司 | Message editing method, message editing device, medium and electronic equipment |
CN117971795A (en) * | 2024-02-05 | 2024-05-03 | 陕西巨微图书文化传播有限公司 | Multi-level associated file retrieving and storing method |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20180173719A1 (en) * | 2016-12-16 | 2018-06-21 | International Business Machines Corporation | Shared document editing in the blockchain |
US20190236559A1 (en) * | 2018-01-31 | 2019-08-01 | Salesforce.Com, Inc. | Systems, methods, and apparatuses for implementing smart flow contracts using distributed ledger technologies in a cloud based computing environment |
CN110309494A (en) * | 2019-05-31 | 2019-10-08 | 深圳壹账通智能科技有限公司 | Method, apparatus and computer equipment based on page end synchro edit document |
KR102038088B1 (en) * | 2019-04-03 | 2019-11-26 | 주식회사 한국정보보호경영연구소 | System for managing disigtal documents based on block chain providing digital signet |
-
2020
- 2020-03-06 CN CN202010152533.7A patent/CN113361236A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20180173719A1 (en) * | 2016-12-16 | 2018-06-21 | International Business Machines Corporation | Shared document editing in the blockchain |
US20190236559A1 (en) * | 2018-01-31 | 2019-08-01 | Salesforce.Com, Inc. | Systems, methods, and apparatuses for implementing smart flow contracts using distributed ledger technologies in a cloud based computing environment |
KR102038088B1 (en) * | 2019-04-03 | 2019-11-26 | 주식회사 한국정보보호경영연구소 | System for managing disigtal documents based on block chain providing digital signet |
CN110309494A (en) * | 2019-05-31 | 2019-10-08 | 深圳壹账通智能科技有限公司 | Method, apparatus and computer equipment based on page end synchro edit document |
Non-Patent Citations (3)
Title |
---|
ANDREW S.TANENBAUM: "现代操作系统", vol. 1, 30 November 1999, 机械工业出版社, pages: 350 * |
天津滨海迅腾科技集团有限公司: "软件工程", vol. 1, 31 January 2017, 南开大学出版社, pages: 174 * |
郭拥宾;施运梅;李宁;: "基于文档标注和锁的一致性维护方法", 计算机工程与设计, no. 08, 16 August 2016 (2016-08-16) * |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115081404A (en) * | 2022-08-22 | 2022-09-20 | 佳瑛科技有限公司 | Block chain-based shared document editing management method and device |
CN115081404B (en) * | 2022-08-22 | 2022-11-15 | 佳瑛科技有限公司 | Block chain-based shared document editing management method and device |
CN116170527A (en) * | 2023-02-16 | 2023-05-26 | 南京金阵微电子技术有限公司 | Message editing method, message editing device, medium and electronic equipment |
CN116170527B (en) * | 2023-02-16 | 2023-11-07 | 南京金阵微电子技术有限公司 | Message editing method, message editing device, medium and electronic equipment |
CN117971795A (en) * | 2024-02-05 | 2024-05-03 | 陕西巨微图书文化传播有限公司 | Multi-level associated file retrieving and storing method |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11740891B2 (en) | Providing access to a hybrid application offline | |
US11985192B2 (en) | Synchronized content library | |
CN109254733B (en) | Method, device and system for storing data | |
US20140304384A1 (en) | Uploading large content items | |
CN113361236A (en) | Method and device for editing document | |
CN109144785A (en) | Method and apparatus for Backup Data | |
US20200364241A1 (en) | Method for data synchronization between a source database system and target database system | |
US20160149827A1 (en) | Bulk uploading of multiple self-referencing objects | |
US20120215888A1 (en) | Interfacing distinct services for providing web based document manipulation access | |
US20150163326A1 (en) | Approaches for remotely unzipping content | |
CN113722007B (en) | Configuration method, device and system of VPN branch equipment | |
CN111984686A (en) | Data processing method and device | |
US10185759B2 (en) | Distinguishing event type | |
CN113760841B (en) | Method and device for realizing distributed lock | |
US20170091253A1 (en) | Interrupted synchronization detection and recovery | |
CN108537621B (en) | Data operation method and device | |
US11656950B2 (en) | Method, electronic device and computer program product for storage management | |
CN113010475B (en) | Method and apparatus for storing track data | |
US10917468B2 (en) | Systems and methods of re-associating content items | |
US10623491B2 (en) | Namespace translation | |
CN114896206A (en) | Retrieval method and device of object storage file system | |
CN114722125A (en) | Database transaction processing method, device, equipment and computer readable medium | |
CN116894010A (en) | Resource state processing method and device, electronic equipment and storage medium | |
CN117539832A (en) | File system object renaming method, device and computer program product | |
CN113760860A (en) | Data reading method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |