Compare commits

..

220 Commits

Author SHA1 Message Date
1ac382d3c0 java-spring: https 2023-02-10 10:39:03 +03:00
5933aa83ad Merge remote-tracking branch 'remotes/origin/master' into develop 2023-02-09 12:27:46 +05:00
2e1854f6c1 Merge pull request #342 from ONLYOFFICE/fix/actions-on
fix: remove on develop pull request
2023-02-09 10:27:10 +03:00
2d9a7ed502 fix: remove on develop pull request 2023-02-09 11:49:50 +05:00
78bd037486 Merge pull request #340 from ONLYOFFICE/refactor/linter-formatting
Refactor/linter formatting
2023-02-09 09:31:32 +03:00
17beef45f4 php: linter to changelog 2023-02-09 11:30:13 +05:00
b11a1be481 php: PSR1.Files.SideEffects disabled in ruleset.xml 2023-02-09 09:16:46 +03:00
a3e140981d php: correct license type 2023-02-08 22:53:48 +05:00
e0386f7cf9 php: added licenses of new dependency (PHP_CodeSniffer) 2023-02-03 17:25:17 +03:00
0521f20413 php: deleted unused ruleset (uses - ruleset.xml) 2023-02-03 17:23:02 +03:00
61b5746ddf php: deleted dependency: cs-fixer 2023-02-03 17:17:40 +03:00
57d823acb1 Merge branch 'develop' into refactor/linter-formatting 2023-02-03 14:47:29 +03:00
4d99e2e406 php: example namespace for class User (users.php) added 2023-02-03 12:01:22 +03:00
bec48ed834 php: spaces in "mixed"-php files auto-fixed 2023-02-03 11:17:45 +03:00
e856f5bcb1 php: fixed spaces and new lines for multi-line functions 2023-02-03 11:06:05 +03:00
c57a710bca Merge pull request #339 from ONLYOFFICE/fix/phpcs-ruleset
ci: custom ruleset
2023-02-03 09:09:39 +03:00
248e9213a1 ci: custom ruleset 2023-02-03 11:06:55 +05:00
a035adcbd9 php: function names converted to camelCase (exclude mime_content_type) 2023-02-02 17:23:42 +03:00
7fd1b65fec php: fixed doc comments and multi-line assignments 2023-02-02 16:48:58 +03:00
8ee0aa45b9 php: line exceeds maximum limit of 120 characters 2023-02-02 15:28:05 +03:00
dfcf244dc8 php: comments for functions are standardized to PEAR Docblock Comment standards 2023-02-02 14:14:57 +03:00
0563795494 php: spaces and new lines around operators fixed 2023-02-02 11:27:14 +03:00
b6b6e80ffb php: no additional blank lines at end of doc comment 2023-02-02 10:53:15 +03:00
bd3b91d02f php: include/require and file path should be divided with a single space 2023-02-02 10:34:58 +03:00
555f8d43cd php: braces after functions and oop constructs on the next line 2023-02-01 16:46:31 +03:00
3f48a8d492 php: trailing whitespace at the end of blank line removed 2023-02-01 15:57:27 +03:00
bb921e7eff php: method argument spaces normalized 2023-02-01 14:48:48 +03:00
13d5e6fa94 php: binary operators should be surrounded by single space 2023-02-01 14:12:28 +03:00
cbfcf5de96 php: no spaces after function name 2023-02-01 14:06:41 +03:00
4771d96819 php: unary operators should be placed adjacent to their operands 2023-02-01 13:47:04 +03:00
d2aa6f0653 php: used null coalescing operator ?? where possible 2023-02-01 13:44:26 +03:00
cf2a00a374 php: used operator ?: where possible 2023-02-01 13:39:40 +03:00
bdfb75dc84 php: standardized spaces around ternary operator 2023-02-01 13:37:03 +03:00
9e21ca625c Merge pull request #334 from ONLYOFFICE/feature/token-and-address-required-on-download
Feature/token and address required on download
2023-02-01 12:59:22 +03:00
02def07f23 php: require user address on download 2023-02-01 14:30:54 +05:00
fc4dac6c4b java-spring: token and user address required on download 2023-02-01 14:29:52 +05:00
486a09f3b2 java: token and address required on download 2023-02-01 14:28:28 +05:00
9a22fc854b csharp-mvc: user address required on download 2023-02-01 14:27:32 +05:00
ac4d5561a2 c-sharp: user address required on download 2023-02-01 14:26:37 +05:00
98cdda06c4 ruby: user address required on download 2023-02-01 14:25:24 +05:00
744fccf913 python: user address required on download 2023-02-01 14:24:34 +05:00
349ff5d61d php: all classes must be final, except abstract ones and doctrine entities 2023-02-01 11:22:29 +03:00
dbba22df23 php: array_push() converted to short usage 2023-02-01 09:21:35 +03:00
2ddd822b24 php: replace non multibyte-safe functions with corresponding mb function 2023-02-01 09:09:58 +03:00
6b4d6baf4b php: short scalar cast 2023-01-31 17:29:58 +03:00
2c8d151cc7 php: there must be no trailing spaces inside comment or PHPDoc 2023-01-31 17:10:22 +03:00
60c7c025a3 Merge remote-tracking branch 'remotes/origin/hotfix/v7.3.1' into develop 2023-01-31 18:44:33 +05:00
7aaf5243cb Merge pull request #337 from ONLYOFFICE/feature/add-oform-parameter
nodejs: disable oform module
2023-01-31 16:15:43 +03:00
44b0f4d53d php: There must not be a space after the opening parenthesis 2023-01-31 16:05:35 +03:00
b765d43612 nodejs: disable oform module 2023-01-31 18:01:46 +05:00
70b63636e3 php: there must not be spaces around offset brace 2023-01-31 16:00:00 +03:00
8d4582e379 php: each statement must be indented 2023-01-31 15:54:07 +03:00
a1ec2cf366 php: remove trailing whitespace at the end of non-blank lines 2023-01-31 15:46:55 +03:00
4907e9d3c8 php: header comment needed 2023-01-31 15:43:37 +03:00
88f3d6da59 php: closing ?> tag must be omitted from files containing only PHP 2023-01-31 15:20:22 +03:00
481b111cb2 php: multi-line arrays must have a trailing comma 2023-01-31 15:14:01 +03:00
a1e13f3315 php: visibility must be declared on all methods 2023-01-31 14:58:18 +03:00
d1dd289c77 php: replace control structure alternative syntax to use braces 2023-01-31 14:52:04 +03:00
7b4e40c4e4 php: keyword elseif should be used instead of else if 2023-01-31 12:56:57 +03:00
6d4cad2215 php: curly opening braces after control structures and oop-structures on the same line 2023-01-31 12:31:33 +03:00
f43a4471ef php: whitespace after each comma in array declaration 2023-01-31 11:42:13 +03:00
0cf90e86c7 php: trim array spaces 2023-01-31 11:32:59 +03:00
406de99b01 php: single space or none should be between cast and variable 2023-01-31 10:30:26 +03:00
f4bcb15d33 php: each element of an array must be indented exactly once 2023-01-31 10:17:54 +03:00
d2a0164738 Merge branch 'refactor/linter-formatting' of https://github.com/ONLYOFFICE/document-server-integration into refactor/linter-formatting 2023-01-31 10:02:56 +03:00
a49ef4cc13 php: lower case for constants "true", "false" and "null" 2023-01-31 09:59:37 +03:00
3ca29cd402 Merge branch 'feature/deploy' into develop 2023-01-31 00:48:16 +05:00
c398b30e33 build: exclude packages from csharp examples 2023-01-31 00:45:02 +05:00
8caea9fab0 java: fix dockerfile path 2023-01-31 00:45:02 +05:00
f44c62540c php: lower case for constants "true", "false" and "null" 2023-01-30 17:33:48 +03:00
7644db80e3 php: no multiple statements per line 2023-01-30 17:26:31 +03:00
880497cd01 php: curly opening braces on the same line 2023-01-30 17:18:37 +03:00
34f8174d9d php: no mixed "print" and "echo" 2023-01-30 17:02:09 +03:00
99bc9d3fdf php: useless "else" deleted 2023-01-30 16:36:58 +03:00
165c292ab8 php: extra blank lines deleted 2023-01-30 16:26:04 +03:00
8fe41cd8e6 php: used short syntax for arrays 2023-01-30 15:23:00 +03:00
705ea097e2 php: used PSR-2 standart for linter 2023-01-30 14:56:32 +03:00
f4799bebb4 php: added needed dependencies 2023-01-30 14:42:05 +03:00
4ffa524de0 Merge pull request #336 from ONLYOFFICE/bugfix/java-dockerfile
java: fix dockerfile path
2023-01-30 13:16:21 +03:00
cd055317e0 java: fix dockerfile path 2023-01-30 09:46:27 +00:00
b1941c5980 Merge branch 'develop' of https://github.com/ONLYOFFICE/document-server-integration into develop 2023-01-30 08:58:52 +03:00
83bc0fed5e Merge remote-tracking branch 'remotes/origin/master' into develop 2023-01-27 18:54:25 +05:00
8b71bb0433 Merge pull request #335 from ONLYOFFICE/release/1.5.0
Release/1.5.0
2023-01-27 13:48:34 +03:00
5620f49f8f Merge pull request #321 from ONLYOFFICE/dependabot/bundler/web/documentserver-example/ruby/loofah-2.19.1
build(deps): bump loofah from 2.19.0 to 2.19.1 in /web/documentserver-example/ruby
2023-01-27 11:53:41 +03:00
d9fefef834 Merge branch 'develop' into dependabot/bundler/web/documentserver-example/ruby/loofah-2.19.1 2023-01-27 10:40:40 +03:00
37591d847c Merge pull request #323 from ONLYOFFICE/dependabot/bundler/web/documentserver-example/ruby/rails-html-sanitizer-1.4.4
build(deps): bump rails-html-sanitizer from 1.4.3 to 1.4.4 in /web/documentserver-example/ruby
2023-01-26 17:36:27 +03:00
77290d88f3 build(deps): bump rails-html-sanitizer
Bumps [rails-html-sanitizer](https://github.com/rails/rails-html-sanitizer) from 1.4.3 to 1.4.4.
- [Release notes](https://github.com/rails/rails-html-sanitizer/releases)
- [Changelog](https://github.com/rails/rails-html-sanitizer/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rails/rails-html-sanitizer/compare/v1.4.3...v1.4.4)

---
updated-dependencies:
- dependency-name: rails-html-sanitizer
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-26 19:35:36 +05:00
6befd87761 Merge pull request #330 from ONLYOFFICE/dependabot/bundler/web/documentserver-example/ruby/rack-2.2.6.2
build(deps): bump rack from 2.2.4 to 2.2.6.2 in /web/documentserver-example/ruby
2023-01-26 17:13:57 +03:00
f3e270c1ad Merge pull request #332 from ONLYOFFICE/dependabot/bundler/web/documentserver-example/ruby/globalid-1.0.1
build(deps): bump globalid from 1.0.0 to 1.0.1 in /web/documentserver-example/ruby
2023-01-26 17:13:11 +03:00
f5f1e4b391 Merge pull request #333 from ONLYOFFICE/bugfix/saving-file
Bugfix/saving file
2023-01-26 15:20:30 +03:00
8ba389d02f Merge pull request #328 from ONLYOFFICE/bugfix/php-example-warnings
php: empty GET parameters warnings fixed
2023-01-25 22:33:06 +03:00
45910ff1f3 php: empty GET parameters warnings fixed
Empty GET-parameters "user", "directUrl",  "fileUrl", "fileExt" no longer give a warning, the example can work without them.
2023-01-26 00:11:03 +05:00
3bd6f51edc 1.5.0 2023-01-24 00:55:41 +05:00
fe9791f03d Merge pull request #320 from ONLYOFFICE/feature/putRelativeFile
Feature/put relative file
2023-01-22 11:57:22 +03:00
531137dca4 nodejs: log X-WOPI-FileConversion header 2023-01-22 13:57:01 +05:00
e267b30b26 Merge remote-tracking branch 'remotes/origin/develop' into release/v7.3.0 2023-01-22 13:14:39 +05:00
8733baa04b Merge pull request #327 from ONLYOFFICE/dependabot/npm_and_yarn/web/documentserver-example/nodejs/jsonwebtoken-9.0.0
build(deps): bump jsonwebtoken from 8.5.1 to 9.0.0 in /web/documentserver-example/nodejs
2023-01-22 11:11:08 +03:00
8cec9fc465 Merge remote-tracking branch 'remotes/origin/develop' into release/v7.3.0 2023-01-22 12:57:46 +05:00
7ec969f4d9 ruby: check file availability when saving 2023-01-22 12:51:46 +05:00
c7e13ef8a8 python: check file availability when saving 2023-01-22 12:51:46 +05:00
3d488f89b2 java: check file availability when saving 2023-01-22 12:50:30 +05:00
cc00af1510 java-spring: check file availability when saving 2023-01-22 12:23:07 +05:00
f8aa55143c csharp: check file availability when saving 2023-01-22 02:16:20 +05:00
1b44c04893 csharp-mvc: check file availability when saving 2023-01-22 02:16:20 +05:00
1585d1821e Merge pull request #325 from ONLYOFFICE/refactor/java-linter
Refactor/java linter
2023-01-22 00:01:26 +03:00
e996c4d265 Merge remote-tracking branch 'remotes/origin/develop' into refactor/java-linter
# Conflicts:
#	web/documentserver-example/java/src/main/java/entities/CommentGroups.java
#	web/documentserver-example/java/src/main/java/helpers/TrackManager.java
2023-01-22 01:59:44 +05:00
cc0c6189bd Merge pull request #324 from ONLYOFFICE/refactor/java-spring-linter
Refactor/java spring linter
2023-01-21 23:47:25 +03:00
ef7662c069 java-spring: Header formatting 2023-01-22 01:46:01 +05:00
79ff84a4cc Merge remote-tracking branch 'remotes/origin/develop' into refactor/java-spring-linter
# Conflicts:
#	web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/callback/DefaultCallbackManager.java
#	web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/history/DefaultHistoryManager.java
#	web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/Template.java
#	web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/storage/FileStorageMutator.java
#	web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/storage/FileStoragePathBuilder.java
#	web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/util/Misc.java
#	web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/util/SSLUtils.java
#	web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/ChangesHistory.java
#	web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/ChangesUser.java
2023-01-22 01:40:46 +05:00
e4bab17b08 Merge pull request #326 from ONLYOFFICE/fix/java-spring-example-link
Java Spring example fix in Readme
2023-01-21 23:20:53 +03:00
c734f5dd69 Merge pull request #322 from ONLYOFFICE/feature/remove-parsing-url
Feature/remove parsing url
2023-01-21 22:14:07 +03:00
d79feca18c remove parsing url for getting ext 2023-01-22 00:11:47 +05:00
3181c7449d Copyright 2023 2023-01-20 15:27:03 +05:00
8ea2edefb9 python: apache (8050ec572a) 2023-01-20 15:25:28 +05:00
1a51759154 build(deps): bump globalid in /web/documentserver-example/ruby
Bumps [globalid](https://github.com/rails/globalid) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/rails/globalid/releases)
- [Commits](https://github.com/rails/globalid/compare/v1.0.0...v1.0.1)

---
updated-dependencies:
- dependency-name: globalid
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-19 23:00:11 +00:00
77c4caa26f Merge branch 'feature/referenceData' into release/v7.3.0
# Conflicts:
#	web/documentserver-example/nodejs/app.js
#	web/documentserver-example/nodejs/views/editor.ejs
2023-01-19 10:27:07 +05:00
5944e41cb4 Merge remote-tracking branch 'remotes/origin/develop' into release/v7.3.0 2023-01-19 10:26:40 +05:00
09ccde3f84 nodejs: token in referenceData 2023-01-19 10:25:28 +05:00
b27e532a83 nodejs: referenceData 2023-01-19 10:15:41 +05:00
e9632eb5e2 nodejs: fileType in empty history (a7db14811f) 2023-01-19 10:03:31 +05:00
8807328180 build(deps): bump rack in /web/documentserver-example/ruby
Bumps [rack](https://github.com/rack/rack) from 2.2.4 to 2.2.6.2.
- [Release notes](https://github.com/rack/rack/releases)
- [Changelog](https://github.com/rack/rack/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rack/rack/compare/2.2.4...v2.2.6.2)

---
updated-dependencies:
- dependency-name: rack
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-19 01:22:30 +00:00
827e96c506 Merge branch 'develop' into release/v7.3.0 2023-01-17 13:45:43 +05:00
491cbbc843 nodejs: require token on download 2023-01-17 13:45:29 +05:00
68d26c9c66 Merge branch 'release/v7.3.0' into feature/putRelativeFile 2023-01-14 12:26:35 +05:00
80924be536 Merge branch 'develop' into release/v7.3.0 2023-01-14 12:25:50 +05:00
0ca829181c nodejs: convert icon
# Conflicts:
#	web/documentserver-example/nodejs/views/wopiIndex.ejs
2023-01-14 12:24:53 +05:00
64f085d4b7 build(deps): bump jsonwebtoken in /web/documentserver-example/nodejs
Bumps [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) from 8.5.1 to 9.0.0.
- [Release notes](https://github.com/auth0/node-jsonwebtoken/releases)
- [Changelog](https://github.com/auth0/node-jsonwebtoken/blob/master/CHANGELOG.md)
- [Commits](https://github.com/auth0/node-jsonwebtoken/compare/v8.5.1...v9.0.0)

---
updated-dependencies:
- dependency-name: jsonwebtoken
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-11 03:15:32 +00:00
39c2267468 fixed commands for Java Spring example 2023-01-09 18:22:57 +03:00
22af4e097f java: MissingJavadocMethod suppress 2022-12-22 11:22:15 +03:00
1a1cde0f67 java: JavadocVariable suppress 2022-12-22 11:21:14 +03:00
1265ecdee1 java-spring: removed constant EXT_LENGTH_PART 2022-12-22 11:18:18 +03:00
19d11a97f9 java-spring: MissingJavadocMethod suppress 2022-12-22 11:15:58 +03:00
bf6f3373a6 java-spring: JavadocVariable suppress 2022-12-22 11:14:51 +03:00
1fb4d759a3 java-spring: JavadocPackage suppress 2022-12-22 10:49:28 +03:00
de33efa599 java: suppress JavadocPackage 2022-12-22 10:25:00 +03:00
6fa150ade6 java-spring: LineLength formatting 2022-12-22 09:49:09 +03:00
88f4b6327d java-spring: changing LineLength rules 2022-12-22 01:45:17 +03:00
82905fca6c java: LineLength formatting 2022-12-22 01:39:33 +03:00
ccb67ad73d java: changing fileExtensions rules
Max length lines is 120
2022-12-21 17:30:38 +03:00
5a233b8dc7 Revert "java: adding check files by ext"
This reverts commit 8924304bdb.
2022-12-21 17:00:40 +03:00
127183bb16 java: Header formatting 2022-12-21 16:55:10 +03:00
8924304bdb java: adding check files by ext 2022-12-21 16:51:09 +03:00
68dd1fc369 java: filling onlyoffice.header 2022-12-21 16:49:47 +03:00
7251cb1681 java: enable Header rule with template 2022-12-21 16:41:47 +03:00
a82e4b6bdf java: AvoidStarImport formatting 2022-12-21 16:36:32 +03:00
d2f2031fa7 java: HideUtilityClassConstructor formatting 2022-12-21 16:31:04 +03:00
4a902dff94 java: VisibilityModifier formatting 2022-12-21 16:22:54 +03:00
f26220683c java: MagicNumber formatting 2022-12-21 13:14:47 +03:00
c3e4533d1a java: suppress DesignForExtension 2022-12-21 12:15:00 +03:00
f6618c8c92 java: suppress ParameterNumber 2022-12-21 12:14:11 +03:00
efd710c6c0 java: added checkstyle-suppressions.xml 2022-12-21 12:12:06 +03:00
e106677efb java: FinalParameters formatting 2022-12-21 12:08:52 +03:00
ecd02e07c0 java: HiddenField formatting 2022-12-21 11:36:42 +03:00
847902fad9 java: ConstantName formatting 2022-12-21 11:29:45 +03:00
d4b5f86822 java: LocalVariableName formatting 2022-12-21 11:24:50 +03:00
7c35d8127d java: MethodName formatting 2022-12-21 11:03:59 +03:00
d023b23fc9 java: StaticVariableName formatting 2022-12-20 22:04:46 +03:00
8b10c5ac2e java: RegexpSingleline formatting 2022-12-20 22:00:15 +03:00
54bc536329 java: MethodParamPad formatting 2022-12-20 21:54:33 +03:00
07d7e5d887 java: ParenPad formatting 2022-12-20 21:50:49 +03:00
009577b52e java: NoWhitespaceAfter formatting 2022-12-20 21:49:05 +03:00
c1fd896be4 java: WhitespaceAfter formatting 2022-12-20 21:45:04 +03:00
033126583b java: WhitespaceAround formatting 2022-12-20 21:40:20 +03:00
3140d31e9c java: UpperEll formatting 2022-12-20 19:18:05 +03:00
92ea5151ad java: ParameterName formatting 2022-12-20 19:16:33 +03:00
ae4e4c14ad java: OperatorWrap formatting 2022-12-20 19:14:57 +03:00
9a9d3c0b35 java: NewlineAtEndOfFile formatting 2022-12-20 19:12:53 +03:00
13d3fe97d9 java: RightCurly formatting 2022-12-20 19:10:43 +03:00
5bfe32f796 java: MemberName formatting 2022-12-20 19:05:07 +03:00
5a1ad9139f java: SimplifyBooleanExpression formatting 2022-12-20 19:00:54 +03:00
91fbc384f3 java: MissingSwitchDefault formatting 2022-12-20 18:58:27 +03:00
9d275ebe6c java: NeedBraces formatting 2022-12-20 18:56:18 +03:00
09a5d802ec java: InnerAssignment formatting 2022-12-20 18:30:27 +03:00
b548ffb97e java: LeftCurly formatting 2022-12-20 18:23:24 +03:00
50b0c3d29e java: UnusedImports formatting 2022-12-20 16:40:47 +03:00
93b4560c31 java: EmptyBlock formatting 2022-12-20 16:38:24 +03:00
2e9807814a java: used custom checkstyle rules 2022-12-20 16:36:48 +03:00
d0cfd03bf8 java: updated maven-checkstyle-plugin to 3.2.0 2022-12-20 16:34:51 +03:00
72c14a4e7b java: used oracle rules for linter 2022-12-20 16:16:51 +03:00
44a3f29a79 java-spring: Header formatting 2022-12-20 12:09:37 +03:00
98dceacc4c java-spring: add header rule template 2022-12-20 12:08:50 +03:00
05f4063ba6 java-spring: enable Header rule 2022-12-20 12:07:19 +03:00
d5797f7c02 java-spring: HiddenField formatting 2022-12-20 11:41:06 +03:00
5f40faac2a java-spring: AvoidStarImport formatting 2022-12-20 11:34:36 +03:00
c062e554db java-spring: suppress ParameterNumber 2022-12-20 11:23:42 +03:00
41e44985d6 java-spring: suppress DesignForExtension 2022-12-20 11:22:35 +03:00
95e1135e86 java-spring: MagicNumber formatting 2022-12-20 11:18:57 +03:00
cafb79c8d5 java-spring: RegexpSingleline formatting 2022-12-19 18:50:55 +03:00
1dbc275a57 java-spring: FinalParameters formatting 2022-12-19 18:46:30 +03:00
6dd44d2094 java-spring: WhitespaceAfter formatting 2022-12-19 16:20:47 +03:00
b74a3c5565 java-spring: LocalVariableName formatting 2022-12-19 15:41:06 +03:00
27e5fa8482 java-spring: MemberName formatting 2022-12-19 12:35:04 +03:00
46dab40432 java-spring: UpperEll formatting 2022-12-19 12:27:20 +03:00
ebd4ead751 java-spring: NoWhitespaceAfter formatting 2022-12-19 12:23:37 +03:00
9014f96da3 java-spring: FileTabCharacter formatting 2022-12-19 12:19:59 +03:00
273e4d5b77 java-spring: OperatorWrap formatting 2022-12-19 12:14:07 +03:00
d8b6cdcf78 java-spring: TodoComment formatting 2022-12-19 11:57:33 +03:00
6e0899daaf java-spring: NewlineAtEndOfFile formatting 2022-12-19 11:49:15 +03:00
a5d459a744 java-spring: ParenPad formatting 2022-12-19 11:43:41 +03:00
dcb48f3849 java-spring: VisibilityModifier formatting 2022-12-19 11:36:09 +03:00
c8b3ed761e java-spring: WhitespaceAround formatting 2022-12-19 11:23:28 +03:00
01c8b23d1d java-spring: suppress HideUtilityClassConstructor 2022-12-16 16:32:16 +03:00
bf9373842b java-spring: added checkstyle-suppressions.xml 2022-12-16 16:30:19 +03:00
7eaf4f5ae7 java-spring: SimplifyBooleanExpression formatting 2022-12-16 16:22:22 +03:00
e09f258f25 java-spring: EqualsHashCode formatting 2022-12-16 16:16:17 +03:00
054e144d93 java-spring: EmptyStatement formatting 2022-12-16 16:12:00 +03:00
3b698eb974 java-spring: RightCurly formatting 2022-12-16 16:11:11 +03:00
c356d952be java-spring: LeftCurly formatting 2022-12-16 16:04:04 +03:00
b1f3704624 java-spring: NeedBraces formatting 2022-12-16 15:47:51 +03:00
1dd545dc9c java-spring: removed nested blocks 2022-12-16 15:07:25 +03:00
1f6dfb0677 java-spring: removed unused imports 2022-12-16 15:03:26 +03:00
b59874f54b java-spring: updated maven-checkstyle-plugin to 3.2.0 2022-12-16 14:46:43 +03:00
4d9f02c606 java-spring: used oracle rules for linter 2022-12-16 14:37:13 +03:00
ca49e5bdda build(deps): bump loofah in /web/documentserver-example/ruby
Bumps [loofah](https://github.com/flavorjones/loofah) from 2.19.0 to 2.19.1.
- [Release notes](https://github.com/flavorjones/loofah/releases)
- [Changelog](https://github.com/flavorjones/loofah/blob/main/CHANGELOG.md)
- [Commits](https://github.com/flavorjones/loofah/compare/v2.19.0...v2.19.1)

---
updated-dependencies:
- dependency-name: loofah
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-13 20:48:42 +00:00
fdefc25479 Merge branch 'release/v7.3.0' into feature/putRelativeFile
# Conflicts:
#	web/documentserver-example/nodejs/views/wopiIndex.ejs
2022-12-12 17:34:05 +03:00
df83585352 nodejs: putRelativeFile to changelog 2022-12-09 14:37:35 +03:00
6979ec815e Merge remote-tracking branch 'remotes/origin/release/v7.3.0' into feature/putRelativeFile
# Conflicts:
#	web/documentserver-example/nodejs/views/wopiIndex.ejs
2022-12-09 14:36:02 +03:00
96a9dd7990 [wopi] proper putRelativeFile realizaion 2022-12-09 13:35:45 +03:00
91d8fc2487 [wopi] Add putRelativeFile handler 2022-12-09 13:35:12 +03:00
ae64081f97 nodejs: convert icon 2022-12-09 11:44:06 +03:00
275 changed files with 6371 additions and 3656 deletions

View File

@ -6,7 +6,7 @@ on:
branches: [master, main]
paths: ['web/documentserver-example/java/**']
pull_request:
branches: [master, main, develop]
branches: [master, main]
paths: ['web/documentserver-example/java/**']
jobs:

View File

@ -6,7 +6,7 @@ on:
branches: [master, main]
paths: ['web/documentserver-example/nodejs/**']
pull_request:
branches: [master, main, develop]
branches: [master, main]
paths: ['web/documentserver-example/nodejs/**']
env:

View File

@ -6,7 +6,7 @@ on:
branches: [master, main]
paths: ['web/documentserver-example/php/**']
pull_request:
branches: [master, main, develop]
branches: [master, main]
paths: ['web/documentserver-example/php/**']
jobs:
@ -22,8 +22,10 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: cs2pr, phpcs
- name: Run phpcs
run: phpcs -q --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml --ignore=node_modules,bower_components,vendor ./
run: |
phpcs --version
phpcs -q --extensions=php,module,inc,install,test,profile,theme,info --ignore=node_modules,bower_components,vendor,css,js,lib --standard=./ruleset.xml ./

View File

@ -6,7 +6,7 @@ on:
branches: [master, main]
paths: ['web/documentserver-example/python/**']
pull_request:
branches: [master, main, develop]
branches: [master, main]
paths: ['web/documentserver-example/python/**']
jobs:

View File

@ -6,7 +6,7 @@ on:
branches: [master, main]
paths: ['web/documentserver-example/ruby/**']
pull_request:
branches: [master, main, develop]
branches: [master, main]
paths: ['web/documentserver-example/ruby/**']
jobs:

View File

@ -6,7 +6,7 @@ on:
branches: [master, main]
paths: ['web/documentserver-example/java-spring/**']
pull_request:
branches: [master, main, develop]
branches: [master, main]
paths: ['web/documentserver-example/java-spring/**']
jobs:

View File

@ -250,6 +250,14 @@ jQuery.UI - jQuery UI is an open source library of interface components —
License: MIT
License File: jQuery.UI.license
JWT - JSON Web Token implementation (https://github.com/firebase/php-jwt/blob/master/LICENSE)
License: BSD-3-Clause
License File: jwt.license
PHP_CodeSniffer - PHP_CodeSniffer is a set of two PHP scripts; the main phpcs script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second phpcbf script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent. (https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt)
License: BSD-3-Clause
License File: PHP_CodeSniffer.license
web/documentserver-example/ruby

View File

@ -1,5 +1,9 @@
# Change Log
- php: linter refactoring
## 1.5.0
- nodejs: added wopi putRelativeFile action
- nodejs: wopi editnew action for exisiting file
- nodejs: fix wopi actions after restart
- setting an unavailable language

View File

@ -26,13 +26,13 @@
<RemoveDir Directories="$(To)" ContinueOnError="true" />
<ItemGroup>
<ZipFilesCSharp Include="$(DirCSharp)**" Exclude="$(DirCSharp)obj\**;$(DirCSharp)**\.git" />
<ZipFilesCSharp Include="$(DirCSharp)**" Exclude="$(DirCSharp).vs\**;$(DirCSharp)bin\*.pdb;$(DirCSharp)bin\*.xml;$(DirCSharp)obj\**;$(DirCSharp)packages\**;$(DirCSharp)**\.git" />
</ItemGroup>
<Copy SourceFiles="@(ZipFilesCSharp)" DestinationFiles="@(ZipFilesCSharp->'$(NameCSharp)\%(RecursiveDir)%(Filename)%(Extension)')" />
<Zip Files="$(NameCSharp)" WorkingDirectory="$(To)" ZipFileName="$(NameCSharp).zip" />
<ItemGroup>
<ZipFilesMVC Include="$(DirMvc)**" Exclude="$(DirMvc)obj\**;$(DirMvc)**\.git" />
<ZipFilesMVC Include="$(DirMvc)**" Exclude="$(DirMvc).vs\**;$(DirMvc)bin\*.pdb;$(DirMvc)bin\*.xml;$(DirMvc)obj\**;$(DirMvc)packages\**;$(DirMvc)**\.git" />
</ItemGroup>
<Copy SourceFiles="@(ZipFilesMVC)" DestinationFiles="@(ZipFilesMVC->'$(NameMvc)\%(RecursiveDir)%(Filename)%(Extension)')" />
<Zip Files="$(NameMvc)" WorkingDirectory="$(To)" ZipFileName="$(NameMvc).zip" />

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,4 +1,22 @@
@media (min-width: 1280px) and (max-width: 1380px) {
/**
*
* (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.
*
*/
@media (min-width: 1280px) and (max-width: 1380px) {
.copy {
margin-right: 6.5%;
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -98,9 +98,7 @@ namespace OnlineEditorsExampleMVC.Helpers
var downloadUri = (string)fileData["url"];
string curExt = Path.GetExtension(fileName).ToLower(); // get current file extension
var downloadExt = fileData.ContainsKey("filetype")
? "." + (string)fileData["filetype"]
: Path.GetExtension(downloadUri).ToLower() ?? ""; // TODO: Delete in version 7.0 or higher. Support for versions below 7.0
var downloadExt = "." + (string)fileData["filetype"]; // get the extension of the downloaded file
var newFileName = fileName;
@ -130,37 +128,48 @@ namespace OnlineEditorsExampleMVC.Helpers
DocManagerHelper.VerifySSL();
var storagePath = DocManagerHelper.StoragePath(newFileName, userAddress); // get the file path
var histDir = DocManagerHelper.HistoryDir(storagePath); // get the path to the history directory
if (!Directory.Exists(histDir)) Directory.CreateDirectory(histDir);
var versionDir = DocManagerHelper.VersionDir(histDir, DocManagerHelper.GetFileVersion(histDir)); // get the path to the file version
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir); // if the path doesn't exist, create it
// get the path to the previous file version and move it to the storage directory
File.Move(DocManagerHelper.StoragePath(fileName, userAddress), Path.Combine(versionDir, "prev" + curExt));
DownloadToFile(downloadUri, storagePath); // save file to the storage directory
DownloadToFile((string)fileData["changesurl"], Path.Combine(versionDir, "diff.zip")); // save file changes to the diff.zip archive
var hist = fileData.ContainsKey("changeshistory") ? (string)fileData["changeshistory"] : null;
if (string.IsNullOrEmpty(hist) && fileData.ContainsKey("history"))
try
{
var jss = new JavaScriptSerializer();
hist = jss.Serialize(fileData["history"]);
}
var bytesFile = DownloadFile(downloadUri); // download document file
var storagePath = DocManagerHelper.StoragePath(newFileName, userAddress); // get the file path
if (!string.IsNullOrEmpty(hist))
var histDir = DocManagerHelper.HistoryDir(storagePath); // get the path to the history directory
if (!Directory.Exists(histDir)) Directory.CreateDirectory(histDir);
var versionDir = DocManagerHelper.VersionDir(histDir, DocManagerHelper.GetFileVersion(histDir)); // get the path to the file version
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir); // if the path doesn't exist, create it
// get the path to the previous file version and move it to the storage directory
File.Move(DocManagerHelper.StoragePath(fileName, userAddress), Path.Combine(versionDir, "prev" + curExt));
SaveFile(bytesFile, storagePath);// save document file
byte[] bytesChanges = DownloadFile((string)fileData["changesurl"]); // download changes file
SaveFile(bytesChanges, Path.Combine(versionDir, "diff.zip")); // save file changes to the diff.zip archive
var hist = fileData.ContainsKey("changeshistory") ? (string)fileData["changeshistory"] : null;
if (string.IsNullOrEmpty(hist) && fileData.ContainsKey("history"))
{
var jss = new JavaScriptSerializer();
hist = jss.Serialize(fileData["history"]);
}
if (!string.IsNullOrEmpty(hist))
{
File.WriteAllText(Path.Combine(versionDir, "changes.json"), hist); // write the history changes to the changes.json file
}
File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]); // write the key value to the key.txt file
string forcesavePath = DocManagerHelper.ForcesavePath(newFileName, userAddress, false); // get the path to the forcesaved file version
if (!forcesavePath.Equals("")) // if the forcesaved file version exists
{
File.Delete(forcesavePath); // remove it
}
} catch (Exception)
{
File.WriteAllText(Path.Combine(versionDir, "changes.json"), hist); // write the history changes to the changes.json file
}
File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]); // write the key value to the key.txt file
string forcesavePath = DocManagerHelper.ForcesavePath(newFileName, userAddress, false); // get the path to the forcesaved file version
if (!forcesavePath.Equals("")) // if the forcesaved file version exists
{
File.Delete(forcesavePath); // remove it
return 1;
}
return 0;
@ -176,9 +185,7 @@ namespace OnlineEditorsExampleMVC.Helpers
string curExt = Path.GetExtension(fileName).ToLower(); // get current file extension
var downloadExt = fileData.ContainsKey("filetype")
? "." + (string)fileData["filetype"]
: Path.GetExtension(downloadUri).ToLower(); // TODO: Delete in version 7.0 or higher. Support for versions below 7.0
var downloadExt = "." + (string)fileData["filetype"]; // get the extension of the downloaded file
Boolean newFileName = false;
@ -206,43 +213,51 @@ namespace OnlineEditorsExampleMVC.Helpers
}
DocManagerHelper.VerifySSL();
string forcesavePath = "";
Boolean isSubmitForm = fileData["forcesavetype"].ToString().Equals("3"); // SubmitForm
if (isSubmitForm) // if the form is submitted
try
{
if (newFileName)
var bytesFile = DownloadFile(downloadUri); // download document file
string forcesavePath = "";
Boolean isSubmitForm = fileData["forcesavetype"].ToString().Equals("3"); // SubmitForm
if (isSubmitForm) // if the form is submitted
{
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + downloadExt, userAddress); // get the correct file name if it already exists
if (newFileName)
{
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + downloadExt, userAddress); // get the correct file name if it already exists
} else
{
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + curExt, userAddress);
{
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + curExt, userAddress);
}
forcesavePath = DocManagerHelper.StoragePath(fileName, userAddress);
}
forcesavePath = DocManagerHelper.StoragePath(fileName, userAddress);
}
else
{
if (newFileName)
else
{
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
}
forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, false);
if (newFileName)
{
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
}
forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, false);
if (string.IsNullOrEmpty(forcesavePath)) // create forcesave path if it doesn't exist
{
forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, true);
{
forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, true);
}
}
}
DownloadToFile(downloadUri, forcesavePath);
SaveFile(bytesFile, forcesavePath);// save document file
if (isSubmitForm)
if (isSubmitForm)
{
var jss = new JavaScriptSerializer();
var actions = jss.Deserialize<List<object>>(jss.Serialize(fileData["actions"]));
var action = jss.Deserialize<Dictionary<string, object>>(jss.Serialize(actions[0]));
var user = action["userid"].ToString(); // get the user id
DocManagerHelper.CreateMeta(fileName, user, "Filling Form", userAddress); // create meta data for the forcesaved file
}
} catch (Exception)
{
var jss = new JavaScriptSerializer();
var actions = jss.Deserialize<List<object>>(jss.Serialize(fileData["actions"]));
var action = jss.Deserialize<Dictionary<string, object>>(jss.Serialize(actions[0]));
var user = action["userid"].ToString(); // get the user id
DocManagerHelper.CreateMeta(fileName, user, "Filling Form", userAddress); // create meta data for the forcesaved file
return 1;
}
return 0;
@ -314,27 +329,30 @@ namespace OnlineEditorsExampleMVC.Helpers
}
}
// save file
private static void SaveFile(byte[] data, string path)
{
using (var fs = File.Open(path, FileMode.Create))
{
fs.Write(data, 0, data.Length);
}
}
// save file information from the url to the file specified
private static void DownloadToFile(string url, string path)
private static byte[] DownloadFile(string url)
{
if (string.IsNullOrEmpty(url)) throw new ArgumentException("url"); // url isn't specified
if (string.IsNullOrEmpty(path)) throw new ArgumentException("path"); // file isn't specified
var req = (HttpWebRequest)WebRequest.Create(url);
req.Timeout = 5000;
using (var stream = req.GetResponse().GetResponseStream()) // get input stream of the file information from the url
{
if (stream == null) throw new Exception("stream is null");
const int bufferSize = 4096;
using (var fs = File.Open(path, FileMode.Create))
using (MemoryStream memoryStream = new MemoryStream())
{
var buffer = new byte[bufferSize];
int readed;
while ((readed = stream.Read(buffer, 0, bufferSize)) != 0)
{
fs.Write(buffer, 0, readed); // write bytes to the output stream
}
stream.CopyTo(memoryStream);
return memoryStream.ToArray();
}
}
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,4 +1,22 @@
using System.Web;
/**
*
* (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.
*
*/
using System.Web;
namespace OnlineEditorsExampleMVC.Helpers
{

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Ascensio System SIA")]
[assembly: AssemblyProduct("OnlineEditorsExampleMVC")]
[assembly: AssemblyCopyright("Ascensio System SIA 2021")]
[assembly: AssemblyCopyright("Ascensio System SIA 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -14,7 +14,7 @@
<meta name="mobile-web-app-capable" content="yes" />
<!--
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -15,7 +15,7 @@
<meta name="viewport" content="width=device-width" />
<!--
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width" />
<!--
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -461,20 +461,21 @@ namespace OnlineEditorsExampleMVC
var userAddress = context.Request["userAddress"];
var isEmbedded = context.Request["dmode"];
if (JwtManager.Enabled && isEmbedded == null)
if (JwtManager.Enabled && isEmbedded == null && userAddress != null)
{
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
string token = "";
if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase))
{
var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length);
string token = JwtManager.Decode(headerToken);
if (string.IsNullOrEmpty(token))
{
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
context.Response.Write("JWT validation failed");
return;
}
token = JwtManager.Decode(headerToken);
}
if (string.IsNullOrEmpty(token))
{
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
context.Response.Write("JWT validation failed");
return;
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<appSettings>
<clear />
<add key="version" value="1.4.0"/>
<add key="version" value="1.5.0"/>
<add key="filesize-max" value="52428800"/>
<add key="storage-path" value=""/>

View File

@ -1,4 +1,22 @@
@media (min-width: 1280px) and (max-width: 1380px) {
/**
*
* (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.
*
*/
@media (min-width: 1280px) and (max-width: 1380px) {
.copy {
margin-right: 6.5%;
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -16,7 +16,7 @@
<title>ONLYOFFICE</title>
<!--
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -15,7 +15,7 @@
<title>ONLYOFFICE</title>
<!--
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Ascensio System SIA")]
[assembly: AssemblyProduct("OnlineEditorsExample")]
[assembly: AssemblyCopyright("Ascensio System SIA 2021")]
[assembly: AssemblyCopyright("Ascensio System SIA 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -100,9 +100,7 @@ namespace OnlineEditorsExample
var downloadUri = (string)fileData["url"];
var curExt = Path.GetExtension(fileName).ToLower(); // get current file extension
var downloadExt = fileData.ContainsKey("filetype")
? "." + (string)fileData["filetype"]
: Path.GetExtension(downloadUri).ToLower() ?? ""; // TODO: Delete in version 7.0 or higher. Support for versions below 7.0
var downloadExt = "." + (string)fileData["filetype"]; // get the extension of the downloaded file
var newFileName = fileName;
@ -132,37 +130,48 @@ namespace OnlineEditorsExample
_Default.VerifySSL();
var storagePath = _Default.StoragePath(newFileName, userAddress); // get the file path
var histDir = _Default.HistoryDir(storagePath); // get the path to the history directory
if (!Directory.Exists(histDir)) Directory.CreateDirectory(histDir);
var versionDir = _Default.VersionDir(histDir, _Default.GetFileVersion(histDir)); // get the path to the file version
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir); // if the path doesn't exist, create it
// get the path to the previous file version and rename the storage path with it
File.Copy(_Default.StoragePath(fileName, userAddress), Path.Combine(versionDir, "prev" + curExt));
DownloadToFile(downloadUri, storagePath); // save file to the storage directory
DownloadToFile((string)fileData["changesurl"], Path.Combine(versionDir, "diff.zip")); // save file changes to the diff.zip archive
var hist = fileData.ContainsKey("changeshistory") ? (string)fileData["changeshistory"] : null;
if (string.IsNullOrEmpty(hist) && fileData.ContainsKey("history"))
try
{
var jss = new JavaScriptSerializer();
hist = jss.Serialize(fileData["history"]);
}
var bytesFile = DownloadFile(downloadUri); // download document file
var storagePath = _Default.StoragePath(newFileName, userAddress); // get the file path
if (!string.IsNullOrEmpty(hist))
{
File.WriteAllText(Path.Combine(versionDir, "changes.json"), hist); // write the history changes to the changes.json file
}
var histDir = _Default.HistoryDir(storagePath); // get the path to the history directory
if (!Directory.Exists(histDir)) Directory.CreateDirectory(histDir);
File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]); // write the key value to the key.txt file
var versionDir = _Default.VersionDir(histDir, _Default.GetFileVersion(histDir)); // get the path to the file version
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir); // if the path doesn't exist, create it
string forcesavePath = _Default.ForcesavePath(newFileName, userAddress, false); // get the path to the forcesaved file version
// get the path to the previous file version and rename the storage path with it
File.Copy(_Default.StoragePath(fileName, userAddress), Path.Combine(versionDir, "prev" + curExt));
SaveFile(bytesFile, storagePath);// save document file
var bytesChanges = DownloadFile((string)fileData["changesurl"]); // download changes file
SaveFile(bytesChanges, Path.Combine(versionDir, "diff.zip")); // save file changes to the diff.zip archive
var hist = fileData.ContainsKey("changeshistory") ? (string)fileData["changeshistory"] : null;
if (string.IsNullOrEmpty(hist) && fileData.ContainsKey("history"))
{
var jss = new JavaScriptSerializer();
hist = jss.Serialize(fileData["history"]);
}
if (!string.IsNullOrEmpty(hist))
{
File.WriteAllText(Path.Combine(versionDir, "changes.json"), hist); // write the history changes to the changes.json file
}
File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]); // write the key value to the key.txt file
string forcesavePath = _Default.ForcesavePath(newFileName, userAddress, false); // get the path to the forcesaved file version
if (!string.IsNullOrEmpty(forcesavePath)) // if the forcesaved file version exists
{
File.Delete(forcesavePath); // remove it
}
}
catch (Exception)
{
File.Delete(forcesavePath); // remove it
return 1;
}
return 0;
@ -178,9 +187,7 @@ namespace OnlineEditorsExample
string curExt = Path.GetExtension(fileName).ToLower(); // get current file extension
var downloadExt = fileData.ContainsKey("filetype")
? "." + (string)fileData["filetype"]
: Path.GetExtension(downloadUri).ToLower(); // TODO: Delete in version 7.0 or higher. Support for versions below 7.0
var downloadExt = "." + (string)fileData["filetype"]; // get the extension of the downloaded file
Boolean newFileName = false;
@ -209,43 +216,51 @@ namespace OnlineEditorsExample
_Default.VerifySSL();
string forcesavePath = "";
Boolean isSubmitForm = fileData["forcesavetype"].ToString().Equals("3"); // SubmitForm
if (isSubmitForm) // if the form is submitted
try
{
if (newFileName)
var bytesFile = DownloadFile(downloadUri); // download document file
string forcesavePath = "";
Boolean isSubmitForm = fileData["forcesavetype"].ToString().Equals("3"); // SubmitForm
if (isSubmitForm) // if the form is submitted
{
fileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + downloadExt, userAddress); // get the correct file name if it already exists
if (newFileName)
{
fileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + downloadExt, userAddress); // get the correct file name if it already exists
} else
{
fileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + curExt, userAddress);
{
fileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + "-form" + curExt, userAddress);
}
forcesavePath = _Default.StoragePath(fileName, userAddress);
}
forcesavePath = _Default.StoragePath(fileName, userAddress);
}
else
{
if (newFileName)
else
{
fileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
}
if (newFileName)
{
fileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
}
forcesavePath = _Default.ForcesavePath(fileName, userAddress, false);
forcesavePath = _Default.ForcesavePath(fileName, userAddress, false);
if (string.IsNullOrEmpty(forcesavePath)) // create forcesave path if it doesn't exist
{
forcesavePath = _Default.ForcesavePath(fileName, userAddress, true);
}
}
SaveFile(bytesFile, forcesavePath);// save document file
if (isSubmitForm)
{
forcesavePath = _Default.ForcesavePath(fileName, userAddress, true);
var jss = new JavaScriptSerializer();
var actions = jss.Deserialize<List<object>>(jss.Serialize(fileData["actions"]));
var action = jss.Deserialize<Dictionary<string, object>>(jss.Serialize(actions[0]));
var user = action["userid"].ToString(); // get the user id
DocEditor.CreateMeta(fileName, user, "Filling Form", userAddress); // create meta data for the forcesaved file
}
}
DownloadToFile(downloadUri, forcesavePath);
if (isSubmitForm)
catch (Exception)
{
var jss = new JavaScriptSerializer();
var actions = jss.Deserialize<List<object>>(jss.Serialize(fileData["actions"]));
var action = jss.Deserialize<Dictionary<string, object>>(jss.Serialize(actions[0]));
var user = action["userid"].ToString(); // get the user id
DocEditor.CreateMeta(fileName, user, "Filling Form", userAddress); // create meta data for the forcesaved file
return 1;
}
return 0;
@ -317,27 +332,29 @@ namespace OnlineEditorsExample
}
}
private static void SaveFile(byte[] data, string path)
{
using (var fs = File.Open(path, FileMode.Create))
{
fs.Write(data, 0, data.Length);
}
}
// save file information from the url to the file specified
private static void DownloadToFile(string url, string path)
private static byte[] DownloadFile(string url)
{
if (string.IsNullOrEmpty(url)) throw new ArgumentException("url"); // url isn't specified
if (string.IsNullOrEmpty(path)) throw new ArgumentException("path"); // file isn't specified
var req = (HttpWebRequest)WebRequest.Create(url);
req.Timeout = 5000;
using (var stream = req.GetResponse().GetResponseStream()) // get input stream of the file information from the url
{
if (stream == null) throw new Exception("stream is null");
const int bufferSize = 4096;
using (var fs = File.Open(path, FileMode.Create))
using (MemoryStream memoryStream = new MemoryStream())
{
var buffer = new byte[bufferSize];
int readed;
while ((readed = stream.Read(buffer, 0, bufferSize)) != 0)
{
fs.Write(buffer, 0, readed); // write bytes to the output stream
}
stream.CopyTo(memoryStream);
return memoryStream.ToArray();
}
}
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,4 +1,22 @@
using System.Web;
/**
*
* (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.
*
*/
using System.Web;
namespace OnlineEditorsExample
{

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -281,21 +281,21 @@ namespace OnlineEditorsExample
var userAddress = Path.GetFileName(context.Request["userAddress"]);
var isEmbedded = context.Request["dmode"];
if (JwtManager.Enabled && isEmbedded == null)
if (JwtManager.Enabled && isEmbedded == null && userAddress != null)
{
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
string token = "";
if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase))
{
var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length);
string token = JwtManager.Decode(headerToken);
if (string.IsNullOrEmpty(token))
{
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
context.Response.Write("JWT validation failed");
return;
}
token = JwtManager.Decode(headerToken);
}
if (string.IsNullOrEmpty(token))
{
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
context.Response.Write("JWT validation failed");
return;
}
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<clear />
<add key="version" value="1.4.0"/>
<add key="version" value="1.5.0"/>
<add key="filesize-max" value="52428800"/>
<add key="storage-path" value=""/>

View File

@ -139,11 +139,11 @@ See the detailed guide to learn how to install Document Server [for Linux](https
a) archive with Java-Spring:
```
wget https://api.onlyoffice.com/app_data/editor/Java-Spring%20Example.zip
wget https://api.onlyoffice.com/app_data/editor/Java%20Spring%20Example.zip
```
```
unzip Java-Spring\ Example.zip
unzip Java\ Spring\ Example.zip
```
b) git repository:
```
@ -156,7 +156,7 @@ See the detailed guide to learn how to install Document Server [for Linux](https
a) from archive
```
cd Java-Spring\ Example/
cd Java\ Spring\ Example/
```
b) from git repository
```

View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.0//EN"
"https://checkstyle.org/dtds/suppressions_1_0.dtd">
<suppressions>
<suppress checks="HideUtilityClassConstructor" files="IntegrationApplication.java"/>
<suppress checks="DesignForExtension" files="."/>
<suppress checks="ParameterNumber" files="."/>
<suppress checks="JavadocPackage" files="."/>
<suppress checks="JavadocVariable" files="."/>
<suppress checks="MissingJavadocMethod" files="."/>
</suppressions>

View File

@ -0,0 +1,199 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration that checks the sun coding conventions from:
- the Java Language Specification at
https://docs.oracle.com/javase/specs/jls/se11/html/index.html
- the Sun Code Conventions at https://www.oracle.com/java/technologies/javase/codeconventions-contents.html
- the Javadoc guidelines at
https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html
- the JDK Api documentation https://docs.oracle.com/en/java/javase/11/
- some best practices
Checkstyle is very configurable. Be sure to read the documentation at
https://checkstyle.org (or in your downloaded distribution).
Most Checks are configurable, be sure to consult the documentation.
To completely disable a check, just comment it out or delete it from the file.
To suppress certain violations please review suppression filters.
Finally, it is worth reading the documentation.
-->
<module name="Checker">
<!--
If you set the basedir property below, then all reported file
names will be relative to the specified directory. See
https://checkstyle.org/config.html#Checker
<property name="basedir" value="${basedir}"/>
-->
<property name="severity" value="error"/>
<property name="fileExtensions" value="java, properties, xml"/>
<!-- Excludes all 'module-info.java' files -->
<!-- See https://checkstyle.org/config_filefilters.html -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
<module name="SuppressionFilter">
<property name="file" value="${org.checkstyle.sun.suppressionfilter.config}"
default="checkstyle-suppressions.xml" />
<property name="optional" value="true"/>
</module>
<!-- Checks that a package-info.java file exists for each package. -->
<!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage -->
<module name="JavadocPackage"/>
<!-- Checks whether files end with a new line. -->
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"/>
<!-- Checks that property files contain the same keys. -->
<!-- See https://checkstyle.org/config_misc.html#Translation -->
<module name="Translation"/>
<!-- Checks for Size Violations. -->
<!-- See https://checkstyle.org/config_sizes.html -->
<module name="FileLength"/>
<module name="LineLength">
<property name="fileExtensions" value="java"/>
<property name="max" value="120"/>
</module>
<!-- Checks for whitespace -->
<!-- See https://checkstyle.org/config_whitespace.html -->
<module name="FileTabCharacter"/>
<!-- Miscellaneous other checks. -->
<!-- See https://checkstyle.org/config_misc.html -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="minimum" value="0"/>
<property name="maximum" value="0"/>
<property name="message" value="Line has trailing spaces."/>
</module>
<!-- Checks for Headers -->
<!-- See https://checkstyle.org/config_header.html -->
<module name="Header">
<property name="headerFile" value="onlyoffice.header"/>
<property name="fileExtensions" value="java"/>
</module>
<module name="TreeWalker">
<!-- Checks for Javadoc comments. -->
<!-- See https://checkstyle.org/config_javadoc.html -->
<module name="InvalidJavadocPosition"/>
<module name="JavadocMethod"/>
<module name="JavadocType"/>
<module name="JavadocVariable"/>
<module name="JavadocStyle"/>
<module name="MissingJavadocMethod"/>
<!-- Checks for Naming Conventions. -->
<!-- See https://checkstyle.org/config_naming.html -->
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<!-- Checks for imports -->
<!-- See https://checkstyle.org/config_imports.html -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="false"/>
</module>
<!-- Checks for Size Violations. -->
<!-- See https://checkstyle.org/config_sizes.html -->
<module name="MethodLength"/>
<module name="ParameterNumber"/>
<!-- Checks for whitespace -->
<!-- See https://checkstyle.org/config_whitespace.html -->
<module name="EmptyForIteratorPad"/>
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<!-- Modifier Checks -->
<!-- See https://checkstyle.org/config_modifier.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<!-- Checks for blocks. You know, those {}'s -->
<!-- See https://checkstyle.org/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>
<!-- Checks for common coding problems -->
<!-- See https://checkstyle.org/config_coding.html -->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField"/>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber"/>
<module name="MissingSwitchDefault"/>
<module name="MultipleVariableDeclarations"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<!-- Checks for class design -->
<!-- See https://checkstyle.org/config_design.html -->
<module name="DesignForExtension"/>
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier"/>
<!-- Miscellaneous other checks. -->
<!-- See https://checkstyle.org/config_misc.html -->
<module name="ArrayTypeStyle"/>
<module name="FinalParameters"/>
<module name="TodoComment"/>
<module name="UpperEll"/>
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
<module name="SuppressionXpathFilter">
<property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}"
default="checkstyle-xpath-suppressions.xml" />
<property name="optional" value="true"/>
</module>
</module>
</module>

View File

@ -0,0 +1,17 @@
/**
*
* (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.
*
*/

View File

@ -35,6 +35,14 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
@ -86,14 +94,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<version>3.2.0</version>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>google_checks.xml</configLocation>
<encoding>UTF-8</encoding>
<configLocation>checkstyle.xml</configLocation>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
<logViolationsToConsole>true</logViolationsToConsole>

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -32,8 +32,9 @@ public class ExampleData {
@Autowired
private UserServices userService;
@PostConstruct
public void init(){
List<String> description_user_0=List.of( // the description for user 0
public void init() {
// the description for user 0
List<String> descriptionUserZero = List.of(
"The name is requested when the editor is opened",
"Doesnt belong to any group",
"Can review all the changes",
@ -46,7 +47,9 @@ public class ExampleData {
"Can't view chat",
"View file without collaboration"
);
List<String> description_user_1 = List.of( // the description for user 1
// the description for user 1
List<String> descriptionUserFirst = List.of(
"File author by default",
"He doesnt belong to any of the groups",
"He can review all the changes",
@ -56,19 +59,26 @@ public class ExampleData {
"Can see the information about all users",
"Can view chat"
);
List<String> description_user_2 = List.of( // the description for user 2
// the description for user 2
List<String> descriptionUserSecond = List.of(
"He belongs to Group2",
"He can review only his own changes or the changes made by the users who dont belong to any of the groups",
"He can view every comment, edit his comments and the comments left by the users who don't belong to any of the groups and remove only his comments",
"He can review only his own changes or the changes made by the users who dont belong"
+ " to any of the groups",
"He can view every comment, edit his comments and the comments left by the users "
+ "who don't belong to any of the groups and remove only his comments",
"This file is favorite",
"Can create a file from an editor",
"Can see the information about users from Group2 and users who dont belong to any group",
"Can view chat"
);
List<String> description_user_3 = List.of( // the description for user 3
// the description for user 3
List<String> descriptionUserThird = List.of(
"He belongs to Group3",
"He can review only the changes made by the users from Group2",
"He can view the comments left by the users from Group2 and Group3 and edit the comments left by the users from Group2",
"He can view the comments left by the users from Group2 and Group3 and edit the comments left by "
+ "the users from Group2",
"This file isnt favorite",
"He cant copy data from the file into the clipboard",
"He cant download the file",
@ -77,24 +87,27 @@ public class ExampleData {
"Can see the information about Group2 users",
"Can view chat"
);
userService.createUser("John Smith", "smith@example.com", // create user 1 with the specified parameters
description_user_1, "", List.of(FilterState.NULL.toString()),
List.of(FilterState.NULL.toString()),
List.of(FilterState.NULL.toString()),
List.of(FilterState.NULL.toString()),
List.of(FilterState.NULL.toString()),
null, true);
userService.createUser("Mark Pottato", "pottato@example.com", // create user 2 with the specified parameters
description_user_2, "group-2", List.of("","group-2"), List.of(FilterState.NULL.toString()),
List.of("group-2", ""), List.of("group-2"), List.of("group-2", ""), true,
true);
userService.createUser("Hamish Mitchell", "mitchell@example.com", // create user 3 with the specified parameters
description_user_3, "group-3", List.of("group-2"), List.of("group-2", "group-3"),
List.of("group-2"), new ArrayList<>(), List.of("group-2"), false,
true);
userService.createUser("Anonymous",null, // create user 0 with the specified parameters
description_user_0,"", List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()),
List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), new ArrayList<>(),null,
false);
// create user 1 with the specified parameters
userService.createUser("John Smith", "smith@example.com", descriptionUserFirst,
"", List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()),
List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()),
List.of(FilterState.NULL.toString()), null, true);
// create user 2 with the specified parameters
userService.createUser("Mark Pottato", "pottato@example.com", descriptionUserSecond,
"group-2", List.of("", "group-2"), List.of(FilterState.NULL.toString()),
List.of("group-2", ""), List.of("group-2"), List.of("group-2", ""), true, true);
// create user 3 with the specified parameters
userService.createUser("Hamish Mitchell", "mitchell@example.com", descriptionUserThird,
"group-3", List.of("group-2"), List.of("group-2", "group-3"), List.of("group-2"),
new ArrayList<>(), List.of("group-2"), false, true);
// create user 0 with the specified parameters
userService.createUser("Anonymous", null, descriptionUserZero, "",
List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()),
List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()),
new ArrayList<>(), null, false);
}
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -24,9 +24,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class IntegrationApplication {
// run the SpringApplication from the IntagrationApplication with the specified parameters
public static void main(String[] args) {
SpringApplication.run(IntegrationApplication.class, args);
}
// run the SpringApplication from the IntagrationApplication with the specified parameters
public static void main(final String[] args) {
SpringApplication.run(IntegrationApplication.class, args);
}
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -48,39 +48,40 @@ public class IntegrationConfiguration {
private SSLUtils ssl;
@Bean
public ModelMapper mapper(){ // create the model mapper
public ModelMapper mapper() { // create the model mapper
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration() // get the mapper configuration and set new parameters to it
.setMatchingStrategy(MatchingStrategies.STRICT) // specify the STRICT matching strategy
.setFieldMatchingEnabled(true) // define if the field matching is enabled or not
.setSkipNullEnabled(true) // define if null value will be skipped or not
.setFieldAccessLevel(org.modelmapper.config.Configuration.AccessLevel.PRIVATE); // specify the PRIVATE field access level
.setFieldAccessLevel(org.modelmapper.config.Configuration.AccessLevel.PRIVATE); /* specify
the PRIVATE field access level */
return mapper;
}
@Bean
public JSONParser jsonParser(){ // create JSON parser
public JSONParser jsonParser() { // create JSON parser
return new JSONParser();
}
@PostConstruct
public void init(){ // initialize the storage path builder
public void init() { // initialize the storage path builder
storagePathBuilder.configure(storageAddress.isBlank() ? null : storageAddress);
if(!verifyPerrOff.isEmpty()) {
try{
if(verifyPerrOff.equals("true")) {
if (!verifyPerrOff.isEmpty()) {
try {
if (verifyPerrOff.equals("true")) {
ssl.turnOffSslChecking(); //the certificate will be ignored
} else {
ssl.turnOnSslChecking(); //the certificate will be verified
}
} catch(Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Bean
public ObjectMapper objectMapper(){ // create the object mapper
public ObjectMapper objectMapper() { // create the object mapper
return new ObjectMapper();
}
}

View File

@ -0,0 +1,37 @@
/**
*
* (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 com.onlyoffice.integration.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;
@Configuration
public class SecurityConfig {
@Bean
SecurityFilterChain filterChain(final HttpSecurity http) throws Exception {
return http
.requiresChannel(channel -> channel.anyRequest().requiresSecure())
.authorizeRequests(authorize -> authorize.anyRequest().permitAll())
.build();
}
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -40,7 +40,16 @@ import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import static com.onlyoffice.integration.documentserver.util.Constants.ANONYMOUS_USER_ID;
@CrossOrigin("*")
@Controller
@ -75,20 +84,25 @@ public class EditorController {
@GetMapping(path = "${url.editor}")
// process request to open the editor page
public String index(@RequestParam("fileName") String fileName,
@RequestParam(value = "action", required = false) String actionParam,
@RequestParam(value = "type", required = false) String typeParam,
@RequestParam(value = "actionLink", required = false) String actionLink,
@RequestParam(value = "directUrl", required = false, defaultValue = "false") Boolean directUrl,
@CookieValue(value = "uid") String uid,
@CookieValue(value = "ulang") String lang,
Model model) throws JsonProcessingException {
public String index(@RequestParam("fileName") final String fileName,
@RequestParam(value = "action", required = false) final String actionParam,
@RequestParam(value = "type", required = false) final String typeParam,
@RequestParam(value = "actionLink", required = false) final String actionLink,
@RequestParam(value = "directUrl", required = false,
defaultValue = "false") final Boolean directUrl,
@CookieValue(value = "uid") final String uid,
@CookieValue(value = "ulang") final String lang,
final Model model) throws JsonProcessingException {
Action action = Action.edit;
Type type = Type.desktop;
Locale locale = new Locale("en");
if(actionParam != null) action = Action.valueOf(actionParam);
if(typeParam != null) type = Type.valueOf(typeParam);
if (actionParam != null) {
action = Action.valueOf(actionParam);
}
if (typeParam != null) {
type = Type.valueOf(typeParam);
}
List<String> langsAndKeys = Arrays.asList(langs.split("\\|"));
for (String langAndKey : langsAndKeys) {
@ -102,7 +116,9 @@ public class EditorController {
Optional<User> optionalUser = userService.findUserById(Integer.parseInt(uid));
// if the user is not present, return the ONLYOFFICE start page
if(!optionalUser.isPresent()) return "index.html";
if (!optionalUser.isPresent()) {
return "index.html";
}
User user = optionalUser.get();
@ -121,23 +137,38 @@ public class EditorController {
);
// add attributes to the specified model
model.addAttribute("model", fileModel); // add file model with the default parameters to the original model
model.addAttribute("fileHistory", historyManager.getHistory(fileModel.getDocument())); // get file history and add it to the model
model.addAttribute("docserviceApiUrl",docserviceSite + docserviceApiUrl); // create the document service api URL and add it to the model
model.addAttribute("dataInsertImage", getInsertImage(directUrl)); // get an image and add it to the model
model.addAttribute("dataCompareFile", getCompareFile(directUrl)); // get a document for comparison and add it to the model
model.addAttribute("dataMailMergeRecipients", getMailMerge(directUrl)); // get recipients data for mail merging and add it to the model
model.addAttribute("usersForMentions", getUserMentions(uid)); // get user data for mentions and add it to the model
// add file model with the default parameters to the original model
model.addAttribute("model", fileModel);
// get file history and add it to the model
model.addAttribute("fileHistory", historyManager.getHistory(fileModel.getDocument()));
// create the document service api URL and add it to the model
model.addAttribute("docserviceApiUrl", docserviceSite + docserviceApiUrl);
// get an image and add it to the model
model.addAttribute("dataInsertImage", getInsertImage(directUrl));
// get a document for comparison and add it to the model
model.addAttribute("dataCompareFile", getCompareFile(directUrl));
// get recipients data for mail merging and add it to the model
model.addAttribute("dataMailMergeRecipients", getMailMerge(directUrl));
// get user data for mentions and add it to the model
model.addAttribute("usersForMentions", getUserMentions(uid));
return "editor.html";
}
private List<Mentions> getUserMentions(String uid){ // get user data for mentions
List<Mentions> usersForMentions=new ArrayList<>();
if(uid!=null && !uid.equals("4")) {
private List<Mentions> getUserMentions(final String uid) { // get user data for mentions
List<Mentions> usersForMentions = new ArrayList<>();
if (uid != null && !uid.equals("4")) {
List<User> list = userService.findAll();
for (User u : list) {
if (u.getId()!=Integer.parseInt(uid) && u.getId()!=4) {
usersForMentions.add(new Mentions(u.getName(),u.getEmail())); // user data includes user names and emails
if (u.getId() != Integer.parseInt(uid) && u.getId() != ANONYMOUS_USER_ID) {
// user data includes user names and emails
usersForMentions.add(new Mentions(u.getName(), u.getEmail()));
}
}
}
@ -146,41 +177,49 @@ public class EditorController {
}
@SneakyThrows
private String getInsertImage(Boolean directUrl) { // get an image that will be inserted into the document
private String getInsertImage(final Boolean directUrl) { // get an image that will be inserted into the document
Map<String, Object> dataInsertImage = new HashMap<>();
dataInsertImage.put("fileType", "png");
dataInsertImage.put("url", storagePathBuilder.getServerUrl(true) + "/css/img/logo.png");
if (directUrl) {
dataInsertImage.put("directUrl", storagePathBuilder.getServerUrl(false) + "/css/img/logo.png");
dataInsertImage.put("directUrl", storagePathBuilder
.getServerUrl(false) + "/css/img/logo.png");
}
// check if the document token is enabled
if(jwtManager.tokenEnabled()){
dataInsertImage.put("token", jwtManager.createToken(dataInsertImage)); // create token from the dataInsertImage object
if (jwtManager.tokenEnabled()) {
// create token from the dataInsertImage object
dataInsertImage.put("token", jwtManager.createToken(dataInsertImage));
}
return objectMapper.writeValueAsString(dataInsertImage).substring(1, objectMapper.writeValueAsString(dataInsertImage).length()-1);
return objectMapper.writeValueAsString(dataInsertImage)
.substring(1, objectMapper.writeValueAsString(dataInsertImage).length() - 1);
}
// get a document that will be compared with the current document
@SneakyThrows
private String getCompareFile(Boolean directUrl) { // get a document that will be compared with the current document
private String getCompareFile(final Boolean directUrl) {
Map<String, Object> dataCompareFile = new HashMap<>();
dataCompareFile.put("fileType", "docx");
dataCompareFile.put("url", storagePathBuilder.getServerUrl(true) + "/assets?name=sample.docx");
if (directUrl) {
dataCompareFile.put("directUrl", storagePathBuilder.getServerUrl(false) + "/assets?name=sample.docx");
dataCompareFile.put("directUrl", storagePathBuilder
.getServerUrl(false) + "/assets?name=sample.docx");
}
// check if the document token is enabled
if(jwtManager.tokenEnabled()){
dataCompareFile.put("token", jwtManager.createToken(dataCompareFile)); // create token from the dataCompareFile object
if (jwtManager.tokenEnabled()) {
// create token from the dataCompareFile object
dataCompareFile.put("token", jwtManager.createToken(dataCompareFile));
}
return objectMapper.writeValueAsString(dataCompareFile);
}
@SneakyThrows
private String getMailMerge(Boolean directUrl) {
private String getMailMerge(final Boolean directUrl) {
Map<String, Object> dataMailMergeRecipients = new HashMap<>(); // get recipients data for mail merging
dataMailMergeRecipients.put("fileType", "csv");
dataMailMergeRecipients.put("url", storagePathBuilder.getServerUrl(true) + "/csv");
@ -189,8 +228,10 @@ public class EditorController {
}
// check if the document token is enabled
if(jwtManager.tokenEnabled()){
dataMailMergeRecipients.put("token", jwtManager.createToken(dataMailMergeRecipients)); // create token from the dataMailMergeRecipients object
if (jwtManager.tokenEnabled()) {
// create token from the dataMailMergeRecipients object
dataMailMergeRecipients.put("token", jwtManager.createToken(dataMailMergeRecipients));
}
return objectMapper.writeValueAsString(dataMailMergeRecipients);

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -41,16 +41,26 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@CrossOrigin("*")
@Controller
@ -90,10 +100,10 @@ public class FileController {
private CallbackManager callbackManager;
// create user metadata
private String createUserMetadata(String uid, String fullFileName) {
private String createUserMetadata(final String uid, final String fullFileName) {
Optional<User> optionalUser = userService.findUserById(Integer.parseInt(uid)); // find a user by their ID
String documentType = fileUtility.getDocumentType(fullFileName).toString().toLowerCase(); // get document type
if(optionalUser.isPresent()){
if (optionalUser.isPresent()) {
User user = optionalUser.get();
storageMutator.createMeta(fullFileName, // create meta information with the user ID and name specified
String.valueOf(user.getId()), user.getName());
@ -102,33 +112,39 @@ public class FileController {
}
// download data from the specified file
private ResponseEntity<Resource> downloadFile(String fileName){
private ResponseEntity<Resource> downloadFile(final String fileName) {
Resource resource = storageMutator.loadFileAsResource(fileName); // load the specified file as a resource
String contentType = "application/octet-stream";
// create a response with the content type, header and body with the file data
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType(contentType))
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + resource.getFilename() + "\"")
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + resource.getFilename() + "\"")
.body(resource);
}
// download data from the specified history file
private ResponseEntity<Resource> downloadFileHistory(String fileName, String version, String file){
Resource resource = storageMutator.loadFileAsResourceHistory(fileName,version,file); // load the specified file as a resource
private ResponseEntity<Resource> downloadFileHistory(final String fileName,
final String version,
final String file) {
// load the specified file as a resource
Resource resource = storageMutator.loadFileAsResourceHistory(fileName, version, file);
String contentType = "application/octet-stream";
// create a response with the content type, header and body with the file data
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType(contentType))
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + resource.getFilename() + "\"")
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + resource.getFilename() + "\"")
.body(resource);
}
@PostMapping("/upload")
@ResponseBody
public String upload(@RequestParam("file") MultipartFile file, // upload a file
@CookieValue("uid") String uid){
public String upload(@RequestParam("file") final MultipartFile file, // upload a file
@CookieValue("uid") final String uid) {
try {
String fullFileName = file.getOriginalFilename(); // get file name
String fileExtension = fileUtility.getFileExtension(fullFileName); // get file extension
@ -136,17 +152,19 @@ public class FileController {
byte[] bytes = file.getBytes(); // get file in bytes
// check if the file size exceeds the maximum file size or is less than 0
if(fileUtility.getMaxFileSize() < fileSize || fileSize <= 0){
if (fileUtility.getMaxFileSize() < fileSize || fileSize <= 0) {
return "{ \"error\": \"File size is incorrect\"}"; // if so, write an error message to the response
}
// check if file extension is supported by the editor
if(!fileUtility.getFileExts().contains(fileExtension)){
return "{ \"error\": \"File type is not supported\"}"; // if not, write an error message to the response
if (!fileUtility.getFileExts().contains(fileExtension)) {
// if not, write an error message to the response
return "{ \"error\": \"File type is not supported\"}";
}
String fileNamePath = storageMutator.updateFile(fullFileName, bytes); // update a file
if (fileNamePath.isBlank()){
if (fileNamePath.isBlank()) {
throw new IOException("Could not update a file"); // if the file cannot be updated, an error occurs
}
@ -156,31 +174,46 @@ public class FileController {
} catch (Exception e) {
e.printStackTrace();
}
return "{ \"error\": \"Something went wrong when uploading the file.\"}"; // if the operation of file uploading is unsuccessful, an error occurs
// if the operation of file uploading is unsuccessful, an error occurs
return "{ \"error\": \"Something went wrong when uploading the file.\"}";
}
@PostMapping(path = "${url.converter}")
@ResponseBody
public String convert(@RequestBody Converter body, // convert a file
@CookieValue("uid") String uid, @CookieValue("ulang") String lang){
String fileName = body.getFileName(); // get file name
String fileUri = documentManager.getDownloadUrl(fileName, true); // get URL for downloading a file with the specified name
String filePass = body.getFilePass() != null ? body.getFilePass() : null; // get file password if it exists
String fileExt = fileUtility.getFileExtension(fileName); // get file extension
DocumentType type = fileUtility.getDocumentType(fileName); // get document type (word, cell or slide)
String internalFileExt = fileUtility.getInternalExtension(type); // get an editor internal extension (".docx", ".xlsx" or ".pptx")
public String convert(@RequestBody final Converter body, // convert a file
@CookieValue("uid") final String uid, @CookieValue("ulang") final String lang) {
// get file name
String fileName = body.getFileName();
try{
if(fileUtility.getConvertExts().contains(fileExt)){ // check if the file with such an extension can be converted
// get URL for downloading a file with the specified name
String fileUri = documentManager.getDownloadUrl(fileName, true);
// get file password if it exists
String filePass = body.getFilePass() != null ? body.getFilePass() : null;
// get file extension
String fileExt = fileUtility.getFileExtension(fileName);
// get document type (word, cell or slide)
DocumentType type = fileUtility.getDocumentType(fileName);
// get an editor internal extension (".docx", ".xlsx" or ".pptx")
String internalFileExt = fileUtility.getInternalExtension(type);
try {
// check if the file with such an extension can be converted
if (fileUtility.getConvertExts().contains(fileExt)) {
String key = serviceConverter.generateRevisionId(fileUri); // generate document key
String newFileUri = serviceConverter // get the URL to the converted file
.getConvertedUri(fileUri, fileExt, internalFileExt, key, filePass, true, lang);
if(newFileUri.isEmpty()){
if (newFileUri.isEmpty()) {
return "{ \"step\" : \"0\", \"filename\" : \"" + fileName + "\"}";
}
// get a file name of an internal file extension with an index if the file with such a name already exists
/* get a file name of an internal file extension with an index if the file
with such a name already exists */
String nameWithInternalExt = fileUtility.getFileNameWithoutExtension(fileName) + internalFileExt;
String correctedName = documentManager.getCorrectName(nameWithInternalExt);
@ -188,7 +221,7 @@ public class FileController {
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
InputStream stream = connection.getInputStream(); // get input stream of the converted file
if (stream == null){
if (stream == null) {
connection.disconnect();
throw new RuntimeException("Input stream is null");
}
@ -200,87 +233,104 @@ public class FileController {
// create meta information about the converted file with the user ID and name specified
return createUserMetadata(uid, fileName);
}catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
return "{ \"error\": \"" + "The file can't be converted.\"}"; // if the operation of file converting is unsuccessful, an error occurs
// if the operation of file converting is unsuccessful, an error occurs
return "{ \"error\": \"" + "The file can't be converted.\"}";
}
@PostMapping("/delete")
@ResponseBody
public String delete(@RequestBody Converter body){ // delete a file
try
{
public String delete(@RequestBody final Converter body) { // delete a file
try {
String fullFileName = fileUtility.getFileName(body.getFileName()); // get full file name
boolean fileSuccess = storageMutator.deleteFile(fullFileName); // delete a file from the storage and return the status of this operation (true or false)
boolean historySuccess = storageMutator.deleteFileHistory(fullFileName); // delete file history and return the status of this operation (true or false)
return "{ \"success\": \""+ (fileSuccess && historySuccess) +"\"}";
}
catch (Exception e)
{
return "{ \"error\": \"" + e.getMessage() + "\"}"; // if the operation of file deleting is unsuccessful, an error occurs
// delete a file from the storage and return the status of this operation (true or false)
boolean fileSuccess = storageMutator.deleteFile(fullFileName);
// delete file history and return the status of this operation (true or false)
boolean historySuccess = storageMutator.deleteFileHistory(fullFileName);
return "{ \"success\": \"" + (fileSuccess && historySuccess) + "\"}";
} catch (Exception e) {
// if the operation of file deleting is unsuccessful, an error occurs
return "{ \"error\": \"" + e.getMessage() + "\"}";
}
}
@GetMapping("/downloadhistory")
public ResponseEntity<Resource> downloadHistory(HttpServletRequest request,// download a file
@RequestParam("fileName") String fileName,
@RequestParam("ver") String version,
@RequestParam("file") String file){ // history file
try{
public ResponseEntity<Resource> downloadHistory(final HttpServletRequest request, // download a file
@RequestParam("fileName") final String fileName,
@RequestParam("ver") final String version,
@RequestParam("file") final String file) { // history file
try {
// check if a token is enabled or not
if(jwtManager.tokenEnabled()){
if (jwtManager.tokenEnabled()) {
String header = request.getHeader(documentJwtHeader == null // get the document JWT header
|| documentJwtHeader.isEmpty() ? "Authorization" : documentJwtHeader);
if(header != null && !header.isEmpty()){
String token = header.replace("Bearer ", ""); // token is the header without the Bearer prefix
if (header != null && !header.isEmpty()) {
String token = header
.replace("Bearer ", ""); // token is the header without the Bearer prefix
jwtManager.readToken(token); // read the token
}else {
} else {
return null;
}
}
return downloadFileHistory(fileName,version,file); // download data from the specified file
} catch(Exception e){
return downloadFileHistory(fileName, version, file); // download data from the specified file
} catch (Exception e) {
return null;
}
}
@GetMapping(path = "${url.download}")
public ResponseEntity<Resource> download(HttpServletRequest request, // download a file
@RequestParam("fileName") String fileName){
try{
public ResponseEntity<Resource> download(final HttpServletRequest request, // download a file
@RequestParam("fileName") final String fileName,
@RequestParam(value = "userAddress", required = false) final String userAddress){
try {
// check if a token is enabled or not
if(jwtManager.tokenEnabled()){
String header = request.getHeader(documentJwtHeader == null // get the document JWT header
if (jwtManager.tokenEnabled() && userAddress != null) {
String header = request.getHeader(documentJwtHeader == null // get the document JWT header
|| documentJwtHeader.isEmpty() ? "Authorization" : documentJwtHeader);
if(header != null && !header.isEmpty()){
String token = header.replace("Bearer ", ""); // token is the header without the Bearer prefix
if (header != null && !header.isEmpty()) {
String token = header
.replace("Bearer ", ""); // token is the header without the Bearer prefix
jwtManager.readToken(token); // read the token
} else {
return null;
}
}
return downloadFile(fileName); // download data from the specified file
} catch(Exception e){
} catch (Exception e) {
return null;
}
}
@GetMapping("/create")
public String create(@RequestParam("fileExt") String fileExt, // create a sample file of the specified extension
@RequestParam(value = "sample", required = false) Optional<Boolean> isSample,
@CookieValue(value = "uid", required = false) String uid,
Model model){
Boolean sampleData = (isSample.isPresent() && !isSample.isEmpty()) && isSample.get(); // specify if the sample data exists or not
if(fileExt != null){
try{
public String create(@RequestParam("fileExt")
final String fileExt, // create a sample file of the specified extension
@RequestParam(value = "sample", required = false) final Optional<Boolean> isSample,
@CookieValue(value = "uid", required = false) final String uid,
final Model model) {
// specify if the sample data exists or not
Boolean sampleData = (isSample.isPresent() && !isSample.isEmpty()) && isSample.get();
if (fileExt != null) {
try {
Optional<User> user = userService.findUserById(Integer.parseInt(uid)); // find a user by their ID
if (!user.isPresent()) throw new RuntimeException("Could not fine any user with id = "+uid); // if the user with the specified ID doesn't exist, an error occurs
String fileName = documentManager.createDemo(fileExt, sampleData, uid, user.get().getName()); // create a demo document with the sample data
if (!user.isPresent()) {
// if the user with the specified ID doesn't exist, an error occurs
throw new RuntimeException("Could not fine any user with id = " + uid);
}
String fileName = documentManager.createDemo(fileExt,
sampleData,
uid,
user.get().getName()); // create a demo document with the sample data
if (fileName.isBlank() || fileName == null) {
throw new RuntimeException("You must have forgotten to add asset files");
}
return "redirect:editor?fileName=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8); // redirect the request
}catch (Exception ex){
return "redirect:editor?fileName=" + URLEncoder
.encode(fileName, StandardCharsets.UTF_8); // redirect the request
} catch (Exception ex) {
model.addAttribute("error", ex.getMessage());
return "error.html";
}
@ -289,33 +339,35 @@ public class FileController {
}
@GetMapping("/assets")
public ResponseEntity<Resource> assets(@RequestParam("name") String name) // get sample files from the assests
{
public ResponseEntity<Resource> assets(@RequestParam("name")
final String name) { // get sample files from the assests
String fileName = Path.of("assets", "sample", fileUtility.getFileName(name)).toString();
return downloadFile(fileName);
}
@GetMapping("/csv")
public ResponseEntity<Resource> csv() // download a csv file
{
public ResponseEntity<Resource> csv() { // download a csv file
String fileName = Path.of("assets", "sample", "csv.csv").toString();
return downloadFile(fileName);
}
@GetMapping("/files")
@ResponseBody
public ArrayList<Map<String, Object>> files(@RequestParam(value = "fileId", required = false) String fileId){ // get files information
public ArrayList<Map<String, Object>> files(@RequestParam(value = "fileId", required = false)
final String fileId) { // get files information
return fileId == null ? documentManager.getFilesInfo() : documentManager.getFilesInfo(fileId);
}
@PostMapping(path = "${url.track}")
@ResponseBody
public String track(HttpServletRequest request, // track file changes
@RequestParam("fileName") String fileName,
@RequestParam("userAddress") String userAddress,
@RequestBody Track body){
public String track(final HttpServletRequest request, // track file changes
@RequestParam("fileName") final String fileName,
@RequestParam("userAddress") final String userAddress,
@RequestBody final Track body) {
Track track;
try {
String bodyString = objectMapper.writeValueAsString(body); // write the request body to the object mapper as a string
String bodyString = objectMapper
.writeValueAsString(body); // write the request body to the object mapper as a string
String header = request.getHeader(documentJwtHeader == null // get the request header
|| documentJwtHeader.isEmpty() ? "Authorization" : documentJwtHeader);
@ -324,20 +376,20 @@ public class FileController {
}
JSONObject bodyCheck = jwtManager.parseBody(bodyString, header); // parse the request body
body = objectMapper.readValue(bodyCheck.toJSONString(), Track.class); // read the request body
track = objectMapper.readValue(bodyCheck.toJSONString(), Track.class); // read the request body
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
int error = callbackHandler.handle(body, fileName);
int error = callbackHandler.handle(track, fileName);
return"{\"error\":" + error + "}";
return "{\"error\":" + error + "}";
}
@PostMapping("/saveas")
@ResponseBody
public String saveAs(@RequestBody JSONObject body, @CookieValue("uid") String uid) {
public String saveAs(@RequestBody final JSONObject body, @CookieValue("uid") final String uid) {
String title = (String) body.get("title");
String saveAsFileUrl = (String) body.get("url");
@ -368,17 +420,17 @@ public class FileController {
@PostMapping("/rename")
@ResponseBody
public String rename(@RequestBody JSONObject body) {
public String rename(@RequestBody final JSONObject body) {
String newfilename = (String) body.get("newfilename");
String dockey = (String) body.get("dockey");
String origExt = "." + (String) body.get("ext");
String curExt = newfilename;
if(newfilename.indexOf(".") != -1) {
if (newfilename.indexOf(".") != -1) {
curExt = (String) fileUtility.getFileExtension(newfilename);
}
if(origExt.compareTo(curExt) != 0) {
if (origExt.compareTo(curExt) != 0) {
newfilename += origExt;
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -21,16 +21,25 @@ package com.onlyoffice.integration.controllers;
import com.onlyoffice.integration.documentserver.storage.FileStorageMutator;
import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder;
import com.onlyoffice.integration.documentserver.util.Misc;
import com.onlyoffice.integration.entities.*;
import com.onlyoffice.integration.services.UserServices;
import com.onlyoffice.integration.documentserver.util.file.FileUtility;
import com.onlyoffice.integration.entities.User;
import com.onlyoffice.integration.services.UserServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@CrossOrigin("*")
@ -68,8 +77,8 @@ public class IndexController {
private String langs;
@GetMapping("${url.index}")
public String index(@RequestParam(value = "directUrl", required = false) Boolean directUrl,
Model model){
public String index(@RequestParam(value = "directUrl", required = false) final Boolean directUrl,
final Model model) {
java.io.File[] files = storageMutator.getStoredFiles(); // get all the stored files from the storage
List<String> docTypes = new ArrayList<>();
List<Boolean> filesEditable = new ArrayList<>();
@ -87,24 +96,30 @@ public class IndexController {
List<User> users = userService.findAll(); // get a list of all the users
String tooltip = users.stream() // get the tooltip with the user descriptions
.map(user -> mistUtility.convertUserDescriptions(user.getName(), user.getDescriptions())) // convert user descriptions to the specified format
.map(user -> mistUtility.convertUserDescriptions(user.getName(),
user.getDescriptions())) // convert user descriptions to the specified format
.collect(Collectors.joining());
for(java.io.File file:files){ // run through all the files
for (java.io.File file:files) { // run through all the files
String fileName = file.getName(); // get file name
docTypes.add(fileUtility.getDocumentType(fileName).toString().toLowerCase()); // add a document type of each file to the list
filesEditable.add(fileUtility.getEditedExts().contains(fileUtility.getFileExtension(fileName))); // specify if a file is editable or not
versions.add(" ["+storagePathBuilder.getFileVersion(fileName, true)+"]"); // add a file version to the list
docTypes.add(fileUtility
.getDocumentType(fileName)
.toString()
.toLowerCase()); // add a document type of each file to the list
filesEditable.add(fileUtility.getEditedExts()
.contains(fileUtility.getFileExtension(fileName))); // specify if a file is editable or not
versions.add(" [" + storagePathBuilder.
getFileVersion(fileName, true) + "]"); // add a file version to the list
isFillFormDoc.add(fileUtility.getFillExts().contains(fileUtility.getFileExtension(fileName)));
}
// add all the parameters to the model
model.addAttribute("isFillFormDoc", isFillFormDoc);
model.addAttribute("versions",versions);
model.addAttribute("versions", versions);
model.addAttribute("files", files);
model.addAttribute("docTypes", docTypes);
model.addAttribute("filesEditable", filesEditable);
model.addAttribute("datadocs", docserviceSite+docservicePreloader);
model.addAttribute("datadocs", docserviceSite + docservicePreloader);
model.addAttribute("tooltip", tooltip);
model.addAttribute("users", users);
model.addAttribute("languages", languages);
@ -115,12 +130,15 @@ public class IndexController {
@PostMapping("/config")
@ResponseBody
public HashMap<String, String> configParameters(){ // get configuration parameters
public HashMap<String, String> configParameters() { // get configuration parameters
HashMap<String, String> configuration = new HashMap<>();
configuration.put("FillExtList", String.join(",", fileUtility.getFillExts())); // put a list of the extensions that can be filled to config
configuration.put("ConverExtList", String.join(",", fileUtility.getConvertExts())); // put a list of the extensions that can be converted to config
configuration.put("EditedExtList", String.join(",", fileUtility.getEditedExts())); // put a list of the extensions that can be edited to config
configuration.put("FillExtList", String.join(",", fileUtility
.getFillExts())); // put a list of the extensions that can be filled to config
configuration.put("ConverExtList", String.join(",", fileUtility
.getConvertExts())); // put a list of the extensions that can be converted to config
configuration.put("EditedExtList", String.join(",", fileUtility
.getEditedExts())); // put a list of the extensions that can be edited to config
configuration.put("UrlConverter", urlConverter);
configuration.put("UrlEditor", urlEditor);

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -26,7 +26,7 @@ public interface Callback {
int handle(Track body, String fileName); // handle the callback
int getStatus(); // get document status
@Autowired
default void selfRegistration(CallbackHandler callbackHandler){ // register a callback handler
default void selfRegistration(CallbackHandler callbackHandler) { // register a callback handler
callbackHandler.register(getStatus(), this);
}
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -33,14 +33,14 @@ public class CallbackHandler {
private Map<Integer, Callback> callbackHandlers = new HashMap<>();
public void register(int code, Callback callback){ // register a callback handler
public void register(final int code, final Callback callback) { // register a callback handler
callbackHandlers.put(code, callback);
}
public int handle(Track body, String fileName){ // handle a callback
public int handle(final Track body, final String fileName) { // handle a callback
Callback callback = callbackHandlers.get(body.getStatus());
if (callback == null){
logger.warn("Callback status "+body.getStatus()+" is not supported yet");
if (callback == null) {
logger.warn("Callback status " + body.getStatus() + " is not supported yet");
return 0;
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -26,10 +26,10 @@ public enum Status {
MUST_FORCE_SAVE(6), // 6 - document is being edited, but the current document state is saved
CORRUPTED_FORCE_SAVE(7); // 7 - error has occurred while force saving the document
private int code;
Status(int code){
this.code = code;
Status(final int codeParam) {
this.code = codeParam;
}
public int getCode(){ // get document status
public int getCode() { // get document status
return this.code;
}
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -31,15 +31,18 @@ public class EditCallback implements Callback {
@Autowired
private CallbackManager callbackManager;
@Override
public int handle(Track body, String fileName) { // handle the callback when the document is being edited
public int handle(final Track body,
final String fileName) { // handle the callback when the document is being edited
int result = 0;
Action action = body.getActions().get(0); // get the user ID who is editing the document
if (action.getType().equals(com.onlyoffice.integration.documentserver.models.enums.Action.edit)) { // if this value is not equal to the user ID
if (action.getType().equals(com.onlyoffice.integration.documentserver.models.enums
.Action.edit)) { // if this value is not equal to the user ID
String user = action.getUserid(); // get user ID
if (!body.getUsers().contains(user)) { // if this user is not specified in the body
String key = body.getKey(); // get document key
try {
callbackManager.commandRequest("forcesave", key, null); // create a command request to forcibly save the document being edited without closing it
// create a command request to forcibly save the document being edited without closing it
callbackManager.commandRequest("forcesave", key, null);
} catch (Exception e) {
e.printStackTrace();
result = 1;

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -30,7 +30,8 @@ public class ForcesaveCallback implements Callback {
@Autowired
private CallbackManager callbackManager;
@Override
public int handle(Track body, String fileName) { // handle the callback when the force saving request is performed
public int handle(final Track body,
final String fileName) { // handle the callback when the force saving request is performed
int result = 0;
try {
callbackManager.processForceSave(body, fileName); // file force saving process
@ -43,6 +44,7 @@ public class ForcesaveCallback implements Callback {
@Override
public int getStatus() { // get document status
return Status.MUST_FORCE_SAVE.getCode(); // return status 6 - document is being edited, but the current document state is saved
// return status 6 - document is being edited, but the current document state is saved
return Status.MUST_FORCE_SAVE.getCode();
}
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -30,7 +30,8 @@ public class SaveCallback implements Callback {
@Autowired
private CallbackManager callbackManager;
@Override
public int handle(Track body, String fileName) { // handle the callback when the saving request is performed
public int handle(final Track body,
final String fileName) { // handle the callback when the saving request is performed
int result = 0;
try {
callbackManager.processSave(body, fileName); // file saving process

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -32,17 +32,24 @@ import org.json.simple.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import java.io.*;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
//TODO: Refactoring
import static com.onlyoffice.integration.documentserver.util.Constants.FILE_SAVE_TIMEOUT;
// todo: Refactoring
@Component
@Primary
public class DefaultCallbackManager implements CallbackManager {
@ -69,18 +76,20 @@ public class DefaultCallbackManager implements CallbackManager {
@Autowired
private ServiceConverter serviceConverter;
// save file information from the URL to the file specified
private void downloadToFile(String url, Path path) throws Exception {
if (url == null || url.isEmpty()) throw new RuntimeException("Url argument is not specified"); // URL isn't specified
if (path == null) throw new RuntimeException("Path argument is not specified"); // file isn't specified
// download file from url
@SneakyThrows
private byte[] getDownloadFile(final String url) {
if (url == null || url.isEmpty()) {
throw new RuntimeException("Url argument is not specified"); // URL isn't specified
}
URL uri = new URL(url);
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) uri.openConnection();
connection.setConnectTimeout(5000);
connection.setConnectTimeout(FILE_SAVE_TIMEOUT);
InputStream stream = connection.getInputStream(); // get input stream of the file information from the URL
int statusCode = connection.getResponseCode();
if (statusCode != 200) { // checking status code
if (statusCode != HttpStatus.OK.value()) { // checking status code
connection.disconnect();
throw new RuntimeException("Document editing service returned status: " + statusCode);
}
@ -90,11 +99,21 @@ public class DefaultCallbackManager implements CallbackManager {
throw new RuntimeException("Input stream is null");
}
storageMutator.createOrUpdateFile(path, stream); // update a file or create a new one
return stream.readAllBytes();
}
// file saving
@SneakyThrows
private void saveFile(final byte[] byteArray, final Path path) {
if (path == null) {
throw new RuntimeException("Path argument is not specified"); // file isn't specified
}
// update a file or create a new one
storageMutator.createOrUpdateFile(path, new ByteArrayInputStream(byteArray));
}
@SneakyThrows
public void processSave(Track body, String fileName) { // file saving process
public void processSave(final Track body, final String fileName) { // file saving process
String downloadUri = body.getUrl();
String changesUri = body.getChangesurl();
String key = body.getKey();
@ -103,46 +122,57 @@ public class DefaultCallbackManager implements CallbackManager {
String curExt = fileUtility.getFileExtension(fileName); // get current file extension
String downloadExt = "." + body.getFiletype(); // get an extension of the downloaded file
// Todo [Delete in version 7.0 or higher]
if (downloadExt != "." + null) downloadExt = fileUtility.getFileExtension(downloadUri); // Support for versions below 7.0
//TODO: Refactoring
if (!curExt.equals(downloadExt)) { // convert downloaded file to the file with the current extension if these extensions aren't equal
// todo: Refactoring
// convert downloaded file to the file with the current extension if these extensions aren't equal
if (!curExt.equals(downloadExt)) {
try {
String newFileUri = serviceConverter.getConvertedUri(downloadUri, downloadExt, curExt, serviceConverter.generateRevisionId(downloadUri), null, false, null); // convert a file and get URL to a new file
String newFileUri = serviceConverter
.getConvertedUri(downloadUri, downloadExt, curExt,
serviceConverter.generateRevisionId(downloadUri), null, false,
null); // convert a file and get URL to a new file
if (newFileUri.isEmpty()) {
newFileName = documentManager
.getCorrectName(fileUtility.getFileNameWithoutExtension(fileName) + downloadExt); // get the correct file name if it already exists
.getCorrectName(fileUtility.getFileNameWithoutExtension(fileName)
+ downloadExt); // get the correct file name if it already exists
} else {
downloadUri = newFileUri;
}
} catch (Exception e){
newFileName = documentManager.getCorrectName(fileUtility.getFileNameWithoutExtension(fileName) + downloadExt);
} catch (Exception e) {
newFileName = documentManager
.getCorrectName(fileUtility.getFileNameWithoutExtension(fileName) + downloadExt);
}
}
byte[] byteArrayFile = getDownloadFile(downloadUri); // download document file
String storagePath = storagePathBuilder.getFileLocation(newFileName); // get the path to a new file
Path lastVersion = Paths.get(storagePathBuilder.getFileLocation(fileName)); // get the path to the last file version
Path lastVersion = Paths.get(storagePathBuilder
.getFileLocation(fileName)); // get the path to the last file version
if (lastVersion.toFile().exists()) { // if the last file version exists
Path histDir = Paths.get(storagePathBuilder.getHistoryDir(storagePath)); // get the history directory
storageMutator.createDirectory(histDir); // and create it
String versionDir = documentManager.versionDir(histDir.toAbsolutePath().toString(), // get the file version directory
storagePathBuilder.getFileVersion(histDir.toAbsolutePath().toString(), false), true);
String versionDir = documentManager
.versionDir(histDir.toAbsolutePath().toString(), // get the file version directory
storagePathBuilder
.getFileVersion(histDir.toAbsolutePath().toString(), false), true);
Path ver = Paths.get(versionDir);
Path toSave = Paths.get(storagePath);
storageMutator.createDirectory(ver); // create the file version directory
storageMutator.moveFile(lastVersion, Paths.get(versionDir + File.separator + "prev" + curExt)); // move the last file version to the file version directory with the "prev" postfix
downloadToFile(downloadUri, toSave); // save file to the storage path
downloadToFile(changesUri, Path.of(versionDir + File.separator + "diff.zip")); // save file changes to the diff.zip archive
saveFile(byteArrayFile, toSave); // save document file
byte[] byteArrayChanges = getDownloadFile(changesUri); // download file changes
saveFile(byteArrayChanges, Path
.of(versionDir + File.separator + "diff.zip")); // save file changes to the diff.zip archive
JSONObject jsonChanges = new JSONObject(); // create a json object for document changes
jsonChanges.put("changes", body.getHistory().getChanges()); // put the changes to the json object
jsonChanges.put("serverVersion", body.getHistory().getServerVersion()); // put the server version to the json object
jsonChanges.put("serverVersion", body.getHistory()
.getServerVersion()); // put the server version to the json object
String history = objectMapper.writeValueAsString(jsonChanges);
if (history == null && body.getHistory() != null) {
@ -150,20 +180,26 @@ public class DefaultCallbackManager implements CallbackManager {
}
if (history != null && !history.isEmpty()) {
storageMutator.writeToFile(versionDir + File.separator + "changes.json", history); // write the history changes to the changes.json file
// write the history changes to the changes.json file
storageMutator.writeToFile(versionDir + File.separator + "changes.json", history);
}
storageMutator.writeToFile(versionDir + File.separator + "key.txt", key); // write the key value to the key.txt file
storageMutator.deleteFile(storagePathBuilder.getForcesavePath(newFileName, false)); // get the path to the forcesaved file version and remove it
// write the key value to the key.txt file
storageMutator.writeToFile(versionDir + File.separator + "key.txt", key);
// get the path to the forcesaved file version and remove it
storageMutator.deleteFile(storagePathBuilder.getForcesavePath(newFileName, false));
}
}
//TODO: Replace (String method) with (Enum method)
// todo: Replace (String method) with (Enum method)
@SneakyThrows
public void commandRequest(String method, String key, HashMap meta) { // create a command request
String DocumentCommandUrl = docserviceUrlSite + docserviceUrlCommand;
public void commandRequest(final String method,
final String key,
final HashMap meta) { // create a command request
String documentCommandUrl = docserviceUrlSite + docserviceUrlCommand;
URL url = new URL(DocumentCommandUrl);
URL url = new URL(documentCommandUrl);
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
HashMap<String, Object> params = new HashMap<String, Object>();
@ -175,12 +211,14 @@ public class DefaultCallbackManager implements CallbackManager {
}
String headerToken;
if (jwtManager.tokenEnabled()) // check if a secret key to generate token exists or not
{
if (jwtManager.tokenEnabled()) { // check if a secret key to generate token exists or not
Map<String, Object> payloadMap = new HashMap<>();
payloadMap.put("payload", params);
headerToken = jwtManager.createToken(payloadMap); // encode a payload object into a header token
connection.setRequestProperty(documentJwtHeader.equals("") ? "Authorization" : documentJwtHeader, "Bearer " + headerToken); // add a header Authorization with a header token and Authorization prefix in it
// add a header Authorization with a header token and Authorization prefix in it
connection.setRequestProperty(documentJwtHeader.equals("")
? "Authorization" : documentJwtHeader, "Bearer " + headerToken);
String token = jwtManager.createToken(params); // encode a payload object into a body token
params.put("token", token);
@ -191,7 +229,8 @@ public class DefaultCallbackManager implements CallbackManager {
byte[] bodyByte = bodyString.getBytes(StandardCharsets.UTF_8);
connection.setRequestMethod("POST"); // set the request method
connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); // set the Content-Type header
connection
.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); // set the Content-Type header
connection.setDoOutput(true); // set the doOutput field to true
connection.connect();
@ -201,76 +240,82 @@ public class DefaultCallbackManager implements CallbackManager {
InputStream stream = connection.getInputStream(); // get input stream
if (stream == null) throw new RuntimeException("Could not get an answer");
if (stream == null) {
throw new RuntimeException("Could not get an answer");
}
String jsonString = serviceConverter.convertStreamToString(stream); // convert stream to json string
connection.disconnect();
JSONObject response = serviceConverter.convertStringToJSON(jsonString); // convert json string to json object
//TODO: Add errors ENUM
// todo: Add errors ENUM
String responseCode = response.get("error").toString();
switch(responseCode) {
switch (responseCode) {
case "0":
case "4": {
case "4":
break;
}
default: {
default:
throw new RuntimeException(response.toJSONString());
}
}
}
@SneakyThrows
public void processForceSave(Track body, String fileName) { // file force saving process
public void processForceSave(final Track body, final String fileNameParam) { // file force saving process
String downloadUri = body.getUrl();
String fileName = fileNameParam;
String curExt = fileUtility.getFileExtension(fileName); // get current file extension
String downloadExt = "."+body.getFiletype(); // get an extension of the downloaded file
String downloadExt = "." + body.getFiletype(); // get an extension of the downloaded file
// Todo [Delete in version 7.0 or higher]
if (downloadExt != "."+null) downloadExt = fileUtility.getFileExtension(downloadUri); // Support for versions below 7.0
Boolean newFileName = false;
// convert downloaded file to the file with the current extension if these extensions aren't equal
//TODO: Extract function
// todo: Extract function
if (!curExt.equals(downloadExt)) {
try {
String newFileUri = serviceConverter.getConvertedUri(downloadUri, downloadExt,
curExt, serviceConverter.generateRevisionId(downloadUri), null, false, null); // convert file and get URL to a new file
// convert file and get URL to a new file
String newFileUri = serviceConverter
.getConvertedUri(downloadUri, downloadExt, curExt, serviceConverter
.generateRevisionId(downloadUri), null, false, null);
if (newFileUri.isEmpty()) {
newFileName = true;
} else {
downloadUri = newFileUri;
}
} catch (Exception e){
} catch (Exception e) {
newFileName = true;
}
}
byte[] byteArrayFile = getDownloadFile(downloadUri); // download document file
String forcesavePath = "";
//TODO: Use ENUMS
//TODO: Pointless toString conversion
// todo: Use ENUMS
// todo: Pointless toString conversion
boolean isSubmitForm = body.getForcesavetype().toString().equals("3");
//TODO: Extract function
// todo: Extract function
if (isSubmitForm) { // if the form is submitted
if (newFileName){
if (newFileName) {
// get the correct file name if it already exists
fileName = documentManager
.getCorrectName(fileUtility.getFileNameWithoutExtension(fileName) + "-form" + downloadExt); // get the correct file name if it already exists
.getCorrectName(fileUtility
.getFileNameWithoutExtension(fileName) + "-form" + downloadExt);
} else {
fileName = documentManager.getCorrectName(fileUtility.getFileNameWithoutExtension(fileName) + "-form" + curExt);
fileName = documentManager
.getCorrectName(fileUtility.getFileNameWithoutExtension(fileName) + "-form" + curExt);
}
forcesavePath = storagePathBuilder.getFileLocation(fileName); // create forcesave path if it doesn't exist
List<Action> actions = body.getActions();
Action action = actions.get(0);
String user = action.getUserid(); // get the user ID
storageMutator.createMeta(fileName, user, "Filling Form"); // create meta data for the forcesaved file
// create meta data for the forcesaved file
storageMutator.createMeta(fileName, user, "Filling Form");
} else {
if (newFileName){
fileName = documentManager.getCorrectName(fileUtility.getFileNameWithoutExtension(fileName) + downloadExt);
if (newFileName) {
fileName = documentManager
.getCorrectName(fileUtility.getFileNameWithoutExtension(fileName) + downloadExt);
}
forcesavePath = storagePathBuilder.getForcesavePath(fileName, false);
@ -279,6 +324,6 @@ public class DefaultCallbackManager implements CallbackManager {
}
}
downloadToFile(downloadUri, Path.of(forcesavePath));
saveFile(byteArrayFile, Path.of(forcesavePath));
}
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -27,8 +27,9 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import java.io.*;
import java.io.File;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.InetAddress;
@ -37,7 +38,12 @@ import java.net.UnknownHostException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import static com.onlyoffice.integration.documentserver.util.Constants.KILOBYTE_SIZE;
@Component
@Primary
@ -62,23 +68,23 @@ public class DefaultDocumentManager implements DocumentManager {
private ServiceConverter serviceConverter;
// get URL to the created file
public String getCreateUrl(String fileName, Boolean sample){
String fileExt = fileName.substring(fileName.length() - 4);
String url = storagePathBuilder.getServerUrl(true) + "/create?fileExt=" + fileExt + "&sample=" + sample;
public String getCreateUrl(final String fileName, final Boolean sample) {
String fileExt = fileUtility.getFileExtension(fileName).replace(".", "");
String url = storagePathBuilder.getServerUrl(true)
+ "/create?fileExt=" + fileExt + "&sample=" + sample;
return url;
}
// get a file name with an index if the file with such a name already exists
public String getCorrectName(String fileName)
{
public String getCorrectName(final String fileName) {
String baseName = fileUtility.getFileNameWithoutExtension(fileName); // get file name without extension
String ext = fileUtility.getFileExtension(fileName); // get file extension
String name = baseName + ext; // create a full file name
Path path = Paths.get(storagePathBuilder.getFileLocation(name));
for (int i = 1; Files.exists(path); i++) // run through all the files with such a name in the storage directory
{
// run through all the files with such a name in the storage directory
for (int i = 1; Files.exists(path); i++) {
name = baseName + " (" + i + ")" + ext; // and add an index to the base name
path = Paths.get(storagePathBuilder.getFileLocation(name));
}
@ -87,101 +93,94 @@ public class DefaultDocumentManager implements DocumentManager {
}
// get file URL
public String getFileUri(String fileName, Boolean forDocumentServer)
{
try
{
public String getFileUri(final String fileName, final Boolean forDocumentServer) {
try {
String serverPath = storagePathBuilder.getServerUrl(forDocumentServer); // get server URL
String hostAddress = storagePathBuilder.getStorageLocation(); // get the storage directory
String filePathDownload = !fileName.contains(InetAddress.getLocalHost().getHostAddress()) ? fileName
: fileName.substring(fileName.indexOf(InetAddress.getLocalHost().getHostAddress()) + InetAddress.getLocalHost().getHostAddress().length() + 1);
: fileName.substring(fileName.indexOf(InetAddress.getLocalHost()
.getHostAddress()) + InetAddress.getLocalHost().getHostAddress().length() + 1);
if (!filesStorage.isEmpty() && filePathDownload.contains(filesStorage)) {
filePathDownload = filePathDownload.substring(filesStorage.length() + 1);
}
String filePath = serverPath + "/download?fileName=" + URLEncoder.encode(filePathDownload, java.nio.charset.StandardCharsets.UTF_8.toString())
+ "&userAddress" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
String filePath = serverPath + "/download?fileName=" + URLEncoder
.encode(filePathDownload, java.nio.charset.StandardCharsets.UTF_8.toString()) + "&userAddress"
+ URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
return filePath;
}
catch (UnsupportedEncodingException | UnknownHostException e)
{
} catch (UnsupportedEncodingException | UnknownHostException e) {
return "";
}
}
// get file URL
public String getHistoryFileUrl(String fileName, Integer version, String file, Boolean forDocumentServer)
{
try
{
public String getHistoryFileUrl(final String fileName, final Integer version, final String file,
final Boolean forDocumentServer) {
try {
String serverPath = storagePathBuilder.getServerUrl(forDocumentServer); // get server URL
String hostAddress = storagePathBuilder.getStorageLocation(); // get the storage directory
String filePathDownload = !fileName.contains(InetAddress.getLocalHost().getHostAddress()) ? fileName
: fileName.substring(fileName.indexOf(InetAddress.getLocalHost().getHostAddress()) + InetAddress.getLocalHost().getHostAddress().length() + 1);
String userAddress = forDocumentServer ? "&userAddress" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString()) : "";
String filePath = serverPath + "/downloadhistory?fileName=" + URLEncoder.encode(filePathDownload, java.nio.charset.StandardCharsets.UTF_8.toString())
+ "&ver=" + version + "&file="+file
: fileName.substring(fileName.indexOf(InetAddress.getLocalHost().getHostAddress())
+ InetAddress.getLocalHost().getHostAddress().length() + 1);
String userAddress = forDocumentServer ? "&userAddress" + URLEncoder
.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString()) : "";
String filePath = serverPath + "/downloadhistory?fileName=" + URLEncoder
.encode(filePathDownload, java.nio.charset.StandardCharsets.UTF_8.toString())
+ "&ver=" + version + "&file=" + file
+ userAddress;
return filePath;
}
catch (UnsupportedEncodingException | UnknownHostException e)
{
} catch (UnsupportedEncodingException | UnknownHostException e) {
return "";
}
}
// get the callback URL
public String getCallback(String fileName)
{
public String getCallback(final String fileName) {
String serverPath = storagePathBuilder.getServerUrl(true);
String storageAddress = storagePathBuilder.getStorageLocation();
try
{
String query = trackUrl+"?fileName="+
URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString())
+ "&userAddress=" + URLEncoder.encode(storageAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
try {
String query = trackUrl + "?fileName="
+ URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString())
+ "&userAddress=" + URLEncoder
.encode(storageAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
return serverPath + query;
}
catch (UnsupportedEncodingException e)
{
} catch (UnsupportedEncodingException e) {
return "";
}
}
// get URL to download a file
public String getDownloadUrl(String fileName, Boolean isServer) {
public String getDownloadUrl(final String fileName, final Boolean isServer) {
String serverPath = storagePathBuilder.getServerUrl(isServer);
String storageAddress = storagePathBuilder.getStorageLocation();
try
{
String userAddress = isServer ? "&userAddress=" + URLEncoder.encode(storageAddress, java.nio.charset.StandardCharsets.UTF_8.toString()) : "";
String query = downloadUrl+"?fileName="
try {
String userAddress = isServer ? "&userAddress=" + URLEncoder
.encode(storageAddress, java.nio.charset.StandardCharsets.UTF_8.toString()) : "";
String query = downloadUrl + "?fileName="
+ URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString())
+ userAddress;
return serverPath + query;
}
catch (UnsupportedEncodingException e)
{
} catch (UnsupportedEncodingException e) {
return "";
}
}
// get file information
public ArrayList<Map<String, Object>> getFilesInfo(){
public ArrayList<Map<String, Object>> getFilesInfo() {
ArrayList<Map<String, Object>> files = new ArrayList<>();
// run through all the stored files
for(File file : storageMutator.getStoredFiles()){
for (File file : storageMutator.getStoredFiles()) {
Map<String, Object> map = new LinkedHashMap<>(); // write all the parameters to the map
map.put("version", storagePathBuilder.getFileVersion(file.getName(), false));
map.put("id", serviceConverter
.generateRevisionId(storagePathBuilder.getStorageLocation() +
"/" + file.getName() + "/"
.generateRevisionId(storagePathBuilder.getStorageLocation()
+ "/" + file.getName() + "/"
+ Paths.get(storagePathBuilder.getFileLocation(file.getName()))
.toFile()
.lastModified()));
map.put("contentLength", new BigDecimal(String.valueOf((file.length()/1024.0)))
map.put("contentLength", new BigDecimal(String.valueOf((file.length() / Double.valueOf(KILOBYTE_SIZE))))
.setScale(2, RoundingMode.HALF_UP) + " KB");
map.put("pureContentLength", file.length());
map.put("title", file.getName());
@ -193,11 +192,11 @@ public class DefaultDocumentManager implements DocumentManager {
}
// get file information by its ID
public ArrayList<Map<String, Object>> getFilesInfo(String fileId){
public ArrayList<Map<String, Object>> getFilesInfo(final String fileId) {
ArrayList<Map<String, Object>> file = new ArrayList<>();
for (Map<String, Object> map : getFilesInfo()){
if (map.get("id").equals(fileId)){
for (Map<String, Object> map : getFilesInfo()) {
if (map.get("id").equals(fileId)) {
file.add(map);
break;
}
@ -207,26 +206,33 @@ public class DefaultDocumentManager implements DocumentManager {
}
// get the path to the file version by the history path and file version
public String versionDir(String path, Integer version, boolean historyPath) {
if (!historyPath){
public String versionDir(final String path, final Integer version, final boolean historyPath) {
if (!historyPath) {
return storagePathBuilder.getHistoryDir(storagePathBuilder.getFileLocation(path)) + version;
}
return path + File.separator + version;
}
// create demo document
public String createDemo(String fileExt,Boolean sample,String uid,String uname) {
String demoName = (sample ? "sample." : "new.") + fileExt; // create sample or new template file with the necessary extension
String demoPath = "assets" + File.separator + (sample ? "sample" : "new") + File.separator + demoName; // get the path to the sample document
String fileName = getCorrectName(demoName); // get a file name with an index if the file with such a name already exists
public String createDemo(final String fileExt, final Boolean sample, final String uid, final String uname) {
String demoName = (sample ? "sample." : "new.")
+ fileExt; // create sample or new template file with the necessary extension
String demoPath = "assets" + File.separator + (sample ? "sample" : "new")
+ File.separator + demoName; // get the path to the sample document
// get a file name with an index if the file with such a name already exists
String fileName = getCorrectName(demoName);
InputStream stream = Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream(demoPath); // get the input file stream
if (stream == null) return null;
if (stream == null) {
return null;
}
storageMutator.createFile(Path.of(storagePathBuilder.getFileLocation(fileName)), stream); // create a file in the specified directory
storageMutator.createFile(Path.of(storagePathBuilder
.getFileLocation(fileName)), stream); // create a file in the specified directory
storageMutator.createMeta(fileName, uid, uname); // create meta information of the demo file
return fileName;

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -23,14 +23,20 @@ import java.util.Map;
// specify the document manager functions
public interface DocumentManager {
String getCorrectName(String fileName); // get a file name with an index if the file with such a name already exists
// get a file name with an index if the file with such a name already exists
String getCorrectName(String fileName);
String getFileUri(String fileName, Boolean forDocumentServer); // get file URL
String getHistoryFileUrl(String fileName, Integer version, String file, Boolean forDocumentServer); // get file URL
String getCallback(String fileName); // get the callback URL
String getDownloadUrl(String fileName, Boolean forDocumentServer); // get URL to download a file
ArrayList<Map<String, Object>> getFilesInfo(); // get file information
ArrayList<Map<String, Object>> getFilesInfo(String fileId); // get file information by its ID
String versionDir(String path, Integer version, boolean historyPath); // get the path to the file version by the history path and file version
String createDemo(String fileExt,Boolean sample,String uid,String uname) throws Exception; // create demo document
// get the path to the file version by the history path and file version
String versionDir(String path, Integer version, boolean historyPath);
// create demo document
String createDemo(String fileExt, Boolean sample, String uid, String uname) throws Exception;
String getCreateUrl(String fileName, Boolean sample); // get URL to the created file
}

View File

@ -1,17 +1,19 @@
/**
* (c) Copyright Ascensio System SIA 2021
*
* (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
* 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 com.onlyoffice.integration.documentserver.managers.history;
@ -32,9 +34,13 @@ import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileInputStream;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
//TODO: Rebuild completely
// todo: Rebuild completely
@Component
public class DefaultHistoryManager implements HistoryManager {
@ -56,10 +62,12 @@ public class DefaultHistoryManager implements HistoryManager {
@Autowired
private ObjectMapper objectMapper;
//TODO: Refactoring
// todo: Refactoring
@SneakyThrows
public String[] getHistory(Document document) { // get document history
String histDir = storagePathBuilder.getHistoryDir(storagePathBuilder.getFileLocation(document.getTitle())); // get history directory
public String[] getHistory(final Document document) { // get document history
// get history directory
String histDir = storagePathBuilder.getHistoryDir(storagePathBuilder.getFileLocation(document.getTitle()));
Integer curVer = storagePathBuilder.getFileVersion(histDir, false); // get current file version
if (curVer > 0) { // check if the current file version is greater than 0
@ -69,14 +77,17 @@ public class DefaultHistoryManager implements HistoryManager {
for (Integer i = 1; i <= curVer; i++) { // run through all the file versions
Map<String, Object> obj = new HashMap<String, Object>();
Map<String, Object> dataObj = new HashMap<String, Object>();
String verDir = documentManager.versionDir(histDir, i, true); // get the path to the given file version
String verDir = documentManager
.versionDir(histDir, i, true); // get the path to the given file version
String key = i == curVer ? document.getKey() : readFileToEnd(new File(verDir + File.separator + "key.txt")); // get document key
String key = i == curVer ? document.getKey() : readFileToEnd(new File(verDir
+ File.separator + "key.txt")); // get document key
obj.put("key", key);
obj.put("version", i);
if (i == 1) { // check if the version number is equal to 1
String createdInfo = readFileToEnd(new File(histDir + File.separator + "createdInfo.json")); // get file with meta data
String createdInfo = readFileToEnd(new File(histDir
+ File.separator + "createdInfo.json")); // get file with meta data
JSONObject json = (JSONObject) parser.parse(createdInfo); // and turn it into json object
// write meta information to the object (user information and creation date)
@ -87,19 +98,23 @@ public class DefaultHistoryManager implements HistoryManager {
obj.put("user", user);
}
dataObj.put("fileType", fileUtility.getFileExtension(document.getTitle()).replace(".", ""));
dataObj.put("fileType", fileUtility
.getFileExtension(document.getTitle()).replace(".", ""));
dataObj.put("key", key);
dataObj.put("url", i == curVer ? document.getUrl() :
documentManager.getHistoryFileUrl(document.getTitle(), i, "prev" + fileUtility.getFileExtension(document.getTitle()), true));
dataObj.put("url", i == curVer ? document.getUrl()
: documentManager.getHistoryFileUrl(document.getTitle(), i, "prev" + fileUtility
.getFileExtension(document.getTitle()), true));
if (!document.getDirectUrl().equals("")) {
dataObj.put("directUrl", i == curVer ? document.getDirectUrl() :
documentManager.getHistoryFileUrl(document.getTitle(), i, "prev" + fileUtility.getFileExtension(document.getTitle()), false));
dataObj.put("directUrl", i == curVer ? document.getDirectUrl()
: documentManager.getHistoryFileUrl(document.getTitle(), i, "prev" + fileUtility
.getFileExtension(document.getTitle()), false));
}
dataObj.put("version", i);
if (i > 1) { //check if the version number is greater than 1
// if so, get the path to the changes.json file
JSONObject changes = (JSONObject) parser.parse(readFileToEnd(new File(documentManager.versionDir(histDir, i - 1, true) + File.separator + "changes.json")));
JSONObject changes = (JSONObject) parser.parse(readFileToEnd(new File(documentManager
.versionDir(histDir, i - 1, true) + File.separator + "changes.json")));
JSONObject change = (JSONObject) ((JSONArray) changes.get("changes")).get(0);
// write information about changes to the object
@ -108,7 +123,8 @@ public class DefaultHistoryManager implements HistoryManager {
obj.put("created", change.get("created"));
obj.put("user", change.get("user"));
Map<String, Object> prev = (Map<String, Object>) histData.get(Integer.toString(i - 2)); // get the history data from the previous file version
// get the history data from the previous file version
Map<String, Object> prev = (Map<String, Object>) histData.get(Integer.toString(i - 2));
Map<String, Object> prevInfo = new HashMap<String, Object>();
prevInfo.put("fileType", prev.get("fileType"));
prevInfo.put("key", prev.get("key")); // write key and URL information about previous file version
@ -116,13 +132,18 @@ public class DefaultHistoryManager implements HistoryManager {
if (!document.getDirectUrl().equals("")) {
prevInfo.put("directUrl", prev.get("directUrl"));
}
dataObj.put("previous", prevInfo); // write information about previous file version to the data object
// write information about previous file version to the data object
dataObj.put("previous", prevInfo);
// write the path to the diff.zip archive with differences in this file version
Integer verdiff = i - 1;
dataObj.put("changesUrl", documentManager.getHistoryFileUrl(document.getTitle(), verdiff, "diff.zip", true));
dataObj.put("changesUrl", documentManager
.getHistoryFileUrl(document.getTitle(), verdiff, "diff.zip", true));
}
if (jwtManager.tokenEnabled()) dataObj.put("token", jwtManager.createToken(dataObj));
if (jwtManager.tokenEnabled()) {
dataObj.put("token", jwtManager.createToken(dataObj));
}
hist.add(obj);
histData.put(Integer.toString(i - 1), dataObj);
@ -134,7 +155,8 @@ public class DefaultHistoryManager implements HistoryManager {
histObj.put("history", hist);
try {
return new String[]{objectMapper.writeValueAsString(histObj), objectMapper.writeValueAsString(histData)};
return new String[]{objectMapper.writeValueAsString(histObj),
objectMapper.writeValueAsString(histData)};
} catch (JsonProcessingException e) {
e.printStackTrace();
}
@ -143,7 +165,7 @@ public class DefaultHistoryManager implements HistoryManager {
}
// read a file
private String readFileToEnd(File file) {
private String readFileToEnd(final File file) {
String output = "";
try {
try (FileInputStream is = new FileInputStream(file)) {

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -43,7 +43,7 @@ public class DefaultJwtManager implements JwtManager {
private JSONParser parser;
// create document token
public String createToken(Map<String, Object> payloadClaims) {
public String createToken(final Map<String, Object> payloadClaims) {
try {
// build a HMAC signer using a SHA-256 hash
Signer signer = HMACSigner.newSHA256Signer(tokenSecret);
@ -63,18 +63,20 @@ public class DefaultJwtManager implements JwtManager {
}
// read document token
public JWT readToken(String token) {
public JWT readToken(final String token) {
try {
// build a HMAC verifier using the token secret
Verifier verifier = HMACVerifier.newVerifier(tokenSecret);
return JWT.getDecoder().decode(token, verifier); // verify and decode the encoded string JWT to a rich object
// verify and decode the encoded string JWT to a rich object
return JWT.getDecoder().decode(token, verifier);
} catch (Exception exception) {
return null;
}
}
// parse the body
public JSONObject parseBody(String payload, String header) {
public JSONObject parseBody(final String payload, final String header) {
JSONObject body;
try {
Object obj = parser.parse(payload); // get body parameters by parsing the payload
@ -86,7 +88,9 @@ public class DefaultJwtManager implements JwtManager {
String token = (String) body.get("token"); // get token from the body
if (token == null) { // if token is empty
if (header != null && !header.isBlank()) { // and the header is defined
token = header.startsWith("Bearer ") ? header.substring(7) : header; // get token from the header (it is placed after the Bearer prefix if it exists)
// get token from the header (it is placed after the Bearer prefix if it exists)
token = header.startsWith("Bearer ") ? header.substring("Bearer ".length()) : header;
}
}
if (token == null || token.isBlank()) {
@ -100,7 +104,7 @@ public class DefaultJwtManager implements JwtManager {
if (jwt.getObject("payload") != null) { // get payload from the token and check if it is not empty
try {
@SuppressWarnings("unchecked") LinkedHashMap<String, Object> jwtPayload =
(LinkedHashMap<String, Object>)jwt.getObject("payload");
(LinkedHashMap<String, Object>) jwt.getObject("payload");
jwt.claims = jwtPayload;
} catch (Exception ex) {

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -42,24 +42,27 @@ public class SampleTemplateManager implements TemplateManager {
private FileUtility fileUtility;
// create a template document with the specified name
public List<Template> createTemplates(String fileName){
public List<Template> createTemplates(final String fileName) {
List<Template> templates = List.of(
new Template("", "Blank", documentManager.getCreateUrl(fileName, false)), // create a blank template
new Template(getTemplateImageUrl(fileName), "With sample content", documentManager.getCreateUrl(fileName, true)) // create a template with sample content using the template image
new Template("", "Blank", documentManager
.getCreateUrl(fileName, false)), // create a blank template
new Template(getTemplateImageUrl(fileName), "With sample content", documentManager
.getCreateUrl(fileName,
true)) // create a template with sample content using the template image
);
return templates;
}
// get the template image URL for the specified file
public String getTemplateImageUrl(String fileName){
public String getTemplateImageUrl(final String fileName) {
DocumentType fileType = fileUtility.getDocumentType(fileName); // get the file type
String path = storagePathBuilder.getServerUrl(true); // get server URL
if(fileType.equals(DocumentType.word)){ // get URL to the template image for the word document type
if (fileType.equals(DocumentType.word)) { // get URL to the template image for the word document type
return path + "/css/img/file_docx.svg";
} else if(fileType.equals(DocumentType.slide)){ // get URL to the template image for the slide document type
} else if (fileType.equals(DocumentType.slide)) { // get URL to the template image for the slide document type
return path + "/css/img/file_pptx.svg";
} else if(fileType.equals(DocumentType.cell)){ // get URL to the template image for the cell document type
} else if (fileType.equals(DocumentType.cell)) { // get URL to the template image for the cell document type
return path + "/css/img/file_xlsx.svg";
}
return path + "/css/img/file_docx.svg"; // get URL to the template image for the default document type (word)

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -28,21 +28,26 @@ import org.springframework.stereotype.Component;
@Scope("prototype")
@Getter
@Setter
public class Customization { // the parameters which allow to customize the editor interface so that it looked like your other products (if there are any) and change the presence or absence of the additional buttons, links, change logos and editor owner details
/* The parameters which allow to customize the editor interface so that it looked like your
other products (if there are any) and change the presence or absence of the additional buttons,
links, change logos and editor owner details. */
public class Customization {
@Autowired
private Logo logo; // the image file at the top left corner of the Editor header
@Autowired
private Goback goback; // the settings for the Open file location menu button and upper right corner button
private Boolean autosave = true; // if the Autosave menu option is enabled or disabled
private Boolean comments = true; // if the Comments menu button is displayed or hidden
private Boolean compactHeader = false; // if the additional action buttons are displayed in the upper part of the editor window header next to the logo (false) or in the toolbar (true)
private Boolean compactHeader = false; /* if the additional action buttons are displayed
in the upper part of the editor window header next to the logo (false) or in the toolbar (true) */
private Boolean compactToolbar = false; // if the top toolbar type displayed is full (false) or compact (true)
private Boolean compatibleFeatures = false; // the use of functionality only compatible with the OOXML format
private Boolean forcesave = false; // add the request for the forced file saving to the callback handler when saving the document within the document editing service
private Boolean forcesave = false; /* add the request for the forced file saving to the callback handler
when saving the document within the document editing service */
private Boolean help = true; // if the Help menu button is displayed or hidden
private Boolean hideRightMenu = false; // if the right menu is displayed or hidden on first loading
private Boolean hideRulers = false; // if the editor rulers are displayed or hidden
private Boolean submitForm = false; // if the Submit form button is displayed or hidden
private Boolean about = true;
private Boolean feedback =true;
private Boolean feedback = true;
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -28,9 +28,13 @@ import org.springframework.stereotype.Component;
@Scope("prototype")
@Getter
@Setter
public class Embedded { // the parameters which allow to change the settings which define the behavior of the buttons in the embedded mode
private String embedUrl; // the absolute URL to the document serving as a source file for the document embedded into the web page
private String saveUrl; // the absolute URL that will allow the document to be saved onto the user personal computer
/* The parameters which allow to change the settings
which define the behavior of the buttons in the embedded mode */
public class Embedded {
private String embedUrl; /* the absolute URL to the document serving as a source file for the document embedded
into the web page */
private String saveUrl; /* the absolute URL that will allow the document to be saved
onto the user personal computer */
private String shareUrl; // the absolute URL that will allow other users to share this document
private ToolbarDocked toolbarDocked; // the place for the embedded viewer toolbar, can be either top or bottom
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -38,7 +38,8 @@ public class Goback { // the settings for the Open file location menu button an
private String indexMapping;
@Getter
private String url; // the absolute URL to the website address which will be opened when clicking the Open file location menu button
private String url; /* the absolute URL to the website address which will be opened
when clicking the Open file location menu button */
@PostConstruct
private void init() {

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -31,7 +31,9 @@ import java.util.Locale;
@Scope("prototype")
@Getter
@Setter
public class Info { // the additional parameters for the document (document owner, folder where the document is stored, uploading date, sharing settings)
/* The additional parameters for the document (document owner, folder where the document is stored,
uploading date, sharing settings) */
public class Info {
private String owner = "Me"; // the name of the document owner/creator
private Boolean favorite = null; // the highlighting state of the Favorite icon
private String uploaded = getDate(); // the document uploading date

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -0,0 +1,48 @@
/**
*
* (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 com.onlyoffice.integration.documentserver.models.enums;
public enum ConvertErrorType {
EMPTY_ERROR(0, ""),
CONVERTATION_UNKNOWN(-1, "Error convertation unknown"),
CONVERTATION_TIMEOUT(-2, "Error convertation timeout"),
CONVERTATION_ERROR(-3, "Error convertation error"),
DOWNLOAD_ERROR(-4, "Error download error"),
UNEXPECTED_GUID_ERROR(-5, "Error unexpected guid"),
DATABASE_ERROR(-6, "Error database"),
DOCUMENT_REQUEST_ERROR(-7, "Error document request"),
DOCUMENT_VKEY_ERROR(-8, "Error document VKey");
private final int code;
private final String label;
ConvertErrorType(final int codeParam, final String labelParam) {
this.code = codeParam;
this.label = labelParam;
}
public static String labelOfCode(final int code) {
for (ConvertErrorType convertErrorType : values()) {
if (convertErrorType.code == code) {
return convertErrorType.label;
}
}
return "ErrorCode = " + code;
}
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -31,13 +31,16 @@ import org.springframework.stereotype.Component;
@Setter
public class Document { // the parameters pertaining to the document (title, url, file type, etc.)
@Autowired
private Info info; // additional parameters for the document (document owner, folder where the document is stored, uploading date, sharing settings)
private Info info; /* additional parameters for the document (document owner, folder where the document is stored,
uploading date, sharing settings) */
@Autowired
private Permission permissions; // the permission for the document to be edited and downloaded or not
private String fileType; // the file type for the source viewed or edited document
private String key; // the unique document identifier used by the service to recognize the document
private String urlUser; // the absolute URL that will allow the document to be saved onto the user personal computer
private String title; // the desired file name for the viewed or edited document which will also be used as file name when the document is downloaded
private String urlUser; /* the absolute URL that will allow the document to be saved
onto the user personal computer */
private String title; /* the desired file name for the viewed or edited document which will also be used
as file name when the document is downloaded */
private String url; // the absolute URL where the source viewed or edited document is stored
private String directUrl;
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -21,7 +21,9 @@ package com.onlyoffice.integration.documentserver.models.filemodel;
import com.onlyoffice.integration.documentserver.models.configurations.Customization;
import com.onlyoffice.integration.documentserver.models.configurations.Embedded;
import com.onlyoffice.integration.documentserver.models.enums.Mode;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@ -34,18 +36,24 @@ import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class EditorConfig { // the parameters pertaining to the editor interface: opening mode (viewer or editor), interface language, additional buttons, etc.
private HashMap<String, Object> actionLink = null; // the data which contains the information about the action in the document that will be scrolled to
public class EditorConfig { /* the parameters pertaining to the editor interface: opening mode (viewer or editor),
interface language, additional buttons, etc. */
private HashMap<String, Object> actionLink = null; /* the data which contains the information about the
action in the document that will be scrolled to */
private String callbackUrl; // the absolute URL to the document storage service
private HashMap<String, Object> coEditing = null;
private String createUrl; // the absolute URL of the document where it will be created and available after creation
@Autowired
private Customization customization; // the parameters which allow to customize the editor interface so that it looked like your other products (if there are any) and change the presence or absence of the additional buttons, links, change logos and editor owner details
private Customization customization; /* the parameters which allow to customize the editor interface
so that it looked like your other products (if there are any) and change the presence or absence
of the additional buttons, links, change logos and editor owner details */
@Autowired
private Embedded embedded; // the parameters which allow to change the settings which define the behavior of the buttons in the embedded mode
private Embedded embedded; /* the parameters which allow to change the settings which define
the behavior of the buttons in the embedded mode */
private String lang; // the editor interface language
private Mode mode; // the editor opening mode
@Autowired
private User user; // the user currently viewing or editing the document
private List<Template> templates; // the presence or absence of the templates in the <b>Create New...</b> menu option
private List<Template> templates; /* the presence or absence
of the templates in the <b>Create New...</b> menu option */
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -30,12 +30,15 @@ import org.springframework.stereotype.Component;
@Scope("prototype")
@Getter
@Setter
public class FileModel { // the file base parameters which include the platform type used, document display size (width and height) and type of the document opened
/* the file base parameters which include the platform type used,
document display size (width and height) and type of the document opened */
public class FileModel {
@Autowired
private Document document; // the parameters pertaining to the document (title, url, file type, etc.)
private DocumentType documentType; // the document type to be opened
@Autowired
private EditorConfig editorConfig; // the parameters pertaining to the editor interface: opening mode (viewer or editor), interface language, additional buttons, etc.
private EditorConfig editorConfig; /* the parameters pertaining to the
editor interface: opening mode (viewer or editor), interface language, additional buttons, etc. */
private String token; // the encrypted signature added to the Document Server config
private Type type; // the platform type used to access the document
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -40,7 +40,8 @@ public class Permission extends AbstractModel { // the permission for the docum
private Boolean edit = true; // if the document can be edited or only viewed
private Boolean print = true; // if the document can be printed or not
private Boolean fillForms = true; // if the forms can be filled
private Boolean modifyFilter = true; // if the filter can applied globally (true) affecting all the other users, or locally (false)
private Boolean modifyFilter = true; /* if the filter can applied globally (true) affecting all the
other users, or locally (false) */
private Boolean modifyContentControl = true; // if the content control settings can be changed
private Boolean review = true; // if the document can be reviewed or not
private Boolean chat = true; // if a chat can be used

View File

@ -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 com.onlyoffice.integration.documentserver.models.filemodel;
import lombok.AllArgsConstructor;

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -34,9 +34,9 @@ public class User extends AbstractModel {
private String group;
// the user configuration parameters
public void configure(int id, String name, String group){
this.id = "uid-"+id; // the user id
this.name = name; // the user name
this.group = group; // the group the user belongs to
public void configure(final int idParam, final String nameParam, final String groupParam) {
this.id = "uid-" + idParam; // the user id
this.name = nameParam; // the user name
this.group = groupParam; // the group the user belongs to
}
}

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.

View File

@ -1,6 +1,6 @@
/**
*
* (c) Copyright Ascensio System SIA 2021
* (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.
@ -22,13 +22,17 @@ import java.util.List;
public class SerializerFilter {
@Override
public boolean equals(Object obj) {
public boolean equals(final Object obj) {
if (obj instanceof List) {
if(((List<?>) obj).size() == 1 && ((List<?>) obj).get(0) == FilterState.NULL.toString()){
if (((List<?>) obj).size() == 1 && ((List<?>) obj).get(0) == FilterState.NULL.toString()) {
return true;
}
return false;
}
return false;
}
@Override
public int hashCode() {
return super.hashCode();
}
}

View File

@ -1,7 +1,26 @@
/**
*
* (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 com.onlyoffice.integration.documentserver.storage;
import org.springframework.core.io.Resource;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.nio.file.Path;
@ -16,8 +35,8 @@ public interface FileStorageMutator {
boolean writeToFile(String pathName, String payload); // write the payload to the file
boolean moveFile(Path source, Path destination); // move a file to the specified destination
Resource loadFileAsResource(String fileName); // load file as a resource
Resource loadFileAsResourceHistory(String fileName,String version,String file); // load file as a resource
Resource loadFileAsResourceHistory(String fileName, String version, String file); // load file as a resource
File[] getStoredFiles(); // get a collection of all the stored files
void createMeta(String fileName, String uid, String uname); // create the file meta information
boolean createOrUpdateFile(Path path, InputStream stream); // create or update a file
boolean createOrUpdateFile(Path path, ByteArrayInputStream stream); // create or update a file
}

Some files were not shown because too many files have changed in this diff Show More