From 7a8ce5b1fc87b59cf64c1006e96175c758c7a5b8 Mon Sep 17 00:00:00 2001 From: zqjhero Date: Sun, 24 Sep 2023 21:20:59 +0800 Subject: [PATCH 01/87] add contextPath before api url --- .../js/confluence-previews-plugin/onlyoffice-button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/js/confluence-previews-plugin/onlyoffice-button.js b/src/main/resources/js/confluence-previews-plugin/onlyoffice-button.js index 27f8b178..e772d618 100644 --- a/src/main/resources/js/confluence-previews-plugin/onlyoffice-button.js +++ b/src/main/resources/js/confluence-previews-plugin/onlyoffice-button.js @@ -39,7 +39,7 @@ define('cp/component/onlyoffice-button', [ var xhr = new XMLHttpRequest(); - xhr.open("POST", "/plugins/servlet/onlyoffice/confluence/previews/plugin/access", false); + xhr.open("POST", AJS.contextPath() + "/plugins/servlet/onlyoffice/confluence/previews/plugin/access", false); xhr.send(JSON.stringify({ attachmentId: attachmentId })); From a3c5949a1b8b4905697cce0e70ddc4ae66b66ddc Mon Sep 17 00:00:00 2001 From: Maria-Sukhova Date: Wed, 18 Oct 2023 17:24:51 +0300 Subject: [PATCH 02/87] edited de --- src/main/resources/lang-resource_de.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/lang-resource_de.properties b/src/main/resources/lang-resource_de.properties index 68f9032f..d43584c4 100644 --- a/src/main/resources/lang-resource_de.properties +++ b/src/main/resources/lang-resource_de.properties @@ -40,7 +40,7 @@ onlyoffice.configuration.message.error.mixedcontent=Mixed Active Content ist nic onlyoffice.editor.editlink=Mit ONLYOFFICE bearbeiten onlyoffice.editor.viewlink=Ansicht in ONLYOFFICE onlyoffice.editor.fillFormlink=Formular in ONLYOFFICE ausf\u00fcllen -onlyoffice.editor.createlink=Neues dokument +onlyoffice.editor.createlink=Neues Dokument onlyoffice.editor.createlink.tooltip=Erstellen neue datei onlyoffice.editor.dialog.filecreate.docx=Dokument onlyoffice.editor.dialog.filecreate.xlsx=Tabelle From b41278427bdab754957f3a0e744056a31beff7bb Mon Sep 17 00:00:00 2001 From: Maria-Sukhova Date: Wed, 18 Oct 2023 17:48:52 +0300 Subject: [PATCH 03/87] edited de --- src/main/resources/lang-resource_de.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/lang-resource_de.properties b/src/main/resources/lang-resource_de.properties index d43584c4..5b99f8cb 100644 --- a/src/main/resources/lang-resource_de.properties +++ b/src/main/resources/lang-resource_de.properties @@ -41,7 +41,7 @@ onlyoffice.editor.editlink=Mit ONLYOFFICE bearbeiten onlyoffice.editor.viewlink=Ansicht in ONLYOFFICE onlyoffice.editor.fillFormlink=Formular in ONLYOFFICE ausf\u00fcllen onlyoffice.editor.createlink=Neues Dokument -onlyoffice.editor.createlink.tooltip=Erstellen neue datei +onlyoffice.editor.createlink.tooltip=Neue Datei erstellen onlyoffice.editor.dialog.filecreate.docx=Dokument onlyoffice.editor.dialog.filecreate.xlsx=Tabelle onlyoffice.editor.dialog.filecreate.pptx=Pr\u00e4sentation From 842fc84e958aeec76f083e7294cc38864bdb9e83 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 30 Oct 2023 10:23:23 +0300 Subject: [PATCH 04/87] upgrade: org.json:json to version 20231013 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index defbaeef..08ab4fd2 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,7 @@ org.json json - 20230227 + 20231013 provided From b80f24a3110d4587ab14caa3bb880519fc7ceb80 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 10:40:13 +0300 Subject: [PATCH 05/87] add: dependency sdk com.onlyoffice.core-integration-sdk:0.0.1-SNAPSHOT --- 3rd-Party.license | 26 ++- licenses/3rd-Party.license | 26 ++- ...om.atlassian.confluence.confluence.licence | 201 ++++++++++++++++++ licenses/com.auth0.java-jwt.license | 21 -- licenses/commons-io.commons-io.license | 201 ++++++++++++++++++ ...g.apache.httpcomponents.httpclient.license | 201 ++++++++++++++++++ .../{JSON.license => org.json.json.license} | 0 pom.xml | 27 ++- 8 files changed, 659 insertions(+), 44 deletions(-) create mode 100644 licenses/com.atlassian.confluence.confluence.licence delete mode 100644 licenses/com.auth0.java-jwt.license create mode 100644 licenses/commons-io.commons-io.license create mode 100644 licenses/org.apache.httpcomponents.httpclient.license rename licenses/{JSON.license => org.json.json.license} (100%) diff --git a/3rd-Party.license b/3rd-Party.license index 5569e79c..fae3b3c7 100644 --- a/3rd-Party.license +++ b/3rd-Party.license @@ -1,18 +1,26 @@ Confluence ONLYOFFICE integration app uses code from the following 3rd party projects: -com.auth0.java-jwt - Java implementation of JSON Web Token (JWT) (https://github.com/auth0/java-jwt/blob/master/LICENSE) -License: MIT License -License File: com.auth0.java-jwt.license - -com.fasterxml.jackson.core.jackson-databind - General data-binding functionality for Jackson: works on core streaming API (https://github.com/FasterXML/jackson-databind/blob/2.16/LICENSE) +com.atlassian.confluence.confluence - Confluence Core License: Apache License 2.0 -License File: com.fasterxml.jackson.core.jackson-databind.license +License File: com.atlassian.confluence.confluence.licence javax.servlet-api - Java Servlet API (https://opensource.org/licenses/CDDL-1.0 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) License: CDDL, GPL 2.0 License File: javax.servlet-api.license -JSON - JSON is a light-weight, language independent, data interchange format. See http://www.JSON.org/ The files in this package implement JSON encoders/decoders in Java. It also includes the capability to convert between JSON and XML, HTTP headers, Cookies, and CDL. This is a reference implementation. (http://json.org/license.html) -License: JSON -License File: JSON.license +org.json.json - JSON is a light-weight, language independent, data interchange format. See http://www.JSON.org/ The files in this package implement JSON encoders/decoders in Java. It also includes the capability to convert between JSON and XML, HTTP headers, Cookies, and CDL. This is a reference implementation. (https://github.com/stleary/JSON-java/blob/master/LICENSE) +License: Public Domain +License File: org.json.json.license + +com.fasterxml.jackson.core.jackson-databind - General data-binding functionality for Jackson: works on core streaming API (https://github.com/FasterXML/jackson-databind/blob/2.16/LICENSE) +License: Apache License 2.0 +License File: com.fasterxml.jackson.core.jackson-databind.license + +org.apache.httpcomponents.httpclient - HTTPClient provides an efficient, up-to-date, and feature-rich package implementing the client side of the most recent HTTP standards and recommendations. (https://www.apache.org/licenses/LICENSE-2.0.txt) +License: Apache License 2.0 +License File: org.apache.httpcomponents.httpclient.license + +commons-io.commons-io - The Apache Commons IO library contains utility classes, stream implementations, file filters, file comparators, endian transformation classes, and much more. (https://www.apache.org/licenses/LICENSE-2.0.txt) +License: Apache License 2.0 +License File: commons-io.commons-io.license diff --git a/licenses/3rd-Party.license b/licenses/3rd-Party.license index 5569e79c..fae3b3c7 100644 --- a/licenses/3rd-Party.license +++ b/licenses/3rd-Party.license @@ -1,18 +1,26 @@ Confluence ONLYOFFICE integration app uses code from the following 3rd party projects: -com.auth0.java-jwt - Java implementation of JSON Web Token (JWT) (https://github.com/auth0/java-jwt/blob/master/LICENSE) -License: MIT License -License File: com.auth0.java-jwt.license - -com.fasterxml.jackson.core.jackson-databind - General data-binding functionality for Jackson: works on core streaming API (https://github.com/FasterXML/jackson-databind/blob/2.16/LICENSE) +com.atlassian.confluence.confluence - Confluence Core License: Apache License 2.0 -License File: com.fasterxml.jackson.core.jackson-databind.license +License File: com.atlassian.confluence.confluence.licence javax.servlet-api - Java Servlet API (https://opensource.org/licenses/CDDL-1.0 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) License: CDDL, GPL 2.0 License File: javax.servlet-api.license -JSON - JSON is a light-weight, language independent, data interchange format. See http://www.JSON.org/ The files in this package implement JSON encoders/decoders in Java. It also includes the capability to convert between JSON and XML, HTTP headers, Cookies, and CDL. This is a reference implementation. (http://json.org/license.html) -License: JSON -License File: JSON.license +org.json.json - JSON is a light-weight, language independent, data interchange format. See http://www.JSON.org/ The files in this package implement JSON encoders/decoders in Java. It also includes the capability to convert between JSON and XML, HTTP headers, Cookies, and CDL. This is a reference implementation. (https://github.com/stleary/JSON-java/blob/master/LICENSE) +License: Public Domain +License File: org.json.json.license + +com.fasterxml.jackson.core.jackson-databind - General data-binding functionality for Jackson: works on core streaming API (https://github.com/FasterXML/jackson-databind/blob/2.16/LICENSE) +License: Apache License 2.0 +License File: com.fasterxml.jackson.core.jackson-databind.license + +org.apache.httpcomponents.httpclient - HTTPClient provides an efficient, up-to-date, and feature-rich package implementing the client side of the most recent HTTP standards and recommendations. (https://www.apache.org/licenses/LICENSE-2.0.txt) +License: Apache License 2.0 +License File: org.apache.httpcomponents.httpclient.license + +commons-io.commons-io - The Apache Commons IO library contains utility classes, stream implementations, file filters, file comparators, endian transformation classes, and much more. (https://www.apache.org/licenses/LICENSE-2.0.txt) +License: Apache License 2.0 +License File: commons-io.commons-io.license diff --git a/licenses/com.atlassian.confluence.confluence.licence b/licenses/com.atlassian.confluence.confluence.licence new file mode 100644 index 00000000..7f8889ba --- /dev/null +++ b/licenses/com.atlassian.confluence.confluence.licence @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/licenses/com.auth0.java-jwt.license b/licenses/com.auth0.java-jwt.license deleted file mode 100644 index 72de587f..00000000 --- a/licenses/com.auth0.java-jwt.license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Auth0, Inc. (http://auth0.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/licenses/commons-io.commons-io.license b/licenses/commons-io.commons-io.license new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/licenses/commons-io.commons-io.license @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/licenses/org.apache.httpcomponents.httpclient.license b/licenses/org.apache.httpcomponents.httpclient.license new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/licenses/org.apache.httpcomponents.httpclient.license @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/licenses/JSON.license b/licenses/org.json.json.license similarity index 100% rename from licenses/JSON.license rename to licenses/org.json.json.license diff --git a/pom.xml b/pom.xml index 08ab4fd2..b6dfde5a 100644 --- a/pom.xml +++ b/pom.xml @@ -37,16 +37,29 @@ 20231013 provided - - com.auth0 - java-jwt - 4.0.0 - com.fasterxml.jackson.core jackson-databind 2.13.4.2 + + com.onlyoffice + core-integration-sdk + 0.0.1-SNAPSHOT + + + org.apache.httpcomponents + httpclient + 4.5.14 + provided + + + commons-io + commons-io + 2.13.0 + provided + + @@ -120,6 +133,10 @@ atlassian-public https://maven.atlassian.com/repository/public + + ossrh + http://192.168.4.26:8081/repository/maven-public + From e445daff1a71237f1d2a2ad73d88141aa323a9cf Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:05:11 +0300 Subject: [PATCH 06/87] add: implementations sdk managers (DocumentManager, JwtManager, SettingsManager, UrlManager, RequestManger) --- .../sdk/manager/document/DocumentManager.java | 24 +++ .../manager/document/DocumentManagerImpl.java | 127 +++++++++++ .../sdk/manager/security/JwtManager.java | 28 +++ .../sdk/manager/security/JwtManagerImpl.java | 115 ++++++++++ .../manager/settings/SettingsManagerImpl.java | 43 ++++ .../sdk/manager/url/UrlManager.java | 31 +++ .../sdk/manager/url/UrlManagerImpl.java | 201 ++++++++++++++++++ src/main/resources/atlassian-plugin.xml | 18 ++ 8 files changed, 587 insertions(+) create mode 100644 src/main/java/onlyoffice/sdk/manager/document/DocumentManager.java create mode 100644 src/main/java/onlyoffice/sdk/manager/document/DocumentManagerImpl.java create mode 100644 src/main/java/onlyoffice/sdk/manager/security/JwtManager.java create mode 100644 src/main/java/onlyoffice/sdk/manager/security/JwtManagerImpl.java create mode 100644 src/main/java/onlyoffice/sdk/manager/settings/SettingsManagerImpl.java create mode 100644 src/main/java/onlyoffice/sdk/manager/url/UrlManager.java create mode 100644 src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java diff --git a/src/main/java/onlyoffice/sdk/manager/document/DocumentManager.java b/src/main/java/onlyoffice/sdk/manager/document/DocumentManager.java new file mode 100644 index 00000000..0d2f5020 --- /dev/null +++ b/src/main/java/onlyoffice/sdk/manager/document/DocumentManager.java @@ -0,0 +1,24 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package onlyoffice.sdk.manager.document; + +public interface DocumentManager extends com.onlyoffice.manager.document.DocumentManager { + String getCorrectNewFileName(String fileName, String fileExt, Long pageID); + String getMimeType(String name); +} diff --git a/src/main/java/onlyoffice/sdk/manager/document/DocumentManagerImpl.java b/src/main/java/onlyoffice/sdk/manager/document/DocumentManagerImpl.java new file mode 100644 index 00000000..84fe4164 --- /dev/null +++ b/src/main/java/onlyoffice/sdk/manager/document/DocumentManagerImpl.java @@ -0,0 +1,127 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package onlyoffice.sdk.manager.document; + +import com.atlassian.confluence.core.ContentEntityManager; +import com.atlassian.confluence.core.ContentEntityObject; +import com.atlassian.confluence.pages.Attachment; +import com.atlassian.confluence.pages.AttachmentManager; +import com.atlassian.spring.container.ContainerManager; +import com.onlyoffice.manager.document.DefaultDocumentManager; +import com.onlyoffice.manager.settings.SettingsManager; +import onlyoffice.utils.attachment.AttachmentUtil; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; + +public class DocumentManagerImpl extends DefaultDocumentManager implements DocumentManager { + private final Logger log = LogManager.getLogger("onlyoffice.sdk.manager.document.DocumentManagerImpl"); + private static final int MAX_KEY_LENGTH = 20; + + private final AttachmentUtil attachmentUtil; + private final AttachmentManager attachmentManager; + + public DocumentManagerImpl(final SettingsManager settingsManager, final AttachmentUtil attachmentUtil, + final AttachmentManager attachmentManager) { + super(settingsManager); + this.attachmentUtil = attachmentUtil; + this.attachmentManager = attachmentManager; + } + + @Override + public String getDocumentKey(final String fileId, final boolean embedded) { + Long attachmentId = Long.parseLong(fileId); + String key = attachmentUtil.getCollaborativeEditingKey(attachmentId); + if (key == null) { + String hashCode = attachmentUtil.getHashCode(attachmentId); + key = generateRevisionId(hashCode); + } + + return embedded ? key + "_embedded" : key; + } + + @Override + public String getDocumentName(final String fileId) { + Long attachmentId = Long.parseLong(fileId); + + Attachment attachment = attachmentManager.getAttachment(attachmentId); + + if (attachment != null) { + return attachment.getFileName(); + } + + return null; + } + @Override + + public String getCorrectNewFileName(final String fileName, final String fileExtension, final Long pageID) { + ContentEntityManager contentEntityManager = + (ContentEntityManager) ContainerManager.getComponent("contentEntityManager"); + AttachmentManager attachmentManager = (AttachmentManager) ContainerManager.getComponent("attachmentManager"); + ContentEntityObject contentEntityObject = contentEntityManager.getById(pageID); + + List attachments = attachmentManager.getLatestVersionsOfAttachments(contentEntityObject); + String name = (fileName + "." + fileExtension).replaceAll("[*?:\"<>/|\\\\]", "_"); + int count = 0; + Boolean flag = true; + + while (flag) { + flag = false; + for (Attachment attachment : attachments) { + if (attachment.getFileName().equals(name)) { + count++; + name = fileName + " (" + count + ")." + fileExtension; + flag = true; + break; + } + } + } + + return name; + } + + public String getMimeType(final String name) { + Path path = new File(name).toPath(); + String mimeType = null; + try { + mimeType = Files.probeContentType(path); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + return mimeType != null ? mimeType : "application/octet-stream"; + } + + private String generateRevisionId(final String expectedKey) { + String result = expectedKey; + + if (result.length() > MAX_KEY_LENGTH) { + result = Integer.toString(result.hashCode()); + } + String key = result.replace("[^0-9-.a-zA-Z_=]", "_"); + key = key.substring(0, Math.min(key.length(), MAX_KEY_LENGTH)); + log.info("key = " + key); + return key; + } + +} diff --git a/src/main/java/onlyoffice/sdk/manager/security/JwtManager.java b/src/main/java/onlyoffice/sdk/manager/security/JwtManager.java new file mode 100644 index 00000000..412aa9d6 --- /dev/null +++ b/src/main/java/onlyoffice/sdk/manager/security/JwtManager.java @@ -0,0 +1,28 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package onlyoffice.sdk.manager.security; + +import java.util.Map; + +public interface JwtManager extends com.onlyoffice.manager.security.JwtManager { + String createInternalToken(Map payloadMap); + String verifyInternalToken(String token); + String createHash(String str); + String readHash(String base64); +} diff --git a/src/main/java/onlyoffice/sdk/manager/security/JwtManagerImpl.java b/src/main/java/onlyoffice/sdk/manager/security/JwtManagerImpl.java new file mode 100644 index 00000000..915b2111 --- /dev/null +++ b/src/main/java/onlyoffice/sdk/manager/security/JwtManagerImpl.java @@ -0,0 +1,115 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package onlyoffice.sdk.manager.security; + +import com.atlassian.sal.api.pluginsettings.PluginSettings; +import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; +import com.onlyoffice.manager.security.DefaultJwtManager; +import org.apache.commons.codec.binary.Hex; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; + +import java.security.MessageDigest; +import java.util.Base64; +import java.util.Map; +import java.util.Random; + +public class JwtManagerImpl extends DefaultJwtManager implements JwtManager { + private final Logger log = LogManager.getLogger("onlyoffice.sdk.manager.security.JwtManagerImpl"); + private static final int PLUGIN_SECRET_LENGTH = 32; + private static final String FILES_CONFLUENCE_SECRET = "Vskoproizvolny Salt par Chivreski"; + private final PluginSettings pluginSettings; + + public JwtManagerImpl(final PluginSettingsFactory pluginSettingsFactory, + final com.onlyoffice.manager.settings.SettingsManager settingsManagerSdk) { + super(settingsManagerSdk); + this.pluginSettings = pluginSettingsFactory.createGlobalSettings(); + } + + + public String createInternalToken(final Map payloadMap) { + return super.createToken(payloadMap, getPluginSecret()); + } + + public String verifyInternalToken(final String token) { + return verifyToken(token, getPluginSecret()); + } + + public String createHash(final String str) { + try { + String payload = getHashHex(str + FILES_CONFLUENCE_SECRET) + "?" + str; + + String base64 = Base64.getEncoder().encodeToString(payload.getBytes("UTF-8")); + return base64; + } catch (Exception ex) { + log.error(ex); + } + return ""; + } + + public String readHash(final String base64) { + try { + String str = new String(Base64.getDecoder().decode(base64), "UTF-8"); + + String[] payloadParts = str.split("\\?"); + + String payload = getHashHex(payloadParts[1] + FILES_CONFLUENCE_SECRET); + if (payload.equals(payloadParts[0])) { + return payloadParts[1]; + } + } catch (Exception ex) { + log.error(ex); + } + return ""; + } + + private String getHashHex(final String str) { + try { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + byte[] digest = md.digest(str.getBytes()); + String hex = Hex.encodeHexString(digest); + + return hex; + } catch (Exception ex) { + log.error(ex); + } + return ""; + } + + private String getPluginSecret() { + if (pluginSettings.get("onlyoffice.plugin-secret") == null + || pluginSettings.get("onlyoffice.plugin-secret").equals("")) { + Random random = new Random(); + char[] numbersAndLetters = ("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").toCharArray(); + + char[] randBuffer = new char[PLUGIN_SECRET_LENGTH]; + for (int i = 0; i < randBuffer.length; i++) { + randBuffer[i] = numbersAndLetters[random.nextInt(numbersAndLetters.length)]; + } + + String secret = new String(randBuffer); + + pluginSettings.put("onlyoffice.plugin-secret", secret); + + return secret; + } else { + return (String) pluginSettings.get("onlyoffice.plugin-secret"); + } + } +} diff --git a/src/main/java/onlyoffice/sdk/manager/settings/SettingsManagerImpl.java b/src/main/java/onlyoffice/sdk/manager/settings/SettingsManagerImpl.java new file mode 100644 index 00000000..5b6b307a --- /dev/null +++ b/src/main/java/onlyoffice/sdk/manager/settings/SettingsManagerImpl.java @@ -0,0 +1,43 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package onlyoffice.sdk.manager.settings; + +import com.atlassian.sal.api.pluginsettings.PluginSettings; +import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; +import com.onlyoffice.manager.settings.DefaultSettingsManager; + +public class SettingsManagerImpl extends DefaultSettingsManager { + private static final String SETTINGS_PREFIX = "onlyoffice."; + + private final PluginSettings pluginSettings; + + public SettingsManagerImpl(final PluginSettingsFactory pluginSettingsFactory) { + this.pluginSettings = pluginSettingsFactory.createGlobalSettings(); + } + + @Override + public String getSetting(final String name) { + return (String) pluginSettings.get(SETTINGS_PREFIX + name); + } + + @Override + public void setSetting(final String name, final String value) { + pluginSettings.put(SETTINGS_PREFIX + name, value); + } +} diff --git a/src/main/java/onlyoffice/sdk/manager/url/UrlManager.java b/src/main/java/onlyoffice/sdk/manager/url/UrlManager.java new file mode 100644 index 00000000..aa3abb70 --- /dev/null +++ b/src/main/java/onlyoffice/sdk/manager/url/UrlManager.java @@ -0,0 +1,31 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package onlyoffice.sdk.manager.url; + +import com.onlyoffice.model.documenteditor.config.document.DocumentType; + +public interface UrlManager extends com.onlyoffice.manager.url.UrlManager { + String getAttachmentDiffUri(Long attachmentId); + String getHistoryInfoUri(Long attachmentId); + String getHistoryDataUri(Long attachmentId); + String getAttachmentDataUri(); + String getSaveAsUri(); + String getReferenceDataUri(Long pageId); + String getFaviconUrl(DocumentType documentType); +} diff --git a/src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java b/src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java new file mode 100644 index 00000000..9298f586 --- /dev/null +++ b/src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java @@ -0,0 +1,201 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package onlyoffice.sdk.manager.url; + +import com.atlassian.confluence.pages.Attachment; +import com.atlassian.confluence.pages.AttachmentManager; +import com.atlassian.confluence.setup.settings.SettingsManager; +import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; +import com.atlassian.confluence.user.ConfluenceUser; +import com.atlassian.confluence.util.GeneralUtil; +import com.atlassian.plugin.webresource.UrlMode; +import com.atlassian.plugin.webresource.WebResourceUrlProvider; +import com.atlassian.spring.container.ContainerManager; +import com.onlyoffice.manager.document.DocumentManager; +import com.onlyoffice.manager.url.DefaultUrlManager; +import com.onlyoffice.model.documenteditor.config.document.DocumentType; +import com.onlyoffice.model.settings.SettingsConstants; +import onlyoffice.sdk.manager.security.JwtManager; +import onlyoffice.utils.attachment.AttachmentUtil; + +import java.util.HashMap; +import java.util.Map; + +public class UrlManagerImpl extends DefaultUrlManager implements UrlManager { + + private final String apiServlet = "/plugins/servlet/onlyoffice/api"; + private final String docEditorServlet = "/plugins/servlet/onlyoffice/doceditor"; + private final String fileProviderServlet = "/plugins/servlet/onlyoffice/file-provider"; + private final String callbackServlet = "/plugins/servlet/onlyoffice/save"; + private final String historyServlet = "/plugins/servlet/onlyoffice/history"; + + private final WebResourceUrlProvider webResourceUrlProvider; + private final SettingsManager settingsManager; + + private final JwtManager jwtManager; + private final AttachmentUtil attachmentUtil; + private final DocumentManager documentManager; + + public UrlManagerImpl(final WebResourceUrlProvider webResourceUrlProvider, final SettingsManager settingsManager, + final JwtManager jwtManager, final AttachmentUtil attachmentUtil, + final DocumentManager documentManager, + final com.onlyoffice.manager.settings.SettingsManager settingsManagerSdk) { + super(settingsManagerSdk); + this.webResourceUrlProvider = webResourceUrlProvider; + this.settingsManager = settingsManager; + this.jwtManager = jwtManager; + this.attachmentUtil = attachmentUtil; + this.documentManager = documentManager; + } + + @Override + public String getFileUrl(final String fileId) { + ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + + Map params = new HashMap<>(); + + if (user != null) { + params.put("userKey", user.getKey().getStringValue()); + } + params.put("attachmentId", fileId); + params.put("action", "download"); + + String fileUri = + getConfluenceBaseUrl() + fileProviderServlet + "?token=" + jwtManager.createInternalToken(params); + + return fileUri; + } + + @Override + public String getCallbackUrl(final String fileId) { + ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + + Map params = new HashMap<>(); + params.put("userKey", user.getKey().getStringValue()); + params.put("attachmentId", fileId); + params.put("action", "callback"); + + String callbackUrl = getConfluenceBaseUrl() + + callbackServlet + + "?token=" + + jwtManager.createInternalToken(params); + + return callbackUrl; + } + + @Override + public String getGobackUrl(final String fileId) { + String viewPageAttachments = "/pages/viewpageattachments.action?pageId="; + AttachmentManager attachmentManager = + (AttachmentManager) ContainerManager.getComponent("attachmentManager"); + Attachment attachment = attachmentManager.getAttachment(Long.parseLong(fileId)); + return settingsManager.getGlobalSettings().getBaseUrl() + + viewPageAttachments + + attachment.getContainer().getContentId().asLong(); + } + + @Override + public String getCreateUrl(final String fileId) { + Long pageId = attachmentUtil.getAttachmentPageId(Long.parseLong(fileId)); + ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + + if (attachmentUtil.checkAccessCreate(user, pageId)) { + String fileName = documentManager.getDocumentName(fileId); + String extension = documentManager.getExtension(fileName); + DocumentType documentType = documentManager.getDocumentType(fileName); + + if (!extension.equals("docxf")) { + extension = documentManager.getDefaultExtension(documentType); + } + + return getConfluenceBaseUrl() + docEditorServlet + "?pageId=" + pageId + "&fileExt=" + extension; + } else { + return null; + } + } + + @Override + public String getTestConvertUrl(final String url) { + return getConfluenceBaseUrl() + "/plugins/servlet/onlyoffice/test"; + } + + public String getAttachmentDiffUri(final Long attachmentId) { + String hash = jwtManager.createHash(Long.toString(attachmentId)); + String diffAttachmentUrl = + getConfluenceBaseUrl() + historyServlet + "?type=diff&vkey=" + GeneralUtil.urlEncode(hash); + + return diffAttachmentUrl; + } + + public String getHistoryInfoUri(final Long attachmentId) { + String hash = jwtManager.createHash(Long.toString(attachmentId)); + String historyInfoUri = + getConfluenceBaseUrl() + historyServlet + "?type=info&vkey=" + GeneralUtil.urlEncode(hash); + + return historyInfoUri; + } + + public String getHistoryDataUri(final Long attachmentId) { + String hash = jwtManager.createHash(Long.toString(attachmentId)); + String historyDataUri = + getConfluenceBaseUrl() + historyServlet + "?type=data&vkey=" + GeneralUtil.urlEncode(hash); + + return historyDataUri; + } + public String getAttachmentDataUri() { + String attachmentDataUri = getConfluenceBaseUrl() + apiServlet + "?type=attachment-data"; + + return attachmentDataUri; + } + + public String getSaveAsUri() { + String saveAsUri = getConfluenceBaseUrl() + apiServlet + "?type=save-as"; + + return saveAsUri; + } + + public String getReferenceDataUri(final Long pageId) { + String referenceDataUri = getConfluenceBaseUrl() + apiServlet + "?type=reference-data&pageId=" + pageId; + + return referenceDataUri; + } + + public String getFaviconUrl(final DocumentType documentType) { + String nameIcon = "word"; + + if (documentType != null) { + nameIcon = documentType.name().toLowerCase(); + } + + return webResourceUrlProvider.getStaticPluginResourceUrl( + "onlyoffice.onlyoffice-confluence-plugin:onlyoffice-confluence-plugin-resources-editor", + nameIcon + ".ico", + UrlMode.ABSOLUTE + ); + } + + private String getConfluenceBaseUrl() { + String url = getSettingsManager().getSetting(SettingsConstants.PRODUCT_INNER_URL); + if (url == null || url.isEmpty()) { + return sanitizeUrl(settingsManager.getGlobalSettings().getBaseUrl()); + } else { + return sanitizeUrl(url); + } + } +} diff --git a/src/main/resources/atlassian-plugin.xml b/src/main/resources/atlassian-plugin.xml index d402f3b6..6c359e56 100644 --- a/src/main/resources/atlassian-plugin.xml +++ b/src/main/resources/atlassian-plugin.xml @@ -181,6 +181,24 @@ onlyoffice-download-as-action + + + com.onlyoffice.manager.request.RequestManager + + + onlyoffice.sdk.manager.security.JwtManager + + + onlyoffice.sdk.manager.url.UrlManager + + + onlyoffice.sdk.manager.document.DocumentManager + + + com.onlyoffice.manager.settings.SettingsManager + + + onlyoffice.managers.auth.AuthContext From 0daafb2df65681963178ab32443d052d9612f32f Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:14:05 +0300 Subject: [PATCH 07/87] add: implementations sdk services(CallbackService, ConfigService, SettingsValidationService, ConvertService) --- .../sdk/service/CallbackServiceImpl.java | 249 ++++++++++++++++++ .../sdk/service/ConfigServiceImpl.java | 86 ++++++ .../service/SettingsValidationService.java | 27 ++ .../SettingsValidationServiceImpl.java | 140 ++++++++++ src/main/resources/atlassian-plugin.xml | 13 + 5 files changed, 515 insertions(+) create mode 100644 src/main/java/onlyoffice/sdk/service/CallbackServiceImpl.java create mode 100644 src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java create mode 100644 src/main/java/onlyoffice/sdk/service/SettingsValidationService.java create mode 100644 src/main/java/onlyoffice/sdk/service/SettingsValidationServiceImpl.java diff --git a/src/main/java/onlyoffice/sdk/service/CallbackServiceImpl.java b/src/main/java/onlyoffice/sdk/service/CallbackServiceImpl.java new file mode 100644 index 00000000..4d822019 --- /dev/null +++ b/src/main/java/onlyoffice/sdk/service/CallbackServiceImpl.java @@ -0,0 +1,249 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package onlyoffice.sdk.service; + +import com.atlassian.confluence.pages.Attachment; +import com.atlassian.confluence.pages.AttachmentManager; +import com.atlassian.confluence.pages.persistence.dao.AttachmentDao; +import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; +import com.atlassian.confluence.user.ConfluenceUser; +import com.atlassian.sal.api.transaction.TransactionCallback; +import com.atlassian.sal.api.transaction.TransactionTemplate; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.onlyoffice.manager.request.RequestManager; +import com.onlyoffice.manager.security.JwtManager; +import com.onlyoffice.manager.settings.SettingsManager; + +import com.onlyoffice.model.convertservice.ConvertRequest; +import com.onlyoffice.model.convertservice.ConvertResponse; +import com.onlyoffice.model.documenteditor.Callback; +import com.onlyoffice.model.documenteditor.callback.Action; +import com.onlyoffice.model.documenteditor.callback.History; +import com.onlyoffice.model.documenteditor.callback.action.Type; +import com.onlyoffice.service.documenteditor.callback.DefaultCallbackService; +import com.onlyoffice.service.convert.ConvertService; +import onlyoffice.sdk.manager.document.DocumentManager; +import onlyoffice.sdk.manager.url.UrlManager; +import onlyoffice.utils.attachment.AttachmentUtil; +import org.apache.commons.io.IOUtils; +import org.apache.http.HttpEntity; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.List; + +public class CallbackServiceImpl extends DefaultCallbackService { + private final AttachmentUtil attachmentUtil; + private final ConvertService convertService; + private final RequestManager requestManager; + private final TransactionTemplate transactionTemplate; + private final AttachmentManager attachmentManager; + private final SettingsManager settingsManager; + private final UrlManager urlManager; + private final DocumentManager documentManager; + + public CallbackServiceImpl(final JwtManager jwtManager, final AttachmentUtil attachmentUtil, + final ConvertService convertService, final RequestManager requestManager, + final SettingsManager settingsManager, final TransactionTemplate transactionTemplate, + final AttachmentManager attachmentManager, final UrlManager urlManager, + final DocumentManager documentManager) { + super(jwtManager, settingsManager); + this.settingsManager = settingsManager; + this.attachmentUtil = attachmentUtil; + this.convertService = convertService; + this.requestManager = requestManager; + this.urlManager = urlManager; + this.transactionTemplate = transactionTemplate; + this.attachmentManager = attachmentManager; + this.documentManager = documentManager; + } + + public void handlerEditing(final Callback callback, final String fileId) throws Exception { + if (callback.getActions() != null) { + List actions = callback.getActions(); + if (actions.size() > 0) { + Action action = actions.get(0); + if (action.getType().equals(Type.CONNECTED)) { + ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + + if (user == null || !attachmentUtil.checkAccess(Long.valueOf(fileId), user, true)) { + throw new SecurityException("Access denied. User " + user + + " don't have the appropriate permissions to edit this document."); + } + + if (attachmentUtil.getCollaborativeEditingKey(Long.valueOf(fileId)) == null) { + String key = callback.getKey(); + attachmentUtil.setCollaborativeEditingKey(Long.valueOf(fileId), key); + } + } + } + } + } + + public void handlerSave(final Callback callback, final String fileId) throws Exception { + ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + if (user != null && attachmentUtil.checkAccess(Long.valueOf(fileId), user, true)) { + String fileType = callback.getFiletype(); + String downloadUrl = callback.getUrl(); + History history = callback.getHistory(); + String changesUrl = callback.getChangesurl(); + + Boolean forceSaveVersion = + attachmentUtil.getPropertyAsBoolean(Long.valueOf(fileId), "onlyoffice-force-save"); + + attachmentUtil.setCollaborativeEditingKey(Long.valueOf(fileId), null); + + if (forceSaveVersion) { + saveAttachmentFromUrl(Long.valueOf(fileId), downloadUrl, fileType, user, false); + attachmentUtil.removeProperty(Long.valueOf(fileId), "onlyoffice-force-save"); + attachmentUtil.removeAttachmentChanges(Long.valueOf(fileId)); + + File convertedFile = attachmentUtil.getConvertedFile(Long.valueOf(fileId)); + if (convertedFile.exists()) { + convertedFile.delete(); + } + } else { + saveAttachmentFromUrl(Long.valueOf(fileId), downloadUrl, fileType, user, true); + } + + ObjectMapper mapper = new ObjectMapper(); + + saveAttachmentChanges(Long.valueOf(fileId), mapper.writeValueAsString(history), changesUrl); + } else { + throw new SecurityException("Try save without access: " + user); + } + } + + public void handlerForcesave(final Callback callback, final String fileId) throws Exception { + ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + if (user != null && attachmentUtil.checkAccess(Long.valueOf(fileId), user, true)) { + if (settingsManager.getSettingBoolean("forcesave", false)) { + String fileType = callback.getFiletype(); + String downloadUrl = callback.getUrl(); + History history = callback.getHistory(); + String changesUrl = callback.getChangesurl(); + + Boolean forceSaveVersion = + attachmentUtil.getPropertyAsBoolean(Long.valueOf(fileId), "onlyoffice-force-save"); + + if (forceSaveVersion) { + saveAttachmentFromUrl(Long.valueOf(fileId), downloadUrl, fileType, user, false); + attachmentUtil.removeAttachmentChanges(Long.valueOf(fileId)); + } else { + String key = attachmentUtil.getCollaborativeEditingKey(Long.valueOf(fileId)); + attachmentUtil.setCollaborativeEditingKey(Long.valueOf(fileId), null); + + saveAttachmentFromUrl(Long.valueOf(fileId), downloadUrl, fileType, user, true); + attachmentUtil.setCollaborativeEditingKey(Long.valueOf(fileId), key); + attachmentUtil.setProperty(Long.valueOf(fileId), "onlyoffice-force-save", "true"); + } + + ObjectMapper mapper = new ObjectMapper(); + + saveAttachmentChanges(Long.valueOf(fileId), mapper.writeValueAsString(history), + changesUrl); + + File convertedFile = attachmentUtil.getConvertedFile(Long.valueOf(fileId)); + if (convertedFile.exists()) { + convertedFile.delete(); + } + } + } else { + throw new SecurityException("Try save without access: " + user); + } + } + + private void saveAttachmentFromUrl(final Long attachmentId, final String downloadUrl, final String fileType, + final ConfluenceUser user, final boolean newVersion) throws Exception { + String documentName = documentManager.getDocumentName(String.valueOf(attachmentId)); + String extension = documentManager.getExtension(documentName); + String url = urlManager.replaceToInnerDocumentServerUrl(downloadUrl); + + ConvertRequest convertRequest = ConvertRequest.builder() + .outputtype(extension) + .url(url) + .build(); + + if (!extension.equals(fileType)) { + ConvertResponse convertResponse = convertService.processConvert(convertRequest, + String.valueOf(attachmentId)); + url = convertResponse.getFileUrl(); + } + + requestManager.executeGetRequest(url, new RequestManager.Callback() { + @Override + public Void doWork(final Object response) throws Exception { + byte[] bytes = IOUtils.toByteArray(((HttpEntity) response).getContent()); + InputStream inputStream = new ByteArrayInputStream(bytes); + + if (newVersion) { + attachmentUtil.saveAttachmentAsNewVersion(attachmentId, inputStream, bytes.length, user); + } else { + attachmentUtil.updateAttachment(attachmentId, inputStream, bytes.length, user); + } + + return null; + } + }); + } + + private void saveAttachmentChanges(final Long attachmentId, final String history, final String changesUrl) + throws Exception { + Attachment attachment = attachmentManager.getAttachment(attachmentId); + + if (history != null && !history.isEmpty() && changesUrl != null && !changesUrl.isEmpty()) { + InputStream changesStream = new ByteArrayInputStream(history.getBytes(StandardCharsets.UTF_8)); + Attachment changes = + new Attachment("onlyoffice-changes.json", "application/json", changesStream.available(), ""); + changes.setContainer(attachment.getContainer()); + changes.setHidden(true); + + String innerChangesUrl = urlManager.replaceToInnerDocumentServerUrl(changesUrl); + requestManager.executeGetRequest(innerChangesUrl, new RequestManager.Callback() { + @Override + public Void doWork(final Object response) throws Exception { + byte[] bytes = IOUtils.toByteArray(((HttpEntity) response).getContent()); + InputStream streamDiff = new ByteArrayInputStream(bytes); + + Attachment diff = new Attachment("onlyoffice-diff.zip", "application/zip", bytes.length, ""); + diff.setContainer(attachment.getContainer()); + diff.setHidden(true); + + attachment.addAttachment(changes); + attachment.addAttachment(diff); + + AttachmentDao attDao = attachmentManager.getAttachmentDao(); + Object result = transactionTemplate.execute(new TransactionCallback() { + @Override + public Object doInTransaction() { + attDao.saveNewAttachment(changes, changesStream); + attDao.saveNewAttachment(diff, streamDiff); + attDao.updateAttachment(attachment); + return null; + } + }); + + return null; + } + }); + } + } +} diff --git a/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java b/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java new file mode 100644 index 00000000..bd6038f6 --- /dev/null +++ b/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java @@ -0,0 +1,86 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package onlyoffice.sdk.service; + +import com.atlassian.confluence.status.service.SystemInformationService; +import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; +import com.atlassian.confluence.user.ConfluenceUser; +import com.onlyoffice.manager.security.JwtManager; +import com.onlyoffice.manager.settings.SettingsManager; +import com.onlyoffice.manager.url.UrlManager; +import com.onlyoffice.model.common.User; +import com.onlyoffice.model.documenteditor.config.document.Permissions; +import com.onlyoffice.model.documenteditor.config.document.ReferenceData; +import com.onlyoffice.service.documenteditor.config.DefaultConfigService; +import com.onlyoffice.manager.document.DocumentManager; +import onlyoffice.utils.attachment.AttachmentUtil; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; + +public class ConfigServiceImpl extends DefaultConfigService { + + private final Logger log = LogManager.getLogger("onlyoffice.ConfigServiceImpl"); + private final SystemInformationService sysInfoService; + + private AttachmentUtil attachmentUtil; + + public ConfigServiceImpl(final DocumentManager documentManager, final UrlManager urlManager, + final JwtManager jwtManager, final SystemInformationService sysInfoService, + final AttachmentUtil attachmentUtil, final SettingsManager settingsManager) { + super(documentManager, urlManager, jwtManager, settingsManager); + this.sysInfoService = sysInfoService; + this.attachmentUtil = attachmentUtil; + } + + @Override + public ReferenceData getReferenceData(final String fileId) { + return ReferenceData.builder() + .fileKey(fileId) + .instanceId(sysInfoService.getConfluenceInfo().getBaseUrl()) + .build(); + } + + @Override + public Permissions getPermissions(final String fileId) { + ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + String fileName = getDocumentManager().getDocumentName(fileId); + + Boolean editPermission = attachmentUtil.checkAccess(Long.parseLong(fileId), user, true); + Boolean isEditable = super.getDocumentManager().isEditable(fileName) + || super.getDocumentManager().isFillable(fileName); + + return Permissions.builder() + .edit(editPermission && isEditable) + .build(); + } + + @Override + public User getUser() { + ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + + if (user != null) { + return User.builder() + .id(user.getName()) + .name(user.getFullName()) + .build(); + } else { + return super.getUser(); + } + } +} diff --git a/src/main/java/onlyoffice/sdk/service/SettingsValidationService.java b/src/main/java/onlyoffice/sdk/service/SettingsValidationService.java new file mode 100644 index 00000000..2c002700 --- /dev/null +++ b/src/main/java/onlyoffice/sdk/service/SettingsValidationService.java @@ -0,0 +1,27 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package onlyoffice.sdk.service; + +import com.onlyoffice.model.settings.validation.ValidationResult; + +import java.util.Map; + +public interface SettingsValidationService extends com.onlyoffice.service.settings.SettingsValidationService { + Map validateSettings(); +} diff --git a/src/main/java/onlyoffice/sdk/service/SettingsValidationServiceImpl.java b/src/main/java/onlyoffice/sdk/service/SettingsValidationServiceImpl.java new file mode 100644 index 00000000..86edfb01 --- /dev/null +++ b/src/main/java/onlyoffice/sdk/service/SettingsValidationServiceImpl.java @@ -0,0 +1,140 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package onlyoffice.sdk.service; + +import com.atlassian.sal.api.message.I18nResolver; +import com.onlyoffice.manager.request.RequestManager; +import com.onlyoffice.manager.settings.SettingsManager; +import com.onlyoffice.manager.url.UrlManager; +import com.onlyoffice.model.common.CommonResponse; +import com.onlyoffice.model.settings.validation.ValidationResult; +import com.onlyoffice.model.settings.validation.status.Status; +import com.onlyoffice.service.settings.DefaultSettingsValidationService; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; + +import java.util.HashMap; +import java.util.Map; + +public class SettingsValidationServiceImpl extends DefaultSettingsValidationService + implements SettingsValidationService { + private final Logger log = LogManager.getLogger("onlyoffice.ValidationSettingsServiceImpl"); + + private final I18nResolver i18n; + + public SettingsValidationServiceImpl(final I18nResolver i18n, final RequestManager requestManager, + final UrlManager urlManager, final SettingsManager settingsManager) { + super(requestManager, urlManager, settingsManager); + this.i18n = i18n; + } + + @Override + public Map validateSettings() { + Map result = new HashMap<>(); + + try { + result.put( + "documentServer", + checkDocumentServer() + ); + } catch (Exception e) { + log.error(e.getMessage(), e); + + result.put( + "documentServer", + ValidationResult.builder() + .status(Status.FAILED) + .error(CommonResponse.Error.CONNECTION) + .build() + ); + } + + try { + result.put( + "commandService", + checkCommandService() + ); + } catch (Exception e) { + log.error(e.getMessage(), e); + + result.put( + "commandService", + ValidationResult.builder() + .status(Status.FAILED) + .error(CommonResponse.Error.CONNECTION) + .build() + ); + } + + try { + result.put( + "convertService", + checkConvertService() + ); + } catch (Exception e) { + log.error(e.getMessage(), e); + + result.put( + "convertService", + ValidationResult.builder() + .status(Status.FAILED) + .error(CommonResponse.Error.CONNECTION) + .build() + ); + } + + if (result.get("documentServer").getStatus().equals(Status.FAILED)) { + result.get("documentServer") + .setMessage( + i18n.getText( + "onlyoffice.server.common.error." + result.get("documentServer") + .getError() + .toString() + .toLowerCase() + ) + ); + } + + if (result.get("commandService").getStatus().equals(Status.FAILED)) { + result.get("commandService") + .setMessage( + i18n.getText( + "onlyoffice.service.command.error." + result.get("commandService") + .getError() + .toString() + .toLowerCase() + ) + ); + } + + if (result.get("convertService").getStatus().equals(Status.FAILED)) { + result.get("convertService") + .setMessage( + i18n.getText( + "onlyoffice.service.convert.error." + result.get("convertService") + .getError() + .toString() + .toLowerCase() + ) + ); + } + + return result; + } +} diff --git a/src/main/resources/atlassian-plugin.xml b/src/main/resources/atlassian-plugin.xml index 6c359e56..16148499 100644 --- a/src/main/resources/atlassian-plugin.xml +++ b/src/main/resources/atlassian-plugin.xml @@ -197,6 +197,19 @@ com.onlyoffice.manager.settings.SettingsManager + + + com.onlyoffice.service.documenteditor.config.ConfigService + + + com.onlyoffice.service.convert.ConvertService + + + onlyoffice.sdk.service.SettingsValidationService + + + com.onlyoffice.service.documenteditor.callback.CallbackService + From b67a001fc0922ccbc3ed3e37c637867ba1558859 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:19:55 +0300 Subject: [PATCH 08/87] add: OnlyOfficeTestServlet --- .../onlyoffice/OnlyOfficeTestServlet.java | 73 +++++++++++++++++++ src/main/resources/atlassian-plugin.xml | 4 + 2 files changed, 77 insertions(+) create mode 100644 src/main/java/onlyoffice/OnlyOfficeTestServlet.java diff --git a/src/main/java/onlyoffice/OnlyOfficeTestServlet.java b/src/main/java/onlyoffice/OnlyOfficeTestServlet.java new file mode 100644 index 00000000..83cb7731 --- /dev/null +++ b/src/main/java/onlyoffice/OnlyOfficeTestServlet.java @@ -0,0 +1,73 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package onlyoffice; + +import com.onlyoffice.manager.settings.SettingsManager; +import onlyoffice.sdk.manager.security.JwtManager; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class OnlyOfficeTestServlet extends HttpServlet { + private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeTestServlet"); + private static final long serialVersionUID = 1L; + + private final JwtManager jwtManager; + private final SettingsManager settingsManager; + + public OnlyOfficeTestServlet(final JwtManager jwtManager, final SettingsManager settingsManager) { + this.jwtManager = jwtManager; + this.settingsManager = settingsManager; + } + + @Override + public void doGet(final HttpServletRequest request, final HttpServletResponse response) + throws ServletException, IOException { + if (settingsManager.isSecurityEnabled()) { + String jwth = settingsManager.getSecurityHeader(); + String header = request.getHeader(jwth); + String authorizationPrefix = settingsManager.getSecurityPrefix(); + String token = (header != null && header.startsWith(authorizationPrefix)) + ? header.substring(authorizationPrefix.length()) : header; + + if (token == null || token == "") { + throw new SecurityException("Expected JWT"); + } + + try { + String payload = jwtManager.verify(token); + } catch (Exception e) { + throw new SecurityException("JWT verification failed!"); + } + } + + String message = "Test file for conversion"; + + response.setContentType("text/plain"); + response.setContentLength(message.getBytes("UTF-8").length); + response.setHeader("Content-Disposition", "attachment; filename=test.txt"); + + response.getWriter().write(message); + } +} diff --git a/src/main/resources/atlassian-plugin.xml b/src/main/resources/atlassian-plugin.xml index 16148499..745e9db3 100644 --- a/src/main/resources/atlassian-plugin.xml +++ b/src/main/resources/atlassian-plugin.xml @@ -294,6 +294,10 @@ The ONLYOFFICE Formats. /onlyoffice/formats + + The ONLYOFFICE Test. + /onlyoffice/test + From 5cbd2162e69f355137640a38b3145db8cde1a3b5 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:23:22 +0300 Subject: [PATCH 09/87] changed: servlets with using sdk managers and services (OnlyOfficeAPIServlet, OnlyOfficeConfServlet, OnlyOfficeConvertServlet, OnlyOfficeEditorServlet, OnlyOfficeFileProviderServlet, OnlyOfficeFormatsServlet, OnlyOfficeHistoryServlet, OnlyOfficeSaveFileServlet) --- .../java/onlyoffice/OnlyOfficeAPIServlet.java | 77 +++-- .../onlyoffice/OnlyOfficeConfServlet.java | 295 +++++------------- .../onlyoffice/OnlyOfficeConvertServlet.java | 183 ++++++----- .../onlyoffice/OnlyOfficeEditorServlet.java | 94 ++++-- .../OnlyOfficeFileProviderServlet.java | 15 +- .../onlyoffice/OnlyOfficeFormatsServlet.java | 12 +- .../onlyoffice/OnlyOfficeHistoryServlet.java | 197 ++++-------- .../onlyoffice/OnlyOfficeSaveFileServlet.java | 265 ++-------------- 8 files changed, 378 insertions(+), 760 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java index 57a147d3..8c960176 100644 --- a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java @@ -23,19 +23,15 @@ import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.user.ConfluenceUser; import com.google.gson.Gson; -import onlyoffice.managers.configuration.ConfigurationManager; -import onlyoffice.managers.document.DocumentManager; -import onlyoffice.managers.jwt.JwtManager; -import onlyoffice.managers.url.UrlManager; +import com.onlyoffice.manager.request.RequestManager; +import com.onlyoffice.manager.settings.SettingsManager; +import com.onlyoffice.manager.security.JwtManager; +import com.onlyoffice.manager.url.UrlManager; +import onlyoffice.sdk.manager.document.DocumentManager; import onlyoffice.utils.attachment.AttachmentUtil; import onlyoffice.utils.parsing.ParsingUtil; import org.apache.commons.io.IOUtils; import org.apache.http.HttpEntity; -import org.apache.http.HttpException; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.json.JSONArray; @@ -59,24 +55,26 @@ public class OnlyOfficeAPIServlet extends HttpServlet { private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeAPIServlet"); private final SystemInformationService sysInfoService; + private final SettingsManager settingsManager; private final JwtManager jwtManager; private final DocumentManager documentManager; private final AttachmentUtil attachmentUtil; private final ParsingUtil parsingUtil; private final UrlManager urlManager; - private final ConfigurationManager configurationManager; + private final RequestManager requestManager; - public OnlyOfficeAPIServlet(final SystemInformationService sysInfoService, final JwtManager jwtManager, - final DocumentManager documentManager, final AttachmentUtil attachmentUtil, - final ParsingUtil parsingUtil, final UrlManager urlManager, - final ConfigurationManager configurationManager) { + public OnlyOfficeAPIServlet(final SystemInformationService sysInfoService, final SettingsManager settingsManager, + final JwtManager jwtManager, final DocumentManager documentManager, + final AttachmentUtil attachmentUtil, final ParsingUtil parsingUtil, + final UrlManager urlManager, final RequestManager requestManager) { this.sysInfoService = sysInfoService; + this.settingsManager = settingsManager; this.jwtManager = jwtManager; this.documentManager = documentManager; this.attachmentUtil = attachmentUtil; this.parsingUtil = parsingUtil; this.urlManager = urlManager; - this.configurationManager = configurationManager; + this.requestManager = requestManager; } @Override @@ -134,30 +132,23 @@ private void saveAs(final HttpServletRequest request, final HttpServletResponse return; } - downloadUrl = urlManager.replaceDocEditorURLToInternal(downloadUrl); + downloadUrl = urlManager.replaceToInnerDocumentServerUrl(downloadUrl); - try (CloseableHttpClient httpClient = configurationManager.getHttpClient()) { - HttpGet httpGet = new HttpGet(downloadUrl); + requestManager.executeGetRequest(downloadUrl, new RequestManager.Callback() { + @Override + public Void doWork(final Object response) throws Exception { + byte[] bytes = IOUtils.toByteArray(((HttpEntity) response).getContent()); + InputStream inputStream = new ByteArrayInputStream(bytes); - try (CloseableHttpResponse httpResponse = httpClient.execute(httpGet)) { - int status = httpResponse.getStatusLine().getStatusCode(); - HttpEntity entity = httpResponse.getEntity(); + log.info("size = " + bytes.length); - if (status == HttpStatus.SC_OK) { - byte[] bytes = IOUtils.toByteArray(entity.getContent()); - InputStream inputStream = new ByteArrayInputStream(bytes); + String fileName = attachmentUtil.getCorrectName(title, ext, pageId); + String mimeType = documentManager.getMimeType(fileName); - log.info("size = " + bytes.length); - - String fileName = documentManager.getCorrectName(title, ext, pageId); - String mimeType = documentManager.getMimeType(fileName); - - attachmentUtil.createNewAttachment(fileName, mimeType, inputStream, bytes.length, pageId, user); - } else { - throw new HttpException("Document Server returned code " + status); - } + attachmentUtil.createNewAttachment(fileName, mimeType, inputStream, bytes.length, pageId, user); + return null; } - } + }); } catch (Exception e) { throw new IOException(e.getMessage()); } @@ -188,14 +179,15 @@ private void attachmentData(final HttpServletRequest request, final HttpServletR if (attachmentUtil.checkAccess(attachmentId, user, false)) { Map data = new HashMap<>(); - String fileType = attachmentUtil.getFileExt(attachmentId); + String documentName = documentManager.getDocumentName(String.valueOf(attachmentId)); + String fileType = documentManager.getExtension(documentName); if (bodyJson.has("command")) { data.put("command", bodyJson.getString("command")); } data.put("fileType", fileType); - data.put("url", urlManager.getFileUri(attachmentId)); - if (jwtManager.jwtEnabled()) { + data.put("url", urlManager.getFileUrl(String.valueOf(attachmentId))); + if (settingsManager.isSecurityEnabled()) { JSONObject dataJSON = new JSONObject(gson.toJson(data)); data.put("token", jwtManager.createToken(dataJSON)); } @@ -264,12 +256,15 @@ private void referenceData(final HttpServletRequest request, final HttpServletRe JSONObject responseJson = new JSONObject(); - responseJson.put("fileType", attachmentUtil.getFileExt(attachmentId)); - responseJson.put("path", attachmentUtil.getFileName(attachmentId)); + String documentName = documentManager.getDocumentName(String.valueOf(attachmentId)); + String extension = documentManager.getExtension(documentName); + + responseJson.put("fileType", extension); + responseJson.put("path", documentName); responseJson.put("referenceData", referenceData); - responseJson.put("url", urlManager.getFileUri(attachmentId)); + responseJson.put("url", urlManager.getFileUrl(String.valueOf(attachmentId))); - if (jwtManager.jwtEnabled()) { + if (settingsManager.isSecurityEnabled()) { responseJson.put("token", jwtManager.createToken(responseJson)); } diff --git a/src/main/java/onlyoffice/OnlyOfficeConfServlet.java b/src/main/java/onlyoffice/OnlyOfficeConfServlet.java index 89fa9483..b9f9fea5 100644 --- a/src/main/java/onlyoffice/OnlyOfficeConfServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeConfServlet.java @@ -21,55 +21,54 @@ import com.atlassian.confluence.renderer.radeox.macros.MacroUtils; import com.atlassian.confluence.setup.settings.SettingsManager; import com.atlassian.confluence.util.velocity.VelocityUtils; -import com.atlassian.sal.api.pluginsettings.PluginSettings; -import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; import com.atlassian.sal.api.user.UserManager; import com.atlassian.spring.container.ContainerManager; -import onlyoffice.managers.configuration.ConfigurationManager; -import onlyoffice.managers.jwt.JwtManager; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.onlyoffice.model.settings.Settings; +import com.onlyoffice.model.settings.SettingsConstants; +import com.onlyoffice.model.settings.security.Security; +import com.onlyoffice.model.settings.validation.ValidationResult; +import onlyoffice.sdk.manager.document.DocumentManager; +import onlyoffice.sdk.manager.url.UrlManager; +import onlyoffice.sdk.service.SettingsValidationService; import onlyoffice.utils.parsing.ParsingUtil; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.io.IOUtils; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; -import org.json.JSONArray; -import org.json.JSONObject; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.beans.IntrospectionException; import java.io.IOException; import java.io.PrintWriter; -import java.io.StringWriter; import java.io.UnsupportedEncodingException; +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; import java.util.Map; public class OnlyOfficeConfServlet extends HttpServlet { private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeConfServlet"); + private final ObjectMapper objectMapper = new ObjectMapper(); + private final long serialVersionUID = 1L; - private static final int ERROR_INVALID_TOKEN = 6; private final UserManager userManager; - private final PluginSettingsFactory pluginSettingsFactory; - private final JwtManager jwtManager; - private final ConfigurationManager configurationManager; + private final com.onlyoffice.manager.settings.SettingsManager settingsManager; + private final DocumentManager documentManager; private final ParsingUtil parsingUtil; + private final SettingsValidationService settingsValidationService; - public OnlyOfficeConfServlet(final UserManager userManager, final PluginSettingsFactory pluginSettingsFactory, - final JwtManager jwtManager, final ConfigurationManager configurationManager, - final ParsingUtil parsingUtil) { + public OnlyOfficeConfServlet(final UserManager userManager, + final com.onlyoffice.manager.settings.SettingsManager settingsManager, + final DocumentManager documentManager, final UrlManager urlManager, + final ParsingUtil parsingUtil, + final SettingsValidationService settingsValidationService) { this.userManager = userManager; - this.pluginSettingsFactory = pluginSettingsFactory; - this.jwtManager = jwtManager; - this.configurationManager = configurationManager; + this.settingsManager = settingsManager; + this.documentManager = documentManager; this.parsingUtil = parsingUtil; + this.settingsValidationService = settingsValidationService; } @Override @@ -83,57 +82,49 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re return; } - PluginSettings pluginSettings = pluginSettingsFactory.createGlobalSettings(); - String apiUrl = (String) pluginSettings.get("onlyoffice.apiUrl"); - String jwtSecret = (String) pluginSettings.get("onlyoffice.jwtSecret"); - String docInnerUrl = (String) pluginSettings.get("onlyoffice.docInnerUrl"); - String confUrl = (String) pluginSettings.get("onlyoffice.confUrl"); - Boolean verifyCertificate = configurationManager.getBooleanPluginSetting("verifyCertificate", false); - Boolean forceSave = configurationManager.forceSaveEnabled(); - Boolean chat = configurationManager.getBooleanPluginSetting("chat", true); - Boolean compactHeader = configurationManager.getBooleanPluginSetting("compactHeader", false); - Boolean feedback = configurationManager.getBooleanPluginSetting("feedback", false); - Boolean helpMenu = configurationManager.getBooleanPluginSetting("helpMenu", true); - Boolean toolbarNoTabs = configurationManager.getBooleanPluginSetting("toolbarNoTabs", false); - String reviewDisplay = configurationManager.getStringPluginSetting("reviewDisplay", "original"); - Boolean demo = configurationManager.demoEnabled(); - Boolean demoAvailable = configurationManager.demoAvailable(true); - Map defaultCustomizableEditingTypes = configurationManager.getCustomizableEditingTypes(); - - if (apiUrl == null || apiUrl.isEmpty()) { - apiUrl = ""; - } - if (jwtSecret == null || jwtSecret.isEmpty()) { - jwtSecret = ""; - } - if (docInnerUrl == null || docInnerUrl.isEmpty()) { - docInnerUrl = ""; - } - if (confUrl == null || confUrl.isEmpty()) { - confUrl = ""; - } + Boolean demoAvailable = settingsManager.isDemoAvailable(); + Map defaultCustomizableEditingTypes = documentManager.getLossyEditableMap(); response.setContentType("text/html;charset=UTF-8"); PrintWriter writer = response.getWriter(); Map contextMap = MacroUtils.defaultVelocityContext(); - contextMap.put("docserviceApiUrl", apiUrl); - contextMap.put("docserviceInnerUrl", docInnerUrl); - contextMap.put("docserviceConfUrl", confUrl); - contextMap.put("docserviceJwtSecret", jwtSecret); - contextMap.put("verifyCertificate", verifyCertificate); - contextMap.put("forceSave", forceSave); - contextMap.put("chat", chat); - contextMap.put("compactHeader", compactHeader); - contextMap.put("feedback", feedback); - contextMap.put("helpMenu", helpMenu); - contextMap.put("toolbarNoTabs", toolbarNoTabs); - contextMap.put("reviewDisplay", reviewDisplay); - contextMap.put("docserviceDemo", demo); - contextMap.put("docserviceDemoAvailable", demoAvailable); - contextMap.put("pathApiUrl", configurationManager.getProperty("files.docservice.url.api")); - contextMap.put("defaultCustomizableEditingTypes", defaultCustomizableEditingTypes); + contextMap.put("demoAvailable", demoAvailable); + contextMap.put("pathApiUrl", settingsManager.getSDKSetting("integration-sdk.api.url")); + + if (settingsManager.getSetting(SettingsConstants.LOSSY_EDIT) == null + || settingsManager.getSetting(SettingsConstants.LOSSY_EDIT).isEmpty()) { + defaultCustomizableEditingTypes.put("txt", true); + defaultCustomizableEditingTypes.put("csv", true); + } + + contextMap.put("defaultCustomizableEditingTypes", documentManager.getLossyEditableMap()); + + try { + Map settings = settingsManager.getSettings(); + + if (settings.get("customization.review.reviewDisplay") == null + || settings.get("customization.review.reviewDisplay").isEmpty()) { + settings.put("customization.review.reviewDisplay", "ORIGINAL"); + } + + if (settings.get("customization.help") == null || settings.get("customization.help").isEmpty()) { + settings.put("customization.help", "true"); + } + + if (settings.get("customization.chat") == null || settings.get("customization.chat").isEmpty()) { + settings.put("customization.chat", "true"); + } + + contextMap.put("settings", settings); + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } writer.write(getTemplate(contextMap)); } @@ -157,157 +148,37 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r return; } - String apiUrl; - String docInnerUrl; - String jwtSecret; - PluginSettings pluginSettings = pluginSettingsFactory.createGlobalSettings(); - try { - JSONObject jsonObj = new JSONObject(body); - - Boolean demo = jsonObj.getBoolean("demo"); - configurationManager.selectDemo(demo); + Settings settings = objectMapper.readValue(body, Settings.class); - if (configurationManager.demoActive()) { - apiUrl = configurationManager.getDemo("url"); - docInnerUrl = configurationManager.getDemo("url"); - } else { - apiUrl = appendSlash(jsonObj.getString("apiUrl")); - jwtSecret = jsonObj.getString("jwtSecret"); - docInnerUrl = appendSlash(jsonObj.getString("docInnerUrl")); - Boolean verifyCertificate = jsonObj.getBoolean("verifyCertificate"); - pluginSettings.put("onlyoffice.apiUrl", apiUrl); - pluginSettings.put("onlyoffice.jwtSecret", jwtSecret); - pluginSettings.put("onlyoffice.docInnerUrl", docInnerUrl); - pluginSettings.put("onlyoffice.verifyCertificate", verifyCertificate.toString()); - } - - String confUrl = appendSlash(jsonObj.getString("confUrl")); - Boolean forceSave = jsonObj.getBoolean("forceSave"); - Boolean chat = jsonObj.getBoolean("chat"); - Boolean compactHeader = jsonObj.getBoolean("compactHeader"); - Boolean feedback = jsonObj.getBoolean("feedback"); - Boolean helpMenu = jsonObj.getBoolean("helpMenu"); - Boolean toolbarNoTabs = jsonObj.getBoolean("toolbarNoTabs"); - String reviewDisplay = jsonObj.getString("reviewDisplay"); - JSONArray editingTypes = jsonObj.getJSONArray("editingTypes"); - - pluginSettings.put("onlyoffice.confUrl", confUrl); - pluginSettings.put("onlyoffice.forceSave", forceSave.toString()); - pluginSettings.put("onlyoffice.chat", chat.toString()); - pluginSettings.put("onlyoffice.compactHeader", compactHeader.toString()); - pluginSettings.put("onlyoffice.feedback", feedback.toString()); - pluginSettings.put("onlyoffice.helpMenu", helpMenu.toString()); - pluginSettings.put("onlyoffice.toolbarNoTabs", toolbarNoTabs.toString()); - pluginSettings.put("onlyoffice.reviewDisplay", reviewDisplay); - pluginSettings.put("onlyoffice.editingTypes", editingTypes.toString()); - - } catch (Exception ex) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - ex.printStackTrace(pw); - String error = ex.toString() + "\n" + sw.toString(); - log.error(error); - - response.setStatus(HttpServletResponse.SC_BAD_REQUEST); - response.getWriter().write("{\"success\": false, \"message\": \"jsonparse\"}"); - return; + if (settings.getDemo() != null && settings.getDemo()) { + settingsManager.enableDemo(); } - log.debug("Checking docserv url"); - if (!checkDocServUrl((docInnerUrl == null || docInnerUrl.isEmpty()) ? apiUrl : docInnerUrl)) { - response.getWriter().write("{\"success\": false, \"message\": \"docservunreachable\"}"); - return; - } + if (settingsManager.isDemoActive()) { + Security security = settings.getSecurity(); + security.setKey(null); + security.setHeader(null); - try { - log.debug("Checking docserv commandservice"); - if (!checkDocServCommandService((docInnerUrl == null || docInnerUrl.isEmpty()) ? apiUrl : docInnerUrl)) { - response.getWriter().write("{\"success\": false, \"message\": \"docservcommand\"}"); - return; - } - } catch (SecurityException ex) { - response.getWriter().write("{\"success\": false, \"message\": \"jwterror\"}"); - return; + settings.setUrl(null); + settings.setInnerUrl(null); + settings.setSecurity(security); } - response.getWriter().write("{\"success\": true}"); - } - - private String appendSlash(final String str) { - if (str == null || str.isEmpty() || str.endsWith("/")) { - return str; - } else { - return str + "/"; - } - } - - private Boolean checkDocServUrl(final String url) { - try (CloseableHttpClient httpClient = configurationManager.getHttpClient()) { - HttpGet request = new HttpGet(url + "healthcheck"); - try (CloseableHttpResponse response = httpClient.execute(request)) { - - String content = IOUtils.toString(response.getEntity().getContent(), "utf-8").trim(); - if (content.equalsIgnoreCase("true")) { - return true; - } - } - } catch (Exception e) { - log.debug("/healthcheck error: " + e.getMessage()); + try { + settingsManager.setSettings(settings); + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); } - return false; - } - - private Boolean checkDocServCommandService(final String url) throws SecurityException { - Integer errorCode = -1; - try (CloseableHttpClient httpClient = configurationManager.getHttpClient()) { - JSONObject body = new JSONObject(); - body.put("c", "version"); - - HttpPost request = new HttpPost(url + "coauthoring/CommandService.ashx"); - - if (jwtManager.jwtEnabled()) { - String token = jwtManager.createToken(body); - JSONObject payloadBody = new JSONObject(); - payloadBody.put("payload", body); - String headerToken = jwtManager.createToken(body); - body.put("token", token); - String header = jwtManager.getJwtHeader(); - request.setHeader(header, "Bearer " + headerToken); - } - - StringEntity requestEntity = new StringEntity(body.toString(), ContentType.APPLICATION_JSON); - request.setEntity(requestEntity); - request.setHeader("Accept", "application/json"); + Map validationResults = settingsValidationService.validateSettings(); - log.debug("Sending POST to Docserver: " + body.toString()); - try (CloseableHttpResponse response = httpClient.execute(request)) { - int status = response.getStatusLine().getStatusCode(); + Map responseMap = new HashMap<>(); + responseMap.put("validationResults", validationResults); - if (status != HttpStatus.SC_OK) { - return false; - } else { - String content = IOUtils.toString(response.getEntity().getContent(), "utf-8"); - log.debug("/CommandService content: " + content); - JSONObject callBackJson = null; - callBackJson = new JSONObject(content); - - if (callBackJson.isNull("error")) { - return false; - } - - errorCode = callBackJson.getInt("error"); - } - } - } catch (Exception e) { - log.debug("/CommandService error: " + e.getMessage()); - return false; - } - - if (errorCode == ERROR_INVALID_TOKEN) { - throw new SecurityException(); - } else { - return errorCode == 0; - } + response.getWriter().write(objectMapper.writeValueAsString(responseMap)); } } diff --git a/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java b/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java index a88c5b25..4cd1514d 100644 --- a/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java @@ -18,24 +18,23 @@ package onlyoffice; +import com.atlassian.confluence.languages.LocaleManager; import com.atlassian.confluence.pages.Attachment; import com.atlassian.confluence.pages.AttachmentManager; import com.atlassian.confluence.renderer.radeox.macros.MacroUtils; import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.user.ConfluenceUser; import com.atlassian.confluence.util.velocity.VelocityUtils; +import com.onlyoffice.manager.request.RequestManager; +import com.onlyoffice.model.common.CommonResponse; +import com.onlyoffice.model.convertservice.ConvertRequest; +import com.onlyoffice.model.convertservice.ConvertResponse; +import com.onlyoffice.service.convert.ConvertService; import onlyoffice.managers.auth.AuthContext; -import onlyoffice.managers.configuration.ConfigurationManager; -import onlyoffice.managers.convert.ConvertManager; -import onlyoffice.managers.document.DocumentManager; +import onlyoffice.sdk.manager.document.DocumentManager; import onlyoffice.utils.attachment.AttachmentUtil; import org.apache.commons.io.IOUtils; import org.apache.http.HttpEntity; -import org.apache.http.HttpException; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.json.JSONObject; @@ -48,7 +47,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; -import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.util.Map; @@ -56,23 +54,25 @@ public class OnlyOfficeConvertServlet extends HttpServlet { private static final long serialVersionUID = 1L; private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeConvertServlet"); + private final LocaleManager localeManager; private final AttachmentManager attachmentManager; private final AttachmentUtil attachmentUtil; - private final ConvertManager convertManager; + private final ConvertService convertService; private final AuthContext authContext; private final DocumentManager documentManager; - private final ConfigurationManager configurationManager; + private final RequestManager requestManager; - public OnlyOfficeConvertServlet(final AttachmentManager attachmentManager, final AttachmentUtil attachmentUtil, - final ConvertManager convertManager, final AuthContext authContext, - final DocumentManager documentManager, - final ConfigurationManager configurationManager) { + public OnlyOfficeConvertServlet(final LocaleManager localeManager, final AttachmentManager attachmentManager, + final AttachmentUtil attachmentUtil, final ConvertService convertService, + final AuthContext authContext, final DocumentManager documentManager, + final RequestManager requestManager) { + this.localeManager = localeManager; this.attachmentManager = attachmentManager; this.attachmentUtil = attachmentUtil; - this.convertManager = convertManager; + this.convertService = convertService; this.authContext = authContext; this.documentManager = documentManager; - this.configurationManager = configurationManager; + this.requestManager = requestManager; } @Override @@ -94,8 +94,8 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re Map contextMap = MacroUtils.defaultVelocityContext(); Long pageId = attachment.getContainer().getId(); String fileName = attachment.getFileName(); - String ext = attachment.getFileExtension(); - String newExt = convertManager.getTargetExt(ext); + String newFileExtension = documentManager.getDefaultConvertExtension(fileName); + String title = fileName.substring(0, fileName.lastIndexOf(".")); if (pageIdString != null && !pageIdString.isEmpty()) { @@ -108,7 +108,7 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re title = newTitle; } - String newName = documentManager.getCorrectName(title, newExt, pageId); + String newName = documentManager.getCorrectNewFileName(title, newFileExtension, pageId); contextMap.put("attachmentId", attachmentIdString); contextMap.put("oldName", fileName); @@ -132,69 +132,75 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r String errorMessage = null; JSONObject json = null; - try { - Long attachmentId = Long.parseLong(attachmentIdString); - log.info("attachmentId " + attachmentId); - Attachment attachment = attachmentManager.getAttachment(attachmentId); + Long attachmentId = Long.parseLong(attachmentIdString); + log.info("attachmentId " + attachmentId); - user = AuthenticatedUserThreadLocal.get(); - log.info("user " + user); + Attachment attachment = attachmentManager.getAttachment(attachmentId); - String fileName = attachment.getFileName(); - String ext = attachment.getFileExtension(); - String title = fileName.substring(0, fileName.lastIndexOf(".")); + user = AuthenticatedUserThreadLocal.get(); + log.info("user " + user); - String pageIdAsString = request.getParameter("pageId"); - String newTitle = request.getParameter("newTitle"); + String fileName = attachment.getFileName(); + String title = fileName.substring(0, fileName.lastIndexOf(".")); - if (newTitle != null && !newTitle.isEmpty()) { - title = newTitle; - } + String pageIdAsString = request.getParameter("pageId"); + String newTitle = request.getParameter("newTitle"); - Long pageId = null; - if (pageIdAsString != null && !pageIdAsString.isEmpty()) { - pageId = Long.parseLong(pageIdAsString); - } else { - pageId = attachment.getContainer().getId(); - } + if (newTitle != null && !newTitle.isEmpty()) { + title = newTitle; + } - String convertToExt = convertManager.getTargetExt(ext); - - if (attachmentUtil.checkAccess(attachmentId, user, false) - && attachmentUtil.checkAccessCreate(user, pageId)) { - if (convertToExt != null) { - json = convertManager.convert(attachmentId, ext, convertToExt, user, null); - - if (json.has("endConvert") && json.getBoolean("endConvert")) { - String newFileName = documentManager.getCorrectName(title, convertToExt, pageId); - Long newAttachmentId = savefile(attachment, json.getString("fileUrl"), newFileName, pageId); - json.put("attachmentId", newAttachmentId); - } else if (json.has("error")) { - errorMessage = "Unknown conversion error"; - } - } else { - errorMessage = "Files of " + ext + " format cannot be converted"; - } - } else { - log.error("access deny"); - errorMessage = "You don not have enough permission to convert the file"; - } - } catch (Exception ex) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - ex.printStackTrace(pw); - String error = ex.toString() + "\n" + sw.toString(); - log.error(error); - errorMessage = ex.toString(); + Long pageId = null; + if (pageIdAsString != null && !pageIdAsString.isEmpty()) { + pageId = Long.parseLong(pageIdAsString); + } else { + pageId = attachment.getContainer().getId(); + } + + String convertToExt = documentManager.getDefaultConvertExtension(fileName); + + if (!attachmentUtil.checkAccess(attachmentId, user, false) + || !attachmentUtil.checkAccessCreate(user, pageId)) { + response.setStatus(HttpServletResponse.SC_FORBIDDEN); + return; + } + + if (documentManager.getDefaultConvertExtension(fileName) == null) { + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + return; } response.setContentType("application/json"); PrintWriter writer = response.getWriter(); - if (errorMessage != null) { - writer.write("{\"error\":\"" + errorMessage + "\"}"); - } else { + + try { + String region = localeManager.getLocale(user).toLanguageTag(); + + ConvertRequest convertRequest = ConvertRequest.builder() + .async(true) + .region(region) + .build(); + + ConvertResponse convertResponse = convertService.processConvert(convertRequest, + String.valueOf(attachmentId)); + + json = new JSONObject(convertResponse); + + if (convertResponse.getEndConvert() != null && convertResponse.getEndConvert()) { + String newFileName = documentManager.getCorrectNewFileName(title, convertToExt, pageId); + Long newAttachmentId = savefile(attachment, convertResponse.getFileUrl(), newFileName, pageId); + json.put("attachmentId", newAttachmentId); + } + + writer.write(json.toString()); + } catch (IOException e) { + CommonResponse commonResponse = new CommonResponse(); + commonResponse.setError(CommonResponse.Error.CONNECTION); + json = new JSONObject(commonResponse); writer.write(json.toString()); + } catch (Exception e) { + throw new RuntimeException(e); } } @@ -202,33 +208,24 @@ private Long savefile(final Attachment attachment, final String fileUrl, final S throws Exception { log.info("downloadUri = " + fileUrl); - try (CloseableHttpClient httpClient = configurationManager.getHttpClient()) { - HttpGet request = new HttpGet(fileUrl); + return requestManager.executeGetRequest(fileUrl, new RequestManager.Callback() { + @Override + public Long doWork(final Object response) throws Exception { + byte[] bytes = IOUtils.toByteArray(((HttpEntity) response).getContent()); + InputStream inputStream = new ByteArrayInputStream(bytes); - try (CloseableHttpResponse response = httpClient.execute(request)) { + Attachment copy = attachment.copyLatestVersion(); - int status = response.getStatusLine().getStatusCode(); - HttpEntity entity = response.getEntity(); + copy.setContainer(attachmentUtil.getContainer(pageId)); + copy.setFileName(newName); + copy.setFileSize(bytes.length); + copy.setMediaType(documentManager.getMimeType(newName)); - if (status == HttpStatus.SC_OK) { - byte[] bytes = IOUtils.toByteArray(entity.getContent()); - InputStream inputStream = new ByteArrayInputStream(bytes); + attachmentManager.saveAttachment(copy, null, inputStream); - Attachment copy = attachment.copyLatestVersion(); - - copy.setContainer(attachmentUtil.getContainer(pageId)); - copy.setFileName(newName); - copy.setFileSize(bytes.length); - copy.setMediaType(documentManager.getMimeType(newName)); - - attachmentManager.saveAttachment(copy, null, inputStream); - - return copy.getLatestVersionId(); - } else { - throw new HttpException("Document Server returned code " + status); - } + return copy.getLatestVersionId(); } - } + }); } } diff --git a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java index e62980f8..a38dc446 100644 --- a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java @@ -18,21 +18,23 @@ package onlyoffice; +import com.atlassian.confluence.languages.LocaleManager; import com.atlassian.confluence.pages.BlogPost; import com.atlassian.confluence.renderer.radeox.macros.MacroUtils; import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.user.ConfluenceUser; import com.atlassian.confluence.util.velocity.VelocityUtils; import com.atlassian.sal.api.message.I18nResolver; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.onlyoffice.manager.settings.SettingsManager; +import com.onlyoffice.model.documenteditor.Config; +import com.onlyoffice.model.documenteditor.config.document.DocumentType; +import com.onlyoffice.model.documenteditor.config.editorconfig.Mode; +import com.onlyoffice.service.documenteditor.config.ConfigService; import onlyoffice.managers.auth.AuthContext; import com.atlassian.confluence.pages.Attachment; -import onlyoffice.managers.config.ConfigManager; -import onlyoffice.managers.configuration.ConfigurationManager; -import onlyoffice.managers.document.DocumentManager; -import onlyoffice.managers.url.UrlManager; -import onlyoffice.model.config.DocumentType; -import onlyoffice.model.config.Type; -import onlyoffice.model.config.editor.Mode; +import onlyoffice.sdk.manager.document.DocumentManager; +import onlyoffice.sdk.manager.url.UrlManager; import onlyoffice.utils.attachment.AttachmentUtil; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; @@ -44,6 +46,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.InputStream; import java.io.PrintWriter; import java.net.URLEncoder; import java.util.Map; @@ -54,23 +57,26 @@ public class OnlyOfficeEditorServlet extends HttpServlet { private final I18nResolver i18n; private final UrlManager urlManager; - private final ConfigurationManager configurationManager; private final AuthContext authContext; private final DocumentManager documentManager; private final AttachmentUtil attachmentUtil; - private final ConfigManager configManager; + private final ConfigService configService; + private final SettingsManager settingsManager; - public OnlyOfficeEditorServlet(final I18nResolver i18n, final UrlManager urlManager, - final ConfigurationManager configurationManager, final AuthContext authContext, + private final LocaleManager localeManager; + + public OnlyOfficeEditorServlet(final I18nResolver i18n, final UrlManager urlManager, final AuthContext authContext, final DocumentManager documentManager, final AttachmentUtil attachmentUtil, - final ConfigManager configManager) { + final ConfigService configService, final SettingsManager settingsManager, + final LocaleManager localeManager) { this.i18n = i18n; this.urlManager = urlManager; - this.configurationManager = configurationManager; this.authContext = authContext; this.documentManager = documentManager; this.attachmentUtil = attachmentUtil; - this.configManager = configManager; + this.configService = configService; + this.settingsManager = settingsManager; + this.localeManager = localeManager; } @Override @@ -80,8 +86,6 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re String attachmentIdString = request.getParameter("attachmentId"); String actionDataString = request.getParameter("actionData"); - String referer = request.getHeader("referer"); - if (attachmentIdString == null || attachmentIdString.isEmpty()) { if (!authContext.checkUserAuthorization(request, response)) { return; @@ -97,10 +101,30 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re return; } - Long attachmentId = documentManager.createDemo(fileName, fileExt, Long.parseLong(pageId), user); + String extension = fileExt == null + || !fileExt.equals("xlsx") + && !fileExt.equals("pptx") + && !fileExt.equals("docxf") + ? "docx" : fileExt.trim(); + + String name = fileName == null || fileName.equals("") + ? i18n.getText("onlyoffice.editor.dialog.filecreate." + extension) : fileName; + + name = attachmentUtil.getCorrectName(name, extension, Long.parseLong(pageId)); + String mimeType = documentManager.getMimeType(name); + InputStream newBlankFile = documentManager.getNewBlankFile(extension, localeManager.getLocale(user)); + + Attachment attachment = attachmentUtil.createNewAttachment( + name, + mimeType, + newBlankFile, + newBlankFile.available(), + Long.parseLong(pageId), + user + ); response.sendRedirect(request.getContextPath() + "?attachmentId=" - + URLEncoder.encode(attachmentId.toString(), "UTF-8")); + + URLEncoder.encode(String.valueOf(attachment.getId()), "UTF-8")); return; } } @@ -109,8 +133,8 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re Long attachmentId = Long.parseLong(attachmentIdString); Long pageId = attachmentUtil.getAttachmentPageId(attachmentId); Attachment attachment = attachmentUtil.getAttachment(attachmentId); - String extension = attachmentUtil.getFileExt(attachmentId); - DocumentType documentType = documentManager.getDocType(extension); + String fileName = documentManager.getDocumentName(String.valueOf(attachmentId)); + DocumentType documentType = documentManager.getDocumentType(fileName); if (attachment == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); @@ -123,8 +147,8 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re } Map context = MacroUtils.defaultVelocityContext(); - context.put("docserviceApiUrl", urlManager.getDocServiceApiUrl()); - context.put("docTitle", attachmentUtil.getFileName(attachmentId)); + context.put("docserviceApiUrl", urlManager.getDocumentServerApiUrl()); + context.put("docTitle", documentManager.getDocumentName(String.valueOf(attachmentId))); context.put("favicon", urlManager.getFaviconUrl(documentType)); context.put("pageId", pageId); context.put("pageTitle", attachmentUtil.getAttachmentPageTitle(attachmentId)); @@ -133,28 +157,36 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re context.put("isBlogPost", String.valueOf(attachmentUtil.getContainer(pageId) instanceof BlogPost)); if (documentType != null) { - Type type = documentManager.getEditorType(request.getHeader("USER-AGENT")); - JSONObject actionData = null; if (actionDataString != null && !actionDataString.isEmpty()) { actionData = new JSONObject(actionDataString); } - String config = configManager.createConfig(attachmentId, Mode.EDIT, type, actionData, referer); - context.put("configAsHtml", config); + Config config = configService.createConfig( + attachmentId.toString(), + Mode.EDIT, + request.getHeader("USER-AGENT") + ); + + config.getEditorConfig().setActionLink(actionData); + ObjectMapper mapper = new ObjectMapper(); + + context.put("configAsHtml", mapper.writeValueAsString(config)); context.put("historyInfoUriAsHtml", urlManager.getHistoryInfoUri(attachmentId)); context.put("historyDataUriAsHtml", urlManager.getHistoryDataUri(attachmentId)); context.put("attachmentDataAsHtml", urlManager.getAttachmentDataUri()); context.put("saveAsUriAsHtml", urlManager.getSaveAsUri()); context.put("referenceDataUriAsHtml", urlManager.getReferenceDataUri(pageId)); - context.put("insertImageTypesAsHtml", new JSONArray(documentManager.getInsertImageTypes()).toString()); - context.put("compareFileTypesAsHtml", new JSONArray(documentManager.getCompareFileTypes()).toString()); - context.put("mailMergeTypesAsHtml", new JSONArray(documentManager.getMailMergeTypes()).toString()); - context.put("demo", configurationManager.demoActive()); + context.put("insertImageTypesAsHtml", + new JSONArray(documentManager.getInsertImageExtensions()).toString()); + context.put("compareFileTypesAsHtml", + new JSONArray(documentManager.getCompareFileExtensions()).toString()); + context.put("mailMergeTypesAsHtml", new JSONArray(documentManager.getMailMergeExtensions()).toString()); + context.put("demo", settingsManager.isDemoActive()); } else { context.put("errorMessage", i18n.getText("onlyoffice.editor.message.error.unsupported") + "(." - + attachmentUtil.getFileExt(attachmentId) + ")"); + + documentManager.getExtension(fileName) + ")"); } response.setContentType("text/html;charset=UTF-8"); diff --git a/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java b/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java index f3df6e47..88ed13a9 100644 --- a/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java @@ -22,7 +22,9 @@ import com.atlassian.confluence.user.UserAccessor; import com.atlassian.sal.api.user.UserKey; import com.atlassian.spring.container.ContainerManager; -import onlyoffice.managers.jwt.JwtManager; + +import com.onlyoffice.manager.settings.SettingsManager; +import onlyoffice.sdk.manager.security.JwtManager; import onlyoffice.utils.attachment.AttachmentUtil; import org.json.JSONObject; @@ -40,19 +42,22 @@ public class OnlyOfficeFileProviderServlet extends HttpServlet { private final AttachmentUtil attachmentUtil; private final JwtManager jwtManager; + private final SettingsManager settingsManager; - public OnlyOfficeFileProviderServlet(final AttachmentUtil attachmentUtil, final JwtManager jwtManager) { + public OnlyOfficeFileProviderServlet(final AttachmentUtil attachmentUtil, final JwtManager jwtManager, + final SettingsManager settingsManager) { this.attachmentUtil = attachmentUtil; this.jwtManager = jwtManager; + this.settingsManager = settingsManager; } @Override public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { - if (jwtManager.jwtEnabled()) { - String jwth = jwtManager.getJwtHeader(); + if (settingsManager.isSecurityEnabled()) { + String jwth = settingsManager.getSecurityHeader(); String header = request.getHeader(jwth); - String authorizationPrefix = "Bearer "; + String authorizationPrefix = settingsManager.getSecurityPrefix(); String token = (header != null && header.startsWith(authorizationPrefix)) ? header.substring(authorizationPrefix.length()) : header; diff --git a/src/main/java/onlyoffice/OnlyOfficeFormatsServlet.java b/src/main/java/onlyoffice/OnlyOfficeFormatsServlet.java index bce10e48..e6d7dfb8 100644 --- a/src/main/java/onlyoffice/OnlyOfficeFormatsServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeFormatsServlet.java @@ -19,8 +19,8 @@ package onlyoffice; import com.google.gson.Gson; -import onlyoffice.managers.configuration.ConfigurationManager; -import onlyoffice.model.Format; +import com.onlyoffice.model.common.Format; +import onlyoffice.sdk.manager.document.DocumentManager; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; @@ -36,15 +36,15 @@ public class OnlyOfficeFormatsServlet extends HttpServlet { private static final long serialVersionUID = 1L; private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeFormatsServlet"); - private final ConfigurationManager configurationManager; + private final DocumentManager documentManager; - public OnlyOfficeFormatsServlet(final ConfigurationManager configurationManager) { - this.configurationManager = configurationManager; + public OnlyOfficeFormatsServlet(final DocumentManager documentManager) { + this.documentManager = documentManager; } @Override public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException { - List supportedFormats = configurationManager.getSupportedFormats(); + List supportedFormats = documentManager.getFormats(); List result = new ArrayList<>(); for (Format format : supportedFormats) { diff --git a/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java b/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java index 286a7879..7956b833 100644 --- a/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java @@ -27,17 +27,23 @@ import com.atlassian.confluence.user.ConfluenceUserPreferences; import com.atlassian.confluence.user.UserAccessor; import com.atlassian.spring.container.ContainerManager; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; +import com.onlyoffice.model.common.User; +import com.onlyoffice.model.documenteditor.HistoryData; +import com.onlyoffice.model.documenteditor.callback.History; +import com.onlyoffice.model.documenteditor.history.Version; +import com.onlyoffice.model.documenteditor.historydata.Previous; +import onlyoffice.sdk.manager.security.JwtManager; +import com.onlyoffice.manager.settings.SettingsManager; +import onlyoffice.sdk.manager.url.UrlManager; import onlyoffice.managers.auth.AuthContext; -import onlyoffice.managers.document.DocumentManager; -import onlyoffice.managers.jwt.JwtManager; -import onlyoffice.managers.url.UrlManager; +import onlyoffice.sdk.manager.document.DocumentManager; import onlyoffice.utils.attachment.AttachmentUtil; import onlyoffice.utils.parsing.ParsingUtil; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.json.JSONException; -import org.json.JSONObject; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -64,6 +70,7 @@ public class OnlyOfficeHistoryServlet extends HttpServlet { private final DocumentManager documentManager; private final AttachmentUtil attachmentUtil; private final UrlManager urlManager; + private final SettingsManager settingsManager; private final JwtManager jwtManager; private final ParsingUtil parsingUtil; @@ -71,13 +78,15 @@ public OnlyOfficeHistoryServlet(final LocaleManager localeManager, final FormatSettingsManager formatSettingsManager, final AuthContext authContext, final DocumentManager documentManager, final AttachmentUtil attachmentUtil, final UrlManager urlManager, - final JwtManager jwtManager, final ParsingUtil parsingUtil) { + final SettingsManager settingsManager, final JwtManager jwtManager, + final ParsingUtil parsingUtil) { this.localeManager = localeManager; this.formatSettingsManager = formatSettingsManager; this.authContext = authContext; this.documentManager = documentManager; this.attachmentUtil = attachmentUtil; this.urlManager = urlManager; + this.settingsManager = settingsManager; this.jwtManager = jwtManager; this.parsingUtil = parsingUtil; } @@ -110,7 +119,7 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re private void getAttachmentDiff(final HttpServletRequest request, final HttpServletResponse response) throws IOException { String vkey = request.getParameter("vkey"); - String attachmentIdString = documentManager.readHash(vkey); + String attachmentIdString = jwtManager.readHash(vkey); if (attachmentIdString.isEmpty()) { response.sendError(HttpServletResponse.SC_NOT_FOUND); @@ -122,7 +131,7 @@ private void getAttachmentDiff(final HttpServletRequest request, final HttpServl if (diff != null) { InputStream inputStream = attachmentUtil.getAttachmentData(diff.getId()); - String publicDocEditorUrl = urlManager.getPublicDocEditorUrl(); + String publicDocEditorUrl = urlManager.getDocumentServerUrl(); if (publicDocEditorUrl.endsWith("/")) { publicDocEditorUrl = publicDocEditorUrl.substring(0, publicDocEditorUrl.length() - 1); @@ -151,7 +160,7 @@ private void getAttachmentHistoryInfo(final HttpServletRequest request, final Ht } String vkey = request.getParameter("vkey"); - String attachmentIdString = documentManager.readHash(vkey); + String attachmentIdString = jwtManager.readHash(vkey); if (attachmentIdString.isEmpty()) { response.sendError(HttpServletResponse.SC_NOT_FOUND); @@ -177,24 +186,26 @@ private void getAttachmentHistoryInfo(final HttpServletRequest request, final Ht Collections.reverse(attachments); List history = new ArrayList<>(); for (Attachment attachment : attachments) { - Version version = new Version(); - version.setVersion(attachment.getVersion()); - version.setKey(documentManager.getKeyOfFile(attachment.getId(), false)); - version.setCreated(dateFormatter.formatDateTime(attachment.getCreationDate())); - version.setUser(attachment.getCreator().getName(), attachment.getCreator().getFullName()); - - Attachment changes = attachmentUtil.getAttachmentChanges(attachment.getId()); - if (changes != null) { + Version version = Version.builder() + .version(String.valueOf(attachment.getVersion())) + .key(documentManager.getDocumentKey(String.valueOf(attachment.getId()), false)) + .created(dateFormatter.formatDateTime(attachment.getCreationDate())) + .user(User.builder() + .id(attachment.getCreator().getName()) + .name(attachment.getCreator().getFullName()) + .build() + ) + .build(); + + Attachment changesAttachment = attachmentUtil.getAttachmentChanges(attachment.getId()); + if (changesAttachment != null) { if (prevVersion != null && (attachment.getVersion() - prevVersion.getVersion()) == 1) { - InputStream changesSteam = attachmentUtil.getAttachmentData(changes.getId()); - String changesString = parsingUtil.getBody(changesSteam); - JSONObject changesJSON = null; + InputStream changesSteam = attachmentUtil.getAttachmentData(changesAttachment.getId()); + ObjectMapper mapper = new ObjectMapper(); + History changes = mapper.readValue(changesSteam, History.class); try { - changesJSON = new JSONObject(changesString); - version.setServerVersion(changesJSON.getString("serverVersion")); - version.setChanges( - gson.fromJson(changesJSON.getJSONArray("changes").toString(), Object.class) - ); + version.setServerVersion(changes.getServerVersion()); + version.setChanges(changes.getChanges()); } catch (JSONException e) { throw new IOException(e.getMessage()); } @@ -227,7 +238,7 @@ private void getAttachmentHistoryData(final HttpServletRequest request, final Ht } String vkey = request.getParameter("vkey"); - String attachmentIdString = documentManager.readHash(vkey); + String attachmentIdString = jwtManager.readHash(vkey); String versionString = request.getParameter("version"); if (attachmentIdString.isEmpty() || versionString == null || versionString.isEmpty()) { @@ -248,25 +259,35 @@ private void getAttachmentHistoryData(final HttpServletRequest request, final Ht List attachments = attachmentUtil.getAllVersions(attachmentId); if (attachments != null) { Gson gson = new Gson(); - VersionData versionData = null; + HistoryData historyData = null; Attachment prevVersion = null; Collections.reverse(attachments); for (Attachment attachment : attachments) { if (attachment.getVersion() == version) { - versionData = new VersionData(); - versionData.setVersion(attachment.getVersion()); - versionData.setKey(documentManager.getKeyOfFile(attachment.getId(), false)); - versionData.setUrl(urlManager.getFileUri(attachment.getId())); - versionData.setFileType(attachment.getFileExtension()); + historyData = HistoryData.builder() + .version(String.valueOf(attachment.getVersion())) + .key(documentManager.getDocumentKey(String.valueOf(attachment.getId()), false)) + .url(urlManager.getFileUrl(String.valueOf(attachment.getId()))) + .fileType(attachment.getFileExtension()) + .build(); Attachment diff = attachmentUtil.getAttachmentDiff(attachment.getId()); if (prevVersion != null && diff != null) { boolean adjacentVersions = (attachment.getVersion() - prevVersion.getVersion()) == 1; if (adjacentVersions) { - versionData.setChangesUrl(urlManager.getAttachmentDiffUri(attachment.getId())); - versionData.setPrevious(documentManager.getKeyOfFile(prevVersion.getId(), false), - urlManager.getFileUri(prevVersion.getId()), prevVersion.getFileExtension()); + historyData.setChangesUrl(urlManager.getAttachmentDiffUri(attachment.getId())); + historyData.setPrevious(Previous.builder() + .key( + documentManager.getDocumentKey( + String.valueOf(prevVersion.getId()), + false + ) + ) + .url(urlManager.getFileUrl(String.valueOf(prevVersion.getId()))) + .fileType(prevVersion.getFileExtension()) + .build() + ); } } break; @@ -274,11 +295,10 @@ private void getAttachmentHistoryData(final HttpServletRequest request, final Ht prevVersion = attachment; } - if (versionData != null) { - if (jwtManager.jwtEnabled()) { + if (historyData != null) { + if (settingsManager.isSecurityEnabled()) { try { - JSONObject versionDataJSON = new JSONObject(gson.toJson(versionData)); - versionData.setToken(jwtManager.createToken(versionDataJSON)); + historyData.setToken(jwtManager.createToken(historyData)); } catch (Exception e) { throw new IOException(e.getMessage()); } @@ -286,7 +306,7 @@ private void getAttachmentHistoryData(final HttpServletRequest request, final Ht response.setContentType("application/json"); PrintWriter writer = response.getWriter(); - writer.write(gson.toJson(versionData)); + writer.write(gson.toJson(historyData)); } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); return; @@ -296,103 +316,4 @@ private void getAttachmentHistoryData(final HttpServletRequest request, final Ht return; } } - - public class Version { - private int version; - private String key; - private Object changes; - private String created; - private User user; - private String serverVersion; - - public Version() { - } - - public void setVersion(final int version) { - this.version = version; - } - - public void setKey(final String key) { - this.key = key; - } - - public void setChanges(final Object changes) { - this.changes = changes; - } - - public void setCreated(final String created) { - this.created = created; - } - - public void setUser(final String id, final String name) { - this.user = new User(id, name); - } - - public void setServerVersion(final String serverVersion) { - this.serverVersion = serverVersion; - } - - public class User { - private String id; - private String name; - - public User(final String id, final String name) { - this.id = id; - this.name = name; - } - } - } - - public class VersionData { - private int version; - private String key; - private String url; - private String fileType; - private String changesUrl; - private Previous previous; - private String token; - - public VersionData() { - } - - public void setVersion(final int version) { - this.version = version; - } - - public void setKey(final String key) { - this.key = key; - } - - public void setUrl(final String url) { - this.url = url; - } - - public void setFileType(final String fileType) { - this.fileType = fileType; - } - - public void setChangesUrl(final String changesUrl) { - this.changesUrl = changesUrl; - } - - public void setPrevious(final String key, final String url, final String fileType) { - this.previous = new Previous(key, url, fileType); - } - - public void setToken(final String token) { - this.token = token; - } - - public class Previous { - private String key; - private String url; - private String fileType; - - public Previous(final String key, final String url, final String fileType) { - this.key = key; - this.url = url; - this.fileType = fileType; - } - } - } } diff --git a/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java b/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java index 5e102fa2..1c8272e2 100644 --- a/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java @@ -18,67 +18,48 @@ package onlyoffice; +import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.user.ConfluenceUser; import com.atlassian.confluence.user.UserAccessor; import com.atlassian.sal.api.user.UserKey; import com.atlassian.spring.container.ContainerManager; -import onlyoffice.managers.configuration.ConfigurationManager; -import onlyoffice.managers.convert.ConvertManager; -import onlyoffice.managers.jwt.JwtManager; -import onlyoffice.managers.url.UrlManager; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.onlyoffice.manager.settings.SettingsManager; +import com.onlyoffice.model.documenteditor.Callback; +import onlyoffice.sdk.manager.security.JwtManager; +import com.onlyoffice.service.documenteditor.callback.CallbackService; import onlyoffice.utils.attachment.AttachmentUtil; import onlyoffice.utils.parsing.ParsingUtil; -import org.apache.commons.io.IOUtils; -import org.apache.http.HttpEntity; -import org.apache.http.HttpException; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; -import org.json.JSONArray; import org.json.JSONObject; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.ByteArrayInputStream; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; -import java.io.StringWriter; public class OnlyOfficeSaveFileServlet extends HttpServlet { private static final long serialVersionUID = 1L; private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeSaveFileServlet"); - private static final int STATUS_EDITING = 1; - private static final int STATUS_MUST_SAVE = 2; - private static final int STATUS_CORRUPTED = 3; - private static final int STATUS_CLOSED = 4; - private static final int STATUS_FORCE_SAVE = 6; - private static final int STATUS_CORRUPTED_FORCE_SAVE = 7; - + private final SettingsManager settingsManager; private final JwtManager jwtManager; private final AttachmentUtil attachmentUtil; private final ParsingUtil parsingUtil; - private final UrlManager urlManager; - private final ConfigurationManager configurationManager; - private final ConvertManager convertManager; + private final CallbackService callbackService; - public OnlyOfficeSaveFileServlet(final JwtManager jwtManager, final AttachmentUtil attachmentUtil, - final ParsingUtil parsingUtil, final UrlManager urlManager, - final ConfigurationManager configurationManager, - final ConvertManager convertManager) { + public OnlyOfficeSaveFileServlet(final SettingsManager settingsManager, final JwtManager jwtManager, + final AttachmentUtil attachmentUtil, final ParsingUtil parsingUtil, + final CallbackService callbackService) { + this.settingsManager = settingsManager; this.jwtManager = jwtManager; this.attachmentUtil = attachmentUtil; this.parsingUtil = parsingUtil; - this.urlManager = urlManager; - this.configurationManager = configurationManager; - this.convertManager = convertManager; + this.callbackService = callbackService; } @Override @@ -108,6 +89,8 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r UserKey userKey = new UserKey(userKeyString); ConfluenceUser user = userAccessor.getUserByKey(userKey); + AuthenticatedUserThreadLocal.set(user); + Long attachmentId = Long.parseLong(attachmentIdString); if (attachmentUtil.getAttachment(attachmentId) == null) { @@ -117,8 +100,23 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r String error = ""; try { - processData(attachmentId, user, request); + InputStream requestStream = request.getInputStream(); + + String bodyString = parsingUtil.getBody(requestStream); + + if (bodyString.isEmpty()) { + throw new IllegalArgumentException("requestBody is empty"); + } + + ObjectMapper mapper = new ObjectMapper(); + Callback callback = mapper.readValue(bodyString, Callback.class); + + String authorizationHeader = request.getHeader(settingsManager.getSecurityHeader()); + callback = callbackService.verifyCallback(callback, authorizationHeader); + + callbackService.processCallback(callback, attachmentIdString); } catch (Exception e) { + log.error(e.getMessage(), e); error = e.getMessage(); } @@ -129,206 +127,5 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); writer.write("{\"error\":1,\"message\":\"" + error + "\"}"); } - - log.info("error = " + error); - } - - private void processData(final Long attachmentId, final ConfluenceUser user, final HttpServletRequest request) - throws Exception { - log.info("attachmentId = " + attachmentId.toString()); - InputStream requestStream = request.getInputStream(); - - try { - String body = parsingUtil.getBody(requestStream); - log.info("body = " + body); - if (body.isEmpty()) { - throw new IllegalArgumentException("requestBody is empty"); - } - - JSONObject jsonObj = new JSONObject(body); - - if (jwtManager.jwtEnabled()) { - String token = jsonObj.optString("token"); - String payload = null; - Boolean inBody = true; - - if (token == null || token == "") { - String jwth = jwtManager.getJwtHeader(); - String header = (String) request.getHeader(jwth); - String authorizationPrefix = "Bearer "; - token = (header != null && header.startsWith(authorizationPrefix)) - ? header.substring(authorizationPrefix.length()) : header; - inBody = false; - } - - if (token == null || token == "") { - throw new SecurityException("Try save without JWT"); - } - - try { - payload = jwtManager.verify(token); - } catch (Exception e) { - throw new SecurityException("Try save with wrong JWT"); - } - - JSONObject bodyFromToken = new JSONObject(payload); - - if (inBody) { - jsonObj = bodyFromToken; - } else { - jsonObj = bodyFromToken.getJSONObject("payload"); - } - } - - long status = jsonObj.getLong("status"); - log.info("status = " + status); - log.info("user = " + user); - - if (status == STATUS_EDITING) { - if (jsonObj.has("actions")) { - JSONArray actions = jsonObj.getJSONArray("actions"); - if (actions.length() > 0) { - JSONObject action = (JSONObject) actions.get(0); - if (action.getLong("type") == 1) { - if (user == null || !attachmentUtil.checkAccess(attachmentId, user, true)) { - throw new SecurityException("Access denied. User " + user - + " don't have the appropriate permissions to edit this document."); - } - - if (attachmentUtil.getCollaborativeEditingKey(attachmentId) == null) { - String key = jsonObj.getString("key"); - attachmentUtil.setCollaborativeEditingKey(attachmentId, key); - } - } - } - } - } - - if (status == STATUS_MUST_SAVE || status == STATUS_CORRUPTED) { - if (user != null && attachmentUtil.checkAccess(attachmentId, user, true)) { - String fileType = jsonObj.getString("filetype"); - String downloadUrl = jsonObj.getString("url"); - downloadUrl = urlManager.replaceDocEditorURLToInternal(downloadUrl); - log.info("downloadUri = " + downloadUrl); - - JSONObject history = jsonObj.getJSONObject("history"); - String changesUrl = !jsonObj.isNull("changesurl") - ? urlManager.replaceDocEditorURLToInternal(jsonObj.getString("changesurl")) - : null; - log.info("changesUri = " + changesUrl); - - Boolean forceSaveVersion = - attachmentUtil.getPropertyAsBoolean(attachmentId, "onlyoffice-force-save"); - - attachmentUtil.setCollaborativeEditingKey(attachmentId, null); - - if (forceSaveVersion) { - saveAttachmentFromUrl(attachmentId, downloadUrl, fileType, user, false); - attachmentUtil.removeProperty(attachmentId, "onlyoffice-force-save"); - attachmentUtil.removeAttachmentChanges(attachmentId); - - File convertedFile = attachmentUtil.getConvertedFile(attachmentId); - if (convertedFile.exists()) { - convertedFile.delete(); - } - } else { - saveAttachmentFromUrl(attachmentId, downloadUrl, fileType, user, true); - } - - attachmentUtil.saveAttachmentChanges(attachmentId, history.toString(), changesUrl); - } else { - throw new SecurityException("Try save without access: " + user); - } - } - - if (status == STATUS_CLOSED) { - attachmentUtil.setCollaborativeEditingKey(attachmentId, null); - } - - if (status == STATUS_FORCE_SAVE || status == STATUS_CORRUPTED_FORCE_SAVE) { - if (user != null && attachmentUtil.checkAccess(attachmentId, user, true)) { - if (configurationManager.forceSaveEnabled()) { - String fileType = jsonObj.getString("filetype"); - String downloadUrl = jsonObj.getString("url"); - downloadUrl = urlManager.replaceDocEditorURLToInternal(downloadUrl); - log.info("downloadUri = " + downloadUrl); - - JSONObject history = jsonObj.getJSONObject("history"); - String changesUrl = !jsonObj.isNull("changesurl") - ? urlManager.replaceDocEditorURLToInternal(jsonObj.getString("changesurl")) - : null; - log.info("changesUri = " + downloadUrl); - - Boolean forceSaveVersion = - attachmentUtil.getPropertyAsBoolean(attachmentId, "onlyoffice-force-save"); - - if (forceSaveVersion) { - saveAttachmentFromUrl(attachmentId, downloadUrl, fileType, user, false); - attachmentUtil.removeAttachmentChanges(attachmentId); - } else { - String key = attachmentUtil.getCollaborativeEditingKey(attachmentId); - attachmentUtil.setCollaborativeEditingKey(attachmentId, null); - - saveAttachmentFromUrl(attachmentId, downloadUrl, fileType, user, true); - attachmentUtil.setCollaborativeEditingKey(attachmentId, key); - attachmentUtil.setProperty(attachmentId, "onlyoffice-force-save", "true"); - } - - attachmentUtil.saveAttachmentChanges(attachmentId, history.toString(), changesUrl); - - File convertedFile = attachmentUtil.getConvertedFile(attachmentId); - if (convertedFile.exists()) { - convertedFile.delete(); - } - } else { - log.info("Forcesave is disabled, ignoring forcesave request"); - } - } else { - throw new SecurityException("Try save without access: " + user); - } - } - } catch (Exception ex) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - ex.printStackTrace(pw); - String error = ex.toString() + "\n" + sw.toString(); - log.error(error); - - throw ex; - } - } - - private void saveAttachmentFromUrl(final Long attachmentId, final String downloadUrl, final String fileType, - final ConfluenceUser user, final boolean newVersion) throws Exception { - String attachmentExt = attachmentUtil.getFileExt(attachmentId); - String url = downloadUrl; - - if (!attachmentExt.equals(fileType)) { - JSONObject response = - convertManager.convert(attachmentId, fileType, attachmentExt, downloadUrl, null, false, null); - url = response.getString("fileUrl"); - } - - try (CloseableHttpClient httpClient = configurationManager.getHttpClient()) { - HttpGet request = new HttpGet(url); - - try (CloseableHttpResponse response = httpClient.execute(request)) { - int status = response.getStatusLine().getStatusCode(); - HttpEntity entity = response.getEntity(); - - if (status == HttpStatus.SC_OK) { - byte[] bytes = IOUtils.toByteArray(entity.getContent()); - InputStream inputStream = new ByteArrayInputStream(bytes); - - if (newVersion) { - attachmentUtil.saveAttachmentAsNewVersion(attachmentId, inputStream, bytes.length, user); - } else { - attachmentUtil.updateAttachment(attachmentId, inputStream, bytes.length, user); - } - } else { - throw new HttpException("Document Server returned code " + status); - } - } - } } } From 6e7b765ed6a6c5159e06b358b79fab95dfc0f111 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:26:38 +0300 Subject: [PATCH 10/87] changed: DownloadAsAction with using sdk managers and services --- .../onlyoffice/action/DownloadAsAction.java | 78 ++++++++++++++----- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/src/main/java/onlyoffice/action/DownloadAsAction.java b/src/main/java/onlyoffice/action/DownloadAsAction.java index 922f4d86..af4e436e 100644 --- a/src/main/java/onlyoffice/action/DownloadAsAction.java +++ b/src/main/java/onlyoffice/action/DownloadAsAction.java @@ -19,33 +19,48 @@ package onlyoffice.action; import com.atlassian.confluence.core.ConfluenceActionSupport; +import com.atlassian.confluence.languages.LocaleManager; import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.core.filters.ServletContextThreadLocal; import com.atlassian.xwork.HttpMethod; import com.atlassian.xwork.PermittedMethods; -import onlyoffice.managers.convert.ConvertManager; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.onlyoffice.model.common.CommonResponse; +import com.onlyoffice.model.convertservice.ConvertRequest; +import com.onlyoffice.model.convertservice.ConvertResponse; +import com.onlyoffice.service.convert.ConvertService; +import onlyoffice.sdk.manager.document.DocumentManager; import onlyoffice.utils.attachment.AttachmentUtil; import com.atlassian.confluence.user.ConfluenceUser; import org.apache.commons.lang3.StringUtils; -import org.json.JSONObject; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.io.PrintWriter; import java.util.List; public class DownloadAsAction extends ConfluenceActionSupport { + private final Logger log = LogManager.getLogger("onlyoffice.action.DownloadAsAction"); + private AttachmentUtil attachmentUtil; - private ConvertManager convertManager; + private ConvertService convertService; + private DocumentManager documentManager; + private final LocaleManager localeManager; private String attachmentId; private String fileName; private String targetFileType; private static final char[] INVALID_CHARS; - public DownloadAsAction(final AttachmentUtil attachmentUtil, final ConvertManager convertManager) { + public DownloadAsAction(final AttachmentUtil attachmentUtil, final ConvertService convertService, + final LocaleManager localeManager, final DocumentManager documentManager) { this.attachmentUtil = attachmentUtil; - this.convertManager = convertManager; + this.convertService = convertService; + this.documentManager = documentManager; + this.localeManager = localeManager; } @PermittedMethods({ HttpMethod.GET }) @@ -58,7 +73,6 @@ public void validate() { super.validate(); Long attachmentId = Long.parseLong(this.attachmentId); - String ext = attachmentUtil.getFileExt(attachmentId); if (!attachmentUtil.checkAccess(attachmentId, getAuthenticatedUser(), false)) { addActionError(getText("onlyoffice.connector.dialog.conversion.message.error.permission")); @@ -82,9 +96,11 @@ public void validate() { return; } - if (convertManager.getTargetExtList(ext) == null - || convertManager.getTargetExtList(ext).isEmpty() - || !convertManager.getTargetExtList(ext).contains(targetFileType) + String documentName = documentManager.getDocumentName(String.valueOf(attachmentId)); + + if (documentManager.getConvertExtensionList(documentName) == null + || documentManager.getConvertExtensionList(documentName).isEmpty() + || !documentManager.getConvertExtensionList(documentName).contains(targetFileType) ) { addActionError(getText("onlyoffice.connector.error.Unknown")); ServletContextThreadLocal.getResponse().setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); @@ -94,21 +110,38 @@ public void validate() { @PermittedMethods({ HttpMethod.POST }) public String execute() throws Exception { Long attachmentId = Long.parseLong(this.attachmentId); - String ext = attachmentUtil.getFileExt(attachmentId); - String targetExt = convertManager.getTargetExt(ext); + String fileName = documentManager.getDocumentName(String.valueOf(attachmentId)); + String targetExt = documentManager.getDefaultConvertExtension(fileName); if (!this.targetFileType.isEmpty()) { targetExt = this.targetFileType; } ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + String region = localeManager.getLocale(user).toLanguageTag(); + + ConvertRequest convertRequest = ConvertRequest.builder() + .async(true) + .outputtype(targetExt) + .region(region) + .build(); - JSONObject convertResult = - convertManager.convert(attachmentId, ext, targetExt, user, this.fileName + "." + targetExt); HttpServletResponse response = ServletContextThreadLocal.getResponse(); response.setContentType("application/json"); PrintWriter writer = response.getWriter(); - writer.write(convertResult.toString()); + ObjectMapper mapper = new ObjectMapper(); + + try { + ConvertResponse convertResponse = convertService.processConvert(convertRequest, this.attachmentId); + writer.write(mapper.writeValueAsString(convertResponse)); + } catch (IOException e) { + log.error(e.getMessage(), e); + + CommonResponse commonResponse = new CommonResponse(); + commonResponse.setError(CommonResponse.Error.CONNECTION); + writer.write(mapper.writeValueAsString(commonResponse)); + } + response.setStatus(HttpServletResponse.SC_OK); return "none"; } @@ -130,23 +163,26 @@ public String getAttachmentId() { } public String getFileName() { - Long attachmentId = Long.parseLong(this.attachmentId); - String fileName = attachmentUtil.getFileName(attachmentId); + String fileName = documentManager.getDocumentName(this.attachmentId); - return fileName.substring(0, fileName.lastIndexOf(".")); + return documentManager.getBaseName(fileName); } public String getFileType() { - Long attachmentId = Long.parseLong(this.attachmentId); - return attachmentUtil.getFileExt(attachmentId); + String fileName = documentManager.getDocumentName(this.attachmentId); + + return documentManager.getExtension(fileName); } public String getTargetFileType() { - return convertManager.getTargetExt(getFileType()); + return documentManager.getDefaultConvertExtension(getFileName()); } public List getTargetFileTypeList() { - return convertManager.getTargetExtList(getFileType()); + Long attachmentId = Long.parseLong(this.attachmentId); + String fileName = documentManager.getDocumentName(String.valueOf(attachmentId)); + + return documentManager.getConvertExtensionList(fileName); } static { From 371932a9fdb7d5698d74c0c61a20cbf45926b9a9 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:28:06 +0300 Subject: [PATCH 11/87] changed: conditions with using sdk managers and services (IsOfficeFileAttachment, IsOfficeFileConvertAttachment, IsOfficeFileDownloadAsAttachment, OnlyofficeButton) --- .../conditions/IsOfficeFileAttachment.java | 14 +++++++----- .../IsOfficeFileConvertAttachment.java | 15 +++++-------- .../IsOfficeFileDownloadAsAttachment.java | 22 +++++++------------ .../previews/plugin/OnlyofficeButton.java | 6 ++--- 4 files changed, 24 insertions(+), 33 deletions(-) diff --git a/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java b/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java index 82b08188..0346935b 100644 --- a/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java +++ b/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java @@ -23,7 +23,7 @@ import com.atlassian.confluence.user.ConfluenceUser; import com.atlassian.plugin.PluginParseException; import com.atlassian.plugin.web.Condition; -import onlyoffice.managers.document.DocumentManager; +import com.onlyoffice.manager.document.DocumentManager; import onlyoffice.utils.attachment.AttachmentUtil; import java.util.Map; @@ -62,21 +62,23 @@ public boolean shouldDisplay(final Map context) { ConfluenceUser user = AuthenticatedUserThreadLocal.get(); boolean accessEdit = attachmentUtil.checkAccess(attachment, user, true); boolean accessView = attachmentUtil.checkAccess(attachment, user, false); - String ext = attachment.getFileExtension(); + String fileName = attachment.getFileName(); if (forEdit) { if (form) { - if (accessEdit && documentManager.isFillForm(ext)) { + if (accessEdit && documentManager.isFillable(fileName)) { return true; } } else { - if (accessEdit && documentManager.isEditable(ext)) { + if (accessEdit && documentManager.isEditable(fileName)) { return true; } } } else { - if (accessView && documentManager.isViewable(ext) - && !(accessEdit && (documentManager.isEditable(ext) || documentManager.isFillForm(ext)))) { + if (accessView + && documentManager.isViewable(fileName) + && !(accessEdit && (documentManager.isEditable(fileName) || documentManager.isFillable(fileName))) + ) { return true; } } diff --git a/src/main/java/onlyoffice/conditions/IsOfficeFileConvertAttachment.java b/src/main/java/onlyoffice/conditions/IsOfficeFileConvertAttachment.java index 140bb73f..da48b1ba 100644 --- a/src/main/java/onlyoffice/conditions/IsOfficeFileConvertAttachment.java +++ b/src/main/java/onlyoffice/conditions/IsOfficeFileConvertAttachment.java @@ -23,8 +23,7 @@ import com.atlassian.confluence.user.ConfluenceUser; import com.atlassian.plugin.PluginParseException; import com.atlassian.plugin.web.Condition; -import onlyoffice.managers.convert.ConvertManager; -import onlyoffice.managers.document.DocumentManager; +import onlyoffice.sdk.manager.document.DocumentManager; import onlyoffice.utils.attachment.AttachmentUtil; import java.util.Map; @@ -32,16 +31,12 @@ public class IsOfficeFileConvertAttachment implements Condition { private boolean form; - - private final DocumentManager documentManager; private final AttachmentUtil attachmentUtil; - private final ConvertManager convertManager; + private final DocumentManager documentManager; - public IsOfficeFileConvertAttachment(final DocumentManager documentManager, final AttachmentUtil attachmentUtil, - final ConvertManager convertManager) { - this.documentManager = documentManager; + public IsOfficeFileConvertAttachment(final AttachmentUtil attachmentUtil, final DocumentManager documentManager) { this.attachmentUtil = attachmentUtil; - this.convertManager = convertManager; + this.documentManager = documentManager; } public void init(final Map params) throws PluginParseException { @@ -65,7 +60,7 @@ public boolean shouldDisplay(final Map context) { ConfluenceUser user = AuthenticatedUserThreadLocal.get(); boolean accessEdit = attachmentUtil.checkAccess(attachment, user, true); - if (!accessEdit || convertManager.getTargetExt(ext) == null || ext.equals("docx")) { + if (!accessEdit || documentManager.getDefaultConvertExtension(attachment.getFileName()) == null) { return false; } diff --git a/src/main/java/onlyoffice/conditions/IsOfficeFileDownloadAsAttachment.java b/src/main/java/onlyoffice/conditions/IsOfficeFileDownloadAsAttachment.java index a4e867fb..87fe7866 100644 --- a/src/main/java/onlyoffice/conditions/IsOfficeFileDownloadAsAttachment.java +++ b/src/main/java/onlyoffice/conditions/IsOfficeFileDownloadAsAttachment.java @@ -23,8 +23,7 @@ import com.atlassian.confluence.user.ConfluenceUser; import com.atlassian.plugin.PluginParseException; import com.atlassian.plugin.web.Condition; -import onlyoffice.managers.convert.ConvertManager; -import onlyoffice.managers.document.DocumentManager; +import onlyoffice.sdk.manager.document.DocumentManager; import onlyoffice.utils.attachment.AttachmentUtil; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; @@ -32,16 +31,13 @@ import java.util.Map; public class IsOfficeFileDownloadAsAttachment implements Condition { - - private final DocumentManager documentManager; private final AttachmentUtil attachmentUtil; - private final ConvertManager convertManager; + private final DocumentManager documentManager; - public IsOfficeFileDownloadAsAttachment(final DocumentManager documentManager, final AttachmentUtil attachmentUtil, - final ConvertManager convertManager) { - this.documentManager = documentManager; + public IsOfficeFileDownloadAsAttachment(final AttachmentUtil attachmentUtil, + final DocumentManager documentManager) { this.attachmentUtil = attachmentUtil; - this.convertManager = convertManager; + this.documentManager = documentManager; } private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeSaveFileServlet"); @@ -57,9 +53,7 @@ public boolean shouldDisplay(final Map map) { return false; } - String ext = attachment.getFileExtension(); - - if (attachment.getFileSize() > documentManager.getConvertationFileSizeMax()) { + if (attachment.getFileSize() > documentManager.getMaxConversionFileSize()) { return false; } @@ -67,7 +61,7 @@ public boolean shouldDisplay(final Map map) { boolean access = attachmentUtil.checkAccess(attachment, user, false); return access - && convertManager.getTargetExtList(ext) != null - && convertManager.getTargetExtList(ext).size() > 0; + && documentManager.getConvertExtensionList(attachment.getFileName()) != null + && documentManager.getConvertExtensionList(attachment.getFileName()).size() > 0; } } diff --git a/src/main/java/onlyoffice/conditions/confluence/previews/plugin/OnlyofficeButton.java b/src/main/java/onlyoffice/conditions/confluence/previews/plugin/OnlyofficeButton.java index d733a350..c25c3a84 100644 --- a/src/main/java/onlyoffice/conditions/confluence/previews/plugin/OnlyofficeButton.java +++ b/src/main/java/onlyoffice/conditions/confluence/previews/plugin/OnlyofficeButton.java @@ -22,7 +22,7 @@ import com.atlassian.confluence.pages.AttachmentManager; import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.user.ConfluenceUser; -import onlyoffice.managers.document.DocumentManager; +import com.onlyoffice.manager.document.DocumentManager; import onlyoffice.utils.attachment.AttachmentUtil; import onlyoffice.utils.parsing.ParsingUtil; import org.json.JSONObject; @@ -70,10 +70,10 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r if (accessEdit && documentManager.isEditable(ext)) { access = "edit"; - } else if (accessEdit && documentManager.isFillForm(ext)) { + } else if (accessEdit && documentManager.isFillable(ext)) { access = "fillform"; } else if (accessView && documentManager.isViewable(ext) - && !(accessEdit && (documentManager.isEditable(ext) || documentManager.isFillForm(ext)))) { + && !(accessEdit && (documentManager.isEditable(ext) || documentManager.isFillable(ext)))) { access = "view"; } From 3343fcefe92910e302d296d6727179df1165522e Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:29:07 +0300 Subject: [PATCH 12/87] changed: OnlyOfficePreviewMacro with using sdk managers and services --- .../macro/OnlyOfficePreviewMacro.java | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/src/main/java/onlyoffice/macro/OnlyOfficePreviewMacro.java b/src/main/java/onlyoffice/macro/OnlyOfficePreviewMacro.java index c5502627..ac868d15 100644 --- a/src/main/java/onlyoffice/macro/OnlyOfficePreviewMacro.java +++ b/src/main/java/onlyoffice/macro/OnlyOfficePreviewMacro.java @@ -33,13 +33,15 @@ import com.atlassian.confluence.plugin.services.VelocityHelperService; import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.util.HtmlUtil; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.onlyoffice.manager.document.DocumentManager; +import com.onlyoffice.manager.url.UrlManager; +import com.onlyoffice.model.documenteditor.Config; +import com.onlyoffice.model.documenteditor.config.document.DocumentType; +import com.onlyoffice.model.documenteditor.config.document.Type; +import com.onlyoffice.model.documenteditor.config.editorconfig.Mode; +import com.onlyoffice.service.documenteditor.config.ConfigService; import onlyoffice.macro.components.ContentResolver; -import onlyoffice.managers.config.ConfigManager; -import onlyoffice.managers.document.DocumentManager; -import onlyoffice.managers.url.UrlManager; -import onlyoffice.model.config.DocumentType; -import onlyoffice.model.config.Type; -import onlyoffice.model.config.editor.Mode; import onlyoffice.utils.attachment.AttachmentUtil; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; @@ -61,23 +63,23 @@ public class OnlyOfficePreviewMacro implements Macro, EditorImagePlaceholder, Re private final AttachmentManager attachmentManager; private final VelocityHelperService velocityHelperService; private final ContentResolver contentResolver; - private final ConfigManager configManager; private final UrlManager urlManager; - private final DocumentManager documentManager; private final AttachmentUtil attachmentUtil; + private final ConfigService configSevice; + private final DocumentManager documentManager; public OnlyOfficePreviewMacro(final AttachmentManager attachmentManager, final VelocityHelperService velocityHelperService, - final ContentResolver contentResolver, - final ConfigManager configManager, final UrlManager urlManager, - final DocumentManager documentManager, final AttachmentUtil attachmentUtil) { + final ContentResolver contentResolver, final UrlManager urlManager, + final AttachmentUtil attachmentUtil, final ConfigService configSevice, + final DocumentManager documentManager) { this.attachmentManager = attachmentManager; this.velocityHelperService = velocityHelperService; this.contentResolver = contentResolver; - this.configManager = configManager; this.urlManager = urlManager; - this.documentManager = documentManager; this.attachmentUtil = attachmentUtil; + this.configSevice = configSevice; + this.documentManager = documentManager; } @Override @@ -104,36 +106,33 @@ public String execute(final Map args, final String s, final Conv height = normalizeSize((height == null) ? DEFAULT_HEIGHT : height); try { - String config = configManager.createConfig( - attachment.getId(), - Mode.VIEW, - Type.EMBEDDED, - null, - null, - width, - height - ); - - String extension = attachmentUtil.getFileExt(attachment.getId()); + Config config = configSevice.createConfig(String.valueOf(attachment.getId()), Mode.EDIT, Type.EMBEDDED); + + config.setWidth(width); + config.setHeight(height); + + String fileName = attachment.getFileName(); String action = ""; final boolean isPreview = conversionContext.getOutputType().equals("preview"); if (attachmentUtil.checkAccess(attachment.getId(), AuthenticatedUserThreadLocal.get(), true) && !isPreview) { - if (documentManager.isEditable(extension)) { + if (documentManager.isEditable(fileName)) { action = "edit"; - } else if (documentManager.isFillForm(extension)) { + } else if (documentManager.isFillable(fileName)) { action = "fill"; } } + ObjectMapper mapper = new ObjectMapper(); + final Map context = this.velocityHelperService.createDefaultVelocityContext(); context.put("id", System.currentTimeMillis()); context.put("attachmentId", attachment.getId()); context.put("action", action); - context.put("docServiceApiUrl", urlManager.getDocServiceApiUrl()); - context.put("configAsHtml", config); + context.put("docServiceApiUrl", urlManager.getDocumentServerApiUrl()); + context.put("configAsHtml", mapper.writeValueAsString(config)); return this.velocityHelperService.getRenderedTemplate("templates/preview.vm", context); } catch (Exception e) { @@ -175,8 +174,8 @@ public ImagePlaceholder getImagePlaceholder(final Map args, int dotIdx = name.lastIndexOf(DOT_INDEX); if (dotIdx != -1) { String fileExt = name.substring(dotIdx + 1).toLowerCase(); - if (documentManager.getDocType(fileExt) != null) { - documentType = documentManager.getDocType(fileExt).name().toLowerCase(); + if (documentManager.getDocumentType(name) != null) { + documentType = documentManager.getDocumentType(name).name().toLowerCase(); if (fileExt.equals("oform")) { documentType = "form"; } From 55d00c69a0562a47e10e51d5252a84a54867ecbc Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:33:30 +0300 Subject: [PATCH 13/87] delete: old managers (ConfigManager, ConfigurationManager, ConvertManager, DocumentManager, JwtManager, UrlManager) --- .../managers/config/ConfigManager.java | 14 - .../managers/config/ConfigManagerImpl.java | 100 ------ .../configuration/ConfigurationManager.java | 38 -- .../ConfigurationManagerImpl.java | 244 ------------- .../managers/convert/ConvertManager.java | 18 - .../managers/convert/ConvertManagerImpl.java | 186 ---------- .../managers/document/DocumentManager.java | 43 --- .../document/DocumentManagerImpl.java | 332 ------------------ .../onlyoffice/managers/jwt/JwtManager.java | 23 -- .../managers/jwt/JwtManagerImpl.java | 136 ------- .../onlyoffice/managers/url/UrlManager.java | 37 -- .../managers/url/UrlManagerImpl.java | 238 ------------- src/main/resources/atlassian-plugin.xml | 18 - 13 files changed, 1427 deletions(-) delete mode 100644 src/main/java/onlyoffice/managers/config/ConfigManager.java delete mode 100644 src/main/java/onlyoffice/managers/config/ConfigManagerImpl.java delete mode 100644 src/main/java/onlyoffice/managers/configuration/ConfigurationManager.java delete mode 100644 src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java delete mode 100644 src/main/java/onlyoffice/managers/convert/ConvertManager.java delete mode 100644 src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java delete mode 100644 src/main/java/onlyoffice/managers/document/DocumentManager.java delete mode 100644 src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java delete mode 100644 src/main/java/onlyoffice/managers/jwt/JwtManager.java delete mode 100644 src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java delete mode 100644 src/main/java/onlyoffice/managers/url/UrlManager.java delete mode 100644 src/main/java/onlyoffice/managers/url/UrlManagerImpl.java diff --git a/src/main/java/onlyoffice/managers/config/ConfigManager.java b/src/main/java/onlyoffice/managers/config/ConfigManager.java deleted file mode 100644 index ad40d420..00000000 --- a/src/main/java/onlyoffice/managers/config/ConfigManager.java +++ /dev/null @@ -1,14 +0,0 @@ -package onlyoffice.managers.config; - -import onlyoffice.model.config.Type; -import onlyoffice.model.config.editor.Mode; -import org.json.JSONObject; - -import java.io.Serializable; - -public interface ConfigManager extends Serializable { - String createConfig(Long attachmentId, Mode mode, Type type, JSONObject actionLink, String referer) - throws Exception; - String createConfig(Long attachmentId, Mode mode, Type type, JSONObject actionLink, String referer, - String width, String height) throws Exception; -} diff --git a/src/main/java/onlyoffice/managers/config/ConfigManagerImpl.java b/src/main/java/onlyoffice/managers/config/ConfigManagerImpl.java deleted file mode 100644 index 7a34b470..00000000 --- a/src/main/java/onlyoffice/managers/config/ConfigManagerImpl.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.managers.config; - -import com.atlassian.confluence.languages.LocaleManager; -import com.atlassian.confluence.status.service.SystemInformationService; -import com.google.gson.Gson; -import onlyoffice.managers.configuration.ConfigurationManager; -import onlyoffice.managers.document.DocumentManager; -import onlyoffice.managers.jwt.JwtManager; -import onlyoffice.managers.url.UrlManager; -import onlyoffice.model.config.Config; -import onlyoffice.model.config.Type; -import onlyoffice.model.config.editor.Mode; -import onlyoffice.utils.attachment.AttachmentUtil; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; -import org.json.JSONObject; - -public class ConfigManagerImpl implements ConfigManager { - private final Logger log = LogManager.getLogger("onlyoffice.ConfigManagerImpl"); - - private final LocaleManager localeManager; - private final SystemInformationService sysInfoService; - - private final DocumentManager documentManager; - private final AttachmentUtil attachmentUtil; - private final UrlManager urlManager; - private final ConfigurationManager configurationManager; - private final JwtManager jwtManager; - - public ConfigManagerImpl(final LocaleManager localeManager, final SystemInformationService sysInfoService, - final DocumentManager documentManager, final AttachmentUtil attachmentUtil, - final UrlManager urlManager, final ConfigurationManager configurationManager, - final JwtManager jwtManager) { - this.localeManager = localeManager; - this.sysInfoService = sysInfoService; - this.documentManager = documentManager; - this.attachmentUtil = attachmentUtil; - this.urlManager = urlManager; - this.configurationManager = configurationManager; - this.jwtManager = jwtManager; - - } - - public String createConfig(final Long attachmentId, final Mode mode, final Type type, final JSONObject actionLink, - final String referer) - throws Exception { - return this.createConfig(attachmentId, mode, type, actionLink, referer, null, null); - } - - public String createConfig(final Long attachmentId, final Mode mode, final Type type, final JSONObject actionLink, - final String referer, final String width, final String height) throws Exception { - Gson gson = new Gson(); - - Config config = new Config( - localeManager, - documentManager, - attachmentUtil, - urlManager, - configurationManager, - attachmentId, - mode, - type, - actionLink, - referer, - sysInfoService.getConfluenceInfo().getBaseUrl() - ); - - if (width != null) { - config.setWidth(width); - } - - if (height != null) { - config.setHeight(height); - } - - if (jwtManager.jwtEnabled()) { - config.setToken(jwtManager.createToken(config)); - } - - return gson.toJson(config); - } -} diff --git a/src/main/java/onlyoffice/managers/configuration/ConfigurationManager.java b/src/main/java/onlyoffice/managers/configuration/ConfigurationManager.java deleted file mode 100644 index 4d18f508..00000000 --- a/src/main/java/onlyoffice/managers/configuration/ConfigurationManager.java +++ /dev/null @@ -1,38 +0,0 @@ -package onlyoffice.managers.configuration; - -import onlyoffice.model.Format; -import org.apache.http.impl.client.CloseableHttpClient; - -import java.io.IOException; -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -public interface ConfigurationManager extends Serializable { - Properties getProperties() throws IOException; - - String getProperty(String propertyName); - - boolean forceSaveEnabled(); - - boolean selectDemo(Boolean demo); - - Boolean demoEnabled(); - - Boolean demoAvailable(Boolean forActivate); - - Boolean demoActive(); - - String getDemo(String key); - - Boolean getBooleanPluginSetting(String key, Boolean defaultValue); - - String getStringPluginSetting(String key, String defaultValue); - - Map getCustomizableEditingTypes(); - - CloseableHttpClient getHttpClient() throws Exception; - - List getSupportedFormats(); -} diff --git a/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java b/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java deleted file mode 100644 index acdd8cf4..00000000 --- a/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java +++ /dev/null @@ -1,244 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.managers.configuration; - -import com.atlassian.sal.api.pluginsettings.PluginSettings; -import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import onlyoffice.model.Format; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.ssl.SSLContextBuilder; -import org.apache.http.ssl.TrustStrategy; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLSession; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -public class ConfigurationManagerImpl implements ConfigurationManager { - private final Logger log = LogManager.getLogger("onlyoffice.managers.configuration.ConfigurationManager"); - private final PluginSettings pluginSettings; - - private final String configurationPath = "onlyoffice-config.properties"; - private final String formatsPath = "app_data/document-formats/onlyoffice-docs-formats.json"; - private final String pluginDemoName = "onlyoffice.demo"; - private final String pluginDemoNameStart = "onlyoffice.demoStart"; - - private Map demoData; - private List supportedFormats; - - public ConfigurationManagerImpl(final PluginSettingsFactory pluginSettingsFactory) { - pluginSettings = pluginSettingsFactory.createGlobalSettings(); - - demoData = new HashMap(); - demoData.put("url", "https://onlinedocs.onlyoffice.com/"); - demoData.put("header", "AuthorizationJWT"); - demoData.put("secret", "sn2puSUF7muF5Jas"); - demoData.put("trial", "30"); - - InputStream inputStream = getClass().getClassLoader().getResourceAsStream(formatsPath); - - ObjectMapper objectMapper = new ObjectMapper(); - try { - supportedFormats = objectMapper.readValue(inputStream, new TypeReference>() { }); - } catch (IOException e) { - log.error(e.getMessage(), e); - } - } - - public Properties getProperties() throws IOException { - Properties properties = new Properties(); - InputStream inputStream = getClass().getClassLoader().getResourceAsStream(configurationPath); - if (inputStream != null) { - properties.load(inputStream); - } - return properties; - } - - public String getProperty(final String propertyName) { - try { - Properties properties = getProperties(); - String property = properties.getProperty(propertyName); - return property; - } catch (IOException e) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - e.printStackTrace(pw); - log.error(e.toString() + "\n" + sw.toString()); - return null; - } - } - - public boolean forceSaveEnabled() { - String forceSave = (String) pluginSettings.get("onlyoffice.forceSave"); - if (forceSave == null || forceSave.isEmpty()) { - return false; - } - return Boolean.parseBoolean(forceSave); - } - - public boolean selectDemo(final Boolean demo) { - pluginSettings.put(pluginDemoName, demo.toString()); - if (demo) { - String demoStart = (String) pluginSettings.get(pluginDemoNameStart); - if (demoStart == null || demoStart.isEmpty()) { - DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); - Date date = new Date(); - pluginSettings.put(pluginDemoNameStart, dateFormat.format(date)); - } - return true; - } - return false; - } - - public Boolean demoEnabled() { - String demo = (String) pluginSettings.get(pluginDemoName); - if (demo == null || demo.isEmpty()) { - return false; - } - return Boolean.parseBoolean(demo); - } - - public Boolean demoAvailable(final Boolean forActivate) { - String demoStart = (String) pluginSettings.get(pluginDemoNameStart); - if (demoStart != null && !demoStart.isEmpty()) { - DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); - try { - Calendar date = Calendar.getInstance(); - date.setTime(dateFormat.parse(demoStart)); - date.add(Calendar.DATE, Integer.parseInt(demoData.get("trial"))); - - return date.after(Calendar.getInstance()); - } catch (ParseException e) { - e.printStackTrace(); - } - } - return forActivate; - } - - public Boolean demoActive() { - return demoEnabled() && demoAvailable(false); - } - - public String getDemo(final String key) { - return demoData.get(key); - } - - public Boolean getBooleanPluginSetting(final String key, final Boolean defaultValue) { - String setting = (String) pluginSettings.get("onlyoffice." + key); - if (setting == null || setting.isEmpty()) { - return defaultValue; - } - return Boolean.parseBoolean(setting); - } - - public String getStringPluginSetting(final String key, final String defaultValue) { - String setting = (String) pluginSettings.get("onlyoffice." + key); - if (setting == null || setting.isEmpty()) { - return defaultValue; - } - return setting; - } - - public Map getCustomizableEditingTypes() { - Map customizableEditingTypes = new HashMap<>(); - List editingTypes; - - String editingTypesString = (String) pluginSettings.get("onlyoffice.editingTypes"); - - if (editingTypesString != null && !editingTypesString.isEmpty()) { - editingTypes = Arrays.asList( - editingTypesString.substring(1, editingTypesString.length() - 1).replace("\"", "").split(",")); - } else { - editingTypes = Arrays.asList("csv", "txt"); - } - - List formats = this.getSupportedFormats(); - - for (Format format : formats) { - if (format.getActions().contains("lossy-edit")) { - customizableEditingTypes.put(format.getName(), editingTypes.contains(format.getName())); - } - } - - return customizableEditingTypes; - } - - public CloseableHttpClient getHttpClient() throws Exception { - Integer timeout = (int) TimeUnit.SECONDS.toMillis(Long.parseLong(getProperty("timeout"))); - RequestConfig config = RequestConfig.custom().setConnectTimeout(timeout).setSocketTimeout(timeout).build(); - - CloseableHttpClient httpClient; - - if (getBooleanPluginSetting("verifyCertificate", false) && !demoActive()) { - SSLContextBuilder builder = new SSLContextBuilder(); - - builder.loadTrustMaterial(null, new TrustStrategy() { - @Override - public boolean isTrusted(final X509Certificate[] chain, final String authType) - throws CertificateException { - return true; - } - }); - - SSLConnectionSocketFactory sslConnectionSocketFactory = - new SSLConnectionSocketFactory(builder.build(), new HostnameVerifier() { - @Override - public boolean verify(final String hostname, final SSLSession session) { - return true; - } - }); - - httpClient = - HttpClients.custom().setSSLSocketFactory(sslConnectionSocketFactory).setDefaultRequestConfig(config) - .build(); - } else { - httpClient = HttpClientBuilder.create().setDefaultRequestConfig(config).build(); - } - - return httpClient; - } - - public List getSupportedFormats() { - return supportedFormats; - } -} - diff --git a/src/main/java/onlyoffice/managers/convert/ConvertManager.java b/src/main/java/onlyoffice/managers/convert/ConvertManager.java deleted file mode 100644 index a466aeb2..00000000 --- a/src/main/java/onlyoffice/managers/convert/ConvertManager.java +++ /dev/null @@ -1,18 +0,0 @@ -package onlyoffice.managers.convert; - -import com.atlassian.confluence.user.ConfluenceUser; -import org.json.JSONObject; -import java.util.List; -import java.io.Serializable; - -public interface ConvertManager extends Serializable { - JSONObject convert(Long attachmentId, String ext, String convertToExt, ConfluenceUser user, - String title) throws Exception; - - JSONObject convert(Long attachmentId, String currentExt, String convertToExt, String url, String region, - boolean async, String title) throws Exception; - - String getTargetExt(String ext); - - List getTargetExtList(String ext); -} diff --git a/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java b/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java deleted file mode 100644 index c38e6597..00000000 --- a/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java +++ /dev/null @@ -1,186 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.managers.convert; - -import com.atlassian.confluence.languages.LocaleManager; -import com.atlassian.confluence.user.ConfluenceUser; -import onlyoffice.managers.configuration.ConfigurationManager; -import onlyoffice.managers.document.DocumentManager; -import onlyoffice.managers.jwt.JwtManager; -import onlyoffice.managers.url.UrlManager; -import onlyoffice.model.Format; -import org.apache.commons.io.IOUtils; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; -import org.json.JSONObject; - -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.List; - -public class ConvertManagerImpl implements ConvertManager { - private final Logger log = LogManager.getLogger("onlyoffice.managers.convert.ConvertManager"); - - private static final int NOT_REACHED_STATUS = -10; - - private final LocaleManager localeManager; - private final UrlManager urlManager; - private final JwtManager jwtManager; - private final ConfigurationManager configurationManager; - private final DocumentManager documentManager; - - public ConvertManagerImpl(final UrlManager urlManager, final JwtManager jwtManager, - final ConfigurationManager configurationManager, - final DocumentManager documentManager, final LocaleManager localeManager) { - this.urlManager = urlManager; - this.jwtManager = jwtManager; - this.configurationManager = configurationManager; - this.documentManager = documentManager; - this.localeManager = localeManager; - } - - public JSONObject convert(final Long attachmentId, final String ext, final String convertToExt, - final ConfluenceUser user, final String title) throws Exception { - String url = urlManager.getFileUri(attachmentId); - String region = localeManager.getLocale(user).toLanguageTag(); - return convert(attachmentId, ext, convertToExt, url, region, true, title); - } - - public JSONObject convert(final Long attachmentId, final String currentExt, final String convertToExt, - final String url, final String region, final boolean async, - final String title) throws Exception { - try (CloseableHttpClient httpClient = configurationManager.getHttpClient()) { - JSONObject body = new JSONObject(); - body.put("async", async); - body.put("embeddedfonts", true); - body.put("filetype", currentExt); - body.put("outputtype", convertToExt); - body.put("key", documentManager.getKeyOfFile(attachmentId, false)); - body.put("url", url); - body.put("region", region); - body.put("title", title); - - if (Arrays.asList("bmp", "gif", "jpg", "png").contains(convertToExt)) { - JSONObject thumbnail = new JSONObject(); - thumbnail.put("first", false); - body.put("thumbnail", thumbnail); - } - - StringEntity requestEntity = new StringEntity(body.toString(), ContentType.APPLICATION_JSON); - String conversionServiceUrl = urlManager.getInnerDocEditorUrl() + configurationManager - .getProperties() - .getProperty("files.docservice.url.convert"); - - HttpPost request = new HttpPost(conversionServiceUrl); - request.setEntity(requestEntity); - request.setHeader("Accept", "application/json"); - - if (jwtManager.jwtEnabled()) { - String token = jwtManager.createToken(body); - JSONObject payloadBody = new JSONObject(); - payloadBody.put("payload", body); - String headerToken = jwtManager.createToken(body); - body.put("token", token); - String header = jwtManager.getJwtHeader(); - request.setHeader(header, "Bearer " + headerToken); - } - - log.debug("Sending POST to Docserver: " + body.toString()); - JSONObject callBackJson = new JSONObject(); - - try (CloseableHttpResponse response = httpClient.execute(request)) { - int status = response.getStatusLine().getStatusCode(); - - if (status != HttpStatus.SC_OK) { - log.error("Conversion service returned code " + status + ". URL: " + conversionServiceUrl); - callBackJson.put("error", NOT_REACHED_STATUS); - } else { - InputStream is = response.getEntity().getContent(); - String content = IOUtils.toString(is, StandardCharsets.UTF_8); - - log.debug("Docserver returned: " + content); - - try { - callBackJson = new JSONObject(content); - } catch (Exception e) { - throw new Exception("Couldn't convert JSON from docserver: " + e.getMessage()); - } - } - - return callBackJson; - } - } - } - - public String getTargetExt(final String ext) { - List supportedFormats = configurationManager.getSupportedFormats(); - - for (Format format : supportedFormats) { - if (format.getName().equals(ext)) { - switch (format.getType()) { - case WORD: - if (format.getName().equals("docxf") && format.getConvert().contains("oform")) { - return "oform"; - } - if (format.getName().equals("docx") && format.getConvert().contains("docxf")) { - return "docxf"; - } - if (format.getConvert().contains("docx")) { - return "docx"; - } - break; - case CELL: - if (format.getConvert().contains("xlsx")) { - return "xlsx"; - } - break; - case SLIDE: - if (format.getConvert().contains("pptx")) { - return "pptx"; - } - break; - default: - break; - } - } - } - - return null; - } - - public List getTargetExtList(final String ext) { - List supportedFormats = configurationManager.getSupportedFormats(); - - for (Format format : supportedFormats) { - if (format.getName().equals(ext)) { - return format.getConvert(); - } - } - - return null; - } - -} diff --git a/src/main/java/onlyoffice/managers/document/DocumentManager.java b/src/main/java/onlyoffice/managers/document/DocumentManager.java deleted file mode 100644 index 5e826f99..00000000 --- a/src/main/java/onlyoffice/managers/document/DocumentManager.java +++ /dev/null @@ -1,43 +0,0 @@ -package onlyoffice.managers.document; - -import com.atlassian.confluence.user.ConfluenceUser; -import onlyoffice.model.config.DocumentType; -import onlyoffice.model.config.Type; - -import java.io.IOException; -import java.io.Serializable; -import java.util.List; - -public interface DocumentManager extends Serializable { - long getMaxFileSize(); - - long getConvertationFileSizeMax(); - - String getKeyOfFile(Long attachmentId, boolean embedded); - - String createHash(String str); - - String readHash(String base64); - - String getCorrectName(String fileName, String fileExt, Long pageID); - - Long createDemo(String fileName, String fileExt, Long pageID, ConfluenceUser user) throws IOException; - - DocumentType getDocType(String ext); - - Type getEditorType(String userAgent); - - String getMimeType(String name); - - boolean isEditable(String fileExtension); - - boolean isFillForm(String fileExtension); - - boolean isViewable(String fileExtension); - - List getInsertImageTypes(); - - List getCompareFileTypes(); - - List getMailMergeTypes(); -} diff --git a/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java b/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java deleted file mode 100644 index cd89cf26..00000000 --- a/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java +++ /dev/null @@ -1,332 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.managers.document; - - -import com.atlassian.confluence.core.ContentEntityManager; -import com.atlassian.confluence.core.ContentEntityObject; -import com.atlassian.confluence.languages.LocaleManager; -import com.atlassian.confluence.pages.Attachment; -import com.atlassian.confluence.pages.AttachmentManager; -import com.atlassian.confluence.user.ConfluenceUser; -import com.atlassian.plugin.PluginAccessor; -import com.atlassian.sal.api.message.I18nResolver; -import com.atlassian.spring.container.ContainerManager; -import onlyoffice.managers.configuration.ConfigurationManager; -import onlyoffice.model.Format; -import onlyoffice.model.config.DocumentType; -import onlyoffice.model.config.Type; -import onlyoffice.utils.attachment.AttachmentUtil; -import org.apache.commons.codec.binary.Hex; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.security.MessageDigest; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; -import java.util.List; -import java.util.Map; -import java.util.regex.Pattern; - -public class DocumentManagerImpl implements DocumentManager { - private final Logger log = LogManager.getLogger("onlyoffice.managers.document.DocumentManager"); - private static final String USER_AGENT_MOBILE = "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec" - + "|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone" - + "|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap" - + "|windows (ce|phone)|xda|xiino"; - private static final int DEFAULT_MAX_FILE_SIZE = 5242880; - private static final int MAX_KEY_LENGTH = 20; - - private final I18nResolver i18nResolver; - private final ConfigurationManager configurationManager; - private final AttachmentUtil attachmentUtil; - - public DocumentManagerImpl(final I18nResolver i18nResolver, final ConfigurationManager configurationManager, - final AttachmentUtil attachmentUtil) { - this.i18nResolver = i18nResolver; - this.configurationManager = configurationManager; - this.attachmentUtil = attachmentUtil; - } - - public long getMaxFileSize() { - long size; - try { - String filesizeMax = configurationManager.getProperty("filesize-max"); - size = Long.parseLong(filesizeMax); - } catch (Exception ex) { - size = 0; - } - - return size > 0 ? size : DEFAULT_MAX_FILE_SIZE; - } - - public String getKeyOfFile(final Long attachmentId, final boolean embedded) { - String key = attachmentUtil.getCollaborativeEditingKey(attachmentId); - if (key == null) { - String hashCode = attachmentUtil.getHashCode(attachmentId); - key = generateRevisionId(hashCode); - } - - return embedded ? key + "_embedded" : key; - } - - public long getConvertationFileSizeMax() { - long size; - try { - String filesizeMax = configurationManager.getProperty("convertation-filesize-max"); - size = Long.parseLong(filesizeMax); - } catch (Exception ex) { - size = 0; - } - - return size > 0 ? size : DEFAULT_MAX_FILE_SIZE; - } - - private String generateRevisionId(final String expectedKey) { - String result = expectedKey; - - if (result.length() > MAX_KEY_LENGTH) { - result = Integer.toString(result.hashCode()); - } - String key = result.replace("[^0-9-.a-zA-Z_=]", "_"); - key = key.substring(0, Math.min(key.length(), MAX_KEY_LENGTH)); - log.info("key = " + key); - return key; - } - - public String createHash(final String str) { - try { - String secret = configurationManager.getProperty("files.docservice.secret"); - - String payload = getHashHex(str + secret) + "?" + str; - - String base64 = Base64.getEncoder().encodeToString(payload.getBytes("UTF-8")); - return base64; - } catch (Exception ex) { - log.error(ex); - } - return ""; - } - - public String readHash(final String base64) { - try { - String str = new String(Base64.getDecoder().decode(base64), "UTF-8"); - - String secret = configurationManager.getProperty("files.docservice.secret"); - - String[] payloadParts = str.split("\\?"); - - String payload = getHashHex(payloadParts[1] + secret); - if (payload.equals(payloadParts[0])) { - return payloadParts[1]; - } - } catch (Exception ex) { - log.error(ex); - } - return ""; - } - - private String getHashHex(final String str) { - try { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - byte[] digest = md.digest(str.getBytes()); - String hex = Hex.encodeHexString(digest); - - return hex; - } catch (Exception ex) { - log.error(ex); - } - return ""; - } - - public String getCorrectName(final String fileName, final String fileExt, final Long pageID) { - ContentEntityManager contentEntityManager = - (ContentEntityManager) ContainerManager.getComponent("contentEntityManager"); - AttachmentManager attachmentManager = (AttachmentManager) ContainerManager.getComponent("attachmentManager"); - ContentEntityObject contentEntityObject = contentEntityManager.getById(pageID); - - List attachments = attachmentManager.getLatestVersionsOfAttachments(contentEntityObject); - String name = (fileName + "." + fileExt).replaceAll("[*?:\"<>/|\\\\]", "_"); - int count = 0; - Boolean flag = true; - - while (flag) { - flag = false; - for (Attachment attachment : attachments) { - if (attachment.getFileName().equals(name)) { - count++; - name = fileName + " (" + count + ")." + fileExt; - flag = true; - break; - } - } - } - - return name; - } - - private InputStream getDemoFile(final ConfluenceUser user, final String fileExt) { - LocaleManager localeManager = (LocaleManager) ContainerManager.getComponent("localeManager"); - PluginAccessor pluginAccessor = (PluginAccessor) ContainerManager.getComponent("pluginAccessor"); - - String pathToDemoFile = "app_data/document-templates/" + localeManager - .getLocale(user) - .toString() - .replace("_", "-"); - - if (pluginAccessor.getDynamicResourceAsStream(pathToDemoFile) == null) { - pathToDemoFile = "app_data/en-US"; - } - - return pluginAccessor.getDynamicResourceAsStream(pathToDemoFile + "/new." + fileExt); - } - - public Long createDemo(final String fileName, final String fileExt, final Long pageId, final ConfluenceUser user) - throws - IOException { - String extension = - fileExt == null || !fileExt.equals("xlsx") && !fileExt.equals("pptx") && !fileExt.equals("docxf") - ? "docx" : fileExt.trim(); - String name = fileName == null || fileName.equals("") - ? i18nResolver.getText("onlyoffice.editor.dialog.filecreate." + extension) : fileName; - - InputStream demoFile = getDemoFile(user, extension); - - name = getCorrectName(name, extension, pageId); - String mimeType = getMimeType(name); - - Attachment attachment = - attachmentUtil.createNewAttachment(name, mimeType, demoFile, demoFile.available(), pageId, user); - - return attachment.getContentId().asLong(); - } - - public DocumentType getDocType(final String ext) { - List supportedFormats = configurationManager.getSupportedFormats(); - - for (Format format : supportedFormats) { - if (format.getName().equals(ext)) { - - return format.getType(); - } - } - - return null; - } - - public String getMimeType(final String name) { - Path path = new File(name).toPath(); - String mimeType = null; - try { - mimeType = Files.probeContentType(path); - } catch (IOException e) { - log.error(e.getMessage(), e); - } - return mimeType != null ? mimeType : "application/octet-stream"; - } - - public Type getEditorType(final String userAgent) { - Pattern pattern = Pattern.compile(USER_AGENT_MOBILE, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); - if (userAgent != null && pattern.matcher(userAgent).find()) { - return Type.MOBILE; - } else { - return Type.DESKTOP; - } - } - - public boolean isEditable(final String ext) { - List supportedFormats = configurationManager.getSupportedFormats(); - - for (Format format : supportedFormats) { - if (format.getName().equals(ext) && format.getActions().contains("edit")) { - return true; - } - } - - Map customizableEditingTypes = configurationManager.getCustomizableEditingTypes(); - - for (Map.Entry customizableEditingType : customizableEditingTypes.entrySet()) { - if (customizableEditingType.getKey().equals(ext) && customizableEditingType.getValue()) { - return true; - } - } - - return false; - } - - public boolean isFillForm(final String ext) { - List supportedFormats = configurationManager.getSupportedFormats(); - - for (Format format : supportedFormats) { - if (format.getName().equals(ext) && format.getActions().contains("fill")) { - return true; - } - } - - return false; - } - - public boolean isViewable(final String fileExtension) { - List supportedFormats = configurationManager.getSupportedFormats(); - - for (Format format : supportedFormats) { - if (format.getName().equals(fileExtension) && format.getActions().contains("view")) { - return true; - } - } - - return false; - } - - public List getInsertImageTypes() { - return Arrays.asList("bmp", "gif", "jpeg", "jpg", "png"); - } - - public List getCompareFileTypes() { - List supportedFormats = configurationManager.getSupportedFormats(); - List result = new ArrayList<>(); - - for (Format format : supportedFormats) { - if (format.getType().equals(DocumentType.WORD)) { - result.add(format.getName()); - } - } - - return result; - } - - public List getMailMergeTypes() { - List supportedFormats = configurationManager.getSupportedFormats(); - List result = new ArrayList<>(); - - for (Format format : supportedFormats) { - if (format.getType().equals(DocumentType.CELL)) { - result.add(format.getName()); - } - } - - return result; - } -} diff --git a/src/main/java/onlyoffice/managers/jwt/JwtManager.java b/src/main/java/onlyoffice/managers/jwt/JwtManager.java deleted file mode 100644 index fb87286d..00000000 --- a/src/main/java/onlyoffice/managers/jwt/JwtManager.java +++ /dev/null @@ -1,23 +0,0 @@ -package onlyoffice.managers.jwt; - -import org.json.JSONObject; - -import java.io.Serializable; -import java.util.Map; - -public interface JwtManager extends Serializable { - - String createToken(Object payload) throws Exception; - - String createToken(JSONObject payload) throws Exception; - - String verify(String token); - - String createInternalToken(Map payloadMap); - - String verifyInternalToken(String token); - - Boolean jwtEnabled(); - - String getJwtHeader(); -} diff --git a/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java b/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java deleted file mode 100644 index ae9c0f27..00000000 --- a/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.managers.jwt; - -import com.atlassian.config.ApplicationConfiguration; -import com.atlassian.sal.api.pluginsettings.PluginSettings; -import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; -import com.auth0.jwt.JWT; -import com.auth0.jwt.algorithms.Algorithm; -import com.auth0.jwt.interfaces.DecodedJWT; -import com.fasterxml.jackson.databind.ObjectMapper; -import onlyoffice.managers.configuration.ConfigurationManager; -import org.json.JSONObject; - -import java.util.Base64; -import java.util.Map; -import java.util.Random; - -public class JwtManagerImpl implements JwtManager { - - private static final long ACCEPT_LEEWAY = 3; - private static final int PLUGIN_SECRET_LENGTH = 32; - - private final ApplicationConfiguration applicationConfiguration; - private final ConfigurationManager configurationManager; - private final PluginSettings settings; - - public JwtManagerImpl(final PluginSettingsFactory pluginSettingsFactory, - final ApplicationConfiguration applicationConfiguration, - final ConfigurationManager configurationManager) { - settings = pluginSettingsFactory.createGlobalSettings(); - this.applicationConfiguration = applicationConfiguration; - this.configurationManager = configurationManager; - } - - public String createToken(final Object payload) { - ObjectMapper objectMapper = new ObjectMapper(); - Map payloadMap = objectMapper.convertValue(payload, Map.class); - - return createToken(payloadMap, getJwtSecret()); - } - - public String createToken(final JSONObject payload) throws Exception { - ObjectMapper objectMapper = new ObjectMapper(); - Map payloadMap = objectMapper.readValue(payload.toString(), Map.class); - - return createToken(payloadMap, getJwtSecret()); - } - - public String verify(final String token) { - return verifyToken(token, getJwtSecret()); - } - - public String createInternalToken(final Map payloadMap) { - return createToken(payloadMap, getPluginSecret()); - } - - public String verifyInternalToken(final String token) { - return verifyToken(token, getPluginSecret()); - } - - public Boolean jwtEnabled() { - return configurationManager.demoActive() || settings.get("onlyoffice.jwtSecret") != null - && !((String) settings.get("onlyoffice.jwtSecret")).isEmpty(); - } - - public String getJwtHeader() { - String header = configurationManager.demoActive() - ? configurationManager - .getDemo("header") : (String) applicationConfiguration.getProperty("onlyoffice.jwt.header"); - return header == null || header.isEmpty() ? "Authorization" : header; - } - - private String getJwtSecret() { - return configurationManager.demoActive() - ? configurationManager.getDemo("secret") : (String) settings.get("onlyoffice.jwtSecret"); - } - - private String createToken(final Map payloadMap, final String key) { - Algorithm algorithm = Algorithm.HMAC256(key); - - String token = JWT.create() - .withPayload(payloadMap) - .sign(algorithm); - - return token; - } - - private String verifyToken(final String token, final String key) { - Algorithm algorithm = Algorithm.HMAC256(key); - Base64.Decoder decoder = Base64.getUrlDecoder(); - - DecodedJWT jwt = JWT.require(algorithm) - .acceptLeeway(ACCEPT_LEEWAY) - .build() - .verify(token); - - return new String(decoder.decode(jwt.getPayload())); - } - - private String getPluginSecret() { - if (settings.get("onlyoffice.plugin-secret") == null || settings.get("onlyoffice.plugin-secret").equals("")) { - Random random = new Random(); - char[] numbersAndLetters = ("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").toCharArray(); - - char[] randBuffer = new char[PLUGIN_SECRET_LENGTH]; - for (int i = 0; i < randBuffer.length; i++) { - randBuffer[i] = numbersAndLetters[random.nextInt(numbersAndLetters.length)]; - } - - String secret = new String(randBuffer); - - settings.put("onlyoffice.plugin-secret", secret); - - return secret; - } else { - return (String) settings.get("onlyoffice.plugin-secret"); - } - } -} diff --git a/src/main/java/onlyoffice/managers/url/UrlManager.java b/src/main/java/onlyoffice/managers/url/UrlManager.java deleted file mode 100644 index de89e877..00000000 --- a/src/main/java/onlyoffice/managers/url/UrlManager.java +++ /dev/null @@ -1,37 +0,0 @@ -package onlyoffice.managers.url; - -import onlyoffice.model.config.DocumentType; - -import java.io.Serializable; - -public interface UrlManager extends Serializable { - String getPublicDocEditorUrl(); - - String getInnerDocEditorUrl(); - - String getFileUri(Long attachmentId); - - String getAttachmentDiffUri(Long attachmentId); - - String getHistoryInfoUri(Long attachmentId); - - String getHistoryDataUri(Long attachmentId); - - String getAttachmentDataUri(); - - String getSaveAsUri(); - - String getReferenceDataUri(Long pageId); - - String getCallbackUrl(Long attachmentId); - - String getGobackUrl(Long attachmentId, String referer); - - String getCreateUri(Long pageId, String ext); - - String replaceDocEditorURLToInternal(String url); - - String getDocServiceApiUrl(); - - String getFaviconUrl(DocumentType documentType); -} diff --git a/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java b/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java deleted file mode 100644 index 3bd4db02..00000000 --- a/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java +++ /dev/null @@ -1,238 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.managers.url; - -import com.atlassian.confluence.pages.Attachment; -import com.atlassian.confluence.pages.AttachmentManager; -import com.atlassian.plugin.webresource.UrlMode; -import com.atlassian.plugin.webresource.WebResourceUrlProvider; -import com.atlassian.confluence.setup.settings.SettingsManager; -import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; -import com.atlassian.confluence.user.ConfluenceUser; -import com.atlassian.confluence.util.GeneralUtil; -import com.atlassian.sal.api.pluginsettings.PluginSettings; -import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; -import com.atlassian.spring.container.ContainerManager; -import onlyoffice.managers.configuration.ConfigurationManager; -import onlyoffice.managers.document.DocumentManager; -import onlyoffice.model.config.DocumentType; -import onlyoffice.managers.jwt.JwtManager; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; - -import java.util.HashMap; -import java.util.Map; - -public class UrlManagerImpl implements UrlManager { - private final Logger log = LogManager.getLogger("onlyoffice.managers.url.UrlManager"); - private final String docEditorServlet = "plugins/servlet/onlyoffice/doceditor"; - private final String callbackServlet = "plugins/servlet/onlyoffice/save"; - private final String historyServlet = "plugins/servlet/onlyoffice/history"; - private final String fileProviderServlet = "plugins/servlet/onlyoffice/file-provider"; - private final String apiServlet = "plugins/servlet/onlyoffice/api"; - - private final WebResourceUrlProvider webResourceUrlProvider; - private final SettingsManager settingsManager; - private final PluginSettings pluginSettings; - private final ConfigurationManager configurationManager; - private final DocumentManager documentManager; - private final JwtManager jwtManager; - - public UrlManagerImpl(final WebResourceUrlProvider webResourceUrlProvider, - final PluginSettingsFactory pluginSettingsFactory, final SettingsManager settingsManager, - final ConfigurationManager configurationManager, final DocumentManager documentManager, - final JwtManager jwtManager) { - this.webResourceUrlProvider = webResourceUrlProvider; this.settingsManager = settingsManager; - this.configurationManager = configurationManager; - this.documentManager = documentManager; - this.jwtManager = jwtManager; - pluginSettings = pluginSettingsFactory.createGlobalSettings(); - } - - public String getPublicDocEditorUrl() { - String url = ""; - if (configurationManager.demoActive()) { - url = configurationManager.getDemo("url"); - } else { - url = (String) pluginSettings.get("onlyoffice.apiUrl"); - } - return (url == null || url.isEmpty()) ? "" : url; - } - - - public String getInnerDocEditorUrl() { - String url = (String) pluginSettings.get("onlyoffice.docInnerUrl"); - if (url == null || url.isEmpty() || configurationManager.demoActive()) { - return getPublicDocEditorUrl(); - } else { - return url; - } - } - - public String getFileUri(final Long attachmentId) { - ConfluenceUser user = AuthenticatedUserThreadLocal.get(); - - Map params = new HashMap<>(); - - if (user != null) { - params.put("userKey", user.getKey().getStringValue()); - } - params.put("attachmentId", attachmentId.toString()); - params.put("action", "download"); - - String fileUri = - getConfluenceBaseUrl() + fileProviderServlet + "?token=" + jwtManager.createInternalToken(params); - - return fileUri; - } - - public String getAttachmentDiffUri(final Long attachmentId) { - String hash = documentManager.createHash(Long.toString(attachmentId)); - String diffAttachmentUrl = - getConfluenceBaseUrl() + historyServlet + "?type=diff&vkey=" + GeneralUtil.urlEncode(hash); - - return diffAttachmentUrl; - } - - public String getHistoryInfoUri(final Long attachmentId) { - String hash = documentManager.createHash(Long.toString(attachmentId)); - String historyInfoUri = - getConfluenceBaseUrl() + historyServlet + "?type=info&vkey=" + GeneralUtil.urlEncode(hash); - - return historyInfoUri; - } - - public String getHistoryDataUri(final Long attachmentId) { - String hash = documentManager.createHash(Long.toString(attachmentId)); - String historyDataUri = - getConfluenceBaseUrl() + historyServlet + "?type=data&vkey=" + GeneralUtil.urlEncode(hash); - - return historyDataUri; - } - - public String getAttachmentDataUri() { - String attachmentDataUri = getConfluenceBaseUrl() + apiServlet + "?type=attachment-data"; - - return attachmentDataUri; - } - - public String getSaveAsUri() { - String saveAsUri = getConfluenceBaseUrl() + apiServlet + "?type=save-as"; - - return saveAsUri; - } - - public String getReferenceDataUri(final Long pageId) { - String referenceDataUri = getConfluenceBaseUrl() + apiServlet + "?type=reference-data&pageId=" + pageId; - - return referenceDataUri; - } - - public String getCallbackUrl(final Long attachmentId) { - ConfluenceUser user = AuthenticatedUserThreadLocal.get(); - - Map params = new HashMap<>(); - params.put("userKey", user.getKey().getStringValue()); - params.put("attachmentId", attachmentId.toString()); - params.put("action", "callback"); - - String callbackUrl = - getConfluenceBaseUrl() + callbackServlet + "?token=" + jwtManager.createInternalToken(params); - log.info("callbackUrl " + callbackUrl); - - return callbackUrl; - } - - public String getGobackUrl(final Long attachmentId, final String referer) { - String gobackUrl = ""; - - if (referer != null && referer.contains("/display/")) { - gobackUrl = referer; - } else { - String viewPageAttachments = "/pages/viewpageattachments.action?pageId="; - AttachmentManager attachmentManager = - (AttachmentManager) ContainerManager.getComponent("attachmentManager"); - Attachment attachment = attachmentManager.getAttachment(attachmentId); - gobackUrl = settingsManager.getGlobalSettings().getBaseUrl() + viewPageAttachments - + attachment.getContainer().getContentId().asLong(); - } - - log.info("gobackUrl = " + gobackUrl); - - return gobackUrl; - } - - public String getCreateUri(final Long pageId, final String ext) { - - String targetExt = "docx"; - - switch (documentManager.getDocType(ext)) { - case WORD: - targetExt = ext.equals("docxf") ? "docxf" : "docx"; - break; - case CELL: - targetExt = "xlsx"; - break; - case SLIDE: - targetExt = "pptx"; - break; - default: - } - - return getConfluenceBaseUrl() + docEditorServlet + "?pageId=" + pageId + "&fileExt=" + targetExt; - } - - private String getConfluenceBaseUrl() { - String url = (String) pluginSettings.get("onlyoffice.confUrl"); - if (url == null || url.isEmpty()) { - return settingsManager.getGlobalSettings().getBaseUrl() + "/"; - } else { - return url; - } - } - - public String replaceDocEditorURLToInternal(final String url) { - String innerDocEditorUrl = getInnerDocEditorUrl(); - String publicDocEditorUrl = getPublicDocEditorUrl(); - String result = url; - - if (!publicDocEditorUrl.equals(innerDocEditorUrl) && !configurationManager.demoActive()) { - result = result.replace(publicDocEditorUrl, innerDocEditorUrl); - } - return result; - } - - public String getDocServiceApiUrl() { - return getPublicDocEditorUrl() + configurationManager.getProperty("files.docservice.url.api"); - } - - public String getFaviconUrl(final DocumentType documentType) { - String nameIcon = "word"; - - if (documentType != null) { - nameIcon = documentType.name().toLowerCase(); - } - - return webResourceUrlProvider.getStaticPluginResourceUrl( - "onlyoffice.onlyoffice-confluence-plugin:onlyoffice-confluence-plugin-resources-editor", - nameIcon + ".ico", - UrlMode.ABSOLUTE - ); - } -} diff --git a/src/main/resources/atlassian-plugin.xml b/src/main/resources/atlassian-plugin.xml index 745e9db3..68238dcb 100644 --- a/src/main/resources/atlassian-plugin.xml +++ b/src/main/resources/atlassian-plugin.xml @@ -215,30 +215,12 @@ onlyoffice.managers.auth.AuthContext - - onlyoffice.managers.configuration.ConfigurationManager - - - onlyoffice.managers.convert.ConvertManager - - - onlyoffice.managers.document.DocumentManager - - - onlyoffice.managers.jwt.JwtManager - - - onlyoffice.managers.url.UrlManager - onlyoffice.utils.attachment.AttachmentUtil onlyoffice.utils.parsing.ParsingUtil - - onlyoffice.managers.config.ConfigManager - onlyoffice.macro.components.ContentResolver From 41679d2bb1c647189a38f7ae3bace2f0a08273fb Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:34:21 +0300 Subject: [PATCH 14/87] delete: unused models --- src/main/java/onlyoffice/model/Format.java | 72 ----------- .../java/onlyoffice/model/config/Config.java | 114 ----------------- .../onlyoffice/model/config/DocumentType.java | 34 ----- .../java/onlyoffice/model/config/Type.java | 30 ----- .../model/config/document/Document.java | 83 ------------ .../model/config/document/Permissions.java | 42 ------ .../model/config/document/ReferenceData.java | 45 ------- .../model/config/editor/Customization.java | 120 ------------------ .../model/config/editor/EditorConfig.java | 118 ----------------- .../model/config/editor/Goback.java | 37 ------ .../onlyoffice/model/config/editor/Mode.java | 28 ---- .../model/config/editor/ReviewDisplay.java | 30 ----- .../onlyoffice/model/config/editor/User.java | 47 ------- 13 files changed, 800 deletions(-) delete mode 100644 src/main/java/onlyoffice/model/Format.java delete mode 100644 src/main/java/onlyoffice/model/config/Config.java delete mode 100644 src/main/java/onlyoffice/model/config/DocumentType.java delete mode 100644 src/main/java/onlyoffice/model/config/Type.java delete mode 100644 src/main/java/onlyoffice/model/config/document/Document.java delete mode 100644 src/main/java/onlyoffice/model/config/document/Permissions.java delete mode 100644 src/main/java/onlyoffice/model/config/document/ReferenceData.java delete mode 100644 src/main/java/onlyoffice/model/config/editor/Customization.java delete mode 100644 src/main/java/onlyoffice/model/config/editor/EditorConfig.java delete mode 100644 src/main/java/onlyoffice/model/config/editor/Goback.java delete mode 100644 src/main/java/onlyoffice/model/config/editor/Mode.java delete mode 100644 src/main/java/onlyoffice/model/config/editor/ReviewDisplay.java delete mode 100644 src/main/java/onlyoffice/model/config/editor/User.java diff --git a/src/main/java/onlyoffice/model/Format.java b/src/main/java/onlyoffice/model/Format.java deleted file mode 100644 index d99b824c..00000000 --- a/src/main/java/onlyoffice/model/Format.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.model; - -import onlyoffice.model.config.DocumentType; - -import java.util.List; - -public class Format { - private String name; - private DocumentType type; - private List actions; - private List convert; - private List mime; - - public String getName() { - return name; - } - - public DocumentType getType() { - return type; - } - - public List getActions() { - return actions; - } - - public List getConvert() { - return convert; - } - - public List getMime() { - return mime; - } - - public void setName(final String name) { - this.name = name; - } - - public void setType(final DocumentType type) { - this.type = type; - } - - public void setAction(final List actions) { - this.actions = actions; - } - - public void setConvert(final List convert) { - this.convert = convert; - } - - public void setMime(final List mime) { - this.mime = mime; - } - -} diff --git a/src/main/java/onlyoffice/model/config/Config.java b/src/main/java/onlyoffice/model/config/Config.java deleted file mode 100644 index f5f69bdf..00000000 --- a/src/main/java/onlyoffice/model/config/Config.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.model.config; - -import com.atlassian.confluence.languages.LocaleManager; -import onlyoffice.managers.configuration.ConfigurationManager; -import onlyoffice.managers.document.DocumentManager; -import onlyoffice.managers.url.UrlManager; -import onlyoffice.model.config.document.Document; -import onlyoffice.model.config.editor.EditorConfig; -import onlyoffice.model.config.editor.Mode; -import onlyoffice.utils.attachment.AttachmentUtil; -import org.json.JSONObject; - -public class Config { - private Type type; - private DocumentType documentType; - private EditorConfig editorConfig; - private Document document; - private String token; - private String height = "100%"; - private String width = "100%"; - - public Config(final LocaleManager localeManager, final DocumentManager documentManager, - final AttachmentUtil attachmentUtil, final UrlManager urlManager, - final ConfigurationManager configurationManager, final Long attachmentId, final Mode mode, - final Type type, final JSONObject actionLink, final String referer, final String instanceId) { - this.type = type; - this.documentType = documentManager.getDocType(attachmentUtil.getFileExt(attachmentId)); - this.document = new Document(documentManager, attachmentUtil, urlManager, attachmentId, type, instanceId); - this.editorConfig = new EditorConfig( - localeManager, - attachmentUtil, - urlManager, - configurationManager, - attachmentId, - mode, - actionLink, - referer - ); - } - - public String getToken() { - return token; - } - - public void setToken(final String token) { - this.token = token; - } - - public String getHeight() { - return height; - } - - public void setHeight(final String height) { - this.height = height; - } - - public String getWidth() { - return width; - } - - public void setWidth(final String width) { - this.width = width; - } - - public Type getType() { - return type; - } - - public void setType(final Type type) { - this.type = type; - } - - public DocumentType getDocumentType() { - return documentType; - } - - public void setDocumentType(final DocumentType documentType) { - this.documentType = documentType; - } - - public EditorConfig getEditorConfig() { - return editorConfig; - } - - public void setEditorConfig(final EditorConfig editorConfig) { - this.editorConfig = editorConfig; - } - - public Document getDocument() { - return document; - } - - public void setDocument(final Document document) { - this.document = document; - } -} diff --git a/src/main/java/onlyoffice/model/config/DocumentType.java b/src/main/java/onlyoffice/model/config/DocumentType.java deleted file mode 100644 index ebb0a343..00000000 --- a/src/main/java/onlyoffice/model/config/DocumentType.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.model.config; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.gson.annotations.SerializedName; - -public enum DocumentType { - @JsonProperty("word") - @SerializedName("word") - WORD, - @JsonProperty("cell") - @SerializedName("cell") - CELL, - @JsonProperty("slide") - @SerializedName("slide") - SLIDE -} diff --git a/src/main/java/onlyoffice/model/config/Type.java b/src/main/java/onlyoffice/model/config/Type.java deleted file mode 100644 index 33c31c8a..00000000 --- a/src/main/java/onlyoffice/model/config/Type.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.model.config; - -import com.google.gson.annotations.SerializedName; - -public enum Type { - @SerializedName("desktop") - DESKTOP, - @SerializedName("mobile") - MOBILE, - @SerializedName("embedded") - EMBEDDED -} diff --git a/src/main/java/onlyoffice/model/config/document/Document.java b/src/main/java/onlyoffice/model/config/document/Document.java deleted file mode 100644 index cfb4cf2a..00000000 --- a/src/main/java/onlyoffice/model/config/document/Document.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.model.config.document; - -import onlyoffice.managers.document.DocumentManager; -import onlyoffice.managers.url.UrlManager; -import onlyoffice.model.config.Type; -import onlyoffice.utils.attachment.AttachmentUtil; - -public class Document { - private String key; - private String title; - private String url; - private String fileType; - private Permissions permissions; - private ReferenceData referenceData; - - public Document(final DocumentManager documentManager, final AttachmentUtil attachmentUtil, - final UrlManager urlManager, final Long attachmentId, final Type type, final String instanceId) { - key = documentManager.getKeyOfFile(attachmentId, type.equals(Type.EMBEDDED)); - title = attachmentUtil.getFileName(attachmentId); - fileType = attachmentUtil.getFileExt(attachmentId); - url = urlManager.getFileUri(attachmentId); - permissions = new Permissions(documentManager, attachmentUtil, attachmentId); - referenceData = new ReferenceData(attachmentId, instanceId); - } - - public String getKey() { - return key; - } - - public void setKey(final String key) { - this.key = key; - } - - public String getTitle() { - return title; - } - - public void setTitle(final String title) { - this.title = title; - } - - public String getUrl() { - return url; - } - - public void setUrl(final String url) { - this.url = url; - } - - public String getFileType() { - return fileType; - } - - public void setFileType(final String fileType) { - this.fileType = fileType; - } - - public Permissions getPermissions() { - return permissions; - } - - public void setPermissions(final Permissions permissions) { - this.permissions = permissions; - } -} diff --git a/src/main/java/onlyoffice/model/config/document/Permissions.java b/src/main/java/onlyoffice/model/config/document/Permissions.java deleted file mode 100644 index b37b9c48..00000000 --- a/src/main/java/onlyoffice/model/config/document/Permissions.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.model.config.document; - -import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; -import onlyoffice.managers.document.DocumentManager; -import onlyoffice.utils.attachment.AttachmentUtil; - -public class Permissions { - private boolean edit; - - public Permissions(final DocumentManager documentManager, final AttachmentUtil attachmentUtil, - final Long attachmentId) { - String fileExt = attachmentUtil.getFileExt(attachmentId); - boolean isEditable = documentManager.isEditable(fileExt) || documentManager.isFillForm(fileExt); - edit = attachmentUtil.checkAccess(attachmentId, AuthenticatedUserThreadLocal.get(), true) && isEditable; - } - - public boolean isEdit() { - return edit; - } - - public void setEdit(final boolean edit) { - this.edit = edit; - } -} diff --git a/src/main/java/onlyoffice/model/config/document/ReferenceData.java b/src/main/java/onlyoffice/model/config/document/ReferenceData.java deleted file mode 100644 index 352e7f40..00000000 --- a/src/main/java/onlyoffice/model/config/document/ReferenceData.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.model.config.document; - -public class ReferenceData { - private long fileKey; - private String instanceId; - - public ReferenceData(final long fileKey, final String instanceId) { - this.fileKey = fileKey; - this.instanceId = instanceId; - } - - public long getFileKey() { - return fileKey; - } - - public void setFileKey(final long fileKey) { - this.fileKey = fileKey; - } - - public String getInstanceId() { - return instanceId; - } - - public void setInstanceId(final String instanceId) { - this.instanceId = instanceId; - } -} diff --git a/src/main/java/onlyoffice/model/config/editor/Customization.java b/src/main/java/onlyoffice/model/config/editor/Customization.java deleted file mode 100644 index 20ec88fe..00000000 --- a/src/main/java/onlyoffice/model/config/editor/Customization.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package onlyoffice.model.config.editor; - -import onlyoffice.managers.configuration.ConfigurationManager; -import onlyoffice.managers.url.UrlManager; - -public class Customization { - private boolean forcesave; - private boolean chat; - private boolean compactHeader; - private boolean feedback; - private boolean help; - private boolean toolbarNoTabs; - private ReviewDisplay reviewDisplay; - private Goback goback; - - public Customization(final UrlManager urlManager, final ConfigurationManager configurationManager, - final Long attachmentId, final String referer) { - this.forcesave = configurationManager.forceSaveEnabled(); - this.chat = configurationManager.getBooleanPluginSetting("chat", true); - this.compactHeader = configurationManager.getBooleanPluginSetting("compactHeader", false); - this.feedback = configurationManager.getBooleanPluginSetting("feedback", false); - this.help = configurationManager.getBooleanPluginSetting("helpMenu", true); - this.toolbarNoTabs = configurationManager.getBooleanPluginSetting("toolbarNoTabs", false); - if (!configurationManager.getStringPluginSetting("reviewDisplay", "original").equals("original")) { - switch (configurationManager.getStringPluginSetting("reviewDisplay", "original")) { - case "markup": - this.reviewDisplay = ReviewDisplay.MARKUP; - break; - case "final": - this.reviewDisplay = ReviewDisplay.FINAL; - break; - case "original": - default: - this.reviewDisplay = ReviewDisplay.ORIGINAL; - } - } - this.goback = new Goback(urlManager, attachmentId, referer); - } - - public boolean isForcesave() { - return forcesave; - } - - public void setForcesave(final boolean forcesave) { - this.forcesave = forcesave; - } - - public boolean isChat() { - return chat; - } - - public void setChat(final boolean chat) { - this.chat = chat; - } - - public boolean isCompactHeader() { - return compactHeader; - } - - public void setCompactHeader(final boolean compactHeader) { - this.compactHeader = compactHeader; - } - - public boolean isFeedback() { - return feedback; - } - - public void setFeedback(final boolean feedback) { - this.feedback = feedback; - } - - public boolean isHelp() { - return help; - } - - public void setHelp(final boolean help) { - this.help = help; - } - - public boolean isToolbarNoTabs() { - return toolbarNoTabs; - } - - public void setToolbarNoTabs(final boolean toolbarNoTabs) { - this.toolbarNoTabs = toolbarNoTabs; - } - - public ReviewDisplay getReviewDisplay() { - return reviewDisplay; - } - - public void setReviewDisplay(final ReviewDisplay reviewDisplay) { - this.reviewDisplay = reviewDisplay; - } - - public Goback getGoback() { - return goback; - } - - public void setGoback(final Goback goback) { - this.goback = goback; - } -} diff --git a/src/main/java/onlyoffice/model/config/editor/EditorConfig.java b/src/main/java/onlyoffice/model/config/editor/EditorConfig.java deleted file mode 100644 index 081273b1..00000000 --- a/src/main/java/onlyoffice/model/config/editor/EditorConfig.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.model.config.editor; - -import com.atlassian.confluence.languages.LocaleManager; -import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; -import com.atlassian.confluence.user.ConfluenceUser; -import onlyoffice.managers.configuration.ConfigurationManager; -import onlyoffice.managers.url.UrlManager; -import onlyoffice.utils.attachment.AttachmentUtil; -import org.json.JSONObject; - -public class EditorConfig { - private Mode mode; - private String createUrl; - private String callbackUrl; - private String lang; - private JSONObject actionLink; - private Customization customization; - private User user; - - public EditorConfig(final LocaleManager localeManager, final AttachmentUtil attachmentUtil, - final UrlManager urlManager, final ConfigurationManager configurationManager, - final Long attachmentId, final Mode mode, final JSONObject actionLink, final String referer) { - ConfluenceUser user = AuthenticatedUserThreadLocal.get(); - Long pageId = attachmentUtil.getAttachmentPageId(attachmentId); - String fileExt = attachmentUtil.getFileExt(attachmentId); - - this.mode = mode; - this.actionLink = actionLink; - this.lang = localeManager.getLocale(user).toLanguageTag(); - this.customization = new Customization(urlManager, configurationManager, attachmentId, referer); - - if (user != null) { - this.user = new User(user); - } - - if (attachmentUtil.checkAccessCreate(user, pageId)) { - this.createUrl = urlManager.getCreateUri(pageId, fileExt); - } - - if (attachmentUtil.checkAccess(attachmentId, user, true)) { - this.callbackUrl = urlManager.getCallbackUrl(attachmentId); - } - } - - public Mode getMode() { - return mode; - } - - public void setMode(final Mode mode) { - this.mode = mode; - } - - public String getCreateUrl() { - return createUrl; - } - - public void setCreateUrl(final String createUrl) { - this.createUrl = createUrl; - } - - public String getCallbackUrl() { - return callbackUrl; - } - - public void setCallbackUrl(final String callbackUrl) { - this.callbackUrl = callbackUrl; - } - - public String getLang() { - return lang; - } - - public void setLang(final String lang) { - this.lang = lang; - } - - public JSONObject getActionLink() { - return actionLink; - } - - public void setActionLink(final JSONObject actionLink) { - this.actionLink = actionLink; - } - - public Customization getCustomization() { - return customization; - } - - public void setCustomization(final Customization customization) { - this.customization = customization; - } - - public User getUser() { - return user; - } - - public void setUser(final User user) { - this.user = user; - } -} diff --git a/src/main/java/onlyoffice/model/config/editor/Goback.java b/src/main/java/onlyoffice/model/config/editor/Goback.java deleted file mode 100644 index f095d40a..00000000 --- a/src/main/java/onlyoffice/model/config/editor/Goback.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.model.config.editor; - -import onlyoffice.managers.url.UrlManager; - -public class Goback { - private String url; - - public Goback(final UrlManager urlManager, final Long attachmentId, final String referer) { - this.url = urlManager.getGobackUrl(attachmentId, referer); - } - - public String getUrl() { - return url; - } - - public void setUrl(final String url) { - this.url = url; - } -} diff --git a/src/main/java/onlyoffice/model/config/editor/Mode.java b/src/main/java/onlyoffice/model/config/editor/Mode.java deleted file mode 100644 index 2d5d7dad..00000000 --- a/src/main/java/onlyoffice/model/config/editor/Mode.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.model.config.editor; - -import com.google.gson.annotations.SerializedName; - -public enum Mode { - @SerializedName("view") - VIEW, - @SerializedName("edit") - EDIT -} diff --git a/src/main/java/onlyoffice/model/config/editor/ReviewDisplay.java b/src/main/java/onlyoffice/model/config/editor/ReviewDisplay.java deleted file mode 100644 index be09896d..00000000 --- a/src/main/java/onlyoffice/model/config/editor/ReviewDisplay.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.model.config.editor; - -import com.google.gson.annotations.SerializedName; - -public enum ReviewDisplay { - @SerializedName("markup") - MARKUP, - @SerializedName("final") - FINAL, - @SerializedName("original") - ORIGINAL -} diff --git a/src/main/java/onlyoffice/model/config/editor/User.java b/src/main/java/onlyoffice/model/config/editor/User.java deleted file mode 100644 index 21852e7f..00000000 --- a/src/main/java/onlyoffice/model/config/editor/User.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package onlyoffice.model.config.editor; - -import com.atlassian.confluence.user.ConfluenceUser; - -public class User { - private String id; - private String name; - - public User(final ConfluenceUser user) { - this.id = user.getName(); - this.name = user.getFullName(); - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public void setId(final String id) { - this.id = id; - } - - public void setName(final String name) { - this.name = name; - } -} From ee249f06bdbbfef096b97fcf394d3214aada6691 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:35:12 +0300 Subject: [PATCH 15/87] delete: unused resources --- .gitmodules | 8 -------- src/main/resources/app_data/document-formats | 1 - src/main/resources/app_data/document-templates | 1 - src/main/resources/onlyoffice-config.properties | 8 -------- 4 files changed, 18 deletions(-) delete mode 100644 .gitmodules delete mode 160000 src/main/resources/app_data/document-formats delete mode 160000 src/main/resources/app_data/document-templates delete mode 100644 src/main/resources/onlyoffice-config.properties diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index fe80f429..00000000 --- a/.gitmodules +++ /dev/null @@ -1,8 +0,0 @@ -[submodule "src/main/resources/app_data/document-templates"] - path = src/main/resources/app_data/document-templates - url = https://github.com/ONLYOFFICE/document-templates - branch = main/new -[submodule "src/main/resources/app_data/document-formats"] - path = src/main/resources/app_data/document-formats - url = https://github.com/ONLYOFFICE/document-formats - branch = master diff --git a/src/main/resources/app_data/document-formats b/src/main/resources/app_data/document-formats deleted file mode 160000 index 6c4927a0..00000000 --- a/src/main/resources/app_data/document-formats +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6c4927a0d153350202492e6f6b5e434faf1e80d2 diff --git a/src/main/resources/app_data/document-templates b/src/main/resources/app_data/document-templates deleted file mode 160000 index f00ab3a3..00000000 --- a/src/main/resources/app_data/document-templates +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f00ab3a3efe6e2f8542ba026d1fc1d72df7dfd5f diff --git a/src/main/resources/onlyoffice-config.properties b/src/main/resources/onlyoffice-config.properties deleted file mode 100644 index c147f0df..00000000 --- a/src/main/resources/onlyoffice-config.properties +++ /dev/null @@ -1,8 +0,0 @@ -filesize-max=104857600 -convertation-filesize-max=26214400 -timeout=60 - -files.docservice.secret=Vskoproizvolny Salt par Chivreski - -files.docservice.url.api=web-apps/apps/api/documents/api.js -files.docservice.url.convert=ConvertService.ashx From 20d1a79e8fc158d3064e7725b912aa1941e1d146 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:41:34 +0300 Subject: [PATCH 16/87] add: missed license block in header files --- .../onlyoffice/managers/auth/AuthContext.java | 18 ++++++++++++++++++ .../utils/attachment/AttachmentUtil.java | 18 ++++++++++++++++++ .../onlyoffice/utils/parsing/ParsingUtil.java | 18 ++++++++++++++++++ .../utils/parsing/ParsingUtilImpl.java | 18 ++++++++++++++++++ 4 files changed, 72 insertions(+) diff --git a/src/main/java/onlyoffice/managers/auth/AuthContext.java b/src/main/java/onlyoffice/managers/auth/AuthContext.java index 7c2b0fed..0d021513 100644 --- a/src/main/java/onlyoffice/managers/auth/AuthContext.java +++ b/src/main/java/onlyoffice/managers/auth/AuthContext.java @@ -1,3 +1,21 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package onlyoffice.managers.auth; import javax.servlet.http.HttpServletRequest; diff --git a/src/main/java/onlyoffice/utils/attachment/AttachmentUtil.java b/src/main/java/onlyoffice/utils/attachment/AttachmentUtil.java index b92f3a38..01562e35 100644 --- a/src/main/java/onlyoffice/utils/attachment/AttachmentUtil.java +++ b/src/main/java/onlyoffice/utils/attachment/AttachmentUtil.java @@ -1,3 +1,21 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package onlyoffice.utils.attachment; import com.atlassian.confluence.core.ContentEntityObject; diff --git a/src/main/java/onlyoffice/utils/parsing/ParsingUtil.java b/src/main/java/onlyoffice/utils/parsing/ParsingUtil.java index e81171fc..47911d46 100644 --- a/src/main/java/onlyoffice/utils/parsing/ParsingUtil.java +++ b/src/main/java/onlyoffice/utils/parsing/ParsingUtil.java @@ -1,3 +1,21 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package onlyoffice.utils.parsing; import java.io.InputStream; diff --git a/src/main/java/onlyoffice/utils/parsing/ParsingUtilImpl.java b/src/main/java/onlyoffice/utils/parsing/ParsingUtilImpl.java index 3e8bf310..633d61d8 100644 --- a/src/main/java/onlyoffice/utils/parsing/ParsingUtilImpl.java +++ b/src/main/java/onlyoffice/utils/parsing/ParsingUtilImpl.java @@ -1,3 +1,21 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package onlyoffice.utils.parsing; import java.io.InputStream; From b7f8ce48324399bd37e8f02338929d577309d875 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:46:37 +0300 Subject: [PATCH 17/87] refactoring: AttachmentUtil, removed saveAttachmentChanges(), getFileName(), getFileExt(), added getCorrectName() --- .../utils/attachment/AttachmentUtil.java | 8 +- .../utils/attachment/AttachmentUtilImpl.java | 99 +++++-------------- 2 files changed, 29 insertions(+), 78 deletions(-) diff --git a/src/main/java/onlyoffice/utils/attachment/AttachmentUtil.java b/src/main/java/onlyoffice/utils/attachment/AttachmentUtil.java index 01562e35..f879e74f 100644 --- a/src/main/java/onlyoffice/utils/attachment/AttachmentUtil.java +++ b/src/main/java/onlyoffice/utils/attachment/AttachmentUtil.java @@ -45,18 +45,12 @@ void saveAttachmentAsNewVersion(Long attachmentId, InputStream attachmentData, i void updateAttachment(Long attachmentId, InputStream attachmentData, int size, ConfluenceUser user); - void saveAttachmentChanges(Long attachmentId, String history, String changesUrl) throws Exception; - void removeAttachmentChanges(Long attachmentId); InputStream getAttachmentData(Long attachmentId); String getMediaType(Long attachmentId); - String getFileName(Long attachmentId); - - String getFileExt(Long attachmentId); - String getHashCode(Long attachmentId); String getCollaborativeEditingKey(Long attachmentId); @@ -93,4 +87,6 @@ Attachment createNewAttachment(String title, String mimeType, InputStream file, File getConvertedFile(Long attachmentId); ContentEntityObject getContainer(Long containerId); + + String getCorrectName(String fileName, String fileExt, Long pageID); } diff --git a/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java b/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java index c29a935c..01b4b449 100644 --- a/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java +++ b/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java @@ -35,22 +35,12 @@ import com.atlassian.sal.api.transaction.TransactionTemplate; import com.atlassian.spring.container.ContainerManager; import com.atlassian.user.User; -import onlyoffice.managers.configuration.ConfigurationManager; -import org.apache.commons.io.IOUtils; -import org.apache.http.HttpEntity; -import org.apache.http.HttpException; -import org.apache.http.HttpStatus; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.nio.charset.StandardCharsets; import java.util.Calendar; import java.util.Date; import java.util.List; @@ -65,14 +55,10 @@ public class AttachmentUtilImpl implements AttachmentUtil { private final PageManager pageManager; private final BootstrapManager bootstrapManager; - private final ConfigurationManager configurationManager; - public AttachmentUtilImpl(final AttachmentManager attachmentManager, final TransactionTemplate transactionTemplate, - final ConfigurationManager configurationManager, final PageManager pageManager, - final BootstrapManager bootstrapManager) { + final PageManager pageManager, final BootstrapManager bootstrapManager) { this.attachmentManager = attachmentManager; this.transactionTemplate = transactionTemplate; - this.configurationManager = configurationManager; this.pageManager = pageManager; this.bootstrapManager = bootstrapManager; } @@ -166,53 +152,6 @@ public Object doInTransaction() { }); } - public void saveAttachmentChanges(final Long attachmentId, final String history, final String changesUrl) - throws Exception { - Attachment attachment = attachmentManager.getAttachment(attachmentId); - - if (history != null && !history.isEmpty() && changesUrl != null && !changesUrl.isEmpty()) { - InputStream changesStream = new ByteArrayInputStream(history.getBytes(StandardCharsets.UTF_8)); - Attachment changes = - new Attachment("onlyoffice-changes.json", "application/json", changesStream.available(), ""); - changes.setContainer(attachment.getContainer()); - changes.setHidden(true); - - try (CloseableHttpClient httpClient = configurationManager.getHttpClient()) { - HttpGet request = new HttpGet(changesUrl); - - try (CloseableHttpResponse response = httpClient.execute(request)) { - int status = response.getStatusLine().getStatusCode(); - HttpEntity entity = response.getEntity(); - - if (status == HttpStatus.SC_OK) { - byte[] bytes = IOUtils.toByteArray(entity.getContent()); - InputStream streamDiff = new ByteArrayInputStream(bytes); - - Attachment diff = new Attachment("onlyoffice-diff.zip", "application/zip", bytes.length, ""); - diff.setContainer(attachment.getContainer()); - diff.setHidden(true); - - attachment.addAttachment(changes); - attachment.addAttachment(diff); - - AttachmentDao attDao = attachmentManager.getAttachmentDao(); - Object result = transactionTemplate.execute(new TransactionCallback() { - @Override - public Object doInTransaction() { - attDao.saveNewAttachment(changes, changesStream); - attDao.saveNewAttachment(diff, streamDiff); - attDao.updateAttachment(attachment); - return null; - } - }); - } else { - throw new HttpException("Docserver returned code " + status); - } - } - } - } - } - public void removeAttachmentChanges(final Long attachmentId) { Attachment changes = getAttachmentChanges(attachmentId); Attachment diff = getAttachmentDiff(attachmentId); @@ -242,16 +181,6 @@ public String getMediaType(final Long attachmentId) { return attachment.getMediaType(); } - public String getFileName(final Long attachmentId) { - Attachment attachment = attachmentManager.getAttachment(attachmentId); - return attachment.getFileName(); - } - - public String getFileExt(final Long attachmentId) { - String fileName = getFileName(attachmentId); - return fileName.substring(fileName.lastIndexOf(".") + 1).trim().toLowerCase(); - } - public String getHashCode(final Long attachmentId) { Attachment attachment = attachmentManager.getAttachment(attachmentId); int hashCode = attachment.hashCode(); @@ -421,4 +350,30 @@ public ContentEntityObject getContainer(final Long containerId) { return container; } + + public String getCorrectName(final String fileName, final String fileExt, final Long pageID) { + ContentEntityManager contentEntityManager = + (ContentEntityManager) ContainerManager.getComponent("contentEntityManager"); + AttachmentManager attachmentManager = (AttachmentManager) ContainerManager.getComponent("attachmentManager"); + ContentEntityObject contentEntityObject = contentEntityManager.getById(pageID); + + List attachments = attachmentManager.getLatestVersionsOfAttachments(contentEntityObject); + String name = (fileName + "." + fileExt).replaceAll("[*?:\"<>/|\\\\]", "_"); + int count = 0; + Boolean flag = true; + + while (flag) { + flag = false; + for (Attachment attachment : attachments) { + if (attachment.getFileName().equals(name)) { + count++; + name = fileName + " (" + count + ")." + fileExt; + flag = true; + break; + } + } + } + + return name; + } } From 512ae722a2fa8182ebdf9d3995d87922fc811326 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:53:20 +0300 Subject: [PATCH 18/87] changed: configure page, using settings from sdk --- src/main/resources/atlassian-plugin.xml | 6 + src/main/resources/js/settings.js | 221 ++++++++++++++++++++++ src/main/resources/templates/configure.vm | 198 +++---------------- 3 files changed, 250 insertions(+), 175 deletions(-) create mode 100644 src/main/resources/js/settings.js diff --git a/src/main/resources/atlassian-plugin.xml b/src/main/resources/atlassian-plugin.xml index 68238dcb..dda0d357 100644 --- a/src/main/resources/atlassian-plugin.xml +++ b/src/main/resources/atlassian-plugin.xml @@ -29,6 +29,12 @@ + com.atlassian.auiplugin:ajs + com.atlassian.auiplugin:aui-spinner + + + + diff --git a/src/main/resources/js/settings.js b/src/main/resources/js/settings.js new file mode 100644 index 00000000..5c3acedc --- /dev/null +++ b/src/main/resources/js/settings.js @@ -0,0 +1,221 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +(function($) { + $(document).ready(function() { + var url = AJS.contextPath() + "/plugins/servlet/onlyoffice/configure"; + var msgBox = $("#onlyofficeMsg"); + var submitBtn = $("#onlyofficeSubmitBtn"); + + function updateConfig() { + var editingTypes = new Array(); + $(".editing-types").each(function () { + if ($(this).is(":checked")) editingTypes.push($(this).attr("id")); + }); + + var data = { + "url": $("#apiUrlField").attr("value"), + "innerUrl": $("#docInnerUrlField").attr("value"), + "productInnerUrl": $("#confUrlField").attr("value"), + "security": { + "key": $("#jwtSecretField").attr("value"), + "ignoreSSLCertificate": $("#verifyCertificate").is(":checked") + }, + "customization": { + "forcesave": $("#forceSave").is(":checked"), + "chat": $("#chat").is(":checked"), + "compactHeader": $("#compactHeader").is(":checked"), + "feedback": $("#feedback").is(":checked"), + "help": $("#helpMenu").is(":checked"), + "toolbarNoTabs": $("#toolbarNoTabs").is(":checked"), + "review": { + "reviewDisplay": $("input[name='reviewDisplay']:checked").attr("id").replace("reviewDisplay_", "") + }, + }, + "demo": $("#onlyofficeDemo").is(":checked"), + "lossyEdit": editingTypes + }; + + $.ajax({ + url: url, + type: "POST", + contentType: "application/json", + data: JSON.stringify(data), + processData: false, + success: function (response) { onResponse(response, data); }, + error: function (response) { onResponse(response, data); } + }); + } + + function onResponse(response) { + $("#onlyoffice-loader").hide(); + submitBtn.attr("disabled", false); + + if (response) { + const responseJson = JSON.parse(response); + const validationResults = responseJson.validationResults; + + if (validationResults.documentServer) { + if (validationResults.documentServer.status == "failed") { + AJS.messages.error( + msgBox, + { + body: validationResults.documentServer.message + } + ); + } + } + + if (validationResults.commandService) { + if (validationResults.commandService.status == "failed") { + AJS.messages.error( + msgBox, + { + body: AJS.I18n.getText("onlyoffice.service.command.check.error-prefix").replace( + "$", + validationResults.commandService.message + ) + } + ); + } + } + + if (validationResults.convertService) { + if (validationResults.convertService.status == "failed") { + AJS.messages.error( + msgBox, + { + body: AJS.I18n.getText("onlyoffice.service.convert.check.error-prefix").replace( + "$", + validationResults.convertService.message + ) + } + ); + } + } + + AJS.messages.success( + msgBox, + { + body: AJS.I18n.getText("onlyoffice.configuration.message.settings.saved") + } + ); + } else { + AJS.messages.error( + msgBox, + { + body: AJS.I18n.getText("onlyoffice.configuration.message.settings.saving-error") + } + ); + } + }; + + var testDocServiceApi = function () { + var testApiResult = function () { + var result = typeof DocsAPI != "undefined"; + + if (result) { + updateConfig(); + } else { + AJS.messages.error( + msgBox, + { + body: AJS.I18n.getText("onlyoffice.server.common.error.api-js") + } + ); + + updateConfig(); + } + }; + + if (window.location.protocol == "https:" && $("#apiUrlField").val().startsWith("http:")) { + AJS.messages.error( + msgBox, + { + body: AJS.I18n.getText("onlyoffice.server.common.error.mixed-content") + } + ); + } + + delete DocsAPI; + + $("#scriptDocServiceAddress").remove(); + + var js = document.createElement("script"); + js.setAttribute("type", "text/javascript"); + js.setAttribute("id", "scriptDocServiceAddress"); + document.getElementsByTagName("head")[0].appendChild(js); + + var scriptAddress = $("#scriptDocServiceAddress"); + + scriptAddress.on("load", testApiResult).on("error", testApiResult); + + var docServiceUrlApi = $("#apiUrlField").val(); + + if (docServiceUrlApi.endsWith("/")) { + docServiceUrlApi = docServiceUrlApi.slice(0, -1); + } + docServiceUrlApi += $("#pathApiUrl").html(); + + scriptAddress.attr("src", docServiceUrlApi); + }; + + $("#onlyofficeConf").submit(function(e) { + e.preventDefault(); + + $("#onlyoffice-loader").show(); + submitBtn.attr("disabled", true); + $("#admin-body-content .aui-message").remove(); + + if ($("#onlyofficeDemo").is(":checked") && !$("#onlyofficeDemo").prop("disabled")) { + updateConfig(); + } else { + testDocServiceApi(); + } + }); + + $("#onlyofficeConf").on("click", ".view-control", function() { + if ($("#jwtSecretField").attr("type") == "password"){ + $(this).addClass("view"); + $("#jwtSecretField").attr("type", "text"); + } else { + $(this).removeClass("view"); + $("#jwtSecretField").attr("type", "password"); + } + return false; + }); + + var demoToggle = function () { + if (!$("#onlyofficeDemo").prop("disabled")) { + $("#apiUrlField, #jwtSecretField, #docInnerUrlField, #verifyCertificate").prop("disabled", $("#onlyofficeDemo").prop("checked")); + if ($("#onlyofficeDemo").prop("checked")) { + $(".view-control").css("pointer-events", "none"); + $(".view-control").removeClass("view"); + $("#jwtSecretField").attr("type", "password"); + } else { + $(".view-control").css("pointer-events", ""); + } + } + }; + + $("#onlyofficeDemo").click(demoToggle); + demoToggle(); + + $(".onlyoffice-tooltip").tooltip(); + }); +})(AJS.$); \ No newline at end of file diff --git a/src/main/resources/templates/configure.vm b/src/main/resources/templates/configure.vm index 15081e2e..3fcd9218 100644 --- a/src/main/resources/templates/configure.vm +++ b/src/main/resources/templates/configure.vm @@ -25,171 +25,15 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl -
+

$i18n.getText('onlyoffice.configuration.section.server')

- +
- +
@@ -197,17 +41,17 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl
- +
- +
- #if($docserviceDemoAvailable) + #if($demoAvailable)
$i18n.getText('onlyoffice.configuration.demo.trial')
#else
$i18n.getText('onlyoffice.configuration.demo.trial-is-over')
@@ -218,11 +62,11 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl

$i18n.getText('onlyoffice.configuration.advanced-section')

- +
- +

$i18n.getText('onlyoffice.configuration.section.common')

@@ -241,7 +85,7 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl
- +
$i18n.getText('onlyoffice.configuration.force-save.description')
@@ -250,23 +94,23 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl
- +
- +
- +
- +
- +
$i18n.getText('onlyoffice.configuration.interface.description')
@@ -275,22 +119,22 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl
- +
- +
- +
$i18n.getText('onlyoffice.configuration.reviewDisplay.description')
- +
@@ -306,5 +150,9 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl $i18n.getText('onlyoffice.configuration.banner.button')
+ + From 4899256f60f5059b8b64d18f101b55411d504288 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:48:06 +0300 Subject: [PATCH 19/87] changed: convert page, using sdk --- src/main/resources/templates/convert.vm | 81 +++++++++++++++++++++---- 1 file changed, 70 insertions(+), 11 deletions(-) diff --git a/src/main/resources/templates/convert.vm b/src/main/resources/templates/convert.vm index 976db38c..0faaff17 100644 --- a/src/main/resources/templates/convert.vm +++ b/src/main/resources/templates/convert.vm @@ -66,34 +66,41 @@ $webResourceManager.requireResource("com.atlassian.auiplugin:aui-progress-indica url: url, type: "POST", cache: false, - success: function (data) { onResponse(data); }, - error: function (data) { onError(data.status); } + success: function (response) { onResponse(response); }, + error: function (response) { + if (response.status == 403) { + onError("$i18n.getText('onlyoffice.connector.dialog.conversion.message.error.permission')"); + } else { + onError("$i18n.getText('onlyoffice.connector.error.Unknown')"); + } + } }); }; - function onError(error) { + function onError(errorMessage) { thumb.css("background", "#de350b"); - msg.text("$i18n.getText('onlyoffice.convert.message.error') " + error); + msg.text(errorMessage); btn.removeAttr("disabled"); } - function onResponse(data) { - if (data.error) { - onError(data.error); + function onResponse(response) { + if (response.error) { + var errorMessage = getErrorMessage(response); + onError(errorMessage); return; } - if (data.percent != null) { - var perc = data.percent / 100; + if (response.percent != null) { + var perc = response.percent / 100; if (perc > 0) { AJS.progressBars.update(progress, perc); } } - if (!data.endConvert) { + if (!response.endConvert) { setTimeout(poll, 1000); } else { - window.location = editorUrl + data.attachmentId; + window.location = editorUrl + response.attachmentId; } }; @@ -104,6 +111,58 @@ $webResourceManager.requireResource("com.atlassian.auiplugin:aui-progress-indica AJS.progressBars.update(progress, 0.1); poll(); }); + + function getErrorMessage(response) { + var errorMessage; + var servicePrefix = false; + + switch (response.error) { + case "UNKNOWN": + errorMessage = "$i18n.getText('onlyoffice.service.convert.error.unknown')"; + servicePrefix = true; + break; + case "TIMEOUT": + errorMessage = "$i18n.getText('onlyoffice.service.convert.error.timeout')"; + servicePrefix = true; + break; + case "CONVERSION": + errorMessage = "$i18n.getText('onlyoffice.service.convert.error.conversion')"; + servicePrefix = true; + break; + case "DOWNLOADING": + errorMessage = "$i18n.getText('onlyoffice.service.convert.error.downloading')"; + servicePrefix = true; + break; + case "PASSWORD": + errorMessage = "$i18n.getText('onlyoffice.service.convert.error.password')"; + servicePrefix = true; + break; + case "DATABASE": + errorMessage = "$i18n.getText('onlyoffice.service.convert.error.database')"; + servicePrefix = true; + break; + case "INPUT": + errorMessage = "$i18n.getText('onlyoffice.service.convert.error.input')"; + servicePrefix = true; + break; + case "TOKEN": + errorMessage = "$i18n.getText('onlyoffice.service.convert.error.token')"; + servicePrefix = true; + break; + case "CONNECTION": + errorMessage = "$i18n.getText('onlyoffice.service.convert.error.connection')"; + servicePrefix = true; + break; + default: + errorMessage = "$i18n.getText('onlyoffice.connector.error.Unknown')"; + } + + if (servicePrefix) { + errorMessage ="$i18n.getText('onlyoffice.connector.dialog.conversion.message.error.service-prefix')".replace("$", errorMessage); + } + + return errorMessage; + } })(jQuery); From 04fc2b84143336f6e5aaba53c9696f2fd79b893c Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:48:57 +0300 Subject: [PATCH 20/87] changed: onlyoffice-download-as.js using new api --- .../resources/js/onlyoffice-download-as.js | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/main/resources/js/onlyoffice-download-as.js b/src/main/resources/js/onlyoffice-download-as.js index a0f4f255..d9c045a8 100644 --- a/src/main/resources/js/onlyoffice-download-as.js +++ b/src/main/resources/js/onlyoffice-download-as.js @@ -106,40 +106,41 @@ var servicePrefix = false; switch (response.error) { - case -1: - errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.unknown"); + case "UNKNOWN": + errorMessage = AJS.I18n.getText("onlyoffice.service.convert.error.unknown"); servicePrefix = true; break; - case -2: - errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.timeout"); + case "TIMEOUT": + errorMessage = AJS.I18n.getText("onlyoffice.service.convert.error.timeout"); servicePrefix = true; break; - case -3: - errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.conversion"); + case "CONVERSION": + errorMessage = AJS.I18n.getText("onlyoffice.service.convert.error.conversion"); servicePrefix = true; break; - case -4: - errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.download"); + case "DOWNLOADING": + errorMessage = AJS.I18n.getText("onlyoffice.service.convert.error.downloading"); servicePrefix = true; break; - case -5: - errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.password"); + case "PASSWORD": + errorMessage = AJS.I18n.getText("onlyoffice.service.convert.error.password"); servicePrefix = true; break; - case -6: - errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.database"); + case "DATABASE": + errorMessage = AJS.I18n.getText("onlyoffice.service.convert.error.database"); servicePrefix = true; break; - case -7: - errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.input"); + case "INPUT": + errorMessage = AJS.I18n.getText("onlyoffice.service.convert.error.input"); servicePrefix = true; break; - case -8: - errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.token"); + case "TOKEN": + errorMessage = AJS.I18n.getText("onlyoffice.service.convert.error.token"); servicePrefix = true; break; - case -10: - errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.not-reached"); + case "CONNECTION": + errorMessage = AJS.I18n.getText("onlyoffice.service.convert.error.connection"); + servicePrefix = true; break; default: errorMessage = AJS.I18n.getText("onlyoffice.connector.error.Unknown"); From ed8f39a522671a64b432f6b09e4a29045a60ee16 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:49:17 +0300 Subject: [PATCH 21/87] changed: translations --- src/main/resources/lang-resource.properties | 43 +++++++++++++------ .../resources/lang-resource_de.properties | 43 +++++++++++++------ .../resources/lang-resource_es.properties | 43 +++++++++++++------ .../resources/lang-resource_fr.properties | 43 +++++++++++++------ .../resources/lang-resource_it.properties | 43 +++++++++++++------ .../resources/lang-resource_ru.properties | 43 +++++++++++++------ 6 files changed, 174 insertions(+), 84 deletions(-) diff --git a/src/main/resources/lang-resource.properties b/src/main/resources/lang-resource.properties index 239b65cd..9b48443e 100644 --- a/src/main/resources/lang-resource.properties +++ b/src/main/resources/lang-resource.properties @@ -31,12 +31,8 @@ onlyoffice.configuration.reviewDisplay.markup=Markup onlyoffice.configuration.reviewDisplay.final=Final onlyoffice.configuration.reviewDisplay.original=Original onlyoffice.configuration.button.save=Save -onlyoffice.configuration.message.success=Success -onlyoffice.configuration.message.error.docservcommand=Error when trying to check CommandService -onlyoffice.configuration.message.error.docservunreachable=ONLYOFFICE cannot be reached -onlyoffice.configuration.message.error.jsonparse=Server can't read JSON -onlyoffice.configuration.message.error.jwterror=Authorization error -onlyoffice.configuration.message.error.mixedcontent=Mixed Active Content is not allowed. HTTPS address for Document Server is required. +onlyoffice.configuration.message.settings.saved=Settings saved +onlyoffice.configuration.message.settings.saving-error=Error saving settings onlyoffice.configuration.banner.message=Easily launch the editors in the cloud without downloading and installation onlyoffice.configuration.banner.button=Get Now onlyoffice.editor.editlink=Edit in ONLYOFFICE @@ -68,14 +64,6 @@ onlyoffice.connector.dialog.conversion.header.title=Download As with ONLYOFFICE onlyoffice.connector.dialog.conversion.field.current-type=Current type onlyoffice.connector.dialog.conversion.field.target-type=Target type onlyoffice.connector.dialog.conversion.message.error.service-prefix=ONLYOFFICE conversion service returned error ($). -onlyoffice.connector.dialog.conversion.message.error.unknown=Unknown error -onlyoffice.connector.dialog.conversion.message.error.timeout=Conversion timeout error -onlyoffice.connector.dialog.conversion.message.error.conversion=Conversion error -onlyoffice.connector.dialog.conversion.message.error.download=Error while downloading the document file to be converted -onlyoffice.connector.dialog.conversion.message.error.password=Incorrect password -onlyoffice.connector.dialog.conversion.message.error.database=Error while accessing the conversion result database -onlyoffice.connector.dialog.conversion.message.error.input=Input error -onlyoffice.connector.dialog.conversion.message.error.token=Invalid token onlyoffice.connector.dialog.conversion.message.error.not-reached=ONLYOFFICE Conversion service cannot be reached. Please contact admin. onlyoffice.connector.dialog.conversion.message.error.permission=User does not have rights to perform this operation. onlyoffice.connector.error.Unknown=An unknown error occurred during the operation. @@ -89,3 +77,30 @@ onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.label=Wid onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.desc=Specified either in pixels (default or ''px'') or as a ''%'' of page width. Examples: 200, 200px, 10% onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=Height onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc=Specified either in pixels (default or ''px'') or as a ''%'' of page height. Examples: 200, 200px, 10% + +onlyoffice.server.common.error.connection=Document Server cannot be reached. +onlyoffice.server.common.error.api-js=The API JavaScript file cannot be reached. +onlyoffice.server.common.error.mixed-content=Mixed Active Content is not allowed. HTTPS address for ONLYOFFICE Document Server is required. +onlyoffice.server.common.error.healthcheck=Document Server return bad healthcheck status. + +onlyoffice.service.convert.check.error-prefix=Error when trying to check ConvertService ($). +onlyoffice.service.convert.error.unknown=Unknown error +onlyoffice.service.convert.error.timeout=Conversion timeout error +onlyoffice.service.convert.error.conversion=Conversion error +onlyoffice.service.convert.error.downloading=Error while downloading the document file to be converted +onlyoffice.service.convert.error.password=Incorrect password +onlyoffice.service.convert.error.database=Error while accessing the conversion result database +onlyoffice.service.convert.error.input=Input error +onlyoffice.service.convert.error.token=Invalid token +onlyoffice.service.convert.error.connection=Connection error +onlyoffice.service.convert.error.download_result=Download result file error + +onlyoffice.service.command.check.error-prefix=Error when trying to check CommandService ($). +onlyoffice.service.command.error.no=No errors +onlyoffice.service.command.error.key=Document key is missing or no document with such key could be found +onlyoffice.service.command.error.callback_url=Callback url not correct +onlyoffice.service.command.error.internal_server=Internal server error +onlyoffice.service.command.error.forcesave=No changes were applied to the document before the forcesave command was received +onlyoffice.service.command.error.command=Command not correct +onlyoffice.service.command.error.token=Invalid token +onlyoffice.service.command.error.connection=Connection error diff --git a/src/main/resources/lang-resource_de.properties b/src/main/resources/lang-resource_de.properties index 244b8d21..51cce7be 100644 --- a/src/main/resources/lang-resource_de.properties +++ b/src/main/resources/lang-resource_de.properties @@ -31,12 +31,8 @@ onlyoffice.configuration.reviewDisplay.markup=Markup onlyoffice.configuration.reviewDisplay.final=Endg\u00fcltig onlyoffice.configuration.reviewDisplay.original=Original onlyoffice.configuration.button.save=Speichern -onlyoffice.configuration.message.success=Erfolgreich -onlyoffice.configuration.message.error.docservcommand=Fehler beim Versuch, CommandService zu \u00FCberpr\u00FCfen -onlyoffice.configuration.message.error.docservunreachable=ONLYOFFICE kann nicht erreicht werden -onlyoffice.configuration.message.error.jsonparse=Server kann JSON nicht lesen -onlyoffice.configuration.message.error.jwterror=Autorisierungsfehler -onlyoffice.configuration.message.error.mixedcontent=Mixed Active Content ist nicht m\u00F6glich. HTTPS-Adresse f\u00FCr Document Server ist erforderlich. +onlyoffice.configuration.message.settings.saved= +onlyoffice.configuration.message.settings.saving-error= onlyoffice.configuration.banner.message=\u00d6ffnen Sie die Editoren in der Cloud einfach ohne Herunterladen und Installation onlyoffice.configuration.banner.button=Jetzt erhalten onlyoffice.editor.editlink=Mit ONLYOFFICE bearbeiten @@ -68,14 +64,6 @@ onlyoffice.connector.dialog.conversion.header.title=Herunterladen Als mit ONLYOF onlyoffice.connector.dialog.conversion.field.current-type=Originalformat onlyoffice.connector.dialog.conversion.field.target-type=Ausgabeformat onlyoffice.connector.dialog.conversion.message.error.service-prefix=Der ONLYOFFICE-Konvertierungsdienst hat einen Fehler zur\u00fcckgegeben ($). -onlyoffice.connector.dialog.conversion.message.error.unknown=Unbekannter Fehler -onlyoffice.connector.dialog.conversion.message.error.timeout=Timeout-Fehler bei der Konvertierung -onlyoffice.connector.dialog.conversion.message.error.conversion=Fehler bei der Umwandlung -onlyoffice.connector.dialog.conversion.message.error.download=Fehler beim Herunterladen der Datei, die konvertiert werden muss -onlyoffice.connector.dialog.conversion.message.error.password=Ung\u00fcltiges Passwort -onlyoffice.connector.dialog.conversion.message.error.database=Fehler beim Zugriff auf die Datenbank der Ergebnisse der Konvertierung -onlyoffice.connector.dialog.conversion.message.error.input=Eingabefehler -onlyoffice.connector.dialog.conversion.message.error.token=Ung\u00fcltiges Token onlyoffice.connector.dialog.conversion.message.error.not-reached=Der ONLYOFFICE-Konvertierungsdienst ist nicht erreichbar. Bitte kontaktieren Sie den Administrator. onlyoffice.connector.dialog.conversion.message.error.permission=Benutzer hat keine Berechtigungen, diesen Vorgang auszuf\u00fchren. onlyoffice.connector.error.Unknown=Ein unbekannter Fehler ist w\u00e4hrend des Vorgangs aufgetreten. @@ -89,3 +77,30 @@ onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.label=Bre onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.desc=Wird entweder in Pixel (standardm\u00e4\u00dfig oder ''px'') oder als ''%'' der Seitenbreite angegeben. Beispiele: 200, 200px, 10% onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=H\u00f6he onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc=Wird entweder in Pixel (standardm\u00e4\u00dfig oder ''px'') oder als ''%'' der Seitenh\u00f6he angegeben. Beispiele: 200, 200px, 10% + +onlyoffice.server.common.error.connection= +onlyoffice.server.common.error.api-js= +onlyoffice.server.common.error.mixed-content=Mixed Active Content ist nicht m\u00F6glich. HTTPS-Adresse f\u00FCr Document Server ist erforderlich. +onlyoffice.server.common.error.healthcheck= + +onlyoffice.service.convert.check.error-prefix=Fehler beim Versuch, ConvertService zu überprüfen ($). +onlyoffice.service.convert.error.unknown=Unbekannter Fehler +onlyoffice.service.convert.error.timeout=Timeout-Fehler bei der Konvertierung +onlyoffice.service.convert.error.conversion=Fehler bei der Umwandlung +onlyoffice.service.convert.error.downloading=Fehler beim Herunterladen der Datei, die konvertiert werden muss +onlyoffice.service.convert.error.password=Ung\u00fcltiges Passwort +onlyoffice.service.convert.error.database=Fehler beim Zugriff auf die Datenbank der Ergebnisse der Konvertierung +onlyoffice.service.convert.error.input=Eingabefehler +onlyoffice.service.convert.error.token=Ung\u00fcltiges Token +onlyoffice.service.convert.error.connection= +onlyoffice.service.convert.error.download_result= + +onlyoffice.service.command.check.error-prefix=Fehler beim Versuch, CommandService zu überprüfen ($). +onlyoffice.service.command.error.no= +onlyoffice.service.command.error.key= +onlyoffice.service.command.error.callback_url= +onlyoffice.service.command.error.internal_server= +onlyoffice.service.command.error.forcesave= +onlyoffice.service.command.error.command= +onlyoffice.service.command.error.token=Ung\u00fcltiges Token +onlyoffice.service.command.error.connection= diff --git a/src/main/resources/lang-resource_es.properties b/src/main/resources/lang-resource_es.properties index f92dc8e9..386f1641 100644 --- a/src/main/resources/lang-resource_es.properties +++ b/src/main/resources/lang-resource_es.properties @@ -31,12 +31,8 @@ onlyoffice.configuration.reviewDisplay.markup=Cambios onlyoffice.configuration.reviewDisplay.final=Final onlyoffice.configuration.reviewDisplay.original=Original onlyoffice.configuration.button.save=Guardar -onlyoffice.configuration.message.success=\u00C9xito -onlyoffice.configuration.message.error.docservcommand=Error al intentar\u00A0verificar CommandService -onlyoffice.configuration.message.error.docservunreachable=No se puede establecer contacto con ONLYOFFICE. -onlyoffice.configuration.message.error.jsonparse=Servidor no puede leer\u00A0JSON -onlyoffice.configuration.message.error.jwterror=Error de autorizacion -onlyoffice.configuration.message.error.mixedcontent=Contenido Mixto Activo no est\u00E1 permitido. Se requiere la direcci\u00F3n HTTPS para Servidor de Documentos. +onlyoffice.configuration.message.settings.saved= +onlyoffice.configuration.message.settings.saving-error= onlyoffice.configuration.banner.message=Inicie f\u00e1cilmente los editores en la nube sin tener que descargarlos ni instalarlos onlyoffice.configuration.banner.button=Obtener ahora onlyoffice.editor.editlink=Editar en ONLYOFFICE @@ -68,14 +64,6 @@ onlyoffice.connector.dialog.conversion.header.title=Descargar Como con ONLYOFFIC onlyoffice.connector.dialog.conversion.field.current-type=Tipo presente onlyoffice.connector.dialog.conversion.field.target-type=Tipo di obiettivo onlyoffice.connector.dialog.conversion.message.error.service-prefix=El servicio de conversi\u00f3n de ONLYOFFICE devolvi\u00f3 un error ($). -onlyoffice.connector.dialog.conversion.message.error.unknown=Error desconocido -onlyoffice.connector.dialog.conversion.message.error.timeout=Error de tiempo de espera -onlyoffice.connector.dialog.conversion.message.error.conversion=Error de conversi\u00f3n -onlyoffice.connector.dialog.conversion.message.error.download=Error al descargar el archivo para su conversi\u00f3n -onlyoffice.connector.dialog.conversion.message.error.password=Contrase\u00f1a incorrecta -onlyoffice.connector.dialog.conversion.message.error.database=Error al acceder la base de datos de resultados de conversi\u00f3n -onlyoffice.connector.dialog.conversion.message.error.input=Error de entrada -onlyoffice.connector.dialog.conversion.message.error.token=Token inv\u00e1lido onlyoffice.connector.dialog.conversion.message.error.not-reached=No se puede acceder al servicio de conversi\u00f3n de ONLYOFFICE. Por favor, p\u00f3ngase en contacto con el administrador. onlyoffice.connector.dialog.conversion.message.error.permission=El usuario no tiene derechos a realizar esta operaci\u00f3n. onlyoffice.connector.error.Unknown=Se produjo un error desconocido durante la operaci\u00f3n. @@ -89,3 +77,30 @@ onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.label=Anc onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.desc=Especificado en p\u00edxeles (por defecto o ''px'') o como un ''%'' del ancho de la p\u00e1gina. Ejemplos: 200, 200px, 10% onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=Altura onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc=Especificado en p\u00edxeles (por defecto o ''px'') o como un ''%'' de la altura de la p\u00e1gina. Ejemplos: 200, 200px, 10% + +onlyoffice.server.common.error.connection= +onlyoffice.server.common.error.api-js= +onlyoffice.server.common.error.mixed-content=Contenido Mixto Activo no est\u00E1 permitido. Se requiere la direcci\u00F3n HTTPS para Servidor de Documentos. +onlyoffice.server.common.error.healthcheck= + +onlyoffice.service.convert.check.error-prefix= ($). +onlyoffice.service.convert.error.unknown=Error desconocido +onlyoffice.service.convert.error.timeout=Error de tiempo de espera +onlyoffice.service.convert.error.conversion=Error de conversi\u00f3n +onlyoffice.service.convert.error.downloading=Error al descargar el archivo para su conversi\u00f3n +onlyoffice.service.convert.error.password=Contrase\u00f1a incorrecta +onlyoffice.service.convert.error.database=Error al acceder la base de datos de resultados de conversi\u00f3n +onlyoffice.service.convert.error.input=Error de entrada +onlyoffice.service.convert.error.token=Token inv\u00e1lido +onlyoffice.service.convert.error.connection= +onlyoffice.service.convert.error.download_result= + +onlyoffice.service.command.check.error-prefix= ($). +onlyoffice.service.command.error.no= +onlyoffice.service.command.error.key= +onlyoffice.service.command.error.callback_url= +onlyoffice.service.command.error.internal_server= +onlyoffice.service.command.error.forcesave= +onlyoffice.service.command.error.command= +onlyoffice.service.command.error.token=Token inv\u00e1lido +onlyoffice.service.command.error.connection= diff --git a/src/main/resources/lang-resource_fr.properties b/src/main/resources/lang-resource_fr.properties index 54af5ab6..3a8cf9d4 100644 --- a/src/main/resources/lang-resource_fr.properties +++ b/src/main/resources/lang-resource_fr.properties @@ -31,12 +31,8 @@ onlyoffice.configuration.reviewDisplay.markup=Balisage onlyoffice.configuration.reviewDisplay.final=Finale onlyoffice.configuration.reviewDisplay.original=Original onlyoffice.configuration.button.save=Enregistrer -onlyoffice.configuration.message.success=Succ\u00E8s -onlyoffice.configuration.message.error.docservcommand=Erreur en essayant de v\u00E9rifier CommandService -onlyoffice.configuration.message.error.docservunreachable=ONLYOFFICE ne peut \u00eatre atteint. -onlyoffice.configuration.message.error.jsonparse=Serveur ne peut pas lire JSON -onlyoffice.configuration.message.error.jwterror=Erreur d\u2019autorisation -onlyoffice.configuration.message.error.mixedcontent=Le contenu mixte actif n\u2019est pas autoris\u00E9. Une adresse HTTPS pour le serveur de document est requise. +onlyoffice.configuration.message.settings.saved=Settings saved +onlyoffice.configuration.message.settings.saving-error=Error saving settings onlyoffice.configuration.banner.message=Lancez facilement les \u00e9diteurs dans le cloud sans t\u00e9l\u00e9chargement ni installation onlyoffice.configuration.banner.button=Ottieni ora onlyoffice.editor.editlink=Modifier dans ONLYOFFICE @@ -68,14 +64,6 @@ onlyoffice.connector.dialog.conversion.header.title=T\u00e9l\u00e9charger comme onlyoffice.connector.dialog.conversion.field.current-type=Type actuel onlyoffice.connector.dialog.conversion.field.target-type=Type de cible onlyoffice.connector.dialog.conversion.message.error.service-prefix=Le service de conversion ONLYOFFICE a renvoy\u00e9 une erreur ($). -onlyoffice.connector.dialog.conversion.message.error.unknown=Erreur inconnue -onlyoffice.connector.dialog.conversion.message.error.timeout=Erreur de d\u00e9lai d'attente -onlyoffice.connector.dialog.conversion.message.error.conversion=Erreur de conversion -onlyoffice.connector.dialog.conversion.message.error.download=Erreur lors du t\u00e9l\u00e9chargement du fichier \u00e0 convertir -onlyoffice.connector.dialog.conversion.message.error.password=Mot de passe incorrect -onlyoffice.connector.dialog.conversion.message.error.database=Erreur lors de l'acc\u00e8s \u00e0 la base de donn\u00e9es des r\u00e9sultats de la conversion -onlyoffice.connector.dialog.conversion.message.error.input=Erreur de saisie -onlyoffice.connector.dialog.conversion.message.error.token=Jeton invalide onlyoffice.connector.dialog.conversion.message.error.not-reached=Le service de conversion ONLYOFFICE n'est pas accessible. Veuillez contacter l'administration. onlyoffice.connector.dialog.conversion.message.error.permission=L'utilisateur n'a pas le droit d'effectuer cette op\u00e9ration. onlyoffice.connector.error.Unknown=Une erreur inconnue s'est produite pendant l'op\u00E9ration. @@ -89,3 +77,30 @@ onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.label=Lar onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.desc=Sp\u00e9cifi\u00e9 soit en pixels (par d\u00efaut ou ''px''), soit en ''%'' de la largeur de la page. Exemples : 200, 200px, 10% onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=Hauteur onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc=Sp\u00ecifi\u00e9 soit en pixels (par d\u00efaut ou ''px''), soit en ''%'' de la hauteur de la page. Exemples : 200, 200px, 10%200, 200px, 10% onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=Altezza onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc=Specificato in pixel (predefinito o ''px'') o come ''%'' dell'altezza della pagina. Esempi: 200, 200px, 10% + +onlyoffice.server.common.error.connection= +onlyoffice.server.common.error.api-js= +onlyoffice.server.common.error.mixed-content=Il contenuto attivo misto non \u00E8 consentito. \u00C8 richiesto l\u2019indirizzo HTTPS per Document Server. +onlyoffice.server.common.error.healthcheck= + +onlyoffice.service.convert.check.error-prefix= +onlyoffice.service.convert.error.unknown=Errore sconosciuto +onlyoffice.service.convert.error.timeout=Errore di timeout per la conversione +onlyoffice.service.convert.error.conversion=Errore di conversione +onlyoffice.service.convert.error.downloading=Errore di download del documento da convertire +onlyoffice.service.convert.error.password=Password errata +onlyoffice.service.convert.error.database=Errore durante l'accesso al database dei risultati di conversione +onlyoffice.service.convert.error.input=Errore di input +onlyoffice.service.convert.error.token=Token non valido +onlyoffice.service.convert.error.connection= +onlyoffice.service.convert.error.download_result= + +onlyoffice.service.command.check.error-prefix=Errore durante il tentativo di controllare CommandService ($). +onlyoffice.service.command.error.no= +onlyoffice.service.command.error.key= +onlyoffice.service.command.error.callback_url= +onlyoffice.service.command.error.internal_server= +onlyoffice.service.command.error.forcesave= +onlyoffice.service.command.error.command= +onlyoffice.service.command.error.token=Token non valido +onlyoffice.service.command.error.connection= diff --git a/src/main/resources/lang-resource_ru.properties b/src/main/resources/lang-resource_ru.properties index d3399a8d..9734b6e8 100644 --- a/src/main/resources/lang-resource_ru.properties +++ b/src/main/resources/lang-resource_ru.properties @@ -31,12 +31,8 @@ onlyoffice.configuration.reviewDisplay.markup=\u0418\u0437\u043c\u0435\u043d\u04 onlyoffice.configuration.reviewDisplay.final=\u0418\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0439\u0020\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 onlyoffice.configuration.reviewDisplay.original=\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439\u0020\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 onlyoffice.configuration.button.save=\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C -onlyoffice.configuration.message.success=\u0423\u0441\u043F\u0435\u0448\u043D\u043E -onlyoffice.configuration.message.error.docservcommand=\u041E\u0448\u0438\u0431\u043A\u0430 \u0432\u043E \u0432\u0440\u0435\u043C\u044F \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438 CommandService -onlyoffice.configuration.message.error.docservunreachable=\u041F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 ONLYOFFICE \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E -onlyoffice.configuration.message.error.jsonparse=\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C JSON \u043D\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 -onlyoffice.configuration.message.error.jwterror=\u041E\u0448\u0438\u0431\u043A\u0430 \u0430\u0432\u0442\u043E\u0440\u0438\u0437\u0430\u0446\u0438\u0438 -onlyoffice.configuration.message.error.mixedcontent=\u0421\u043C\u0435\u0448\u0430\u043D\u043D\u043E\u0435 \u0430\u043A\u0442\u0438\u0432\u043D\u043E\u0435 \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u0435 \u0437\u0430\u043F\u0440\u0435\u0449\u0435\u043D\u043E. \u0414\u043B\u044F \u0421\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u043E\u0432 \u043D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C HTTPS-\u0430\u0434\u0440\u0435\u0441. +onlyoffice.configuration.message.settings.saved=\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438\u0020\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b +onlyoffice.configuration.message.settings.saving-error=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f\u0020\u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a onlyoffice.configuration.banner.message=\u041b\u0435\u0433\u043a\u043e\u0020\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0439\u0442\u0435\u0020\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u044b\u0020\u0432\u0020\u043e\u0431\u043b\u0430\u043a\u0435\u0020\u0431\u0435\u0437\u0020\u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f\u0020\u0438\u0020\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 onlyoffice.configuration.banner.button=\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0020\u0441\u0435\u0439\u0447\u0430\u0441 onlyoffice.editor.editlink=\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0432 ONLYOFFICE @@ -68,14 +64,6 @@ onlyoffice.connector.dialog.conversion.header.title=\u0421\u043a\u0430\u0447\u04 onlyoffice.connector.dialog.conversion.field.current-type=\u0422\u0435\u043a\u0443\u0449\u0438\u0439\u0020\u0442\u0438\u043f onlyoffice.connector.dialog.conversion.field.target-type=\u0426\u0435\u043b\u0435\u0432\u043e\u0439\u0020\u0442\u0438\u043f onlyoffice.connector.dialog.conversion.message.error.service-prefix=\u0421\u0435\u0440\u0432\u0438\u0441\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438\u0020\u004f\u004e\u004c\u0059\u004f\u0046\u0046\u0049\u0043\u0045\u0020\u0432\u0435\u0440\u043d\u0443\u043b\u0020\u043e\u0448\u0438\u0431\u043a\u0443 ($). -onlyoffice.connector.dialog.conversion.message.error.unknown=\u041d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f\u0020\u043e\u0448\u0438\u0431\u043a\u0430 -onlyoffice.connector.dialog.conversion.message.error.timeout=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u0432\u0440\u0435\u043c\u0435\u043d\u0438\u0020\u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 -onlyoffice.connector.dialog.conversion.message.error.conversion=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 -onlyoffice.connector.dialog.conversion.message.error.download=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u043f\u0440\u0438\u0020\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435\u0020\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0020\u0434\u043b\u044f\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438. -onlyoffice.connector.dialog.conversion.message.error.password=\u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439\u0020\u043f\u0430\u0440\u043e\u043b\u044c -onlyoffice.connector.dialog.conversion.message.error.database=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u043f\u0440\u0438\u0020\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u0020\u043a\u0020\u0431\u0430\u0437\u0435\u0020\u0434\u0430\u043d\u043d\u044b\u0445\u0020\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 -onlyoffice.connector.dialog.conversion.message.error.input=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u0432\u0432\u043e\u0434\u0430 -onlyoffice.connector.dialog.conversion.message.error.token=\u041d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439\u0020\u0442\u043e\u043a\u0435\u043d onlyoffice.connector.dialog.conversion.message.error.not-reached=\u0421\u0435\u0440\u0432\u0438\u0441\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 ONLYOFFICE \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d. \u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430\u002c\u0020\u0441\u0432\u044f\u0436\u0438\u0442\u0435\u0441\u044c\u0020\u0441\u0020\u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u043e\u043c\u002e. onlyoffice.connector.dialog.conversion.message.error.permission=\u0020\u043d\u0435\u0442\u0020\u043f\u0440\u0430\u0432\u0020\u043d\u0430\u0020\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u0020\u044d\u0442\u043e\u0439\u0020\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. onlyoffice.connector.error.Unknown=\u0412\u0020\u0445\u043e\u0434\u0435\u0020\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438\u0020\u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430\u0020\u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f\u0020\u043e\u0448\u0438\u0431\u043a\u0430. @@ -89,3 +77,30 @@ onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.label=\u0 onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.desc=\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u043b\u0438 ''px'') \u0438\u043b\u0438 \u043a\u0430\u043a ''%'' \u043e\u0442 \u0448\u0438\u0440\u0438\u043d\u044b \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u041f\u0440\u0438\u043c\u0435\u0440\u044b: 200, 200px, 10% onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=\u0412\u044b\u0441\u043e\u0442\u0430 onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc=\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u043b\u0438 ''px'') \u0438\u043b\u0438 \u043a\u0430\u043a ''%'' \u043e\u0442 \u0432\u044b\u0441\u043e\u0442\u044b \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u041f\u0440\u0438\u043c\u0435\u0440\u044b: 200, 200px, 10% + +onlyoffice.server.common.error.connection=\u0421\u0435\u0440\u0432\u0435\u0440\u0020\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432\u0020\u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d\u002e +onlyoffice.server.common.error.api-js=\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0020\u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0020\u0434\u043e\u0441\u0442\u0443\u043f\u0020\u043a\u0020\u0444\u0430\u0439\u043b\u0443\u0020\u0041\u0050\u0049\u0020\u004a\u0061\u0076\u0061\u0053\u0063\u0072\u0069\u0070\u0074\u002e +onlyoffice.server.common.error.mixed-content=\u0421\u043C\u0435\u0448\u0430\u043D\u043D\u043E\u0435 \u0430\u043A\u0442\u0438\u0432\u043D\u043E\u0435 \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u0435 \u0437\u0430\u043F\u0440\u0435\u0449\u0435\u043D\u043E. \u0414\u043B\u044F \u0421\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u043E\u0432 \u043D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C HTTPS-\u0430\u0434\u0440\u0435\u0441. +onlyoffice.server.common.error.healthcheck=\u0421\u0435\u0440\u0432\u0435\u0440\u0020\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432\u0020\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0020\u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0439\u0020\u0441\u0442\u0430\u0442\u0443\u0441\u0020\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438\u0020\u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438\u002e + +onlyoffice.service.convert.check.error-prefix=\u041e\u0448\u0438\u0431\u043a\u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 ConvertService ($). +onlyoffice.service.convert.error.unknown=\u041d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f\u0020\u043e\u0448\u0438\u0431\u043a\u0430 +onlyoffice.service.convert.error.timeout=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u0432\u0440\u0435\u043c\u0435\u043d\u0438\u0020\u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 +onlyoffice.service.convert.error.conversion=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 +onlyoffice.service.convert.error.downloading=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u043f\u0440\u0438\u0020\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435\u0020\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0020\u0434\u043b\u044f\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 +onlyoffice.service.convert.error.password=\u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439\u0020\u043f\u0430\u0440\u043e\u043b\u044c +onlyoffice.service.convert.error.database=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u043f\u0440\u0438\u0020\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u0020\u043a\u0020\u0431\u0430\u0437\u0435\u0020\u0434\u0430\u043d\u043d\u044b\u0445\u0020\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 +onlyoffice.service.convert.error.input=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u0432\u0432\u043e\u0434\u0430 +onlyoffice.service.convert.error.token=\u041d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439\u0020\u0442\u043e\u043a\u0435\u043d +onlyoffice.service.convert.error.connection=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f +onlyoffice.service.convert.error.download_result=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438\u0020\u0444\u0430\u0439\u043b\u0430\u0020\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 + +onlyoffice.service.command.check.error-prefix=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u0432\u043e\u0020\u0432\u0440\u0435\u043c\u044f\u0020\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438\u0020\u0043\u006f\u006d\u006d\u0061\u006e\u0064\u0053\u0065\u0072\u0076\u0069\u0063\u0065\u0020\u0028\u0024\u0029\u002e +onlyoffice.service.command.error.no=\u041d\u0435\u0442\u0020\u043e\u0448\u0438\u0431\u043e\u043a +onlyoffice.service.command.error.key=\u041a\u043b\u044e\u0447\u0020\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0020\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442\u0020\u0438\u043b\u0438\u0020\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0020\u0441\u0020\u0442\u0430\u043a\u0438\u043c\u0020\u043a\u043b\u044e\u0447\u043e\u043c\u0020\u043d\u0435\u0020\u043d\u0430\u0439\u0434\u0435\u043d +onlyoffice.service.command.error.callback_url=\u0055\u0052\u004c\u0020\u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e\u0020\u0432\u044b\u0437\u043e\u0432\u0430\u0020\u043d\u0435\u0432\u0435\u0440\u0435\u043d +onlyoffice.service.command.error.internal_server=\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f\u0020\u043e\u0448\u0438\u0431\u043a\u0430\u0020\u0441\u0435\u0440\u0432\u0435\u0440\u0430 +onlyoffice.service.command.error.forcesave=\u0414\u043e\u0020\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f\u0020\u043a\u043e\u043c\u0430\u043d\u0434\u044b\u0020\u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e\u0020\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f\u0020\u043a\u0020\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0443\u0020\u043d\u0435\u0020\u043f\u0440\u0438\u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c\u0020\u043d\u0438\u043a\u0430\u043a\u0438\u0435\u0020\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f +onlyoffice.service.command.error.command=\u041a\u043e\u043c\u0430\u043d\u0434\u0430\u0020\u043d\u0435\u0020\u0432\u0435\u0440\u043d\u0430 +onlyoffice.service.command.error.token=\u041d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439\u0020\u0442\u043e\u043a\u0435\u043d +onlyoffice.service.command.error.connection=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f From 762de560f0ceb93941a3cf048b8e47449b8b5d2d Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 11:56:53 +0300 Subject: [PATCH 22/87] version: 4.5.0-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 08ab4fd2..80e8952e 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ 4.0.0 onlyoffice onlyoffice-confluence-plugin - 4.4.0 + 4.5.0-SNAPSHOT Ascensio System SIA From c947dc10aa54a4bf331c4960c42feb951eb70de1 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 13:45:43 +0300 Subject: [PATCH 23/87] fix: code style in DocumentManagerImpl --- .../onlyoffice/sdk/manager/document/DocumentManagerImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/onlyoffice/sdk/manager/document/DocumentManagerImpl.java b/src/main/java/onlyoffice/sdk/manager/document/DocumentManagerImpl.java index 84fe4164..5deef2af 100644 --- a/src/main/java/onlyoffice/sdk/manager/document/DocumentManagerImpl.java +++ b/src/main/java/onlyoffice/sdk/manager/document/DocumentManagerImpl.java @@ -73,8 +73,8 @@ public String getDocumentName(final String fileId) { return null; } - @Override + @Override public String getCorrectNewFileName(final String fileName, final String fileExtension, final Long pageID) { ContentEntityManager contentEntityManager = (ContentEntityManager) ContainerManager.getComponent("contentEntityManager"); @@ -101,6 +101,7 @@ public String getCorrectNewFileName(final String fileName, final String fileExte return name; } + @Override public String getMimeType(final String name) { Path path = new File(name).toPath(); String mimeType = null; From 47ea37002c8a8a4151ca92aa5738e6e79f541fcf Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 24 Nov 2023 13:46:09 +0300 Subject: [PATCH 24/87] fix: bug with converting docx to docxf --- .../onlyoffice/OnlyOfficeConvertServlet.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java b/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java index 4cd1514d..80f0950b 100644 --- a/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java @@ -27,6 +27,7 @@ import com.atlassian.confluence.util.velocity.VelocityUtils; import com.onlyoffice.manager.request.RequestManager; import com.onlyoffice.model.common.CommonResponse; +import com.onlyoffice.model.common.Format; import com.onlyoffice.model.convertservice.ConvertRequest; import com.onlyoffice.model.convertservice.ConvertResponse; import com.onlyoffice.service.convert.ConvertService; @@ -96,6 +97,19 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re String fileName = attachment.getFileName(); String newFileExtension = documentManager.getDefaultConvertExtension(fileName); + String extension = documentManager.getExtension(fileName); + Format docx = documentManager.getFormats().stream() + .filter(format -> format.getName().equals("docx")) + .findFirst() + .get(); + + if (docx != null + && extension.equals(docx.getName()) + && docx.getConvert() != null + && docx.getConvert().contains("docxf")) { + newFileExtension = "docxf"; + } + String title = fileName.substring(0, fileName.lastIndexOf(".")); if (pageIdString != null && !pageIdString.isEmpty()) { @@ -160,13 +174,26 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r String convertToExt = documentManager.getDefaultConvertExtension(fileName); + String extension = documentManager.getExtension(fileName); + Format docx = documentManager.getFormats().stream() + .filter(format -> format.getName().equals("docx")) + .findFirst() + .get(); + + if (docx != null + && extension.equals(docx.getName()) + && docx.getConvert() != null + && docx.getConvert().contains("docxf")) { + convertToExt = "docxf"; + } + if (!attachmentUtil.checkAccess(attachmentId, user, false) || !attachmentUtil.checkAccessCreate(user, pageId)) { response.setStatus(HttpServletResponse.SC_FORBIDDEN); return; } - if (documentManager.getDefaultConvertExtension(fileName) == null) { + if (convertToExt == null) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return; } @@ -179,6 +206,7 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r ConvertRequest convertRequest = ConvertRequest.builder() .async(true) + .outputtype(convertToExt) .region(region) .build(); From 5f7f77d922b73295f7776a9b10f7511760bcd21a Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 29 Nov 2023 11:13:58 +0300 Subject: [PATCH 25/87] rename: java sdk to docs-integration-sdk --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d00fae3f..2edd031d 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ com.onlyoffice - core-integration-sdk + docs-integration-sdk 0.0.1-SNAPSHOT From 23e160368d47376443be8d1e6f215353951ea101 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 29 Nov 2023 11:15:11 +0300 Subject: [PATCH 26/87] change: ignoreSSLCertificate moved from security model --- src/main/resources/js/settings.js | 2 +- src/main/resources/templates/configure.vm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/js/settings.js b/src/main/resources/js/settings.js index 5c3acedc..e30ab394 100644 --- a/src/main/resources/js/settings.js +++ b/src/main/resources/js/settings.js @@ -34,8 +34,8 @@ "productInnerUrl": $("#confUrlField").attr("value"), "security": { "key": $("#jwtSecretField").attr("value"), - "ignoreSSLCertificate": $("#verifyCertificate").is(":checked") }, + "ignoreSSLCertificate": $("#verifyCertificate").is(":checked"), "customization": { "forcesave": $("#forceSave").is(":checked"), "chat": $("#chat").is(":checked"), diff --git a/src/main/resources/templates/configure.vm b/src/main/resources/templates/configure.vm index 3fcd9218..3b5e23ec 100644 --- a/src/main/resources/templates/configure.vm +++ b/src/main/resources/templates/configure.vm @@ -33,7 +33,7 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl
- +
From f09b07e6afd5b5c02654cad9931f8fd6a0638f19 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 29 Nov 2023 11:21:10 +0300 Subject: [PATCH 27/87] fix: check forcesave setting in CallbackServiceImpl --- src/main/java/onlyoffice/sdk/service/CallbackServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/onlyoffice/sdk/service/CallbackServiceImpl.java b/src/main/java/onlyoffice/sdk/service/CallbackServiceImpl.java index 4d822019..be24b460 100644 --- a/src/main/java/onlyoffice/sdk/service/CallbackServiceImpl.java +++ b/src/main/java/onlyoffice/sdk/service/CallbackServiceImpl.java @@ -135,7 +135,7 @@ public void handlerSave(final Callback callback, final String fileId) throws Exc public void handlerForcesave(final Callback callback, final String fileId) throws Exception { ConfluenceUser user = AuthenticatedUserThreadLocal.get(); if (user != null && attachmentUtil.checkAccess(Long.valueOf(fileId), user, true)) { - if (settingsManager.getSettingBoolean("forcesave", false)) { + if (settingsManager.getSettingBoolean("customization.forcesave", false)) { String fileType = callback.getFiletype(); String downloadUrl = callback.getUrl(); History history = callback.getHistory(); From bf5691579ff0df0e32c9097067f80df903588874 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 29 Nov 2023 11:22:20 +0300 Subject: [PATCH 28/87] fix: generating token for attachmentData in OnlyOfficeAPIServlet --- src/main/java/onlyoffice/OnlyOfficeAPIServlet.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java index 8c960176..1f3e55c9 100644 --- a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java @@ -188,8 +188,7 @@ private void attachmentData(final HttpServletRequest request, final HttpServletR data.put("fileType", fileType); data.put("url", urlManager.getFileUrl(String.valueOf(attachmentId))); if (settingsManager.isSecurityEnabled()) { - JSONObject dataJSON = new JSONObject(gson.toJson(data)); - data.put("token", jwtManager.createToken(dataJSON)); + data.put("token", jwtManager.createToken(data)); } responseJson.add(data); From 77a6662a5625247c395c01dc452a2cbda82fc03b Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 29 Nov 2023 11:23:00 +0300 Subject: [PATCH 29/87] add: disableDemo in OnlyOfficeConfServlet --- src/main/java/onlyoffice/OnlyOfficeConfServlet.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/onlyoffice/OnlyOfficeConfServlet.java b/src/main/java/onlyoffice/OnlyOfficeConfServlet.java index b9f9fea5..d6fc4592 100644 --- a/src/main/java/onlyoffice/OnlyOfficeConfServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeConfServlet.java @@ -152,6 +152,8 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r if (settings.getDemo() != null && settings.getDemo()) { settingsManager.enableDemo(); + } else { + settingsManager.disableDemo(); } if (settingsManager.isDemoActive()) { From efa8d4f955789ee1e90481c483b3d32164342531 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 29 Nov 2023 11:24:08 +0300 Subject: [PATCH 30/87] fix: getConfluenceBaseUrl in UrlManagerImpl --- .../sdk/manager/url/UrlManagerImpl.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java b/src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java index 9298f586..0fbc7ce2 100644 --- a/src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java +++ b/src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java @@ -77,7 +77,7 @@ public String getFileUrl(final String fileId) { params.put("action", "download"); String fileUri = - getConfluenceBaseUrl() + fileProviderServlet + "?token=" + jwtManager.createInternalToken(params); + getConfluenceBaseUrl(true) + fileProviderServlet + "?token=" + jwtManager.createInternalToken(params); return fileUri; } @@ -91,7 +91,7 @@ public String getCallbackUrl(final String fileId) { params.put("attachmentId", fileId); params.put("action", "callback"); - String callbackUrl = getConfluenceBaseUrl() + String callbackUrl = getConfluenceBaseUrl(true) + callbackServlet + "?token=" + jwtManager.createInternalToken(params); @@ -124,7 +124,7 @@ public String getCreateUrl(final String fileId) { extension = documentManager.getDefaultExtension(documentType); } - return getConfluenceBaseUrl() + docEditorServlet + "?pageId=" + pageId + "&fileExt=" + extension; + return getConfluenceBaseUrl(false) + docEditorServlet + "?pageId=" + pageId + "&fileExt=" + extension; } else { return null; } @@ -132,13 +132,13 @@ public String getCreateUrl(final String fileId) { @Override public String getTestConvertUrl(final String url) { - return getConfluenceBaseUrl() + "/plugins/servlet/onlyoffice/test"; + return getConfluenceBaseUrl(true) + "/plugins/servlet/onlyoffice/test"; } public String getAttachmentDiffUri(final Long attachmentId) { String hash = jwtManager.createHash(Long.toString(attachmentId)); String diffAttachmentUrl = - getConfluenceBaseUrl() + historyServlet + "?type=diff&vkey=" + GeneralUtil.urlEncode(hash); + getConfluenceBaseUrl(false) + historyServlet + "?type=diff&vkey=" + GeneralUtil.urlEncode(hash); return diffAttachmentUrl; } @@ -146,7 +146,7 @@ public String getAttachmentDiffUri(final Long attachmentId) { public String getHistoryInfoUri(final Long attachmentId) { String hash = jwtManager.createHash(Long.toString(attachmentId)); String historyInfoUri = - getConfluenceBaseUrl() + historyServlet + "?type=info&vkey=" + GeneralUtil.urlEncode(hash); + getConfluenceBaseUrl(false) + historyServlet + "?type=info&vkey=" + GeneralUtil.urlEncode(hash); return historyInfoUri; } @@ -154,24 +154,24 @@ public String getHistoryInfoUri(final Long attachmentId) { public String getHistoryDataUri(final Long attachmentId) { String hash = jwtManager.createHash(Long.toString(attachmentId)); String historyDataUri = - getConfluenceBaseUrl() + historyServlet + "?type=data&vkey=" + GeneralUtil.urlEncode(hash); + getConfluenceBaseUrl(false) + historyServlet + "?type=data&vkey=" + GeneralUtil.urlEncode(hash); return historyDataUri; } public String getAttachmentDataUri() { - String attachmentDataUri = getConfluenceBaseUrl() + apiServlet + "?type=attachment-data"; + String attachmentDataUri = getConfluenceBaseUrl(false) + apiServlet + "?type=attachment-data"; return attachmentDataUri; } public String getSaveAsUri() { - String saveAsUri = getConfluenceBaseUrl() + apiServlet + "?type=save-as"; + String saveAsUri = getConfluenceBaseUrl(false) + apiServlet + "?type=save-as"; return saveAsUri; } public String getReferenceDataUri(final Long pageId) { - String referenceDataUri = getConfluenceBaseUrl() + apiServlet + "?type=reference-data&pageId=" + pageId; + String referenceDataUri = getConfluenceBaseUrl(false) + apiServlet + "?type=reference-data&pageId=" + pageId; return referenceDataUri; } @@ -190,12 +190,13 @@ public String getFaviconUrl(final DocumentType documentType) { ); } - private String getConfluenceBaseUrl() { - String url = getSettingsManager().getSetting(SettingsConstants.PRODUCT_INNER_URL); - if (url == null || url.isEmpty()) { - return sanitizeUrl(settingsManager.getGlobalSettings().getBaseUrl()); + private String getConfluenceBaseUrl(final Boolean inner) { + String productInnerUrl = getSettingsManager().getSetting(SettingsConstants.PRODUCT_INNER_URL); + + if (inner && productInnerUrl != null && !productInnerUrl.isEmpty()) { + return sanitizeUrl(productInnerUrl); } else { - return sanitizeUrl(url); + return sanitizeUrl(settingsManager.getGlobalSettings().getBaseUrl()); } } } From d1ee36fa5a8704b117f54a275f35a354af3204e5 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 29 Nov 2023 12:23:27 +0300 Subject: [PATCH 31/87] fix: generating token for referenceData() in OnlyOfficeAPIServlet --- .../java/onlyoffice/OnlyOfficeAPIServlet.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java index 1f3e55c9..3316e33f 100644 --- a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java @@ -22,6 +22,7 @@ import com.atlassian.confluence.status.service.SystemInformationService; import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.user.ConfluenceUser; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.onlyoffice.manager.request.RequestManager; import com.onlyoffice.manager.settings.SettingsManager; @@ -63,6 +64,8 @@ public class OnlyOfficeAPIServlet extends HttpServlet { private final UrlManager urlManager; private final RequestManager requestManager; + private final ObjectMapper objectMapper = new ObjectMapper(); + public OnlyOfficeAPIServlet(final SystemInformationService sysInfoService, final SettingsManager settingsManager, final JwtManager jwtManager, final DocumentManager documentManager, final AttachmentUtil attachmentUtil, final ParsingUtil parsingUtil, @@ -253,23 +256,23 @@ private void referenceData(final HttpServletRequest request, final HttpServletRe return; } - JSONObject responseJson = new JSONObject(); + Map responseMap = new HashMap<>(); String documentName = documentManager.getDocumentName(String.valueOf(attachmentId)); String extension = documentManager.getExtension(documentName); - responseJson.put("fileType", extension); - responseJson.put("path", documentName); - responseJson.put("referenceData", referenceData); - responseJson.put("url", urlManager.getFileUrl(String.valueOf(attachmentId))); + responseMap.put("fileType", extension); + responseMap.put("path", documentName); + responseMap.put("referenceData", referenceData); + responseMap.put("url", urlManager.getFileUrl(String.valueOf(attachmentId))); if (settingsManager.isSecurityEnabled()) { - responseJson.put("token", jwtManager.createToken(responseJson)); + responseMap.put("token", jwtManager.createToken(responseMap)); } response.setContentType("application/json"); PrintWriter writer = response.getWriter(); - writer.write(responseJson.toString()); + writer.write(objectMapper.writeValueAsString(responseMap)); } catch (Exception e) { throw new IOException(e.getMessage(), e); } From e63d3fd16b0498480f05c74f9faefa6d46af7e21 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 29 Nov 2023 12:30:59 +0300 Subject: [PATCH 32/87] fix: attachmentData() in OnlyOfficeAPIServlet when command is null --- src/main/java/onlyoffice/OnlyOfficeAPIServlet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java index 3316e33f..87ac176b 100644 --- a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java @@ -185,7 +185,7 @@ private void attachmentData(final HttpServletRequest request, final HttpServletR String documentName = documentManager.getDocumentName(String.valueOf(attachmentId)); String fileType = documentManager.getExtension(documentName); - if (bodyJson.has("command")) { + if (!bodyJson.get("command").equals(null)) { data.put("command", bodyJson.getString("command")); } data.put("fileType", fileType); From 9c7540444528b0a64a70457ea42b9455d5c496eb Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 29 Nov 2023 12:59:13 +0300 Subject: [PATCH 33/87] add: lang to config --- .../java/onlyoffice/OnlyOfficeEditorServlet.java | 2 ++ .../onlyoffice/macro/OnlyOfficePreviewMacro.java | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java index a38dc446..ad7e7599 100644 --- a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java @@ -169,7 +169,9 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re request.getHeader("USER-AGENT") ); + config.getEditorConfig().setLang(localeManager.getLocale(user).toLanguageTag()); config.getEditorConfig().setActionLink(actionData); + ObjectMapper mapper = new ObjectMapper(); context.put("configAsHtml", mapper.writeValueAsString(config)); diff --git a/src/main/java/onlyoffice/macro/OnlyOfficePreviewMacro.java b/src/main/java/onlyoffice/macro/OnlyOfficePreviewMacro.java index ac868d15..d83bdfce 100644 --- a/src/main/java/onlyoffice/macro/OnlyOfficePreviewMacro.java +++ b/src/main/java/onlyoffice/macro/OnlyOfficePreviewMacro.java @@ -22,6 +22,7 @@ import com.atlassian.confluence.content.render.xhtml.ConversionContext; import com.atlassian.confluence.core.ContentEntityObject; +import com.atlassian.confluence.languages.LocaleManager; import com.atlassian.confluence.macro.Macro; import com.atlassian.confluence.macro.EditorImagePlaceholder; import com.atlassian.confluence.macro.ResourceAware; @@ -32,6 +33,7 @@ import com.atlassian.confluence.pages.AttachmentManager; import com.atlassian.confluence.plugin.services.VelocityHelperService; import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; +import com.atlassian.confluence.user.ConfluenceUser; import com.atlassian.confluence.util.HtmlUtil; import com.fasterxml.jackson.databind.ObjectMapper; import com.onlyoffice.manager.document.DocumentManager; @@ -63,6 +65,7 @@ public class OnlyOfficePreviewMacro implements Macro, EditorImagePlaceholder, Re private final AttachmentManager attachmentManager; private final VelocityHelperService velocityHelperService; private final ContentResolver contentResolver; + private final LocaleManager localeManager; private final UrlManager urlManager; private final AttachmentUtil attachmentUtil; private final ConfigService configSevice; @@ -70,12 +73,13 @@ public class OnlyOfficePreviewMacro implements Macro, EditorImagePlaceholder, Re public OnlyOfficePreviewMacro(final AttachmentManager attachmentManager, final VelocityHelperService velocityHelperService, - final ContentResolver contentResolver, final UrlManager urlManager, - final AttachmentUtil attachmentUtil, final ConfigService configSevice, - final DocumentManager documentManager) { + final ContentResolver contentResolver, final LocaleManager localeManager, + final UrlManager urlManager, final AttachmentUtil attachmentUtil, + final ConfigService configSevice, final DocumentManager documentManager) { this.attachmentManager = attachmentManager; this.velocityHelperService = velocityHelperService; this.contentResolver = contentResolver; + this.localeManager = localeManager; this.urlManager = urlManager; this.attachmentUtil = attachmentUtil; this.configSevice = configSevice; @@ -105,18 +109,21 @@ public String execute(final Map args, final String s, final Conv width = normalizeSize((width == null) ? DEFAULT_WIDTH : width); height = normalizeSize((height == null) ? DEFAULT_HEIGHT : height); + ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + try { Config config = configSevice.createConfig(String.valueOf(attachment.getId()), Mode.EDIT, Type.EMBEDDED); config.setWidth(width); config.setHeight(height); + config.getEditorConfig().setLang(localeManager.getLocale(user).toLanguageTag()); String fileName = attachment.getFileName(); String action = ""; final boolean isPreview = conversionContext.getOutputType().equals("preview"); - if (attachmentUtil.checkAccess(attachment.getId(), AuthenticatedUserThreadLocal.get(), true) + if (attachmentUtil.checkAccess(attachment.getId(), user, true) && !isPreview) { if (documentManager.isEditable(fileName)) { action = "edit"; From 8813624c4316c08e7ede9926ab1f1179c7e2b44c Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 29 Nov 2023 13:11:16 +0300 Subject: [PATCH 34/87] fix: condition for onlyoffice button in preview --- .../confluence/previews/plugin/OnlyofficeButton.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/onlyoffice/conditions/confluence/previews/plugin/OnlyofficeButton.java b/src/main/java/onlyoffice/conditions/confluence/previews/plugin/OnlyofficeButton.java index c25c3a84..4c38aa81 100644 --- a/src/main/java/onlyoffice/conditions/confluence/previews/plugin/OnlyofficeButton.java +++ b/src/main/java/onlyoffice/conditions/confluence/previews/plugin/OnlyofficeButton.java @@ -65,15 +65,16 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r boolean accessEdit = attachmentUtil.checkAccess(attachment, user, true); boolean accessView = attachmentUtil.checkAccess(attachment, user, false); - String ext = attachment.getFileExtension(); + String fileName = attachment.getFileName(); String access = null; - if (accessEdit && documentManager.isEditable(ext)) { + if (accessEdit && documentManager.isEditable(fileName)) { access = "edit"; - } else if (accessEdit && documentManager.isFillable(ext)) { + } else if (accessEdit && documentManager.isFillable(fileName)) { access = "fillform"; - } else if (accessView && documentManager.isViewable(ext) - && !(accessEdit && (documentManager.isEditable(ext) || documentManager.isFillable(ext)))) { + } else if (accessView && documentManager.isViewable(fileName) + && !(accessEdit + && (documentManager.isEditable(fileName) || documentManager.isFillable(fileName)))) { access = "view"; } From d9bc61585780546dd4b3107aabed18897b3d147b Mon Sep 17 00:00:00 2001 From: Maria-Sukhova Date: Thu, 30 Nov 2023 18:14:08 +0300 Subject: [PATCH 35/87] added translations --- src/main/resources/lang-resource_de.properties | 14 +++++++------- src/main/resources/lang-resource_es.properties | 14 +++++++------- src/main/resources/lang-resource_fr.properties | 18 +++++++++--------- src/main/resources/lang-resource_it.properties | 12 ++++++------ 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/main/resources/lang-resource_de.properties b/src/main/resources/lang-resource_de.properties index 51cce7be..223660cd 100644 --- a/src/main/resources/lang-resource_de.properties +++ b/src/main/resources/lang-resource_de.properties @@ -78,12 +78,12 @@ onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.desc=Wird onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=H\u00f6he onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc=Wird entweder in Pixel (standardm\u00e4\u00dfig oder ''px'') oder als ''%'' der Seitenh\u00f6he angegeben. Beispiele: 200, 200px, 10% -onlyoffice.server.common.error.connection= +onlyoffice.server.common.error.connection=Document Server ist zurzeit nicht erreichbar. onlyoffice.server.common.error.api-js= -onlyoffice.server.common.error.mixed-content=Mixed Active Content ist nicht m\u00F6glich. HTTPS-Adresse f\u00FCr Document Server ist erforderlich. +onlyoffice.server.common.error.mixed-content=Mixed Active Content ist nicht m\u00F6glich. HTTPS-Adresse f\u00fcr ONLYOFFICE Document Server ist erforderlich. onlyoffice.server.common.error.healthcheck= -onlyoffice.service.convert.check.error-prefix=Fehler beim Versuch, ConvertService zu überprüfen ($). +onlyoffice.service.convert.check.error-prefix=Fehler beim Versuch, ConvertService zu \u00fcberpr\u00fcfen ($). onlyoffice.service.convert.error.unknown=Unbekannter Fehler onlyoffice.service.convert.error.timeout=Timeout-Fehler bei der Konvertierung onlyoffice.service.convert.error.conversion=Fehler bei der Umwandlung @@ -92,15 +92,15 @@ onlyoffice.service.convert.error.password=Ung\u00fcltiges Passwort onlyoffice.service.convert.error.database=Fehler beim Zugriff auf die Datenbank der Ergebnisse der Konvertierung onlyoffice.service.convert.error.input=Eingabefehler onlyoffice.service.convert.error.token=Ung\u00fcltiges Token -onlyoffice.service.convert.error.connection= +onlyoffice.service.convert.error.connection=Verbindungsfehler onlyoffice.service.convert.error.download_result= -onlyoffice.service.command.check.error-prefix=Fehler beim Versuch, CommandService zu überprüfen ($). +onlyoffice.service.command.check.error-prefix=Fehler beim Versuch, CommandService zu \u00fcberpr\u00fcfen ($). onlyoffice.service.command.error.no= onlyoffice.service.command.error.key= onlyoffice.service.command.error.callback_url= -onlyoffice.service.command.error.internal_server= +onlyoffice.service.command.error.internal_server=Interner Server-Fehler onlyoffice.service.command.error.forcesave= onlyoffice.service.command.error.command= onlyoffice.service.command.error.token=Ung\u00fcltiges Token -onlyoffice.service.command.error.connection= +onlyoffice.service.command.error.connection=Verbindungsfehler diff --git a/src/main/resources/lang-resource_es.properties b/src/main/resources/lang-resource_es.properties index 386f1641..dda10911 100644 --- a/src/main/resources/lang-resource_es.properties +++ b/src/main/resources/lang-resource_es.properties @@ -78,12 +78,12 @@ onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.desc=Espe onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=Altura onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc=Especificado en p\u00edxeles (por defecto o ''px'') o como un ''%'' de la altura de la p\u00e1gina. Ejemplos: 200, 200px, 10% -onlyoffice.server.common.error.connection= +onlyoffice.server.common.error.connection=No se puede acceder al ONLYOFFICE Document Server. onlyoffice.server.common.error.api-js= -onlyoffice.server.common.error.mixed-content=Contenido Mixto Activo no est\u00E1 permitido. Se requiere la direcci\u00F3n HTTPS para Servidor de Documentos. +onlyoffice.server.common.error.mixed-content=Contenido Mixto Activo no est\u00E1 permitido. Se requiere la direcci\u00F3n HTTPS para ONLYOFFICE Document Server. onlyoffice.server.common.error.healthcheck= -onlyoffice.service.convert.check.error-prefix= ($). +onlyoffice.service.convert.check.error-prefix=Error al intentar verificar ConvertService ($). onlyoffice.service.convert.error.unknown=Error desconocido onlyoffice.service.convert.error.timeout=Error de tiempo de espera onlyoffice.service.convert.error.conversion=Error de conversi\u00f3n @@ -92,15 +92,15 @@ onlyoffice.service.convert.error.password=Contrase\u00f1a incorrecta onlyoffice.service.convert.error.database=Error al acceder la base de datos de resultados de conversi\u00f3n onlyoffice.service.convert.error.input=Error de entrada onlyoffice.service.convert.error.token=Token inv\u00e1lido -onlyoffice.service.convert.error.connection= +onlyoffice.service.convert.error.connection=Error de conexi\u00f3n onlyoffice.service.convert.error.download_result= -onlyoffice.service.command.check.error-prefix= ($). +onlyoffice.service.command.check.error-prefix=Error al intentar verificar CommandService ($). onlyoffice.service.command.error.no= onlyoffice.service.command.error.key= onlyoffice.service.command.error.callback_url= -onlyoffice.service.command.error.internal_server= +onlyoffice.service.command.error.internal_server=Error interno de servidor onlyoffice.service.command.error.forcesave= onlyoffice.service.command.error.command= onlyoffice.service.command.error.token=Token inv\u00e1lido -onlyoffice.service.command.error.connection= +onlyoffice.service.command.error.connection=Error de conexi\u00f3n diff --git a/src/main/resources/lang-resource_fr.properties b/src/main/resources/lang-resource_fr.properties index 3a8cf9d4..4bb1b1e6 100644 --- a/src/main/resources/lang-resource_fr.properties +++ b/src/main/resources/lang-resource_fr.properties @@ -34,7 +34,7 @@ onlyoffice.configuration.button.save=Enregistrer onlyoffice.configuration.message.settings.saved=Settings saved onlyoffice.configuration.message.settings.saving-error=Error saving settings onlyoffice.configuration.banner.message=Lancez facilement les \u00e9diteurs dans le cloud sans t\u00e9l\u00e9chargement ni installation -onlyoffice.configuration.banner.button=Ottieni ora +onlyoffice.configuration.banner.button=Obtenir maintenant onlyoffice.editor.editlink=Modifier dans ONLYOFFICE onlyoffice.editor.viewlink=Voir dans ONLYOFFICE onlyoffice.editor.fillFormlink=Remplir le formulaire dans ONLYOFFICE @@ -78,12 +78,12 @@ onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.desc=Sp\u onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=Hauteur onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc=Sp\u00ecifi\u00e9 soit en pixels (par d\u00efaut ou ''px''), soit en ''%'' de la hauteur de la page. Exemples : 200, 200px, 10%200, 200px, 10% -onlyoffice.server.common.error.connection= +onlyoffice.server.common.error.connection=Document Server non può essere raggiunto. onlyoffice.server.common.error.api-js= -onlyoffice.server.common.error.mixed-content=Il contenuto attivo misto non \u00E8 consentito. \u00C8 richiesto l\u2019indirizzo HTTPS per Document Server. +onlyoffice.server.common.error.mixed-content=Il contenuto attivo misto non \u00E8 consentito. \u00C8 richiesto l\u2019indirizzo HTTPS per ONLYOFFICE Document Server. onlyoffice.server.common.error.healthcheck= -onlyoffice.service.convert.check.error-prefix= +onlyoffice.service.convert.check.error-prefix=Errore durante il tentativo di controllare ConvertService ($). onlyoffice.service.convert.error.unknown=Errore sconosciuto onlyoffice.service.convert.error.timeout=Errore di timeout per la conversione onlyoffice.service.convert.error.conversion=Errore di conversione @@ -92,15 +92,15 @@ onlyoffice.service.convert.error.password=Password errata onlyoffice.service.convert.error.database=Errore durante l'accesso al database dei risultati di conversione onlyoffice.service.convert.error.input=Errore di input onlyoffice.service.convert.error.token=Token non valido -onlyoffice.service.convert.error.connection= +onlyoffice.service.convert.error.connection=Errore di connessione onlyoffice.service.convert.error.download_result= onlyoffice.service.command.check.error-prefix=Errore durante il tentativo di controllare CommandService ($). onlyoffice.service.command.error.no= onlyoffice.service.command.error.key= onlyoffice.service.command.error.callback_url= -onlyoffice.service.command.error.internal_server= +onlyoffice.service.command.error.internal_server=Errore interno del server onlyoffice.service.command.error.forcesave= onlyoffice.service.command.error.command= onlyoffice.service.command.error.token=Token non valido -onlyoffice.service.command.error.connection= +onlyoffice.service.command.error.connection=Errore di connessione From 2864c401b6473e474deb498e7c633daa2d4c1f25 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 1 Dec 2023 11:40:39 +0300 Subject: [PATCH 36/87] integration-sdk to changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8fc1711..1ab619cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## +## Added +- core of the plugin has been moved to com.onlyoffice.docs-integration-sdk (https://github.com/ONLYOFFICE/docs-integration-sdk-java) + ## 4.4.0 ## Added - compatible with Confluence 8.6 From 35c339dee83cea2490345455125d12b8aeb4c4cb Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 1 Dec 2023 11:41:59 +0300 Subject: [PATCH 37/87] validation-settings to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ab619cc..30864f50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## ## Added - core of the plugin has been moved to com.onlyoffice.docs-integration-sdk (https://github.com/ONLYOFFICE/docs-integration-sdk-java) +- improved connection settings validation ## 4.4.0 ## Added From 49d36fa3fa9286334aa45ec16538cf0111e0b7b1 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Fri, 1 Dec 2023 17:40:18 +0300 Subject: [PATCH 38/87] reorder licenses --- 3rd-Party.license | 26 +++++++++++++------------- licenses/3rd-Party.license | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/3rd-Party.license b/3rd-Party.license index fae3b3c7..4a7309f6 100644 --- a/3rd-Party.license +++ b/3rd-Party.license @@ -2,25 +2,25 @@ Confluence ONLYOFFICE integration app uses code from the following 3rd party pro com.atlassian.confluence.confluence - Confluence Core -License: Apache License 2.0 +License: Apache 2.0 License File: com.atlassian.confluence.confluence.licence +com.fasterxml.jackson.core.jackson-databind - General data-binding functionality for Jackson: works on core streaming API (https://github.com/FasterXML/jackson-databind/blob/2.16/LICENSE) +License: Apache 2.0 +License File: com.fasterxml.jackson.core.jackson-databind.license + +commons-io.commons-io - The Apache Commons IO library contains utility classes, stream implementations, file filters, file comparators, endian transformation classes, and much more. +License: Apache 2.0 +License File: commons-io.commons-io.license + javax.servlet-api - Java Servlet API (https://opensource.org/licenses/CDDL-1.0 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) License: CDDL, GPL 2.0 License File: javax.servlet-api.license +org.apache.httpcomponents.httpclient - HTTPClient provides an efficient, up-to-date, and feature-rich package implementing the client side of the most recent HTTP standards and recommendations. +License: Apache 2.0 +License File: org.apache.httpcomponents.httpclient.license + org.json.json - JSON is a light-weight, language independent, data interchange format. See http://www.JSON.org/ The files in this package implement JSON encoders/decoders in Java. It also includes the capability to convert between JSON and XML, HTTP headers, Cookies, and CDL. This is a reference implementation. (https://github.com/stleary/JSON-java/blob/master/LICENSE) License: Public Domain License File: org.json.json.license - -com.fasterxml.jackson.core.jackson-databind - General data-binding functionality for Jackson: works on core streaming API (https://github.com/FasterXML/jackson-databind/blob/2.16/LICENSE) -License: Apache License 2.0 -License File: com.fasterxml.jackson.core.jackson-databind.license - -org.apache.httpcomponents.httpclient - HTTPClient provides an efficient, up-to-date, and feature-rich package implementing the client side of the most recent HTTP standards and recommendations. (https://www.apache.org/licenses/LICENSE-2.0.txt) -License: Apache License 2.0 -License File: org.apache.httpcomponents.httpclient.license - -commons-io.commons-io - The Apache Commons IO library contains utility classes, stream implementations, file filters, file comparators, endian transformation classes, and much more. (https://www.apache.org/licenses/LICENSE-2.0.txt) -License: Apache License 2.0 -License File: commons-io.commons-io.license diff --git a/licenses/3rd-Party.license b/licenses/3rd-Party.license index fae3b3c7..4a7309f6 100644 --- a/licenses/3rd-Party.license +++ b/licenses/3rd-Party.license @@ -2,25 +2,25 @@ Confluence ONLYOFFICE integration app uses code from the following 3rd party pro com.atlassian.confluence.confluence - Confluence Core -License: Apache License 2.0 +License: Apache 2.0 License File: com.atlassian.confluence.confluence.licence +com.fasterxml.jackson.core.jackson-databind - General data-binding functionality for Jackson: works on core streaming API (https://github.com/FasterXML/jackson-databind/blob/2.16/LICENSE) +License: Apache 2.0 +License File: com.fasterxml.jackson.core.jackson-databind.license + +commons-io.commons-io - The Apache Commons IO library contains utility classes, stream implementations, file filters, file comparators, endian transformation classes, and much more. +License: Apache 2.0 +License File: commons-io.commons-io.license + javax.servlet-api - Java Servlet API (https://opensource.org/licenses/CDDL-1.0 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) License: CDDL, GPL 2.0 License File: javax.servlet-api.license +org.apache.httpcomponents.httpclient - HTTPClient provides an efficient, up-to-date, and feature-rich package implementing the client side of the most recent HTTP standards and recommendations. +License: Apache 2.0 +License File: org.apache.httpcomponents.httpclient.license + org.json.json - JSON is a light-weight, language independent, data interchange format. See http://www.JSON.org/ The files in this package implement JSON encoders/decoders in Java. It also includes the capability to convert between JSON and XML, HTTP headers, Cookies, and CDL. This is a reference implementation. (https://github.com/stleary/JSON-java/blob/master/LICENSE) License: Public Domain License File: org.json.json.license - -com.fasterxml.jackson.core.jackson-databind - General data-binding functionality for Jackson: works on core streaming API (https://github.com/FasterXML/jackson-databind/blob/2.16/LICENSE) -License: Apache License 2.0 -License File: com.fasterxml.jackson.core.jackson-databind.license - -org.apache.httpcomponents.httpclient - HTTPClient provides an efficient, up-to-date, and feature-rich package implementing the client side of the most recent HTTP standards and recommendations. (https://www.apache.org/licenses/LICENSE-2.0.txt) -License: Apache License 2.0 -License File: org.apache.httpcomponents.httpclient.license - -commons-io.commons-io - The Apache Commons IO library contains utility classes, stream implementations, file filters, file comparators, endian transformation classes, and much more. (https://www.apache.org/licenses/LICENSE-2.0.txt) -License: Apache License 2.0 -License File: commons-io.commons-io.license From 02338ff89ae2b51f4439e156f57afa056470b936 Mon Sep 17 00:00:00 2001 From: Maria-Sukhova Date: Wed, 6 Dec 2023 18:01:38 +0300 Subject: [PATCH 39/87] updated fr, es, it, de --- src/main/resources/lang-resource.properties | 4 ++-- .../resources/lang-resource_de.properties | 20 ++++++++--------- .../resources/lang-resource_es.properties | 20 ++++++++--------- .../resources/lang-resource_fr.properties | 20 ++++++++--------- .../resources/lang-resource_it.properties | 22 +++++++++---------- 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/main/resources/lang-resource.properties b/src/main/resources/lang-resource.properties index 9b48443e..9fa4660b 100644 --- a/src/main/resources/lang-resource.properties +++ b/src/main/resources/lang-resource.properties @@ -32,7 +32,7 @@ onlyoffice.configuration.reviewDisplay.final=Final onlyoffice.configuration.reviewDisplay.original=Original onlyoffice.configuration.button.save=Save onlyoffice.configuration.message.settings.saved=Settings saved -onlyoffice.configuration.message.settings.saving-error=Error saving settings +onlyoffice.configuration.message.settings.saving-error=Error while saving settings onlyoffice.configuration.banner.message=Easily launch the editors in the cloud without downloading and installation onlyoffice.configuration.banner.button=Get Now onlyoffice.editor.editlink=Edit in ONLYOFFICE @@ -93,7 +93,7 @@ onlyoffice.service.convert.error.database=Error while accessing the conversion r onlyoffice.service.convert.error.input=Input error onlyoffice.service.convert.error.token=Invalid token onlyoffice.service.convert.error.connection=Connection error -onlyoffice.service.convert.error.download_result=Download result file error +onlyoffice.service.convert.error.download_result=Error while downloading the result file onlyoffice.service.command.check.error-prefix=Error when trying to check CommandService ($). onlyoffice.service.command.error.no=No errors diff --git a/src/main/resources/lang-resource_de.properties b/src/main/resources/lang-resource_de.properties index 223660cd..d6abbd0b 100644 --- a/src/main/resources/lang-resource_de.properties +++ b/src/main/resources/lang-resource_de.properties @@ -31,8 +31,8 @@ onlyoffice.configuration.reviewDisplay.markup=Markup onlyoffice.configuration.reviewDisplay.final=Endg\u00fcltig onlyoffice.configuration.reviewDisplay.original=Original onlyoffice.configuration.button.save=Speichern -onlyoffice.configuration.message.settings.saved= -onlyoffice.configuration.message.settings.saving-error= +onlyoffice.configuration.message.settings.saved=Einstellungen gespeichert +onlyoffice.configuration.message.settings.saving-error=Fehler beim Speichern der Einstellungen onlyoffice.configuration.banner.message=\u00d6ffnen Sie die Editoren in der Cloud einfach ohne Herunterladen und Installation onlyoffice.configuration.banner.button=Jetzt erhalten onlyoffice.editor.editlink=Mit ONLYOFFICE bearbeiten @@ -79,9 +79,9 @@ onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=H\ onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc=Wird entweder in Pixel (standardm\u00e4\u00dfig oder ''px'') oder als ''%'' der Seitenh\u00f6he angegeben. Beispiele: 200, 200px, 10% onlyoffice.server.common.error.connection=Document Server ist zurzeit nicht erreichbar. -onlyoffice.server.common.error.api-js= +onlyoffice.server.common.error.api-js=Die API-JavaScript-Datei kann nicht erreicht werden. onlyoffice.server.common.error.mixed-content=Mixed Active Content ist nicht m\u00F6glich. HTTPS-Adresse f\u00fcr ONLYOFFICE Document Server ist erforderlich. -onlyoffice.server.common.error.healthcheck= +onlyoffice.server.common.error.healthcheck=Document Server gibt einen fehlerhaften Zustandspr\u00fcfungsstatus zur\u00fcck. onlyoffice.service.convert.check.error-prefix=Fehler beim Versuch, ConvertService zu \u00fcberpr\u00fcfen ($). onlyoffice.service.convert.error.unknown=Unbekannter Fehler @@ -93,14 +93,14 @@ onlyoffice.service.convert.error.database=Fehler beim Zugriff auf die Datenbank onlyoffice.service.convert.error.input=Eingabefehler onlyoffice.service.convert.error.token=Ung\u00fcltiges Token onlyoffice.service.convert.error.connection=Verbindungsfehler -onlyoffice.service.convert.error.download_result= +onlyoffice.service.convert.error.download_result=Fehler beim Herunterladen der Ergebnisdatei onlyoffice.service.command.check.error-prefix=Fehler beim Versuch, CommandService zu \u00fcberpr\u00fcfen ($). -onlyoffice.service.command.error.no= -onlyoffice.service.command.error.key= -onlyoffice.service.command.error.callback_url= +onlyoffice.service.command.error.no=Keine Fehler +onlyoffice.service.command.error.key=Dokument-Key fehlt oder es konnte kein Dokument mit einem solchen Key gefunden werden +onlyoffice.service.command.error.callback_url=Callback-URL ist nicht korrekt onlyoffice.service.command.error.internal_server=Interner Server-Fehler -onlyoffice.service.command.error.forcesave= -onlyoffice.service.command.error.command= +onlyoffice.service.command.error.forcesave=Vor dem Empfang des Forcesave-Befehls wurden keine Änderungen am Dokument vorgenommen +onlyoffice.service.command.error.command=Befehl ist nicht korrekt onlyoffice.service.command.error.token=Ung\u00fcltiges Token onlyoffice.service.command.error.connection=Verbindungsfehler diff --git a/src/main/resources/lang-resource_es.properties b/src/main/resources/lang-resource_es.properties index dda10911..5a68d428 100644 --- a/src/main/resources/lang-resource_es.properties +++ b/src/main/resources/lang-resource_es.properties @@ -31,8 +31,8 @@ onlyoffice.configuration.reviewDisplay.markup=Cambios onlyoffice.configuration.reviewDisplay.final=Final onlyoffice.configuration.reviewDisplay.original=Original onlyoffice.configuration.button.save=Guardar -onlyoffice.configuration.message.settings.saved= -onlyoffice.configuration.message.settings.saving-error= +onlyoffice.configuration.message.settings.saved=Ajustes guardados +onlyoffice.configuration.message.settings.saving-error=Error al guardar los ajustes onlyoffice.configuration.banner.message=Inicie f\u00e1cilmente los editores en la nube sin tener que descargarlos ni instalarlos onlyoffice.configuration.banner.button=Obtener ahora onlyoffice.editor.editlink=Editar en ONLYOFFICE @@ -79,9 +79,9 @@ onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=Al onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc=Especificado en p\u00edxeles (por defecto o ''px'') o como un ''%'' de la altura de la p\u00e1gina. Ejemplos: 200, 200px, 10% onlyoffice.server.common.error.connection=No se puede acceder al ONLYOFFICE Document Server. -onlyoffice.server.common.error.api-js= +onlyoffice.server.common.error.api-js=No se puede acceder al archivo JavaScript de la API. onlyoffice.server.common.error.mixed-content=Contenido Mixto Activo no est\u00E1 permitido. Se requiere la direcci\u00F3n HTTPS para ONLYOFFICE Document Server. -onlyoffice.server.common.error.healthcheck= +onlyoffice.server.common.error.healthcheck=El Document Server devuelve un estado de comprobación malo. onlyoffice.service.convert.check.error-prefix=Error al intentar verificar ConvertService ($). onlyoffice.service.convert.error.unknown=Error desconocido @@ -93,14 +93,14 @@ onlyoffice.service.convert.error.database=Error al acceder la base de datos de r onlyoffice.service.convert.error.input=Error de entrada onlyoffice.service.convert.error.token=Token inv\u00e1lido onlyoffice.service.convert.error.connection=Error de conexi\u00f3n -onlyoffice.service.convert.error.download_result= +onlyoffice.service.convert.error.download_result=Error al descargar el archivo resultante onlyoffice.service.command.check.error-prefix=Error al intentar verificar CommandService ($). -onlyoffice.service.command.error.no= -onlyoffice.service.command.error.key= -onlyoffice.service.command.error.callback_url= +onlyoffice.service.command.error.no=No hay errores +onlyoffice.service.command.error.key=No hay clave de documento o no se ha encontrado ning\u00fan documento con dicha clave. +onlyoffice.service.command.error.callback_url=URL de devoluci\u00f3n de llamada incorrecta onlyoffice.service.command.error.internal_server=Error interno de servidor -onlyoffice.service.command.error.forcesave= -onlyoffice.service.command.error.command= +onlyoffice.service.command.error.forcesave=No se han aplicado cambios al documento antes de recibir el comando de forzar guardar. +onlyoffice.service.command.error.command=Comando incorrecto onlyoffice.service.command.error.token=Token inv\u00e1lido onlyoffice.service.command.error.connection=Error de conexi\u00f3n diff --git a/src/main/resources/lang-resource_fr.properties b/src/main/resources/lang-resource_fr.properties index 4bb1b1e6..00d28ad5 100644 --- a/src/main/resources/lang-resource_fr.properties +++ b/src/main/resources/lang-resource_fr.properties @@ -31,8 +31,8 @@ onlyoffice.configuration.reviewDisplay.markup=Balisage onlyoffice.configuration.reviewDisplay.final=Finale onlyoffice.configuration.reviewDisplay.original=Original onlyoffice.configuration.button.save=Enregistrer -onlyoffice.configuration.message.settings.saved=Settings saved -onlyoffice.configuration.message.settings.saving-error=Error saving settings +onlyoffice.configuration.message.settings.saved=Param\u00e8tres sauvegard\u00e9s +onlyoffice.configuration.message.settings.saving-error=Erreur de sauvegarde des param\u00e8tres onlyoffice.configuration.banner.message=Lancez facilement les \u00e9diteurs dans le cloud sans t\u00e9l\u00e9chargement ni installation onlyoffice.configuration.banner.button=Obtenir maintenant onlyoffice.editor.editlink=Modifier dans ONLYOFFICE @@ -80,8 +80,8 @@ onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc=Sp\ onlyoffice.server.common.error.connection=Document Server est indisponible. onlyoffice.server.common.error.api-js=Fichier JavaScript de l'API est indisponible. -onlyoffice.server.common.error.mixed-content=Le contenu mixte actif n'est pas autoris\u00E9. Une adresse HTTPS pour ONLYOFFICE Document Server est requise. -onlyoffice.server.common.error.healthcheck= +onlyoffice.server.common.error.mixed-content=Le contenu mixte actif n'est pas autoris\u00e9. Une adresse HTTPS pour ONLYOFFICE Document Server est requise. +onlyoffice.server.common.error.healthcheck=Document Server renvoie un mauvais \u00e9tat de contr\u00f4le de sant\u00e9. onlyoffice.service.convert.check.error-prefix=Erreur lors de la v\u00e9rification de ConvertService ($). onlyoffice.service.convert.error.unknown=Erreur inconnue @@ -93,14 +93,14 @@ onlyoffice.service.convert.error.database=Erreur lors de l'acc\u00e8s \u00e0 la onlyoffice.service.convert.error.input=Erreur de saisie onlyoffice.service.convert.error.token=Jeton invalide onlyoffice.service.convert.error.connection=Erreur de connexion -onlyoffice.service.convert.error.download_result= +onlyoffice.service.convert.error.download_result=Erreur de t\u00e9l\u00e9chargement du fichier de r\u00e9sultat onlyoffice.service.command.check.error-prefix=Erreur lors de la v\u00e9rification de CommandService ($). -onlyoffice.service.command.error.no= -onlyoffice.service.command.error.key= -onlyoffice.service.command.error.callback_url= +onlyoffice.service.command.error.no=Aucune erreur +onlyoffice.service.command.error.key=La cl\u00e9 du document est manquante ou aucun document avec cette cl\u00e9 n'a pu \u00eatre trouv\u00e9. +onlyoffice.service.command.error.callback_url=L'URL de rappel n'est pas correcte onlyoffice.service.command.error.internal_server=Erreur interne du serveur -onlyoffice.service.command.error.forcesave= -onlyoffice.service.command.error.command= +onlyoffice.service.command.error.forcesave=Aucune modification n'a \u00e9t\u00e9 apport\u00e9e au document avant la r\u00e9ception de la commande d'enregistrement forc\u00e9 +onlyoffice.service.command.error.command=Commande incorrecte onlyoffice.service.command.error.token=Jeton invalide onlyoffice.service.command.error.connection=Erreur de connexion diff --git a/src/main/resources/lang-resource_it.properties b/src/main/resources/lang-resource_it.properties index 4d4955ef..bfbad307 100644 --- a/src/main/resources/lang-resource_it.properties +++ b/src/main/resources/lang-resource_it.properties @@ -31,8 +31,8 @@ onlyoffice.configuration.reviewDisplay.markup=Markup onlyoffice.configuration.reviewDisplay.final=Finale onlyoffice.configuration.reviewDisplay.original=Originale onlyoffice.configuration.button.save=Salvare -onlyoffice.configuration.message.settings.saved=Settings saved -onlyoffice.configuration.message.settings.saving-error=Error saving settings +onlyoffice.configuration.message.settings.saved=Impostazioni salvate +onlyoffice.configuration.message.settings.saving-error=Errore di salvataggio delle impostazioni onlyoffice.configuration.banner.message=Avvia facilmente gli editor nel cloud senza scaricarli e installarli onlyoffice.configuration.banner.button=Ottieni ora onlyoffice.editor.editlink=Modifica in ONLYOFFICE @@ -78,10 +78,10 @@ onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.desc=Spec onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=Altezza onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc=Specificato in pixel (predefinito o ''px'') o come ''%'' dell'altezza della pagina. Esempi: 200, 200px, 10% -onlyoffice.server.common.error.connection=Document Server non può essere raggiunto. -onlyoffice.server.common.error.api-js= +onlyoffice.server.common.error.connection=Impossibile raggiungere il Document Server. +onlyoffice.server.common.error.api-js=Impossibile raggiungere il file JavaScript dell'API. onlyoffice.server.common.error.mixed-content=Il contenuto attivo misto non \u00E8 consentito. \u00C8 richiesto l\u2019indirizzo HTTPS per ONLYOFFICE Document Server. -onlyoffice.server.common.error.healthcheck= +onlyoffice.server.common.error.healthcheck=Document Server restituisce uno stato di controllo non valido. onlyoffice.service.convert.check.error-prefix=Errore durante il tentativo di controllare ConvertService ($). onlyoffice.service.convert.error.unknown=Errore sconosciuto @@ -93,14 +93,14 @@ onlyoffice.service.convert.error.database=Errore durante l'accesso al database d onlyoffice.service.convert.error.input=Errore di input onlyoffice.service.convert.error.token=Token non valido onlyoffice.service.convert.error.connection=Errore di connessione -onlyoffice.service.convert.error.download_result= +onlyoffice.service.convert.error.download_result=Errore di download del file dei risultati onlyoffice.service.command.check.error-prefix=Errore durante il tentativo di controllare CommandService ($). -onlyoffice.service.command.error.no= -onlyoffice.service.command.error.key= -onlyoffice.service.command.error.callback_url= +onlyoffice.service.command.error.no=Nessun errore +onlyoffice.service.command.error.key=Manca la chiave del documento oppure non \u00E8 stato trovato alcun documento con tale chiave +onlyoffice.service.command.error.callback_url=URL di callback non corretto onlyoffice.service.command.error.internal_server=Errore interno del server -onlyoffice.service.command.error.forcesave= -onlyoffice.service.command.error.command= +onlyoffice.service.command.error.forcesave=Nessuna modifica \u00E8 stata applicata al documento prima della ricezione del comando di salvataggio forzato +onlyoffice.service.command.error.command=Comando non corretto onlyoffice.service.command.error.token=Token non valido onlyoffice.service.command.error.connection=Errore di connessione From ae58e750c4f2446539186f8df1b13613a8778861 Mon Sep 17 00:00:00 2001 From: Kseniya Fedoruk Date: Fri, 8 Dec 2023 13:10:44 +0300 Subject: [PATCH 40/87] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 6bdfb565..5af5953b 100644 --- a/README.md +++ b/README.md @@ -178,12 +178,18 @@ The table below will help you make the right choice. | Font and paragraph formatting | + | + | | Object insertion | + | + | | Transitions | + | + | +| Animations | + | + | | Presenter mode | + | + | | Notes | + | + | | **Form creator features** | **Community Edition** | **Enterprise Edition** | | Adding form fields | + | + | | Form preview | + | + | | Saving as PDF | + | + | +| **Working with PDF** | **Community Edition** | **Enterprise Edition** | +| Text annotations (highlight, underline, cross out) | + | + | +| Comments | + | + | +| Freehand drawings | + | + | +| Form filling | + | + | | | [Get it now](https://www.onlyoffice.com/download-docs.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubConfluence#docs-community) | [Start Free Trial](https://www.onlyoffice.com/download-docs.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubConfluence#docs-enterprise) | \* If supported by DMS. \ No newline at end of file From 9b61af78c768afa7a250035d174c9c0b6cf9281d Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 20 Dec 2023 15:41:49 +0300 Subject: [PATCH 41/87] change: use com.onlyoffice.docs-integration-sdk from maven-central --- pom.xml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 2edd031d..556d7752 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ com.onlyoffice docs-integration-sdk - 0.0.1-SNAPSHOT + 0.0.1 org.apache.httpcomponents @@ -133,10 +133,6 @@ atlassian-public https://maven.atlassian.com/repository/public - - ossrh - http://192.168.4.26:8081/repository/maven-public - From 836a431f32807535d6caf640d9a90cce666ed592 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 20 Dec 2023 15:49:28 +0300 Subject: [PATCH 42/87] change: UrlManagerImpl servlets paths as constants --- .../sdk/manager/url/UrlManagerImpl.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java b/src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java index 0fbc7ce2..1769a41f 100644 --- a/src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java +++ b/src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java @@ -39,11 +39,11 @@ public class UrlManagerImpl extends DefaultUrlManager implements UrlManager { - private final String apiServlet = "/plugins/servlet/onlyoffice/api"; - private final String docEditorServlet = "/plugins/servlet/onlyoffice/doceditor"; - private final String fileProviderServlet = "/plugins/servlet/onlyoffice/file-provider"; - private final String callbackServlet = "/plugins/servlet/onlyoffice/save"; - private final String historyServlet = "/plugins/servlet/onlyoffice/history"; + public static final String API_SERVLET = "/plugins/servlet/onlyoffice/api"; + public static final String DOC_EDITOR_SERVLET = "/plugins/servlet/onlyoffice/doceditor"; + public static final String FILE_PROVIDER_SERVLET = "/plugins/servlet/onlyoffice/file-provider"; + public static final String CALLBACK_SERVLET = "/plugins/servlet/onlyoffice/save"; + public static final String HISTORY_SERVLET = "/plugins/servlet/onlyoffice/history"; private final WebResourceUrlProvider webResourceUrlProvider; private final SettingsManager settingsManager; @@ -77,7 +77,7 @@ public String getFileUrl(final String fileId) { params.put("action", "download"); String fileUri = - getConfluenceBaseUrl(true) + fileProviderServlet + "?token=" + jwtManager.createInternalToken(params); + getConfluenceBaseUrl(true) + FILE_PROVIDER_SERVLET + "?token=" + jwtManager.createInternalToken(params); return fileUri; } @@ -92,7 +92,7 @@ public String getCallbackUrl(final String fileId) { params.put("action", "callback"); String callbackUrl = getConfluenceBaseUrl(true) - + callbackServlet + + CALLBACK_SERVLET + "?token=" + jwtManager.createInternalToken(params); @@ -124,7 +124,7 @@ public String getCreateUrl(final String fileId) { extension = documentManager.getDefaultExtension(documentType); } - return getConfluenceBaseUrl(false) + docEditorServlet + "?pageId=" + pageId + "&fileExt=" + extension; + return getConfluenceBaseUrl(false) + DOC_EDITOR_SERVLET + "?pageId=" + pageId + "&fileExt=" + extension; } else { return null; } @@ -138,7 +138,7 @@ public String getTestConvertUrl(final String url) { public String getAttachmentDiffUri(final Long attachmentId) { String hash = jwtManager.createHash(Long.toString(attachmentId)); String diffAttachmentUrl = - getConfluenceBaseUrl(false) + historyServlet + "?type=diff&vkey=" + GeneralUtil.urlEncode(hash); + getConfluenceBaseUrl(false) + HISTORY_SERVLET + "?type=diff&vkey=" + GeneralUtil.urlEncode(hash); return diffAttachmentUrl; } @@ -146,7 +146,7 @@ public String getAttachmentDiffUri(final Long attachmentId) { public String getHistoryInfoUri(final Long attachmentId) { String hash = jwtManager.createHash(Long.toString(attachmentId)); String historyInfoUri = - getConfluenceBaseUrl(false) + historyServlet + "?type=info&vkey=" + GeneralUtil.urlEncode(hash); + getConfluenceBaseUrl(false) + HISTORY_SERVLET + "?type=info&vkey=" + GeneralUtil.urlEncode(hash); return historyInfoUri; } @@ -154,24 +154,24 @@ public String getHistoryInfoUri(final Long attachmentId) { public String getHistoryDataUri(final Long attachmentId) { String hash = jwtManager.createHash(Long.toString(attachmentId)); String historyDataUri = - getConfluenceBaseUrl(false) + historyServlet + "?type=data&vkey=" + GeneralUtil.urlEncode(hash); + getConfluenceBaseUrl(false) + HISTORY_SERVLET + "?type=data&vkey=" + GeneralUtil.urlEncode(hash); return historyDataUri; } public String getAttachmentDataUri() { - String attachmentDataUri = getConfluenceBaseUrl(false) + apiServlet + "?type=attachment-data"; + String attachmentDataUri = getConfluenceBaseUrl(false) + API_SERVLET + "?type=attachment-data"; return attachmentDataUri; } public String getSaveAsUri() { - String saveAsUri = getConfluenceBaseUrl(false) + apiServlet + "?type=save-as"; + String saveAsUri = getConfluenceBaseUrl(false) + API_SERVLET + "?type=save-as"; return saveAsUri; } public String getReferenceDataUri(final Long pageId) { - String referenceDataUri = getConfluenceBaseUrl(false) + apiServlet + "?type=reference-data&pageId=" + pageId; + String referenceDataUri = getConfluenceBaseUrl(false) + API_SERVLET + "?type=reference-data&pageId=" + pageId; return referenceDataUri; } From cdfc6751a23c07b5d366add4b56cc1f6b1bb3dd1 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 20 Dec 2023 15:56:01 +0300 Subject: [PATCH 43/87] fix: issue #116 --- src/main/java/onlyoffice/OnlyOfficeEditorServlet.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java index ad7e7599..645146ea 100644 --- a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java @@ -51,6 +51,8 @@ import java.net.URLEncoder; import java.util.Map; +import static onlyoffice.sdk.manager.url.UrlManagerImpl.DOC_EDITOR_SERVLET; + public class OnlyOfficeEditorServlet extends HttpServlet { private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeEditorServlet"); private final long serialVersionUID = 1L; @@ -123,7 +125,7 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re user ); - response.sendRedirect(request.getContextPath() + "?attachmentId=" + response.sendRedirect(request.getContextPath() + DOC_EDITOR_SERVLET + "?attachmentId=" + URLEncoder.encode(String.valueOf(attachment.getId()), "UTF-8")); return; } From e1019e0dc75d762222a85eb976dd8cb36b17eb9f Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 21 Dec 2023 10:33:17 +0300 Subject: [PATCH 44/87] fix: api reference data (5cbd2162e69f355137640a38b3145db8cde1a3b5) --- src/main/java/onlyoffice/OnlyOfficeAPIServlet.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java index 87ac176b..02521c43 100644 --- a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java @@ -28,6 +28,7 @@ import com.onlyoffice.manager.settings.SettingsManager; import com.onlyoffice.manager.security.JwtManager; import com.onlyoffice.manager.url.UrlManager; +import com.onlyoffice.model.documenteditor.config.document.ReferenceData; import onlyoffice.sdk.manager.document.DocumentManager; import onlyoffice.utils.attachment.AttachmentUtil; import onlyoffice.utils.parsing.ParsingUtil; @@ -220,13 +221,14 @@ private void referenceData(final HttpServletRequest request, final HttpServletRe try { JSONObject bodyJson = new JSONObject(body); - JSONObject referenceData = new JSONObject(); + ReferenceData referenceData = new ReferenceData(); Long attachmentId = null; if (bodyJson.has("referenceData")) { - referenceData = bodyJson.getJSONObject("referenceData"); - if (referenceData.getString("instanceId").equals(sysInfoService.getConfluenceInfo().getBaseUrl())) { - attachmentId = referenceData.getLong("fileKey"); + String referenceDataString = bodyJson.getJSONObject("referenceData").toString(); + referenceData = objectMapper.readValue(referenceDataString, ReferenceData.class); + if (referenceData.getInstanceId().equals(sysInfoService.getConfluenceInfo().getBaseUrl())) { + attachmentId = Long.valueOf(referenceData.getFileKey()); } } @@ -240,8 +242,8 @@ private void referenceData(final HttpServletRequest request, final HttpServletRe attachment = attachmentUtil.getAttachmentByName(bodyJson.getString("path"), pageId); if (attachment != null) { attachmentId = attachment.getId(); - referenceData.put("fileKey", attachment.getId()); - referenceData.put("instanceId", sysInfoService.getConfluenceInfo().getBaseUrl()); + referenceData.setFileKey(String.valueOf(attachment.getId())); + referenceData.setInstanceId(sysInfoService.getConfluenceInfo().getBaseUrl()); } } } From 2d2674ee0882eeaf0cd055870c6190310896ce6e Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 21 Dec 2023 10:35:31 +0300 Subject: [PATCH 45/87] fix: context path --- .../js/confluence-previews-plugin/onlyoffice-button.js | 1 + src/main/resources/js/dialog-filecreate.js | 2 +- src/main/resources/js/onlyoffice-preview-macro-fields.js | 2 +- .../confluence-previews-plugin/onlyoffice-button.soy | 2 +- src/main/resources/templates/preview.vm | 4 ++-- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/resources/js/confluence-previews-plugin/onlyoffice-button.js b/src/main/resources/js/confluence-previews-plugin/onlyoffice-button.js index e772d618..36ef5287 100644 --- a/src/main/resources/js/confluence-previews-plugin/onlyoffice-button.js +++ b/src/main/resources/js/confluence-previews-plugin/onlyoffice-button.js @@ -60,6 +60,7 @@ define('cp/component/onlyoffice-button', [ if (title) { this.$el.html(templateStore.get('controlOnlyofficeButton')({ + contextPath: AJS.contextPath(), attachmentId: attachmentId, title: title })); diff --git a/src/main/resources/js/dialog-filecreate.js b/src/main/resources/js/dialog-filecreate.js index 1ff654db..e1b25739 100644 --- a/src/main/resources/js/dialog-filecreate.js +++ b/src/main/resources/js/dialog-filecreate.js @@ -85,7 +85,7 @@ AJS.toInit(function ($) { var insertImageDialog = AJS.Editor.ImageDialog.insertImageDialog(function(a) { var fileExt = a.selectItems[0].attributes.fileName.split(".").pop(); if (fileExt == "docx") { - window.open("/plugins/servlet/onlyoffice/convert?attachmentId=" + a.selectItems[0].attributes.id + + window.open(AJS.contextPath() + "/plugins/servlet/onlyoffice/convert?attachmentId=" + a.selectItems[0].attributes.id + "&pageId=" + AJS.params.pageId + "&newTitle=" + $("#view-input-docxf").attr("value") ) setTimeout(function () { document.location.reload(); }, 1000); diff --git a/src/main/resources/js/onlyoffice-preview-macro-fields.js b/src/main/resources/js/onlyoffice-preview-macro-fields.js index afb59a45..a15962aa 100644 --- a/src/main/resources/js/onlyoffice-preview-macro-fields.js +++ b/src/main/resources/js/onlyoffice-preview-macro-fields.js @@ -17,7 +17,7 @@ */ (function($) { - $.getJSON("/plugins/servlet/onlyoffice/formats", function(data) { + $.getJSON(AJS.contextPath() + "/plugins/servlet/onlyoffice/formats", function(data) { AJS.MacroBrowser.activateSmartFieldsAttachmentsOnPage("onlyoffice-preview", data); }); })(AJS.$); diff --git a/src/main/resources/templates/confluence-previews-plugin/onlyoffice-button.soy b/src/main/resources/templates/confluence-previews-plugin/onlyoffice-button.soy index 90e01700..c63a43c8 100644 --- a/src/main/resources/templates/confluence-previews-plugin/onlyoffice-button.soy +++ b/src/main/resources/templates/confluence-previews-plugin/onlyoffice-button.soy @@ -6,5 +6,5 @@ * @param title The title ONLYOFFICE button. */ {template .controlOnlyofficeButton} - + {/template} diff --git a/src/main/resources/templates/preview.vm b/src/main/resources/templates/preview.vm index cdc90fa7..72c2f03e 100644 --- a/src/main/resources/templates/preview.vm +++ b/src/main/resources/templates/preview.vm @@ -2,9 +2,9 @@ #if($action == "edit") - $i18n.getText('onlyoffice.editor.editlink') + $i18n.getText('onlyoffice.editor.editlink') #elseif($action == "fill") - $i18n.getText('onlyoffice.editor.fillFormlink') + $i18n.getText('onlyoffice.editor.fillFormlink') #end
From 29b0939f0b00fa431c9da46c161ce1cdd179d628 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 21 Dec 2023 10:40:21 +0300 Subject: [PATCH 46/87] fix: de translations --- src/main/resources/lang-resource_de.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/lang-resource_de.properties b/src/main/resources/lang-resource_de.properties index d6abbd0b..8def0b96 100644 --- a/src/main/resources/lang-resource_de.properties +++ b/src/main/resources/lang-resource_de.properties @@ -100,7 +100,7 @@ onlyoffice.service.command.error.no=Keine Fehler onlyoffice.service.command.error.key=Dokument-Key fehlt oder es konnte kein Dokument mit einem solchen Key gefunden werden onlyoffice.service.command.error.callback_url=Callback-URL ist nicht korrekt onlyoffice.service.command.error.internal_server=Interner Server-Fehler -onlyoffice.service.command.error.forcesave=Vor dem Empfang des Forcesave-Befehls wurden keine Änderungen am Dokument vorgenommen +onlyoffice.service.command.error.forcesave=Vor dem Empfang des Forcesave-Befehls wurden keine \u00c4nderungen am Dokument vorgenommen onlyoffice.service.command.error.command=Befehl ist nicht korrekt onlyoffice.service.command.error.token=Ung\u00fcltiges Token onlyoffice.service.command.error.connection=Verbindungsfehler From 600f2a54523e409a488cc83c97a330e95bad86cf Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 21 Dec 2023 12:25:53 +0300 Subject: [PATCH 47/87] fix: bug with download as if set inner url setting --- .../onlyoffice/action/DownloadAsAction.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/onlyoffice/action/DownloadAsAction.java b/src/main/java/onlyoffice/action/DownloadAsAction.java index af4e436e..a823813d 100644 --- a/src/main/java/onlyoffice/action/DownloadAsAction.java +++ b/src/main/java/onlyoffice/action/DownloadAsAction.java @@ -30,6 +30,7 @@ import com.onlyoffice.model.convertservice.ConvertResponse; import com.onlyoffice.service.convert.ConvertService; import onlyoffice.sdk.manager.document.DocumentManager; +import onlyoffice.sdk.manager.url.UrlManager; import onlyoffice.utils.attachment.AttachmentUtil; import com.atlassian.confluence.user.ConfluenceUser; import org.apache.commons.lang3.StringUtils; @@ -49,6 +50,7 @@ public class DownloadAsAction extends ConfluenceActionSupport { private ConvertService convertService; private DocumentManager documentManager; private final LocaleManager localeManager; + private final UrlManager urlManager; private String attachmentId; private String fileName; @@ -56,11 +58,13 @@ public class DownloadAsAction extends ConfluenceActionSupport { private static final char[] INVALID_CHARS; public DownloadAsAction(final AttachmentUtil attachmentUtil, final ConvertService convertService, - final LocaleManager localeManager, final DocumentManager documentManager) { + final LocaleManager localeManager, final DocumentManager documentManager, + final UrlManager urlManager) { this.attachmentUtil = attachmentUtil; this.convertService = convertService; this.documentManager = documentManager; this.localeManager = localeManager; + this.urlManager = urlManager; } @PermittedMethods({ HttpMethod.GET }) @@ -133,6 +137,20 @@ public String execute() throws Exception { try { ConvertResponse convertResponse = convertService.processConvert(convertRequest, this.attachmentId); + + if (convertResponse.getEndConvert() != null && convertResponse.getEndConvert()) { + String fileUrl = convertResponse.getFileUrl(); + + String documentServerUrl = urlManager.getDocumentServerUrl(); + String innerDocumentServerUrl = urlManager.getInnerDocumentServerUrl(); + + if (!documentServerUrl.equals(innerDocumentServerUrl)) { + return fileUrl.replace(innerDocumentServerUrl, documentServerUrl); + } + + convertResponse.setFileUrl(fileUrl); + } + writer.write(mapper.writeValueAsString(convertResponse)); } catch (IOException e) { log.error(e.getMessage(), e); From 309a850808126aca9859a449ff0692d10d7ac8a9 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 29 Dec 2023 09:08:31 +0300 Subject: [PATCH 48/87] fix: (600f2a54523e409a488cc83c97a330e95bad86cf) --- src/main/java/onlyoffice/action/DownloadAsAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/onlyoffice/action/DownloadAsAction.java b/src/main/java/onlyoffice/action/DownloadAsAction.java index a823813d..c5146a41 100644 --- a/src/main/java/onlyoffice/action/DownloadAsAction.java +++ b/src/main/java/onlyoffice/action/DownloadAsAction.java @@ -145,7 +145,7 @@ public String execute() throws Exception { String innerDocumentServerUrl = urlManager.getInnerDocumentServerUrl(); if (!documentServerUrl.equals(innerDocumentServerUrl)) { - return fileUrl.replace(innerDocumentServerUrl, documentServerUrl); + fileUrl = fileUrl.replace(innerDocumentServerUrl, documentServerUrl); } convertResponse.setFileUrl(fileUrl); From 02066cd25bc41ebb90f73ca3a384774445aa4edc Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 9 Jan 2024 14:19:39 +0300 Subject: [PATCH 49/87] change: url to diff zip using setting productInnerUrl --- src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java b/src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java index 1769a41f..c910947d 100644 --- a/src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java +++ b/src/main/java/onlyoffice/sdk/manager/url/UrlManagerImpl.java @@ -138,7 +138,7 @@ public String getTestConvertUrl(final String url) { public String getAttachmentDiffUri(final Long attachmentId) { String hash = jwtManager.createHash(Long.toString(attachmentId)); String diffAttachmentUrl = - getConfluenceBaseUrl(false) + HISTORY_SERVLET + "?type=diff&vkey=" + GeneralUtil.urlEncode(hash); + getConfluenceBaseUrl(true) + HISTORY_SERVLET + "?type=diff&vkey=" + GeneralUtil.urlEncode(hash); return diffAttachmentUrl; } From ea8909a5a96405f6c4e992a97740b1a4e00ce7ec Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 9 Jan 2024 14:22:26 +0300 Subject: [PATCH 50/87] add: check jwt on history diff zip servlet point --- CHANGELOG.md | 1 + .../onlyoffice/OnlyOfficeHistoryServlet.java | 24 ++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30864f50..1ab92cb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ## Added - core of the plugin has been moved to com.onlyoffice.docs-integration-sdk (https://github.com/ONLYOFFICE/docs-integration-sdk-java) - improved connection settings validation +- improved history servlet security ## 4.4.0 ## Added diff --git a/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java b/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java index 7956b833..0043d027 100644 --- a/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java @@ -118,6 +118,24 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re private void getAttachmentDiff(final HttpServletRequest request, final HttpServletResponse response) throws IOException { + if (settingsManager.isSecurityEnabled()) { + String securityHeader = settingsManager.getSecurityHeader(); + String bodySecurityHeader = request.getHeader(securityHeader); + String authorizationPrefix = settingsManager.getSecurityPrefix(); + String token = (bodySecurityHeader != null && bodySecurityHeader.startsWith(authorizationPrefix)) + ? bodySecurityHeader.substring(authorizationPrefix.length()) : bodySecurityHeader; + + if (token == null || token == "") { + throw new SecurityException("Expected JWT"); + } + + try { + String payload = jwtManager.verify(token); + } catch (Exception e) { + throw new SecurityException("JWT verification failed!"); + } + } + String vkey = request.getParameter("vkey"); String attachmentIdString = jwtManager.readHash(vkey); @@ -131,15 +149,9 @@ private void getAttachmentDiff(final HttpServletRequest request, final HttpServl if (diff != null) { InputStream inputStream = attachmentUtil.getAttachmentData(diff.getId()); - String publicDocEditorUrl = urlManager.getDocumentServerUrl(); - - if (publicDocEditorUrl.endsWith("/")) { - publicDocEditorUrl = publicDocEditorUrl.substring(0, publicDocEditorUrl.length() - 1); - } response.setContentType(diff.getMediaType()); response.setContentLength(inputStream.available()); - response.addHeader("Access-Control-Allow-Origin", publicDocEditorUrl); byte[] buffer = new byte[BUFFER_SIZE]; From 745d857872773705434c7f6a0fbd97b1103a0330 Mon Sep 17 00:00:00 2001 From: myname <30490759+lumos0@users.noreply.github.com> Date: Wed, 10 Jan 2024 17:03:29 +0800 Subject: [PATCH 51/87] add zh-CN lang-resource file (#120) * i18n-zh_cn * Update lang-resource_zh_CN.properties --- README.md | 2 +- .../resources/lang-resource_zh_CN.properties | 91 +++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/lang-resource_zh_CN.properties diff --git a/README.md b/README.md index 5af5953b..faa3138b 100644 --- a/README.md +++ b/README.md @@ -192,4 +192,4 @@ The table below will help you make the right choice. | Form filling | + | + | | | [Get it now](https://www.onlyoffice.com/download-docs.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubConfluence#docs-community) | [Start Free Trial](https://www.onlyoffice.com/download-docs.aspx?utm_source=github&utm_medium=cpc&utm_campaign=GitHubConfluence#docs-enterprise) | -\* If supported by DMS. \ No newline at end of file +\* If supported by DMS. diff --git a/src/main/resources/lang-resource_zh_CN.properties b/src/main/resources/lang-resource_zh_CN.properties new file mode 100644 index 00000000..91b4a6b0 --- /dev/null +++ b/src/main/resources/lang-resource_zh_CN.properties @@ -0,0 +1,91 @@ +onlyoffice.configuration.section.server=Server settings +onlyoffice.configuration.doc-url=Document Editing Service address +onlyoffice.configuration.doc-url.tooltip=Document Editing Service address e.g. http\://localhost/ +onlyoffice.configuration.jwt-secret=Secret key (leave blank to disable) +onlyoffice.configuration.jwt-secret.tooltip=Secret key to generate the token +onlyoffice.configuration.verify-certificate=Disable certificate verification (insecure) +onlyoffice.configuration.demo.connect=Connect to demo ONLYOFFICE Document Server +onlyoffice.configuration.demo.trial=This is a public test server, please do not use it for private sensitive data. The server will be available during a 30-day period. +onlyoffice.configuration.demo.trial-is-over=The 30-day test period is over, you can no longer connect to demo ONLYOFFICE Document Server. +onlyoffice.configuration.advanced-section=Advanced server settings +onlyoffice.configuration.conf-url=Confluence Server internal address +onlyoffice.configuration.conf-url.tooltip=Confluence Server address for internal requests from the Document Editing Service +onlyoffice.configuration.doc-url-inner=Document Editing Service internal address +onlyoffice.configuration.doc-url-inner.tooltip=Document Editing Service address for internal requests from the Confluence Server +onlyoffice.configuration.section.common=Common settings +onlyoffice.configuration.editing-types.label=Editable formats +onlyoffice.configuration.editing-types.description=Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below) +onlyoffice.configuration.force-save.label=Force Save +onlyoffice.configuration.force-save.enable=Enable +onlyoffice.configuration.force-save.description=Keep intermediate versions when editing +onlyoffice.configuration.interface.label=Editor interface +onlyoffice.configuration.interface.description=Customizing the editor's appearance +onlyoffice.configuration.interface.chat=Display Chat menu button +onlyoffice.configuration.interface.compactHeader=Display the header more compact +onlyoffice.configuration.interface.feedback=Display Feedback & Support menu button +onlyoffice.configuration.interface.helpMenu=Display Help menu button +onlyoffice.configuration.interface.toolbarNoTabs=Display monochrome toolbar header +onlyoffice.configuration.reviewDisplay.label=Review mode for viewing +onlyoffice.configuration.reviewDisplay.description=Defines the review editing mode in the document editor +onlyoffice.configuration.reviewDisplay.markup=Markup +onlyoffice.configuration.reviewDisplay.final=Final +onlyoffice.configuration.reviewDisplay.original=Original +onlyoffice.configuration.button.save=Save +onlyoffice.configuration.message.success=Success +onlyoffice.configuration.message.error.docservcommand=Error when trying to check CommandService +onlyoffice.configuration.message.error.docservunreachable=ONLYOFFICE cannot be reached +onlyoffice.configuration.message.error.jsonparse=Server can't read JSON +onlyoffice.configuration.message.error.jwterror=Authorization error +onlyoffice.configuration.message.error.mixedcontent=Mixed Active Content is not allowed. HTTPS address for Document Server is required. +onlyoffice.configuration.banner.message=Easily launch the editors in the cloud without downloading and installation +onlyoffice.configuration.banner.button=Get Now +onlyoffice.editor.editlink=\u5728\u7ebf\u7f16\u8f91(ONLYOFFICE) +onlyoffice.editor.viewlink=\u5728\u7ebf\u9884\u89c8(ONLYOFFICE) +onlyoffice.editor.fillFormlink=\u5728ONLYOFFICE\u4e2d\u586b\u5199\u8868\u5355 +onlyoffice.editor.createlink=\u521b\u5efa\u65b0\u7684OFFICE\u6587\u6863\u9644\u4ef6 +onlyoffice.editor.createlink.tooltip=Create new file +onlyoffice.editor.dialog.filecreate.docx=Word\u6587\u6863 +onlyoffice.editor.dialog.filecreate.xlsx=Excel\u8868\u683c +onlyoffice.editor.dialog.filecreate.pptx=PPT\u5e7b\u706f\u7247 +onlyoffice.editor.dialog.filecreate.docxf=oForm(\u4e00\u79cdPDF\u5f0f\u8868\u5355) +onlyoffice.editor.dialog.save-as.title=\u5c06\u6587\u6863\u53e6\u5b58\u4e3a +onlyoffice.editor.dialog.save-as.message.success=Attachment $ was successfully saved. +onlyoffice.editor.dialog.create.form.title=Select the DOCX file +onlyoffice.editor.dialog.create.form.button.create=Create +onlyoffice.editor.dialog.create.form.button.create-blank=Create from blank +onlyoffice.editor.dialog.create.form.message.error=The selected file is not in DOCX format +onlyoffice.editor.message.demo=You are using public demo ONLYOFFICE Document Server. Please do not store private sensitive data. +onlyoffice.editor.message.docs-api-undefined=ONLYOFFICE cannot be reached. Please contact admin +onlyoffice.editor.message.docs-api-unsupported=Not supported version DocumentServer. +onlyoffice.editor.message.forms.error.version=Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online. +onlyoffice.editor.message.error.unsupported=Sorry, this file format isn't supported +onlyoffice.convert.link=\u4f7f\u7528ONLYOFFICE\u8f6c\u6362\u683c\u5f0f +onlyoffice.convert.label=\u4ece {0} \u683c\u5f0f\u8f6c\u6362\u4e3a {1}... +onlyoffice.convert.message.error=Error\: +onlyoffice.form.create.link=\u4f7f\u7528ONLYOFFICE\u521b\u5efaform(\u7c7b\u4f3cpdf\u8868\u5355). +onlyoffice.connector.download-as.link=\u8f6c\u6362\u5e76\u4e0b\u8f7d +onlyoffice.connector.dialog.conversion.header.title=\u4f7f\u7528ONLYOFFICE\u8f6c\u6362\u683c\u5f0f\u5e76\u4e0b\u8f7d\u4e3a +onlyoffice.connector.dialog.conversion.field.current-type=\u5f53\u524d\u683c\u5f0f +onlyoffice.connector.dialog.conversion.field.target-type=\u76ee\u6807\u8f6c\u6362\u683c\u5f0f +onlyoffice.connector.dialog.conversion.message.error.service-prefix=ONLYOFFICE conversion service returned error ($). +onlyoffice.connector.dialog.conversion.message.error.unknown=Unknown error +onlyoffice.connector.dialog.conversion.message.error.timeout=Conversion timeout error +onlyoffice.connector.dialog.conversion.message.error.conversion=Conversion error +onlyoffice.connector.dialog.conversion.message.error.download=Error while downloading the document file to be converted +onlyoffice.connector.dialog.conversion.message.error.password=Incorrect password +onlyoffice.connector.dialog.conversion.message.error.database=Error while accessing the conversion result database +onlyoffice.connector.dialog.conversion.message.error.input=Input error +onlyoffice.connector.dialog.conversion.message.error.token=Invalid token +onlyoffice.connector.dialog.conversion.message.error.not-reached=ONLYOFFICE\u670d\u52a1\u65e0\u6cd5\u8fde\u63a5\uff0c\u8bf7\u8054\u7cfb\u7ba1\u7406\u5458\u3002 +onlyoffice.connector.dialog.conversion.message.error.permission=\u7528\u6237\u65e0\u6267\u884c\u6b64\u64cd\u4f5c\u7684\u6743\u9650\u3002 +onlyoffice.connector.error.Unknown=An unknown error occurred during the operation. +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.label=ONLYOFFICE preview\u9884\u89c8 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.desc=\u5728\u9875\u9762\u4e2d\u63d2\u5165ONLYOFFICE preview\uff08OFFICE\u6587\u6863\u9884\u89c8\u5c55\u793a\u63a7\u4ef6\uff09\u3002 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.page.label=\u9875\u9762\u540d\u79f0 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.page.desc=\u9644\u4ef6\u6240\u9644\u5c5e\u7684\u9875\u9762\u540d\u79f0\uff08\u7559\u7a7a\u5219\u4e3a\u5f53\u524d\u9875\u9762\uff09 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.name.label=\u9644\u4ef6\u540d\u79f0 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.name.desc=Name of the attached file to view in this page. +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.label=\u9884\u89c8\u63a7\u4ef6\u5bbd\u5ea6 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.desc=\u7528\u50cf\u7d20(px,\u4e0d\u8f93\u5165\u5355\u4f4d\u9ed8\u8ba4\u4e3a\u50cf\u7d20)\u6216\u767e\u5206\u6bd4(%)\u6765\u63cf\u8ff0,\u4e3e\u4f8b: 200, 200px, 10%\u3002\u53ef\u7559\u7a7a\u3002 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=\u9884\u89c8\u63a7\u4ef6\u9ad8\u5ea6 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc==\u7528\u50cf\u7d20(px,\u4e0d\u8f93\u5165\u5355\u4f4d\u9ed8\u8ba4\u4e3a\u50cf\u7d20)\u6216\u767e\u5206\u6bd4(%)\u6765\u63cf\u8ff0,\u4e3e\u4f8b: 200, 200px, 10%\u3002\u53ef\u7559\u7a7a\u3002 From 34cbcb586d9f7c2770dccad4a225b282668d94da Mon Sep 17 00:00:00 2001 From: Maria-Sukhova Date: Wed, 10 Jan 2024 16:32:09 +0300 Subject: [PATCH 52/87] edited en --- src/main/resources/lang-resource.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/lang-resource.properties b/src/main/resources/lang-resource.properties index 9fa4660b..35c05a89 100644 --- a/src/main/resources/lang-resource.properties +++ b/src/main/resources/lang-resource.properties @@ -87,7 +87,7 @@ onlyoffice.service.convert.check.error-prefix=Error when trying to check Convert onlyoffice.service.convert.error.unknown=Unknown error onlyoffice.service.convert.error.timeout=Conversion timeout error onlyoffice.service.convert.error.conversion=Conversion error -onlyoffice.service.convert.error.downloading=Error while downloading the document file to be converted +onlyoffice.service.convert.error.downloading=Error while downloading the file to be converted onlyoffice.service.convert.error.password=Incorrect password onlyoffice.service.convert.error.database=Error while accessing the conversion result database onlyoffice.service.convert.error.input=Input error From 1433b064c7b94ca40d963fec42bbf409157be322 Mon Sep 17 00:00:00 2001 From: Maria-Sukhova Date: Thu, 18 Jan 2024 18:29:16 +0300 Subject: [PATCH 53/87] added translations zh --- .../resources/lang-resource_zh_CN.properties | 197 ++++++++++-------- 1 file changed, 106 insertions(+), 91 deletions(-) diff --git a/src/main/resources/lang-resource_zh_CN.properties b/src/main/resources/lang-resource_zh_CN.properties index 91b4a6b0..dc7cae68 100644 --- a/src/main/resources/lang-resource_zh_CN.properties +++ b/src/main/resources/lang-resource_zh_CN.properties @@ -1,91 +1,106 @@ -onlyoffice.configuration.section.server=Server settings -onlyoffice.configuration.doc-url=Document Editing Service address -onlyoffice.configuration.doc-url.tooltip=Document Editing Service address e.g. http\://localhost/ -onlyoffice.configuration.jwt-secret=Secret key (leave blank to disable) -onlyoffice.configuration.jwt-secret.tooltip=Secret key to generate the token -onlyoffice.configuration.verify-certificate=Disable certificate verification (insecure) -onlyoffice.configuration.demo.connect=Connect to demo ONLYOFFICE Document Server -onlyoffice.configuration.demo.trial=This is a public test server, please do not use it for private sensitive data. The server will be available during a 30-day period. -onlyoffice.configuration.demo.trial-is-over=The 30-day test period is over, you can no longer connect to demo ONLYOFFICE Document Server. -onlyoffice.configuration.advanced-section=Advanced server settings -onlyoffice.configuration.conf-url=Confluence Server internal address -onlyoffice.configuration.conf-url.tooltip=Confluence Server address for internal requests from the Document Editing Service -onlyoffice.configuration.doc-url-inner=Document Editing Service internal address -onlyoffice.configuration.doc-url-inner.tooltip=Document Editing Service address for internal requests from the Confluence Server -onlyoffice.configuration.section.common=Common settings -onlyoffice.configuration.editing-types.label=Editable formats -onlyoffice.configuration.editing-types.description=Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below) -onlyoffice.configuration.force-save.label=Force Save -onlyoffice.configuration.force-save.enable=Enable -onlyoffice.configuration.force-save.description=Keep intermediate versions when editing -onlyoffice.configuration.interface.label=Editor interface -onlyoffice.configuration.interface.description=Customizing the editor's appearance -onlyoffice.configuration.interface.chat=Display Chat menu button -onlyoffice.configuration.interface.compactHeader=Display the header more compact -onlyoffice.configuration.interface.feedback=Display Feedback & Support menu button -onlyoffice.configuration.interface.helpMenu=Display Help menu button -onlyoffice.configuration.interface.toolbarNoTabs=Display monochrome toolbar header -onlyoffice.configuration.reviewDisplay.label=Review mode for viewing -onlyoffice.configuration.reviewDisplay.description=Defines the review editing mode in the document editor -onlyoffice.configuration.reviewDisplay.markup=Markup -onlyoffice.configuration.reviewDisplay.final=Final -onlyoffice.configuration.reviewDisplay.original=Original -onlyoffice.configuration.button.save=Save -onlyoffice.configuration.message.success=Success -onlyoffice.configuration.message.error.docservcommand=Error when trying to check CommandService -onlyoffice.configuration.message.error.docservunreachable=ONLYOFFICE cannot be reached -onlyoffice.configuration.message.error.jsonparse=Server can't read JSON -onlyoffice.configuration.message.error.jwterror=Authorization error -onlyoffice.configuration.message.error.mixedcontent=Mixed Active Content is not allowed. HTTPS address for Document Server is required. -onlyoffice.configuration.banner.message=Easily launch the editors in the cloud without downloading and installation -onlyoffice.configuration.banner.button=Get Now -onlyoffice.editor.editlink=\u5728\u7ebf\u7f16\u8f91(ONLYOFFICE) -onlyoffice.editor.viewlink=\u5728\u7ebf\u9884\u89c8(ONLYOFFICE) -onlyoffice.editor.fillFormlink=\u5728ONLYOFFICE\u4e2d\u586b\u5199\u8868\u5355 -onlyoffice.editor.createlink=\u521b\u5efa\u65b0\u7684OFFICE\u6587\u6863\u9644\u4ef6 -onlyoffice.editor.createlink.tooltip=Create new file -onlyoffice.editor.dialog.filecreate.docx=Word\u6587\u6863 -onlyoffice.editor.dialog.filecreate.xlsx=Excel\u8868\u683c -onlyoffice.editor.dialog.filecreate.pptx=PPT\u5e7b\u706f\u7247 -onlyoffice.editor.dialog.filecreate.docxf=oForm(\u4e00\u79cdPDF\u5f0f\u8868\u5355) -onlyoffice.editor.dialog.save-as.title=\u5c06\u6587\u6863\u53e6\u5b58\u4e3a -onlyoffice.editor.dialog.save-as.message.success=Attachment $ was successfully saved. -onlyoffice.editor.dialog.create.form.title=Select the DOCX file -onlyoffice.editor.dialog.create.form.button.create=Create -onlyoffice.editor.dialog.create.form.button.create-blank=Create from blank -onlyoffice.editor.dialog.create.form.message.error=The selected file is not in DOCX format -onlyoffice.editor.message.demo=You are using public demo ONLYOFFICE Document Server. Please do not store private sensitive data. -onlyoffice.editor.message.docs-api-undefined=ONLYOFFICE cannot be reached. Please contact admin -onlyoffice.editor.message.docs-api-unsupported=Not supported version DocumentServer. -onlyoffice.editor.message.forms.error.version=Please update ONLYOFFICE Docs to version 7.0 to work on fillable forms online. -onlyoffice.editor.message.error.unsupported=Sorry, this file format isn't supported -onlyoffice.convert.link=\u4f7f\u7528ONLYOFFICE\u8f6c\u6362\u683c\u5f0f -onlyoffice.convert.label=\u4ece {0} \u683c\u5f0f\u8f6c\u6362\u4e3a {1}... -onlyoffice.convert.message.error=Error\: -onlyoffice.form.create.link=\u4f7f\u7528ONLYOFFICE\u521b\u5efaform(\u7c7b\u4f3cpdf\u8868\u5355). -onlyoffice.connector.download-as.link=\u8f6c\u6362\u5e76\u4e0b\u8f7d -onlyoffice.connector.dialog.conversion.header.title=\u4f7f\u7528ONLYOFFICE\u8f6c\u6362\u683c\u5f0f\u5e76\u4e0b\u8f7d\u4e3a -onlyoffice.connector.dialog.conversion.field.current-type=\u5f53\u524d\u683c\u5f0f -onlyoffice.connector.dialog.conversion.field.target-type=\u76ee\u6807\u8f6c\u6362\u683c\u5f0f -onlyoffice.connector.dialog.conversion.message.error.service-prefix=ONLYOFFICE conversion service returned error ($). -onlyoffice.connector.dialog.conversion.message.error.unknown=Unknown error -onlyoffice.connector.dialog.conversion.message.error.timeout=Conversion timeout error -onlyoffice.connector.dialog.conversion.message.error.conversion=Conversion error -onlyoffice.connector.dialog.conversion.message.error.download=Error while downloading the document file to be converted -onlyoffice.connector.dialog.conversion.message.error.password=Incorrect password -onlyoffice.connector.dialog.conversion.message.error.database=Error while accessing the conversion result database -onlyoffice.connector.dialog.conversion.message.error.input=Input error -onlyoffice.connector.dialog.conversion.message.error.token=Invalid token -onlyoffice.connector.dialog.conversion.message.error.not-reached=ONLYOFFICE\u670d\u52a1\u65e0\u6cd5\u8fde\u63a5\uff0c\u8bf7\u8054\u7cfb\u7ba1\u7406\u5458\u3002 -onlyoffice.connector.dialog.conversion.message.error.permission=\u7528\u6237\u65e0\u6267\u884c\u6b64\u64cd\u4f5c\u7684\u6743\u9650\u3002 -onlyoffice.connector.error.Unknown=An unknown error occurred during the operation. -onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.label=ONLYOFFICE preview\u9884\u89c8 -onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.desc=\u5728\u9875\u9762\u4e2d\u63d2\u5165ONLYOFFICE preview\uff08OFFICE\u6587\u6863\u9884\u89c8\u5c55\u793a\u63a7\u4ef6\uff09\u3002 -onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.page.label=\u9875\u9762\u540d\u79f0 -onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.page.desc=\u9644\u4ef6\u6240\u9644\u5c5e\u7684\u9875\u9762\u540d\u79f0\uff08\u7559\u7a7a\u5219\u4e3a\u5f53\u524d\u9875\u9762\uff09 -onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.name.label=\u9644\u4ef6\u540d\u79f0 -onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.name.desc=Name of the attached file to view in this page. -onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.label=\u9884\u89c8\u63a7\u4ef6\u5bbd\u5ea6 -onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.desc=\u7528\u50cf\u7d20(px,\u4e0d\u8f93\u5165\u5355\u4f4d\u9ed8\u8ba4\u4e3a\u50cf\u7d20)\u6216\u767e\u5206\u6bd4(%)\u6765\u63cf\u8ff0,\u4e3e\u4f8b: 200, 200px, 10%\u3002\u53ef\u7559\u7a7a\u3002 -onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=\u9884\u89c8\u63a7\u4ef6\u9ad8\u5ea6 -onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc==\u7528\u50cf\u7d20(px,\u4e0d\u8f93\u5165\u5355\u4f4d\u9ed8\u8ba4\u4e3a\u50cf\u7d20)\u6216\u767e\u5206\u6bd4(%)\u6765\u63cf\u8ff0,\u4e3e\u4f8b: 200, 200px, 10%\u3002\u53ef\u7559\u7a7a\u3002 +onlyoffice.configuration.section.server=\u670D\u52A1\u5668\u8BBE\u7F6E +onlyoffice.configuration.doc-url=\u6587\u6863\u7F16\u8F91\u670D\u52A1\u5730\u5740 +onlyoffice.configuration.doc-url.tooltip=\u6587\u6863\u7F16\u8F91\u670D\u52A1\u5730\u5740\uFF0C\u4F8B\u5982 http\://localhost/ +onlyoffice.configuration.jwt-secret=\u79D8\u94A5 (\u7559\u7A7A\u4E3A\u5173\u95ED) +onlyoffice.configuration.jwt-secret.tooltip=\u7528\u4E8E\u751F\u6210\u4EE4\u724C\u7684\u5BC6\u94A5 +onlyoffice.configuration.verify-certificate=\u5173\u95ED\u8BC1\u4E66\u6821\u9A8C(\u4E0D\u5B89\u5168) +onlyoffice.configuration.demo.connect=\u8FDE\u63A5\u5230 ONLYOFFICE \u6587\u6863\u670D\u52A1\u5668\u6F14\u793A\u7248 +onlyoffice.configuration.demo.trial=\u8FD9\u662F\u4E00\u4E2A\u516C\u5171\u6D4B\u8BD5\u670D\u52A1\u5668\uFF0C\u8BF7\u52FF\u5B58\u50A8\u79C1\u4EBA\u654F\u611F\u6570\u636E\u3002 \u670D\u52A1\u5668\u5C06\u5728 30 \u5929\u5185\u53EF\u7528\u3002 +onlyoffice.configuration.demo.trial-is-over=30 \u5929\u6D4B\u8BD5\u671F\u7ED3\u675F\u540E\uFF0C\u60A8\u5C06\u65E0\u6CD5\u518D\u8FDE\u63A5\u5230%20 ONLYOFFICE \u6587\u6863\u670D\u52A1\u5668\u6F14\u793A\u7248\u3002 +onlyoffice.configuration.advanced-section=\u670D\u52A1\u5668\u9AD8\u7EA7\u8BBE\u7F6E +onlyoffice.configuration.conf-url=Confluence \u670D\u52A1\u5668\u5185\u90E8\u5730\u5740 +onlyoffice.configuration.conf-url.tooltip=\u6587\u6863\u7F16\u8F91\u670D\u52A1\u5185\u90E8\u8BF7\u6C42\u7684 Confluence \u670D\u52A1\u5668\u5730\u5740 +onlyoffice.configuration.doc-url-inner=\u6587\u6863\u7F16\u8F91\u670D\u52A1\u7684\u5185\u90E8\u5730\u5740 +onlyoffice.configuration.doc-url-inner.tooltip=Confluence \u670D\u52A1\u5668\u5185\u90E8\u8BF7\u6C42\u7684\u6587\u6863\u7F16\u8F91\u670D\u52A1\u5730\u5740 +onlyoffice.configuration.section.common=\u5E38\u7528\u8BBE\u7F6E +onlyoffice.configuration.editing-types.label=\u53EF\u7F16\u8F91\u7684\u683C\u5F0F +onlyoffice.configuration.editing-types.description=\u6253\u5F00\u7F16\u8F91\u6587\u6863 (\u7531\u4E8E\u6587\u4EF6\u683C\u5F0F\u9650\u5236\uFF0C\u4FDD\u5B58\u4E3A\u4E0B\u5217\u683C\u5F0F\u65F6\uFF0C\u6570\u636E\u53EF\u80FD\u4F1A\u7F3A\u5931) +onlyoffice.configuration.force-save.label=\u5F3A\u5236\u4FDD\u5B58 +onlyoffice.configuration.force-save.enable=\u542F\u7528 +onlyoffice.configuration.force-save.description=\u7F16\u8F91\u65F6\u4FDD\u7559\u4E2D\u95F4\u7248\u672C +onlyoffice.configuration.interface.label=\u7F16\u8F91\u5668\u754C\u9762 +onlyoffice.configuration.interface.description=\u81EA\u5B9A\u4E49\u7F16\u8F91\u5668\u754C\u9762 +onlyoffice.configuration.interface.chat=\u663E\u793A\u804A\u5929\u83DC\u5355\u6309\u94AE +onlyoffice.configuration.interface.compactHeader=\u66F4\u7D27\u81F4\u7684\u663E\u793A\u83DC\u5355\u680F +onlyoffice.configuration.interface.feedback=\u663E\u793A\u53CD\u9988&\u652F\u6301\u83DC\u5355\u6309\u94AE +onlyoffice.configuration.interface.helpMenu=\u663E\u793A\u5E2E\u52A9\u83DC\u5355\u6309\u94AE +onlyoffice.configuration.interface.toolbarNoTabs=\u663E\u793A\u5355\u8272\u5DE5\u5177\u680F\u6807\u9898 +onlyoffice.configuration.reviewDisplay.label=\u5BA1\u9605\u6A21\u5F0F +onlyoffice.configuration.reviewDisplay.description=\u5B9A\u4E49\u6587\u6863\u7F16\u8F91\u5668\u4E2D\u7684\u5BA1\u9605\u7F16\u8F91\u6A21\u5F0F +onlyoffice.configuration.reviewDisplay.markup=\u4FEE\u8BA2 +onlyoffice.configuration.reviewDisplay.final=\u6700\u7EC8\u7248 +onlyoffice.configuration.reviewDisplay.original=\u539F\u59CB\u7248\u672C +onlyoffice.configuration.button.save=\u4FDD\u5B58 +onlyoffice.configuration.message.settings.saved=Settings saved +onlyoffice.configuration.message.settings.saving-error=Error while saving settings +onlyoffice.configuration.banner.message=\u65E0\u9700\u4E0B\u8F7D\u548C\u5B89\u88C5\u5373\u53EF\u8F7B\u677E\u542F\u52A8\u4E91\u7AEF\u7F16\u8F91\u5668 +onlyoffice.configuration.banner.button=\u7ACB\u5373\u83B7\u53D6 +onlyoffice.editor.editlink=\u4F7F\u7528 ONLYOFFICE \u7F16\u8F91 +onlyoffice.editor.viewlink=\u4F7F\u7528 ONLYOFFICE \u67E5\u770B +onlyoffice.editor.fillFormlink=\u4F7F\u7528 ONLYOFFICE \u586B\u5199\u8868\u5355 +onlyoffice.editor.createlink=\u65B0\u5EFA\u6587\u6863 +onlyoffice.editor.createlink.tooltip=\u65B0\u5EFA\u6587\u4EF6 +onlyoffice.editor.dialog.filecreate.docx=\u6587\u672C\u6587\u6863 +onlyoffice.editor.dialog.filecreate.xlsx=\u7535\u5B50\u8868\u683C +onlyoffice.editor.dialog.filecreate.pptx=\u6F14\u793A\u6587\u7A3F +onlyoffice.editor.dialog.filecreate.docxf=\u8868\u5355\u6A21\u677F +onlyoffice.editor.dialog.save-as.title=\u5C06\u6587\u6863\u53E6\u5B58\u4E3A +onlyoffice.editor.dialog.save-as.message.success=\u9644\u4EF6 $ \u5DF2\u6210\u529F\u4FDD\u5B58\u3002 +onlyoffice.editor.dialog.create.form.title=\u9009\u62E9 DOCX \u6587\u4EF6 +onlyoffice.editor.dialog.create.form.button.create=\u521B\u5EFA +onlyoffice.editor.dialog.create.form.button.create-blank=\u4ECE\u7A7A\u767D\u521B\u5EFA +onlyoffice.editor.dialog.create.form.message.error=\u9009\u62E9\u7684\u6587\u4EF6\u4E0D\u662F DOCX \u683C\u5F0F +onlyoffice.editor.message.demo=\u60A8\u6B63\u5728\u4F7F\u7528 ONLYOFFICE \u6587\u6863\u670D\u52A1\u5668\u7684\u516C\u5F00\u6F14\u793A\u7248\u3002\u8BF7\u52FF\u5B58\u50A8\u79C1\u4EBA\u654F\u611F\u6570\u636E\u3002 +onlyoffice.editor.message.docs-api-undefined=ONLYOFFICE \u670D\u52A1\u5668\u65E0\u6CD5\u8FDE\u63A5\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u3002 +onlyoffice.editor.message.docs-api-unsupported=\u4E0D\u652F\u6301\u7684 DocumentServer \u7248\u672C\u3002 +onlyoffice.editor.message.forms.error.version=\u8BF7\u5C06 ONLYOFFICE \u6587\u6863\u66F4\u65B0\u52307.0\u7248\u672C\uFF0C\u5373\u53EF\u5728\u7EBF\u7F16\u8F91\u53EF\u586B\u5199\u7684\u8868\u5355\u3002 +onlyoffice.editor.message.error.unsupported=\u62B1\u6B49, \u4E0D\u652F\u6301\u6B64\u6587\u4EF6\u683C\u5F0F +onlyoffice.convert.link=\u4F7F\u7528 ONLYOFFICE u8F6C\u6362\u683C\u5F0F +onlyoffice.convert.label=\u4ECE {0} \u683C\u5F0F\u8F6C\u6362\u4E3A {1}... +onlyoffice.convert.message.error=\u9519\u8BEF\: +onlyoffice.form.create.link=\u4F7F\u7528 ONLYOFFICE \u521B\u5EFA\u8868\u5355 +onlyoffice.connector.download-as.link=\u4E0B\u8F7D\u4E3A +onlyoffice.connector.dialog.conversion.header.title=\u4F7F\u7528 ONLYOFFICE \u4E0B\u8F7D\u4E3A +onlyoffice.connector.dialog.conversion.field.current-type=\u5F53\u524D\u683C\u5F0F +onlyoffice.connector.dialog.conversion.field.target-type=\u76EE\u6807\u8F6C\u6362\u683C\u5F0F +onlyoffice.connector.dialog.conversion.message.error.service-prefix=ONLYOFFICE \u8F6C\u6362\u670D\u52A1\u8FD4\u56DE\u9519\u8BEF ($)\u3002 +onlyoffice.connector.dialog.conversion.message.error.not-reached=ONLYOFFICE \u8F6C\u6362\u670D\u52A1\u65E0\u6CD5\u8FDE\u63A5,\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u3002 +onlyoffice.connector.dialog.conversion.message.error.permission=\u7528\u6237\u65E0\u6743\u6267\u884C\u6B64\u64CD\u4F5C\u3002 +onlyoffice.connector.error.Unknown=\u64CD\u4F5C\u8FC7\u7A0B\u4E2D\u51FA\u73B0\u672A\u77E5\u9519\u8BEF\u3002 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.label=ONLYOFFICE \u9884\u89C8 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.desc=\u5728\u9875\u9762\u4E2D\u63D2\u5165 ONLYOFFICE \u9884\u89C8\u3002 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.page.label=\u9875\u9762\u540D\u79F0 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.page.desc=\u5305\u62EC\u9644\u4EF6\u7684 Confluence \u9875\u9762 (\u7559\u7A7A\u5219\u4E3A\u5F53\u524D\u9875\u9762)\u3002 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.name.label=\u6587\u4EF6\u540D\u79F0 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.name.desc=\u8981\u5728\u672C\u9875\u67E5\u770B\u7684\u9644\u4EF6\u6587\u4EF6\u540D\u79F0\u3002 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.label=\u5BBD\u5EA6 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.desc=\u7528\u50CF\u7D20 (\u9ED8\u8BA4\u6216 px) \u6216\u9875\u9762\u5BBD\u5EA6\u7684\u767E\u5206\u6BD4 (%) \u6765\u63CF\u8FF0, \u4E3E\u4F8B: 200, 200px, 10% +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=\u9AD8\u5EA6 +onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc=\u7528\u50CF\u7D20 (\u9ED8\u8BA4\u6216 px) \u6216\u9875\u9762\u9AD8\u5EA6\u7684\u767E\u5206\u6BD4 (%) \u6765\u63CF\u8FF0, \u4E3E\u4F8B: 200, 200px, 10% + +onlyoffice.server.common.error.connection=Document Server cannot be reached. +onlyoffice.server.common.error.api-js=The API JavaScript file cannot be reached. +onlyoffice.server.common.error.mixed-content=\u4E0D\u5141\u8BB8\u6DF7\u5408\u6D3B\u52A8\u5185\u5BB9\u3002\u6587\u6863\u670D\u52A1\u5668\u9700\u8981 HTTPS \u5730\u5740\u3002 +onlyoffice.server.common.error.healthcheck=Document Server return bad healthcheck status. + +onlyoffice.service.convert.check.error-prefix=\u5C1D\u8BD5\u68C0\u67E5 ConvertService \u65F6\u51FA\u9519 ($). +onlyoffice.service.convert.error.unknown=\u672A\u77E5\u9519\u8BEF +onlyoffice.service.convert.error.timeout=\u8F6C\u6362\u8D85\u65F6\u9519\u8BEF +onlyoffice.service.convert.error.conversion=\u8F6C\u6362\u9519\u8BEF +onlyoffice.service.convert.error.downloading=\u4E0B\u8F7D\u8981\u8F6C\u6362\u7684\u6587\u4EF6\u65F6\u51FA\u9519 +onlyoffice.service.convert.error.password=\u5BC6\u7801\u9519\u8BEF +onlyoffice.service.convert.error.database=\u8BBF\u95EE\u8F6C\u6362\u7ED3\u679C\u6570\u636E\u5E93\u65F6\u51FA\u9519 +onlyoffice.service.convert.error.input=\u8F93\u5165\u9519\u8BEF +onlyoffice.service.convert.error.token=\u65E0\u6548\u4EE4\u724C +onlyoffice.service.convert.error.connection=\u8FDE\u63A5\u9519\u8BEF +onlyoffice.service.convert.error.download_result=Error while downloading the result file + +onlyoffice.service.command.check.error-prefix=\u5C1D\u8BD5\u68C0\u67E5 CommandService \u65F6\u51FA\u9519 ($). +onlyoffice.service.command.error.no=No errors +onlyoffice.service.command.error.key=Document key is missing or no document with such key could be found +onlyoffice.service.command.error.callback_url=Callback url not correct +onlyoffice.service.command.error.internal_server=\u5185\u90E8\u670D\u52A1\u5668\u9519\u8BEF\u3002\u7A0D\u540E\u518D\u8BD5 +onlyoffice.service.command.error.forcesave=No changes were applied to the document before the forcesave command was received +onlyoffice.service.command.error.command=Command not correct +onlyoffice.service.command.error.token=\u65E0\u6548\u4EE4\u724C +onlyoffice.service.command.error.connection=\u8FDE\u63A5\u9519\u8BEF From 0658b86ae5618c8e417d2984bf36058cd028c4ba Mon Sep 17 00:00:00 2001 From: Maria-Sukhova Date: Fri, 19 Jan 2024 14:59:10 +0300 Subject: [PATCH 54/87] added translations zh --- .../resources/lang-resource_zh_CN.properties | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/resources/lang-resource_zh_CN.properties b/src/main/resources/lang-resource_zh_CN.properties index dc7cae68..558beb86 100644 --- a/src/main/resources/lang-resource_zh_CN.properties +++ b/src/main/resources/lang-resource_zh_CN.properties @@ -31,8 +31,8 @@ onlyoffice.configuration.reviewDisplay.markup=\u4FEE\u8BA2 onlyoffice.configuration.reviewDisplay.final=\u6700\u7EC8\u7248 onlyoffice.configuration.reviewDisplay.original=\u539F\u59CB\u7248\u672C onlyoffice.configuration.button.save=\u4FDD\u5B58 -onlyoffice.configuration.message.settings.saved=Settings saved -onlyoffice.configuration.message.settings.saving-error=Error while saving settings +onlyoffice.configuration.message.settings.saved=\u8BBE\u7F6E\u5DF2\u4FDD\u5B58 +onlyoffice.configuration.message.settings.saving-error=\u4FDD\u5B58\u8BBE\u7F6E\u65F6\u51FA\u9519 onlyoffice.configuration.banner.message=\u65E0\u9700\u4E0B\u8F7D\u548C\u5B89\u88C5\u5373\u53EF\u8F7B\u677E\u542F\u52A8\u4E91\u7AEF\u7F16\u8F91\u5668 onlyoffice.configuration.banner.button=\u7ACB\u5373\u83B7\u53D6 onlyoffice.editor.editlink=\u4F7F\u7528 ONLYOFFICE \u7F16\u8F91 @@ -78,10 +78,10 @@ onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.width.desc=\u75 onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.label=\u9AD8\u5EA6 onlyoffice.onlyoffice-confluence-plugin.onlyoffice-preview.param.height.desc=\u7528\u50CF\u7D20 (\u9ED8\u8BA4\u6216 px) \u6216\u9875\u9762\u9AD8\u5EA6\u7684\u767E\u5206\u6BD4 (%) \u6765\u63CF\u8FF0, \u4E3E\u4F8B: 200, 200px, 10% -onlyoffice.server.common.error.connection=Document Server cannot be reached. -onlyoffice.server.common.error.api-js=The API JavaScript file cannot be reached. +onlyoffice.server.common.error.connection=\u65E0\u6CD5\u8FDE\u63A5\u6587\u6863\u670D\u52A1\u5668\u3002 +onlyoffice.server.common.error.api-js=\u65E0\u6CD5\u8BBF\u95EE API JavaScript \u6587\u4EF6\u3002 onlyoffice.server.common.error.mixed-content=\u4E0D\u5141\u8BB8\u6DF7\u5408\u6D3B\u52A8\u5185\u5BB9\u3002\u6587\u6863\u670D\u52A1\u5668\u9700\u8981 HTTPS \u5730\u5740\u3002 -onlyoffice.server.common.error.healthcheck=Document Server return bad healthcheck status. +onlyoffice.server.common.error.healthcheck=\u6587\u6863\u670D\u52A1\u5668\u8FD4\u56DE\u4E0D\u826F\u5065\u5EB7\u68C0\u67E5\u72B6\u6001\u3002 onlyoffice.service.convert.check.error-prefix=\u5C1D\u8BD5\u68C0\u67E5 ConvertService \u65F6\u51FA\u9519 ($). onlyoffice.service.convert.error.unknown=\u672A\u77E5\u9519\u8BEF @@ -93,14 +93,14 @@ onlyoffice.service.convert.error.database=\u8BBF\u95EE\u8F6C\u6362\u7ED3\u679C\u onlyoffice.service.convert.error.input=\u8F93\u5165\u9519\u8BEF onlyoffice.service.convert.error.token=\u65E0\u6548\u4EE4\u724C onlyoffice.service.convert.error.connection=\u8FDE\u63A5\u9519\u8BEF -onlyoffice.service.convert.error.download_result=Error while downloading the result file +onlyoffice.service.convert.error.download_result=\u4E0B\u8F7D\u7ED3\u679C\u6587\u4EF6\u65F6\u51FA\u9519 onlyoffice.service.command.check.error-prefix=\u5C1D\u8BD5\u68C0\u67E5 CommandService \u65F6\u51FA\u9519 ($). -onlyoffice.service.command.error.no=No errors -onlyoffice.service.command.error.key=Document key is missing or no document with such key could be found -onlyoffice.service.command.error.callback_url=Callback url not correct +onlyoffice.service.command.error.no=\u65E0\u9519\u8BEF +onlyoffice.service.command.error.key=\u7F3A\u5C11\u6587\u6863\u5BC6\u94A5\u6216\u672A\u627E\u5230\u5177\u6709\u6B64\u7C7B\u5BC6\u94A5\u7684\u6587\u6863 +onlyoffice.service.command.error.callback_url=\u56DE\u8C03 URL \u4E0D\u6B63\u786E onlyoffice.service.command.error.internal_server=\u5185\u90E8\u670D\u52A1\u5668\u9519\u8BEF\u3002\u7A0D\u540E\u518D\u8BD5 -onlyoffice.service.command.error.forcesave=No changes were applied to the document before the forcesave command was received -onlyoffice.service.command.error.command=Command not correct +onlyoffice.service.command.error.forcesave=\u5728\u6536\u5230 forcesave \u547D\u4EE4\u4E4B\u524D, \u5BF9\u6587\u6863\u6CA1\u8FDB\u884C\u66F4\u6539 +onlyoffice.service.command.error.command=\u547D\u4EE4\u4E0D\u6B63\u786E onlyoffice.service.command.error.token=\u65E0\u6548\u4EE4\u724C onlyoffice.service.command.error.connection=\u8FDE\u63A5\u9519\u8BEF From 5093fb6b54da7c8b35509a1aa2454c65e0a820cf Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 1 Feb 2024 16:34:57 +0300 Subject: [PATCH 55/87] build: use docs-integration-sdk:1.0.0 --- pom.xml | 2 +- src/main/java/onlyoffice/OnlyOfficeConfServlet.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 556d7752..2fdc8bc5 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ com.onlyoffice docs-integration-sdk - 0.0.1 + 1.0.0 org.apache.httpcomponents diff --git a/src/main/java/onlyoffice/OnlyOfficeConfServlet.java b/src/main/java/onlyoffice/OnlyOfficeConfServlet.java index d6fc4592..73fee626 100644 --- a/src/main/java/onlyoffice/OnlyOfficeConfServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeConfServlet.java @@ -91,7 +91,7 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re Map contextMap = MacroUtils.defaultVelocityContext(); contextMap.put("demoAvailable", demoAvailable); - contextMap.put("pathApiUrl", settingsManager.getSDKSetting("integration-sdk.api.url")); + contextMap.put("pathApiUrl", settingsManager.getDocsIntegrationSdkProperties().getDocumentServer().getApiUrl()); if (settingsManager.getSetting(SettingsConstants.LOSSY_EDIT) == null || settingsManager.getSetting(SettingsConstants.LOSSY_EDIT).isEmpty()) { From c10581cbab16d683c5a5a10b900ee8659abbf8dc Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 1 Feb 2024 17:04:54 +0300 Subject: [PATCH 56/87] feat: add setting authorization header on settings page --- CHANGELOG.md | 1 + src/main/resources/js/settings.js | 1 + src/main/resources/lang-resource.properties | 1 + src/main/resources/lang-resource_de.properties | 1 + src/main/resources/lang-resource_es.properties | 1 + src/main/resources/lang-resource_fr.properties | 1 + src/main/resources/lang-resource_it.properties | 1 + src/main/resources/lang-resource_ru.properties | 1 + src/main/resources/templates/configure.vm | 4 ++++ 9 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ab92cb8..cd75bae8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - core of the plugin has been moved to com.onlyoffice.docs-integration-sdk (https://github.com/ONLYOFFICE/docs-integration-sdk-java) - improved connection settings validation - improved history servlet security +- setting authorization header on settings page ## 4.4.0 ## Added diff --git a/src/main/resources/js/settings.js b/src/main/resources/js/settings.js index e30ab394..809f5861 100644 --- a/src/main/resources/js/settings.js +++ b/src/main/resources/js/settings.js @@ -34,6 +34,7 @@ "productInnerUrl": $("#confUrlField").attr("value"), "security": { "key": $("#jwtSecretField").attr("value"), + "header": $("#securityHeader").attr("value") }, "ignoreSSLCertificate": $("#verifyCertificate").is(":checked"), "customization": { diff --git a/src/main/resources/lang-resource.properties b/src/main/resources/lang-resource.properties index 35c05a89..9d2f4a17 100644 --- a/src/main/resources/lang-resource.properties +++ b/src/main/resources/lang-resource.properties @@ -3,6 +3,7 @@ onlyoffice.configuration.doc-url=Document Editing Service address onlyoffice.configuration.doc-url.tooltip=Document Editing Service address e.g. http\://localhost/ onlyoffice.configuration.jwt-secret=Secret key (leave blank to disable) onlyoffice.configuration.jwt-secret.tooltip=Secret key to generate the token +onlyoffice.configuration.security.header=Authorization header (Leave blank to use default header) onlyoffice.configuration.verify-certificate=Disable certificate verification (insecure) onlyoffice.configuration.demo.connect=Connect to demo ONLYOFFICE Document Server onlyoffice.configuration.demo.trial=This is a public test server, please do not use it for private sensitive data. The server will be available during a 30-day period. diff --git a/src/main/resources/lang-resource_de.properties b/src/main/resources/lang-resource_de.properties index 8def0b96..67c199dc 100644 --- a/src/main/resources/lang-resource_de.properties +++ b/src/main/resources/lang-resource_de.properties @@ -3,6 +3,7 @@ onlyoffice.configuration.doc-url=Adresse des Dienstes f\u00fcr Dokumentenbearbei onlyoffice.configuration.doc-url.tooltip=Adresse des Dienstes f\u00fcr Dokumentenbearbeitung, z.B., http\://localhost/ onlyoffice.configuration.jwt-secret=Geheimschl\u00fcssel (freilassen, um zu deaktivieren) onlyoffice.configuration.jwt-secret.tooltip=Geheimschl\u00fcssel zum Generieren eines Tokens +onlyoffice.configuration.security.header=Authorization-Header (Leer lassen, um die standardm\u00e4ßige Kopfzeile zu verwenden) onlyoffice.configuration.verify-certificate=Zertifikats\u00fcberpr\u00fcfung deaktivieren (unsicher) onlyoffice.configuration.demo.connect=Verbindung zu Demo ONLYOFFICE Document Server herstellen onlyoffice.configuration.demo.trial=Dies ist ein \u00f6ffentlicher Testserver. Bitte verwenden Sie beim Testen keine privaten sensiblen Daten. Der Server ist 30 Tage lang verf\u00fcgbar. diff --git a/src/main/resources/lang-resource_es.properties b/src/main/resources/lang-resource_es.properties index 5a68d428..ca50c8ab 100644 --- a/src/main/resources/lang-resource_es.properties +++ b/src/main/resources/lang-resource_es.properties @@ -3,6 +3,7 @@ onlyoffice.configuration.doc-url=Direcci\u00F3n del Servicio de edici\u00F3n de onlyoffice.configuration.doc-url.tooltip=Direcci\u00F3n de servicio de edici\u00F3n de documentos, ej. http\://localhost/ onlyoffice.configuration.jwt-secret=Clave secreta (deje en blanco o desactive) onlyoffice.configuration.jwt-secret.tooltip=Clave secreta para generar el token +onlyoffice.configuration.security.header=Encabezado de autenticaci\u00f3n (Dejar en blanco para utilizar el encabezado predeterminado) onlyoffice.configuration.verify-certificate=Desactivar la verificaci\u00f3n de certificados (inseguro) onlyoffice.configuration.demo.connect=Conectarse al ONLYOFFICE Document Server de demostraci\u00f3n onlyoffice.configuration.demo.trial=Este es un servidor de pruebas p\u00fablico, por favor no lo uses para tus datos confidenciales. El servidor estar\u00e1 disponible durante un per\u00edodo de 30 d\u00edas. diff --git a/src/main/resources/lang-resource_fr.properties b/src/main/resources/lang-resource_fr.properties index 00d28ad5..3a969dff 100644 --- a/src/main/resources/lang-resource_fr.properties +++ b/src/main/resources/lang-resource_fr.properties @@ -3,6 +3,7 @@ onlyoffice.configuration.doc-url=Adresse du service d\u2019\u00E9dition de docum onlyoffice.configuration.doc-url.tooltip=Adresse du service de modification de documents, par ex. http\://localhost/ onlyoffice.configuration.jwt-secret=Cl\u00E9 secr\u00E8te (laisser vide pour d\u00E9sactiver) onlyoffice.configuration.jwt-secret.tooltip=Cl\u00e9 secr\u00e8te pour g\u00e9n\u00e9rer le jeton +onlyoffice.configuration.security.header=En-t\u00eate d'autorisation (Laissez vide pour utiliser l'en-tête par d\u00e9faut) onlyoffice.configuration.verify-certificate=D\u00e9sactiver la v\u00e9rification du certificat (non sur) onlyoffice.configuration.demo.connect=Se connecter \u00e0 la version d\u00e9mo de ONLYOFFICE Document Server onlyoffice.configuration.demo.trial=C\u2019est un serveur public propos\u00e9 \u00e0 des fins de tests, veuillez ne pas l\u2019utiliser pour vos donn\u00e9es personnelles sensibles. Le serveur est disponible pendant 30 jours. diff --git a/src/main/resources/lang-resource_it.properties b/src/main/resources/lang-resource_it.properties index bfbad307..68b6a8ce 100644 --- a/src/main/resources/lang-resource_it.properties +++ b/src/main/resources/lang-resource_it.properties @@ -3,6 +3,7 @@ onlyoffice.configuration.doc-url=Indirizzo del Servizio di modifica documenti onlyoffice.configuration.doc-url.tooltip=Indirizzo del Servizio di modifica documenti, per esempio http\://localhost/ onlyoffice.configuration.jwt-secret=Chiave segreta (lasciare vuoto per disabilitare) onlyoffice.configuration.jwt-secret.tooltip=Chiave segreta per generare il token +onlyoffice.configuration.security.header=Intestazione di autorizzazione (Lascia vuoto per utilizzare l'intestazione predefinita) onlyoffice.configuration.verify-certificate=Disattiva la verifica del certificato (non sicuro) onlyoffice.configuration.demo.connect=Collegati alla demo di ONLYOFFICE Document Server onlyoffice.configuration.demo.trial=Questo \u00e8 un server di prova pubblico, non utilizzarlo per dati sensibili privati. Il server sar\u00e0 disponibile per un periodo di 30 giorni. diff --git a/src/main/resources/lang-resource_ru.properties b/src/main/resources/lang-resource_ru.properties index 9734b6e8..cdbe8b09 100644 --- a/src/main/resources/lang-resource_ru.properties +++ b/src/main/resources/lang-resource_ru.properties @@ -3,6 +3,7 @@ onlyoffice.configuration.doc-url=\u0410\u0434\u0440\u0435\u0441 \u0441\u043B\u04 onlyoffice.configuration.doc-url.tooltip=\u0410\u0434\u0440\u0435\u0441 \u0441\u043B\u0443\u0436\u0431\u044B \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u043E\u0432, \u043D\u0430\u043F\u0440\u0438\u043C\u0435\u0440 http\://localhost/ onlyoffice.configuration.jwt-secret=\u0421\u0435\u043A\u0440\u0435\u0442\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 (\u043E\u0441\u0442\u0430\u0432\u044C\u0442\u0435 \u043F\u0443\u0441\u0442\u044B\u043C \u0434\u043B\u044F \u043E\u0442\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u044F) onlyoffice.configuration.jwt-secret.tooltip=\u0421\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439\u0020\u043a\u043b\u044e\u0447\u0020\u0434\u043b\u044f\u0020\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f\u0020\u0442\u043e\u043a\u0435\u043d\u0430 +onlyoffice.configuration.security.header=\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 (\u041e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043f\u0443\u0441\u0442\u044b\u043c, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e) onlyoffice.configuration.verify-certificate=\u041e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 (\u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e) onlyoffice.configuration.demo.connect=\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f\u0020\u043a\u0020\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c\u0443\u0020\u0421\u0435\u0440\u0432\u0435\u0440\u0443\u0020\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432\u0020\u004f\u004e\u004c\u0059\u004f\u0046\u0046\u0049\u0043\u0045 onlyoffice.configuration.demo.trial=\u042d\u0442\u043e\u0020\u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439\u0020\u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439\u0020\u0441\u0435\u0440\u0432\u0435\u0440\u002c\u0020\u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430\u002c\u0020\u043d\u0435\u0020\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0020\u0435\u0433\u043e\u0020\u0434\u043b\u044f\u0020\u043b\u0438\u0447\u043d\u044b\u0445\u0020\u043a\u043e\u043d\u0444\u0438\u0434\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445\u0020\u0434\u0430\u043d\u043d\u044b\u0445\u002e\u0020\u0421\u0435\u0440\u0432\u0435\u0440\u0020\u0431\u0443\u0434\u0435\u0442\u0020\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d\u0020\u0432\u0020\u0442\u0435\u0447\u0435\u043d\u0438\u0435\u0020\u0033\u0030\u0020\u0434\u043d\u0435\u0439\u002e diff --git a/src/main/resources/templates/configure.vm b/src/main/resources/templates/configure.vm index 3b5e23ec..cb7a3b5f 100644 --- a/src/main/resources/templates/configure.vm +++ b/src/main/resources/templates/configure.vm @@ -44,6 +44,10 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl
+
+ + +
Date: Tue, 6 Feb 2024 10:23:39 +0300 Subject: [PATCH 57/87] build: use docs-integration-sdk:1.1.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2fdc8bc5..c281e800 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ com.onlyoffice docs-integration-sdk - 1.0.0 + 1.1.1 org.apache.httpcomponents From 502fce7ded16443e8d0f2966eb18f5fd8ae3bd5b Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 6 Feb 2024 15:03:30 +0300 Subject: [PATCH 58/87] fix: user.id from ConfluenceUser key --- src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java b/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java index bd6038f6..4ee54b28 100644 --- a/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java +++ b/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java @@ -76,7 +76,7 @@ public User getUser() { if (user != null) { return User.builder() - .id(user.getName()) + .id(user.getKey().getStringValue()) .name(user.getFullName()) .build(); } else { From c8d916bc06a3e17196d2487f550569794eb9c024 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 6 Feb 2024 15:34:44 +0300 Subject: [PATCH 59/87] feat: user image in editor --- .../sdk/service/ConfigServiceImpl.java | 17 ++++++++++ src/main/resources/templates/editor.vm | 31 ++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java b/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java index 4ee54b28..a008387f 100644 --- a/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java +++ b/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java @@ -21,6 +21,10 @@ import com.atlassian.confluence.status.service.SystemInformationService; import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.user.ConfluenceUser; +import com.atlassian.confluence.user.UserAccessor; +import com.atlassian.confluence.user.actions.ProfilePictureInfo; +import com.atlassian.plugin.webresource.UrlMode; +import com.atlassian.plugin.webresource.WebResourceIntegration; import com.onlyoffice.manager.security.JwtManager; import com.onlyoffice.manager.settings.SettingsManager; import com.onlyoffice.manager.url.UrlManager; @@ -37,14 +41,19 @@ public class ConfigServiceImpl extends DefaultConfigService { private final Logger log = LogManager.getLogger("onlyoffice.ConfigServiceImpl"); private final SystemInformationService sysInfoService; + private final WebResourceIntegration webResourceIntegration; + private final UserAccessor userAccessor; private AttachmentUtil attachmentUtil; public ConfigServiceImpl(final DocumentManager documentManager, final UrlManager urlManager, final JwtManager jwtManager, final SystemInformationService sysInfoService, + final WebResourceIntegration webResourceIntegration, final UserAccessor userAccessor, final AttachmentUtil attachmentUtil, final SettingsManager settingsManager) { super(documentManager, urlManager, jwtManager, settingsManager); this.sysInfoService = sysInfoService; + this.webResourceIntegration = webResourceIntegration; + this.userAccessor = userAccessor; this.attachmentUtil = attachmentUtil; } @@ -73,11 +82,19 @@ public Permissions getPermissions(final String fileId) { @Override public User getUser() { ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + ProfilePictureInfo profilePictureInfo = userAccessor.getUserProfilePicture(user); + String userImage = null; + + if (!profilePictureInfo.isDefault()) { + userImage = webResourceIntegration.getBaseUrl(UrlMode.ABSOLUTE) + profilePictureInfo.getUriReference() + .substring(webResourceIntegration.getBaseUrl(UrlMode.RELATIVE).length()); + } if (user != null) { return User.builder() .id(user.getKey().getStringValue()) .name(user.getFullName()) + .image(userImage) .build(); } else { return super.getUser(); diff --git a/src/main/resources/templates/editor.vm b/src/main/resources/templates/editor.vm index 22c90daa..4b42a181 100644 --- a/src/main/resources/templates/editor.vm +++ b/src/main/resources/templates/editor.vm @@ -338,6 +338,34 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl } }; + + var onRequestUsers = function(event) { + switch (event.data.c) { + case "info": + var users = []; + for (var i = 0; i < event.data.id.length; i++) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", AJS.contextPath() + "/rest/api/user?key=" + event.data.id[i], false); + xhr.send(); + + if (xhr.status == 200) { + const user = JSON.parse(xhr.responseText); + users.push({ + "id": user.username, + "name": user.displayName, + "image": document.location.origin + user.profilePicture.path + }); + } + } + + docEditor.setUsers({ + "c": event.data.c, + "users": users, + }); + break; + } + } + var connectEditor = function () { if (typeof DocsAPI === "undefined") { alert("$i18n.getText('onlyoffice.editor.message.docs-api-undefined')"); @@ -361,7 +389,8 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl "onRequestCompareFile": onRequestCompareFile, "onRequestMailMergeRecipients": onRequestMailMergeRecipients, "onMakeActionLink": onMakeActionLink, - "onRequestReferenceData": onRequestReferenceData + "onRequestReferenceData": onRequestReferenceData, + "onRequestUsers": onRequestUsers }, }; From 90e9944f9d7cf894b0025e9c1649899d4011c4e1 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 6 Feb 2024 15:35:57 +0300 Subject: [PATCH 60/87] docs: feature/user-image to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd75bae8..93d81b01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - improved connection settings validation - improved history servlet security - setting authorization header on settings page +- user image in editor ## 4.4.0 ## Added From 0c5f6b1efa0374bd67331887a7ea6b5ff4f1cc3d Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 7 Feb 2024 10:29:59 +0300 Subject: [PATCH 61/87] fix: date formatting in history changes --- CHANGELOG.md | 3 ++ .../onlyoffice/OnlyOfficeHistoryServlet.java | 46 +++++++++++++------ 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd75bae8..3c4c98eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ - improved history servlet security - setting authorization header on settings page +## Changed +- improved date formatting in history changes + ## 4.4.0 ## Added - compatible with Confluence 8.6 diff --git a/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java b/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java index 0043d027..0379eb2b 100644 --- a/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java @@ -26,9 +26,9 @@ import com.atlassian.confluence.user.ConfluenceUser; import com.atlassian.confluence.user.ConfluenceUserPreferences; import com.atlassian.confluence.user.UserAccessor; -import com.atlassian.spring.container.ContainerManager; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; +import com.onlyoffice.model.common.Changes; import com.onlyoffice.model.common.User; import com.onlyoffice.model.documenteditor.HistoryData; import com.onlyoffice.model.documenteditor.callback.History; @@ -40,10 +40,8 @@ import onlyoffice.managers.auth.AuthContext; import onlyoffice.sdk.manager.document.DocumentManager; import onlyoffice.utils.attachment.AttachmentUtil; -import onlyoffice.utils.parsing.ParsingUtil; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; -import org.json.JSONException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -53,8 +51,12 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -66,29 +68,28 @@ public class OnlyOfficeHistoryServlet extends HttpServlet { private final LocaleManager localeManager; private final FormatSettingsManager formatSettingsManager; + private final UserAccessor userAccessor; private final AuthContext authContext; private final DocumentManager documentManager; private final AttachmentUtil attachmentUtil; private final UrlManager urlManager; private final SettingsManager settingsManager; private final JwtManager jwtManager; - private final ParsingUtil parsingUtil; public OnlyOfficeHistoryServlet(final LocaleManager localeManager, - final FormatSettingsManager formatSettingsManager, + final FormatSettingsManager formatSettingsManager, final UserAccessor userAccessor, final AuthContext authContext, final DocumentManager documentManager, final AttachmentUtil attachmentUtil, final UrlManager urlManager, - final SettingsManager settingsManager, final JwtManager jwtManager, - final ParsingUtil parsingUtil) { + final SettingsManager settingsManager, final JwtManager jwtManager) { this.localeManager = localeManager; this.formatSettingsManager = formatSettingsManager; + this.userAccessor = userAccessor; this.authContext = authContext; this.documentManager = documentManager; this.attachmentUtil = attachmentUtil; this.urlManager = urlManager; this.settingsManager = settingsManager; this.jwtManager = jwtManager; - this.parsingUtil = parsingUtil; } @Override @@ -189,7 +190,6 @@ private void getAttachmentHistoryInfo(final HttpServletRequest request, final Ht List attachments = attachmentUtil.getAllVersions(attachmentId); if (attachments != null) { - UserAccessor userAccessor = (UserAccessor) ContainerManager.getComponent("userAccessor"); ConfluenceUserPreferences preferences = userAccessor.getConfluenceUserPreferences(user); DateFormatter dateFormatter = preferences.getDateFormatter(formatSettingsManager, localeManager); Gson gson = new Gson(); @@ -213,14 +213,13 @@ private void getAttachmentHistoryInfo(final HttpServletRequest request, final Ht if (changesAttachment != null) { if (prevVersion != null && (attachment.getVersion() - prevVersion.getVersion()) == 1) { InputStream changesSteam = attachmentUtil.getAttachmentData(changesAttachment.getId()); + ObjectMapper mapper = new ObjectMapper(); History changes = mapper.readValue(changesSteam, History.class); - try { - version.setServerVersion(changes.getServerVersion()); - version.setChanges(changes.getChanges()); - } catch (JSONException e) { - throw new IOException(e.getMessage()); - } + changes.setChanges(formatChanges(changes.getChanges(), user)); + + version.setServerVersion(changes.getServerVersion()); + version.setChanges(changes.getChanges()); } else { attachmentUtil.removeAttachmentChanges(attachment.getId()); } @@ -243,6 +242,23 @@ private void getAttachmentHistoryInfo(final HttpServletRequest request, final Ht } } + private List formatChanges(final List changes, final ConfluenceUser user) { + ConfluenceUserPreferences preferences = userAccessor.getConfluenceUserPreferences(user); + DateFormatter dateFormatter = preferences.getDateFormatter(formatSettingsManager, localeManager); + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + for (Changes changesEntity : changes) { + try { + Date created = dateFormat.parse(changesEntity.getCreated()); + changesEntity.setCreated(dateFormatter.formatDateTime(created)); + } catch (ParseException e) { + log.error(e); + } + } + + return changes; + } + private void getAttachmentHistoryData(final HttpServletRequest request, final HttpServletResponse response) throws IOException { if (!authContext.checkUserAuthorization(request, response)) { From 314bb2c3b9dcca812363e3a642d61f29efaa4f1e Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 7 Feb 2024 11:42:29 +0300 Subject: [PATCH 62/87] feat: delete permission edit for isFillable formats --- src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java b/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java index a008387f..87fa2b30 100644 --- a/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java +++ b/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java @@ -71,8 +71,7 @@ public Permissions getPermissions(final String fileId) { String fileName = getDocumentManager().getDocumentName(fileId); Boolean editPermission = attachmentUtil.checkAccess(Long.parseLong(fileId), user, true); - Boolean isEditable = super.getDocumentManager().isEditable(fileName) - || super.getDocumentManager().isFillable(fileName); + Boolean isEditable = super.getDocumentManager().isEditable(fileName); return Permissions.builder() .edit(editPermission && isEditable) From 023c77fb69cf902311b175a1e0ea06f9f341d338 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 7 Feb 2024 11:43:09 +0300 Subject: [PATCH 63/87] feat: add button open in onlyoffice for isFillable formats --- src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java b/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java index 0346935b..8a8be73e 100644 --- a/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java +++ b/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java @@ -77,7 +77,7 @@ public boolean shouldDisplay(final Map context) { } else { if (accessView && documentManager.isViewable(fileName) - && !(accessEdit && (documentManager.isEditable(fileName) || documentManager.isFillable(fileName))) + && !(accessEdit && documentManager.isEditable(fileName)) ) { return true; } From 0f7ad23f06f972b5dd75a7f54df85912d5ab4317 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 8 Feb 2024 11:42:28 +0300 Subject: [PATCH 64/87] docs: feature/filling-pdf to changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51a729e1..548f8a0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,12 @@ - improved history servlet security - setting authorization header on settings page - user image in editor +- filling pdf ## Changed - improved date formatting in history changes +- default conversion format (from docxf to pdf instead oform) +- remove filling for oform ## 4.4.0 ## Added From 4959a0cd355552e219811c945f6e31de87f99542 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Wed, 14 Feb 2024 17:43:42 +0300 Subject: [PATCH 65/87] Form template rename as PDF form --- src/main/resources/lang-resource.properties | 2 +- src/main/resources/lang-resource_de.properties | 4 ++-- src/main/resources/lang-resource_es.properties | 2 +- src/main/resources/lang-resource_fr.properties | 4 ++-- src/main/resources/lang-resource_it.properties | 2 +- src/main/resources/lang-resource_ru.properties | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/resources/lang-resource.properties b/src/main/resources/lang-resource.properties index 9d2f4a17..2eb57e97 100644 --- a/src/main/resources/lang-resource.properties +++ b/src/main/resources/lang-resource.properties @@ -44,7 +44,7 @@ onlyoffice.editor.createlink.tooltip=Create new file onlyoffice.editor.dialog.filecreate.docx=Document onlyoffice.editor.dialog.filecreate.xlsx=Spreadsheet onlyoffice.editor.dialog.filecreate.pptx=Presentation -onlyoffice.editor.dialog.filecreate.docxf=Form template +onlyoffice.editor.dialog.filecreate.docxf=PDF form onlyoffice.editor.dialog.save-as.title=Save document as onlyoffice.editor.dialog.save-as.message.success=Attachment $ was successfully saved. onlyoffice.editor.dialog.create.form.title=Select the DOCX file diff --git a/src/main/resources/lang-resource_de.properties b/src/main/resources/lang-resource_de.properties index 67c199dc..1316600f 100644 --- a/src/main/resources/lang-resource_de.properties +++ b/src/main/resources/lang-resource_de.properties @@ -3,7 +3,7 @@ onlyoffice.configuration.doc-url=Adresse des Dienstes f\u00fcr Dokumentenbearbei onlyoffice.configuration.doc-url.tooltip=Adresse des Dienstes f\u00fcr Dokumentenbearbeitung, z.B., http\://localhost/ onlyoffice.configuration.jwt-secret=Geheimschl\u00fcssel (freilassen, um zu deaktivieren) onlyoffice.configuration.jwt-secret.tooltip=Geheimschl\u00fcssel zum Generieren eines Tokens -onlyoffice.configuration.security.header=Authorization-Header (Leer lassen, um die standardm\u00e4ßige Kopfzeile zu verwenden) +onlyoffice.configuration.security.header=Authorization-Header (Leer lassen, um die standardm\u00e4ßige Kopfzeile zu verwenden) onlyoffice.configuration.verify-certificate=Zertifikats\u00fcberpr\u00fcfung deaktivieren (unsicher) onlyoffice.configuration.demo.connect=Verbindung zu Demo ONLYOFFICE Document Server herstellen onlyoffice.configuration.demo.trial=Dies ist ein \u00f6ffentlicher Testserver. Bitte verwenden Sie beim Testen keine privaten sensiblen Daten. Der Server ist 30 Tage lang verf\u00fcgbar. @@ -44,7 +44,7 @@ onlyoffice.editor.createlink.tooltip=Erstellen neue datei onlyoffice.editor.dialog.filecreate.docx=Dokument onlyoffice.editor.dialog.filecreate.xlsx=Tabelle onlyoffice.editor.dialog.filecreate.pptx=Pr\u00e4sentation -onlyoffice.editor.dialog.filecreate.docxf=Formularvorlage +onlyoffice.editor.dialog.filecreate.docxf= onlyoffice.editor.dialog.save-as.title=Dokument speichern als onlyoffice.editor.dialog.save-as.message.success=Der Anhang $ wurde erfolgreich gespeichert. onlyoffice.editor.dialog.create.form.title=DOCX-Datei ausw\u00e4hlen diff --git a/src/main/resources/lang-resource_es.properties b/src/main/resources/lang-resource_es.properties index ca50c8ab..5a2043a7 100644 --- a/src/main/resources/lang-resource_es.properties +++ b/src/main/resources/lang-resource_es.properties @@ -44,7 +44,7 @@ onlyoffice.editor.createlink.tooltip=Crear nuevo archivo onlyoffice.editor.dialog.filecreate.docx=Documento onlyoffice.editor.dialog.filecreate.xlsx=Hoja de c\u00e1lculo onlyoffice.editor.dialog.filecreate.pptx=Presentaci\u00f3n -onlyoffice.editor.dialog.filecreate.docxf=Plantilla de formulario +onlyoffice.editor.dialog.filecreate.docxf= onlyoffice.editor.dialog.save-as.title=Guardar documento como onlyoffice.editor.dialog.save-as.message.success=El archivo adjunto $ se ha guardado correctamente. onlyoffice.editor.dialog.create.form.title=Seleccione el archivo DOCX diff --git a/src/main/resources/lang-resource_fr.properties b/src/main/resources/lang-resource_fr.properties index 3a969dff..77d7acb0 100644 --- a/src/main/resources/lang-resource_fr.properties +++ b/src/main/resources/lang-resource_fr.properties @@ -3,7 +3,7 @@ onlyoffice.configuration.doc-url=Adresse du service d\u2019\u00E9dition de docum onlyoffice.configuration.doc-url.tooltip=Adresse du service de modification de documents, par ex. http\://localhost/ onlyoffice.configuration.jwt-secret=Cl\u00E9 secr\u00E8te (laisser vide pour d\u00E9sactiver) onlyoffice.configuration.jwt-secret.tooltip=Cl\u00e9 secr\u00e8te pour g\u00e9n\u00e9rer le jeton -onlyoffice.configuration.security.header=En-t\u00eate d'autorisation (Laissez vide pour utiliser l'en-tête par d\u00e9faut) +onlyoffice.configuration.security.header=En-t\u00eate d'autorisation (Laissez vide pour utiliser l'en-tête par d\u00e9faut) onlyoffice.configuration.verify-certificate=D\u00e9sactiver la v\u00e9rification du certificat (non sur) onlyoffice.configuration.demo.connect=Se connecter \u00e0 la version d\u00e9mo de ONLYOFFICE Document Server onlyoffice.configuration.demo.trial=C\u2019est un serveur public propos\u00e9 \u00e0 des fins de tests, veuillez ne pas l\u2019utiliser pour vos donn\u00e9es personnelles sensibles. Le serveur est disponible pendant 30 jours. @@ -44,7 +44,7 @@ onlyoffice.editor.createlink.tooltip=\u0421\u0072\u00e9\u0065\u0072 un nouveau f onlyoffice.editor.dialog.filecreate.docx=Document onlyoffice.editor.dialog.filecreate.xlsx=Feuille de calcul onlyoffice.editor.dialog.filecreate.pptx=Pr\u00e9sentation -onlyoffice.editor.dialog.filecreate.docxf=Mod\u00e8le de formulaire +onlyoffice.editor.dialog.filecreate.docxf= onlyoffice.editor.dialog.save-as.title=Enregistrer le document comme onlyoffice.editor.dialog.save-as.message.success=La pi\u00e8ce jointe $ a \u00e9t\u00e9 enregistr\u00e9e avec succ\u00e8s. onlyoffice.editor.dialog.create.form.title=Choisir le fichier DOCX diff --git a/src/main/resources/lang-resource_it.properties b/src/main/resources/lang-resource_it.properties index 68b6a8ce..f27f8a37 100644 --- a/src/main/resources/lang-resource_it.properties +++ b/src/main/resources/lang-resource_it.properties @@ -44,7 +44,7 @@ onlyoffice.editor.createlink.tooltip=Crea un nuovo file onlyoffice.editor.dialog.filecreate.docx=Documento onlyoffice.editor.dialog.filecreate.xlsx=Foglio di calcolo onlyoffice.editor.dialog.filecreate.pptx=Presentazione -onlyoffice.editor.dialog.filecreate.docxf=Modello di modulo +onlyoffice.editor.dialog.filecreate.docxf= onlyoffice.editor.dialog.save-as.title=Salvare documento come onlyoffice.editor.dialog.save-as.message.success=Attachment $ Allegato \u00e8 stato salvato con successo. onlyoffice.editor.dialog.create.form.title=Selezionare il file DOCX diff --git a/src/main/resources/lang-resource_ru.properties b/src/main/resources/lang-resource_ru.properties index cdbe8b09..1c68bf53 100644 --- a/src/main/resources/lang-resource_ru.properties +++ b/src/main/resources/lang-resource_ru.properties @@ -44,7 +44,7 @@ onlyoffice.editor.createlink.tooltip=\u0421\u043e\u0437\u0434\u0430\u0442\u044c\ onlyoffice.editor.dialog.filecreate.docx=\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442 onlyoffice.editor.dialog.filecreate.xlsx=\u0422\u0430\u0431\u043b\u0438\u0446\u0430 onlyoffice.editor.dialog.filecreate.pptx=\u041f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u044f -onlyoffice.editor.dialog.filecreate.docxf=\u0428\u0430\u0431\u043b\u043e\u043d\u0020\u0444\u043e\u0440\u043c\u044b +onlyoffice.editor.dialog.filecreate.docxf= onlyoffice.editor.dialog.save-as.title=\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0020\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0020\u043a\u0430\u043a onlyoffice.editor.dialog.save-as.message.success=\u0412\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u0020\u003c\u0062\u003e\u0024\u003c\u002f\u0062\u003e\u0020\u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0020\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e\u002e onlyoffice.editor.dialog.create.form.title=\u0412\u044b\u0431\u0440\u0430\u0442\u044c\u0020\u0444\u0430\u0439\u043b\u0020\u0432\u0020\u0444\u043e\u0440\u043c\u0430\u0442\u0435 DOCX From 20c96678fed72f31ebbf0a6fd92d82d16f533640 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 15 Feb 2024 11:52:56 +0300 Subject: [PATCH 66/87] fix: disable authorization header field when demo is enabled --- src/main/resources/js/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/js/settings.js b/src/main/resources/js/settings.js index 809f5861..c50fef49 100644 --- a/src/main/resources/js/settings.js +++ b/src/main/resources/js/settings.js @@ -203,7 +203,7 @@ var demoToggle = function () { if (!$("#onlyofficeDemo").prop("disabled")) { - $("#apiUrlField, #jwtSecretField, #docInnerUrlField, #verifyCertificate").prop("disabled", $("#onlyofficeDemo").prop("checked")); + $("#apiUrlField, #jwtSecretField, #docInnerUrlField, #verifyCertificate, #securityHeader").prop("disabled", $("#onlyofficeDemo").prop("checked")); if ($("#onlyofficeDemo").prop("checked")) { $(".view-control").css("pointer-events", "none"); $(".view-control").removeClass("view"); From 5fc273753a9c29258faef2fb495d9da409d67b75 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 15 Feb 2024 15:48:15 +0300 Subject: [PATCH 67/87] fix: bug conversion docs opened in the editor --- src/main/java/onlyoffice/OnlyOfficeConvertServlet.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java b/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java index 80f0950b..0260a78e 100644 --- a/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java @@ -250,6 +250,7 @@ public Long doWork(final Object response) throws Exception { copy.setMediaType(documentManager.getMimeType(newName)); attachmentManager.saveAttachment(copy, null, inputStream); + attachmentUtil.setCollaborativeEditingKey(copy.getLatestVersionId(), null); return copy.getLatestVersionId(); } From 9645c22ba3cae0f5f61307c3a0f11bed34ec6875 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 15 Feb 2024 16:36:33 +0300 Subject: [PATCH 68/87] feat: set permission fillforms to editor config --- src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java b/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java index 87fa2b30..0f7d6e60 100644 --- a/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java +++ b/src/main/java/onlyoffice/sdk/service/ConfigServiceImpl.java @@ -72,9 +72,11 @@ public Permissions getPermissions(final String fileId) { Boolean editPermission = attachmentUtil.checkAccess(Long.parseLong(fileId), user, true); Boolean isEditable = super.getDocumentManager().isEditable(fileName); + Boolean isFillable = super.getDocumentManager().isFillable(fileName); return Permissions.builder() .edit(editPermission && isEditable) + .fillForms(editPermission && isFillable) .build(); } From 8e15d12a4b2c9819e6e46141f4f901bdfbd49a14 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 15 Feb 2024 16:37:21 +0300 Subject: [PATCH 69/87] feat: added the ability to open documents for viewing --- pom.xml | 2 +- src/main/java/onlyoffice/OnlyOfficeEditorServlet.java | 9 ++++++++- src/main/resources/atlassian-plugin.xml | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index c281e800..c61e7b3e 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ com.onlyoffice docs-integration-sdk - 1.1.1 + 1.1.3-SNAPSHOT org.apache.httpcomponents diff --git a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java index 645146ea..fc8a8f81 100644 --- a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java @@ -88,6 +88,7 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re String attachmentIdString = request.getParameter("attachmentId"); String actionDataString = request.getParameter("actionData"); + String modeString = request.getParameter("mode"); if (attachmentIdString == null || attachmentIdString.isEmpty()) { if (!authContext.checkUserAuthorization(request, response)) { return; @@ -165,9 +166,15 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re actionData = new JSONObject(actionDataString); } + Mode mode = Mode.EDIT; + + if (modeString != null && modeString.equals("view")) { + mode = Mode.VIEW; + } + Config config = configService.createConfig( attachmentId.toString(), - Mode.EDIT, + mode, request.getHeader("USER-AGENT") ); diff --git a/src/main/resources/atlassian-plugin.xml b/src/main/resources/atlassian-plugin.xml index dda0d357..154f2a5f 100644 --- a/src/main/resources/atlassian-plugin.xml +++ b/src/main/resources/atlassian-plugin.xml @@ -160,7 +160,7 @@ Link and text for this link used to open the document which is available for preview only.