mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-02-11 10:25:15 +08:00
Compare commits
538 Commits
v7.1.1.40
...
feature/ja
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ac382d3c0 | |||
| 5933aa83ad | |||
| 2e1854f6c1 | |||
| 2d9a7ed502 | |||
| 78bd037486 | |||
| 17beef45f4 | |||
| b11a1be481 | |||
| a3e140981d | |||
| e0386f7cf9 | |||
| 0521f20413 | |||
| 61b5746ddf | |||
| 57d823acb1 | |||
| 4d99e2e406 | |||
| bec48ed834 | |||
| e856f5bcb1 | |||
| c57a710bca | |||
| 248e9213a1 | |||
| a035adcbd9 | |||
| 7fd1b65fec | |||
| 8ee0aa45b9 | |||
| dfcf244dc8 | |||
| 0563795494 | |||
| b6b6e80ffb | |||
| bd3b91d02f | |||
| 555f8d43cd | |||
| 3f48a8d492 | |||
| bb921e7eff | |||
| 13d5e6fa94 | |||
| cbfcf5de96 | |||
| 4771d96819 | |||
| d2aa6f0653 | |||
| cf2a00a374 | |||
| bdfb75dc84 | |||
| 9e21ca625c | |||
| 02def07f23 | |||
| fc4dac6c4b | |||
| 486a09f3b2 | |||
| 9a22fc854b | |||
| ac4d5561a2 | |||
| 98cdda06c4 | |||
| 744fccf913 | |||
| 349ff5d61d | |||
| dbba22df23 | |||
| 2ddd822b24 | |||
| 6b4d6baf4b | |||
| 2c8d151cc7 | |||
| 60c7c025a3 | |||
| 7aaf5243cb | |||
| 44b0f4d53d | |||
| b765d43612 | |||
| 70b63636e3 | |||
| 8d4582e379 | |||
| a1ec2cf366 | |||
| 4907e9d3c8 | |||
| 88f3d6da59 | |||
| 481b111cb2 | |||
| a1e13f3315 | |||
| d1dd289c77 | |||
| 7b4e40c4e4 | |||
| 6d4cad2215 | |||
| f43a4471ef | |||
| 0cf90e86c7 | |||
| 406de99b01 | |||
| f4bcb15d33 | |||
| d2a0164738 | |||
| a49ef4cc13 | |||
| 3ca29cd402 | |||
| c398b30e33 | |||
| 8caea9fab0 | |||
| f44c62540c | |||
| 7644db80e3 | |||
| 880497cd01 | |||
| 34f8174d9d | |||
| 99bc9d3fdf | |||
| 165c292ab8 | |||
| 8fe41cd8e6 | |||
| 705ea097e2 | |||
| f4799bebb4 | |||
| 4ffa524de0 | |||
| cd055317e0 | |||
| b1941c5980 | |||
| 83bc0fed5e | |||
| 8b71bb0433 | |||
| 5620f49f8f | |||
| d9fefef834 | |||
| 37591d847c | |||
| 77290d88f3 | |||
| 6befd87761 | |||
| f3e270c1ad | |||
| f5f1e4b391 | |||
| 8ba389d02f | |||
| 45910ff1f3 | |||
| 3bd6f51edc | |||
| fe9791f03d | |||
| 531137dca4 | |||
| e267b30b26 | |||
| 8733baa04b | |||
| 8cec9fc465 | |||
| 7ec969f4d9 | |||
| c7e13ef8a8 | |||
| 3d488f89b2 | |||
| cc00af1510 | |||
| f8aa55143c | |||
| 1b44c04893 | |||
| 1585d1821e | |||
| e996c4d265 | |||
| cc0c6189bd | |||
| ef7662c069 | |||
| 79ff84a4cc | |||
| e4bab17b08 | |||
| c734f5dd69 | |||
| d79feca18c | |||
| 3181c7449d | |||
| 8ea2edefb9 | |||
| 1a51759154 | |||
| 77c4caa26f | |||
| 5944e41cb4 | |||
| 09ccde3f84 | |||
| b27e532a83 | |||
| e9632eb5e2 | |||
| 8807328180 | |||
| 827e96c506 | |||
| 491cbbc843 | |||
| 68d26c9c66 | |||
| 80924be536 | |||
| 0ca829181c | |||
| 64f085d4b7 | |||
| 39c2267468 | |||
| 22af4e097f | |||
| 1a1cde0f67 | |||
| 1265ecdee1 | |||
| 19d11a97f9 | |||
| bf6f3373a6 | |||
| 1fb4d759a3 | |||
| de33efa599 | |||
| 6fa150ade6 | |||
| 88f4b6327d | |||
| 82905fca6c | |||
| ccb67ad73d | |||
| 5a233b8dc7 | |||
| 127183bb16 | |||
| 8924304bdb | |||
| 68dd1fc369 | |||
| 7251cb1681 | |||
| a82e4b6bdf | |||
| d2f2031fa7 | |||
| 4a902dff94 | |||
| f26220683c | |||
| c3e4533d1a | |||
| f6618c8c92 | |||
| efd710c6c0 | |||
| e106677efb | |||
| ecd02e07c0 | |||
| 847902fad9 | |||
| d4b5f86822 | |||
| 7c35d8127d | |||
| d023b23fc9 | |||
| 8b10c5ac2e | |||
| 54bc536329 | |||
| 07d7e5d887 | |||
| 009577b52e | |||
| c1fd896be4 | |||
| 033126583b | |||
| 3140d31e9c | |||
| 92ea5151ad | |||
| ae4e4c14ad | |||
| 9a9d3c0b35 | |||
| 13d3fe97d9 | |||
| 5bfe32f796 | |||
| 5a1ad9139f | |||
| 91fbc384f3 | |||
| 9d275ebe6c | |||
| 09a5d802ec | |||
| b548ffb97e | |||
| 50b0c3d29e | |||
| 93b4560c31 | |||
| 2e9807814a | |||
| d0cfd03bf8 | |||
| 72c14a4e7b | |||
| 44a3f29a79 | |||
| 98dceacc4c | |||
| 05f4063ba6 | |||
| d5797f7c02 | |||
| 5f40faac2a | |||
| c062e554db | |||
| 41e44985d6 | |||
| 95e1135e86 | |||
| cafb79c8d5 | |||
| 1dbc275a57 | |||
| 6dd44d2094 | |||
| b74a3c5565 | |||
| 27e5fa8482 | |||
| 46dab40432 | |||
| ebd4ead751 | |||
| 9014f96da3 | |||
| 273e4d5b77 | |||
| d8b6cdcf78 | |||
| 6e0899daaf | |||
| a5d459a744 | |||
| dcb48f3849 | |||
| c8b3ed761e | |||
| 01c8b23d1d | |||
| bf9373842b | |||
| 7eaf4f5ae7 | |||
| e09f258f25 | |||
| 054e144d93 | |||
| 3b698eb974 | |||
| c356d952be | |||
| b1f3704624 | |||
| 1dd545dc9c | |||
| 1f6dfb0677 | |||
| b59874f54b | |||
| 4d9f02c606 | |||
| c344a1d6a6 | |||
| a53f36eca3 | |||
| ca49e5bdda | |||
| 4882459f51 | |||
| 0a0f5b556c | |||
| fdefc25479 | |||
| 2502c2a979 | |||
| be85920ce4 | |||
| 7d7c10b3bc | |||
| 1cbc6eca2e | |||
| df83585352 | |||
| 6979ec815e | |||
| d007b0a969 | |||
| 63f032d924 | |||
| 96a9dd7990 | |||
| 91d8fc2487 | |||
| ae64081f97 | |||
| 820cafe202 | |||
| e0d7e416d3 | |||
| 806aba967c | |||
| 3ec226109e | |||
| b1f0fa6ecc | |||
| b02ffff33e | |||
| f74f0ba376 | |||
| 96d3bf2e63 | |||
| daf4f62acd | |||
| ade8a07e95 | |||
| 8b613627d1 | |||
| 3d3a10005c | |||
| 801c451899 | |||
| df034c2af2 | |||
| 9726c06c84 | |||
| 3a45e1b0f3 | |||
| ed8d0194b7 | |||
| a59da2d5df | |||
| f5c9a9e924 | |||
| 7b12b970c0 | |||
| 87a11c8633 | |||
| 01e0cefae5 | |||
| 98d42249fa | |||
| fd9454dd5f | |||
| fbf4153dea | |||
| 83b0411a4d | |||
| c60e4e25e2 | |||
| 4ebbecf580 | |||
| 6dbf383e2d | |||
| 1012bf13a6 | |||
| a24e081564 | |||
| 187ee212a9 | |||
| 106d9bfed3 | |||
| 13e243f900 | |||
| 4ccc3fa35e | |||
| be1fa2da14 | |||
| b6645427a8 | |||
| 39d7c366e3 | |||
| 075f464701 | |||
| 9414dff70c | |||
| 05b8989a87 | |||
| 43b6f53652 | |||
| c22c0d72aa | |||
| d61c112aa2 | |||
| ae3def67f5 | |||
| 7c22ba4e9e | |||
| 320881f1cf | |||
| 90c31eb887 | |||
| 702d0f1aa8 | |||
| dbf1047f29 | |||
| 0d27d142d4 | |||
| 807cbbf236 | |||
| e6b0bfd0be | |||
| 943d059c7c | |||
| 399ab0714d | |||
| 8cabbe9c71 | |||
| e40b6b2e28 | |||
| 0a390094e5 | |||
| f7bb668f8b | |||
| 808712ad34 | |||
| 2b0ba914dc | |||
| 249adaab48 | |||
| ee99a80ead | |||
| d61fdaaa53 | |||
| 270cbee160 | |||
| e9721dd655 | |||
| a31a24a871 | |||
| df0e197cb5 | |||
| 09802afc6f | |||
| 1c43679d87 | |||
| 573eeb6e18 | |||
| 78cf6c35f8 | |||
| c7f5003d69 | |||
| 19baff4340 | |||
| cc5c912658 | |||
| 64f2d605c2 | |||
| c9fca685bf | |||
| 820883a584 | |||
| 05a00a33a3 | |||
| 613cb713cc | |||
| 9216ff3a97 | |||
| dbaa7c5113 | |||
| d6ad145111 | |||
| 456df162e6 | |||
| 50fd47cf7c | |||
| f9c0da1696 | |||
| a7807513c6 | |||
| 128430d698 | |||
| 8077a66f16 | |||
| b3d8695a26 | |||
| 00872758ee | |||
| 3301c24de5 | |||
| dd0c049a70 | |||
| 44fb3a089c | |||
| 513bf99adb | |||
| 6f92633ef8 | |||
| b67e768dce | |||
| 751a886bfa | |||
| 66ea4b144b | |||
| 7a73422231 | |||
| 5319e18fb5 | |||
| 93accdac7c | |||
| def268f5f2 | |||
| 6054bffb3f | |||
| a7c917db3f | |||
| 30481005a1 | |||
| 5544768500 | |||
| 14e53970c8 | |||
| 82efd0f18a | |||
| 8ce90d89ed | |||
| 2b184972dc | |||
| 0fb9da4d89 | |||
| 9277d3de58 | |||
| baf7a1e5dd | |||
| e2a14a74db | |||
| 848cfb20bc | |||
| ddd3ec82a8 | |||
| 0ed08fd7b2 | |||
| e1c5907003 | |||
| 9dd2d7c0db | |||
| 8f0cbb78af | |||
| 72e48914aa | |||
| 82a282029a | |||
| 9b7c12b5c0 | |||
| 6ea5546099 | |||
| 92fbd1e293 | |||
| 855c1ed9f9 | |||
| 7e60ec15fd | |||
| 3697a4a888 | |||
| 0b8107d167 | |||
| 885850ee33 | |||
| 98c61250a6 | |||
| 457487844c | |||
| ff72956b68 | |||
| 1593df6aec | |||
| cda8a86c2a | |||
| 16584c0abb | |||
| 1ddda89001 | |||
| 5b76d798fb | |||
| e96200df85 | |||
| de75b11e18 | |||
| f27afe1535 | |||
| 59e17079ff | |||
| 1bdb3c03bc | |||
| 111dc14f2b | |||
| 4a656c025f | |||
| ce9930e5bc | |||
| 9da22d7803 | |||
| d78c677c99 | |||
| b204142c13 | |||
| fd1c26ab9f | |||
| 5993d10bee | |||
| c5771c9008 | |||
| 2fad227272 | |||
| ada438ff0b | |||
| 0dbd65a577 | |||
| 48e5b8d4e0 | |||
| 7f08a96681 | |||
| 3549b4bc2a | |||
| c9265d9ddc | |||
| 44d9ca88c6 | |||
| d964b43087 | |||
| 5a0debd9e8 | |||
| 3b0f942eee | |||
| 4ee110c2d5 | |||
| ad1d93dd20 | |||
| d2d98df5ab | |||
| 7805f7dc91 | |||
| 51ec27d67c | |||
| 9e94716df0 | |||
| 988a8339b1 | |||
| a482635e3f | |||
| d2c679f6b1 | |||
| 1da452d857 | |||
| d9b8d2b7e9 | |||
| 24aee6d194 | |||
| bd108a9c77 | |||
| e737e8ed48 | |||
| b425d15f0a | |||
| 0f8dec1e6e | |||
| 193b31fe75 | |||
| 583403cf78 | |||
| 641e45e24f | |||
| 53c30fbb7d | |||
| 87a1755729 | |||
| 752a2a2364 | |||
| d1affa2911 | |||
| 0ef2a4f3fd | |||
| 675d3f318a | |||
| 05512ffa23 | |||
| 2eeed5d26d | |||
| 9e3dbd5eb5 | |||
| efbab7c113 | |||
| b8f0f6447c | |||
| 8779a90433 | |||
| b3162ee410 | |||
| 42edd5e208 | |||
| e041baeef7 | |||
| 5bf682a007 | |||
| 6dacf49faa | |||
| 63c9c4242e | |||
| b5e345ed50 | |||
| 33f8436d42 | |||
| c5217242ab | |||
| c910d5193b | |||
| 58c27f8f2f | |||
| 1ec831789b | |||
| 0510fd1354 | |||
| 25238b5614 | |||
| 901bb61883 | |||
| 7f3e6c6364 | |||
| b3512ea0ce | |||
| 642a1bd19a | |||
| ac471588de | |||
| 17674ef5bc | |||
| dc2ee2a997 | |||
| c358fa814a | |||
| 143a73e083 | |||
| c266592434 | |||
| 19ed666d56 | |||
| 84b9202af0 | |||
| 8fb698bb75 | |||
| 00f46ef080 | |||
| 5c194da95d | |||
| 0d5cebe28e | |||
| dacf72cae2 | |||
| 208b8926be | |||
| 55c4853f04 | |||
| ccae7c6a06 | |||
| dc84dd3b29 | |||
| 65d3671b09 | |||
| 1fb5ef8bfd | |||
| b630c3802b | |||
| ad3993b532 | |||
| 35ee61e011 | |||
| ee59ab3dfd | |||
| 500f076e38 | |||
| e578f29d9d | |||
| 9de9bc90a4 | |||
| 7a9ebdbbe5 | |||
| 887089bcad | |||
| 680e53823a | |||
| 33e1489cd6 | |||
| 8c90737bf6 | |||
| e5f1bc8ed6 | |||
| 985b179475 | |||
| 775d15132f | |||
| 4a4298ca10 | |||
| cdbd264ed5 | |||
| e61f6cae89 | |||
| 22039078ef | |||
| 62793a42ab | |||
| f49f96a2c2 | |||
| 2031d65adb | |||
| 7f54659d3b | |||
| a3bc13bb6e | |||
| 29ea16c124 | |||
| 6d4c8b926e | |||
| 22d2031426 | |||
| fcc51e8154 | |||
| 8cd85ad63c | |||
| 1d51688884 | |||
| 2c63a85b00 | |||
| d1545c4db4 | |||
| bd8e4d6ec7 | |||
| e1c815b574 | |||
| 4042d2bb8a | |||
| 8c9d2d80bd | |||
| 3a9259d713 | |||
| 39129a537e | |||
| dfaf552bf8 | |||
| cc8b6f3716 | |||
| 13726b3c2f | |||
| 8bcc15e320 | |||
| 8fca045dd7 | |||
| a018cc5787 | |||
| 054236ef8a | |||
| e662c765e6 | |||
| 058bb0d2e2 | |||
| ac78d1fc08 | |||
| 070dac6878 | |||
| cfa0fb1b74 | |||
| 1d624e6831 | |||
| fe83e98b37 | |||
| f9ea7f7b50 | |||
| 328ea46693 | |||
| 41ec2742a7 | |||
| 76fc55c2d4 | |||
| e10f3962b6 | |||
| b9859ef5ca | |||
| 1cb2b586b1 | |||
| e5d31eebbf | |||
| 1ac40c539f | |||
| 371366befa | |||
| 0bee4817e7 | |||
| ad941e0ba4 | |||
| 93c69e51ed | |||
| 8b8b7d3938 | |||
| f8f01a033e | |||
| f497f10913 | |||
| 8b2478ac71 | |||
| 391c347419 | |||
| 5a08009b7b | |||
| 4e5b65f673 | |||
| 13e3d7673b | |||
| c0a46866ce | |||
| e7b76729a4 | |||
| ce2e7f97d6 |
31
.github/workflows/lint-java.yml
vendored
Normal file
31
.github/workflows/lint-java.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
name: Lint Java
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/java/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/java/**']
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./web/documentserver-example/java
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Java 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
|
||||
- name: Run linter
|
||||
run: |
|
||||
mvn -version
|
||||
mvn package
|
||||
35
.github/workflows/lint-nodejs.yml
vendored
Normal file
35
.github/workflows/lint-nodejs.yml
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
name: ESLint
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/nodejs/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/nodejs/**']
|
||||
|
||||
env:
|
||||
NODE_VERSION: 16
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./web/documentserver-example/nodejs
|
||||
steps:
|
||||
- name: Install NodeJS
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- name: Code Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Code Linting
|
||||
run: npm run lint
|
||||
31
.github/workflows/lint-php.yml
vendored
Normal file
31
.github/workflows/lint-php.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
name: PHPCs
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/php/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/php/**']
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./web/documentserver-example/php
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.2'
|
||||
tools: cs2pr, phpcs
|
||||
|
||||
- name: Run phpcs
|
||||
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 ./
|
||||
40
.github/workflows/lint-python.yml
vendored
Normal file
40
.github/workflows/lint-python.yml
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
name: PyLint
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/python/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/python/**']
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./web/documentserver-example/python
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install flake8
|
||||
pip install pylint
|
||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||
|
||||
- name: Lint Flake8
|
||||
run: |
|
||||
flake8 ./**/*.py --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
flake8 ./**/*.py --count --max-complexity=10 --max-line-length=79 --statistics
|
||||
|
||||
- name: Lint Pylint
|
||||
run: |
|
||||
pylint ./**/*.py
|
||||
31
.github/workflows/lint-ruby.yml
vendored
Normal file
31
.github/workflows/lint-ruby.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
name: Rubocop
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/ruby/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/ruby/**']
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./web/documentserver-example/ruby
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: '3.0'
|
||||
bundler-cache: true
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
bundle install
|
||||
- name: Rubocop
|
||||
run: |
|
||||
gem install rubocop
|
||||
rubocop
|
||||
31
.github/workflows/lint-spring.yml
vendored
Normal file
31
.github/workflows/lint-spring.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
name: Lint Spring
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/java-spring/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/java-spring/**']
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./web/documentserver-example/java-spring
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Java 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
|
||||
- name: Run linter
|
||||
run: |
|
||||
mvn -version
|
||||
mvn package
|
||||
@ -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
|
||||
|
||||
|
||||
49
CHANGELOG.md
Normal file
49
CHANGELOG.md
Normal file
@ -0,0 +1,49 @@
|
||||
# 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
|
||||
- description in the tooltip on the main page
|
||||
- nodejs: referenceData
|
||||
- option to send directUrl
|
||||
|
||||
## 1.4.0
|
||||
- nodejs: option to send directUrl
|
||||
- opening file on client by directUrl
|
||||
- offline viewer for anonymous
|
||||
- added hy, eu, zh-TW, ms, pt-PT
|
||||
|
||||
## 1.3.1
|
||||
- charp: fix references
|
||||
- ruby: update rails
|
||||
|
||||
## 1.3.0
|
||||
- update empty files
|
||||
- anonymous without chat
|
||||
- changed jwt implementation in csharp, csharp-mvc, php, ruby
|
||||
|
||||
## 1.2.0
|
||||
- ruby v3.0
|
||||
- set filetype in setHistoryData
|
||||
- read filetype from input request
|
||||
- creating file on WOPI
|
||||
- upload on WOPI page
|
||||
- fix xss
|
||||
- set userInfoGroups
|
||||
- check JWT on downloading history
|
||||
- upload dialog on mobile
|
||||
- anonymous without id
|
||||
- renaming from editor
|
||||
- new skin languages
|
||||
- ignore certificate
|
||||
|
||||
## 1.1.0
|
||||
- creating docxf
|
||||
- opening docxf, oform
|
||||
|
||||
## 1.0.0
|
||||
- added java spring
|
||||
@ -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" />
|
||||
|
||||
@ -24,11 +24,15 @@ jQuery.UI - jQuery UI is an open source library of interface components —
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
JWT - JWT (JSON Web Token) Implementation for .NET (Public Domain) (https://github.com/jwt-dotnet/jwt/)
|
||||
License: MIT
|
||||
License File: JWT.license
|
||||
|
||||
Microsoft.Web.Infrastructure - This package contains the Microsoft.Web.Infrastructure assembly that lets you dynamically register HTTP modules at run time. (https://www.microsoft.com/web/webpi/eula/aspnetmvc3update-eula.htm)
|
||||
License: MS-EULA License
|
||||
License File: Microsoft.Web.Infrastructure.license
|
||||
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://licenses.nuget.org/MIT)
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://github.com/JamesNK/Newtonsoft.Json)
|
||||
License: MIT
|
||||
License File: Newtonsoft.Json.license
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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%;
|
||||
}
|
||||
|
||||
@ -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.
|
||||
@ -167,7 +167,7 @@ label .checkbox {
|
||||
background-image: url("images/file_docxf.svg");
|
||||
}
|
||||
|
||||
.create-sample {
|
||||
.side-option {
|
||||
color: #666666;
|
||||
line-height: 24px;
|
||||
}
|
||||
@ -740,3 +740,28 @@ html {
|
||||
.user-descr > b {
|
||||
margin-left: 25px;
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
background: #FFFFFF;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0px 7px 25px rgba(85, 85, 85, 0.15);
|
||||
color: #666666;
|
||||
line-height: 160%;
|
||||
max-width: 455px;
|
||||
padding: 14px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.tooltip ul {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
border-top: 8px solid transparent;
|
||||
border-bottom: 8px solid transparent;
|
||||
border-right: 8px solid #FFFFFF;
|
||||
left: -4px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
@ -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.
|
||||
@ -16,6 +16,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Web.Mvc;
|
||||
using OnlineEditorsExampleMVC.Helpers;
|
||||
@ -31,13 +32,14 @@ namespace OnlineEditorsExampleMVC.Controllers
|
||||
}
|
||||
|
||||
// viewing file in the editor
|
||||
public ActionResult Editor(string fileName, string editorsMode, string editorsType)
|
||||
public ActionResult Editor(string fileName, string editorsMode, string editorsType, string directUrl)
|
||||
{
|
||||
var file = new FileModel
|
||||
{
|
||||
Mode = editorsMode, // editor mode: edit or view
|
||||
Type = editorsType, // editor type: desktop, mobile, embedded
|
||||
FileName = Path.GetFileName(fileName) // file name
|
||||
FileName = Path.GetFileName(fileName), // file name
|
||||
IsEnabledDirectUrl = directUrl != null ? Convert.ToBoolean(directUrl) : false
|
||||
};
|
||||
|
||||
return View("Editor", 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.
|
||||
|
||||
@ -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.
|
||||
@ -242,7 +242,8 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
{
|
||||
var uri = new UriBuilder(GetServerUrl(forDocumentServer))
|
||||
{
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath + "/"
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ CurUserHostAddress() + "/"
|
||||
+ fileName,
|
||||
Query = ""
|
||||
@ -292,7 +293,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=track"
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(fileName)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))
|
||||
};
|
||||
return callbackUrl.ToString();
|
||||
}
|
||||
@ -312,9 +313,10 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
}
|
||||
|
||||
// create the public history url
|
||||
public static string GetHistoryDownloadUrl(string filename, string version, string file)
|
||||
public static string GetHistoryDownloadUrl(string filename, string version, string file, Boolean isServer = true)
|
||||
{
|
||||
var downloadUrl = new UriBuilder(GetServerUrl(true))
|
||||
var userAddress = "&userAddress=" + HttpUtility.UrlEncode(CurUserHostAddress(HttpContext.Current.Request.UserHostAddress));
|
||||
var downloadUrl = new UriBuilder(GetServerUrl(isServer))
|
||||
{
|
||||
Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
@ -322,7 +324,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=downloadhistory"
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(filename)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress)
|
||||
+ userAddress
|
||||
+ "&ver=" + version
|
||||
+ "&file="+ file
|
||||
};
|
||||
@ -330,9 +332,10 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
}
|
||||
|
||||
// get url to download a file
|
||||
public static string GetDownloadUrl(string fileName)
|
||||
public static string GetDownloadUrl(string fileName, Boolean isServer = true)
|
||||
{
|
||||
var downloadUrl = new UriBuilder(GetServerUrl(true))
|
||||
var userAddress = isServer ? "&userAddress=" + HttpUtility.UrlEncode(CurUserHostAddress(HttpContext.Current.Request.UserHostAddress)) : "";
|
||||
var downloadUrl = new UriBuilder(GetServerUrl(isServer))
|
||||
{
|
||||
Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
@ -340,7 +343,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=download"
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(fileName)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress)
|
||||
+ userAddress
|
||||
};
|
||||
return downloadUrl.ToString();
|
||||
}
|
||||
@ -439,5 +442,11 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
}
|
||||
return languages;
|
||||
}
|
||||
|
||||
public static string GetDirectUrl()
|
||||
{
|
||||
string isEnabledDirectUrl = HttpUtility.ParseQueryString(HttpContext.Current.Request.Url.Query).Get("directUrl");
|
||||
return isEnabledDirectUrl != null ? isEnabledDirectUrl : "false";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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.
|
||||
@ -130,7 +130,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
var payloadToken = JwtManager.Encode(payload); // encode the payload object to the payload token
|
||||
var bodyToken = JwtManager.Encode(body); // encode the body object to the body token
|
||||
// create header token
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
request.Headers.Add(JWTheader, "Bearer " + payloadToken);
|
||||
|
||||
body.Add("token", bodyToken);
|
||||
|
||||
@ -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.
|
||||
@ -16,12 +16,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using JWT;
|
||||
using JWT.Algorithms;
|
||||
using JWT.Builder;
|
||||
using JWT.Serializers;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Script.Serialization;
|
||||
|
||||
namespace OnlineEditorsExampleMVC.Helpers
|
||||
{
|
||||
@ -30,31 +30,19 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
private static readonly string Secret;
|
||||
public static readonly bool Enabled;
|
||||
|
||||
private static readonly JavaScriptSerializer Serializer;
|
||||
|
||||
static JwtManager()
|
||||
{
|
||||
Secret = WebConfigurationManager.AppSettings["files.docservice.secret"] ?? ""; // get token secret from the config parameters
|
||||
Enabled = !string.IsNullOrEmpty(Secret); // check if the token is enabled
|
||||
Serializer = new JavaScriptSerializer(); // define java script serializer
|
||||
}
|
||||
|
||||
// encode a payload object into a token using a secret key
|
||||
public static string Encode(IDictionary<string, object> payload)
|
||||
{
|
||||
// define the hashing algorithm and the token type
|
||||
var header = new Dictionary<string, object>
|
||||
{
|
||||
{ "alg", "HS256" },
|
||||
{ "typ", "JWT" }
|
||||
};
|
||||
|
||||
// three parts of token
|
||||
var encHeader = Base64UrlEncode(Serializer.Serialize(header)); // header
|
||||
var encPayload = Base64UrlEncode(Serializer.Serialize(payload)); // payload
|
||||
var hashSum = Base64UrlEncode(CalculateHash(encHeader, encPayload)); // signature
|
||||
|
||||
return string.Format("{0}.{1}.{2}", encHeader, encPayload, hashSum);
|
||||
var encoder = new JwtEncoder(new HMACSHA256Algorithm(),
|
||||
new JsonNetSerializer(),
|
||||
new JwtBase64UrlEncoder());
|
||||
return encoder.Encode(payload, Secret);
|
||||
}
|
||||
|
||||
// decode a token into a payload object using a secret key
|
||||
@ -62,52 +50,11 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
{
|
||||
if (!Enabled || string.IsNullOrEmpty(token)) return "";
|
||||
|
||||
var split = token.Split('.');
|
||||
if (split.Length != 3) return "";
|
||||
|
||||
var hashSum = Base64UrlEncode(CalculateHash(split[0], split[1])); // get signature
|
||||
if (hashSum != split[2]) return ""; // and check if it is equal to the signature from the token
|
||||
return Base64UrlDecode(split[1]); // decode payload
|
||||
}
|
||||
|
||||
// generate a hash code based on a key using the HMAC method
|
||||
private static byte[] CalculateHash(string encHeader, string encPayload)
|
||||
{
|
||||
using (var hasher = new HMACSHA256(Encoding.UTF8.GetBytes(Secret)))
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(string.Format("{0}.{1}", encHeader, encPayload));
|
||||
return hasher.ComputeHash(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
// encode a string into the base64 value
|
||||
private static string Base64UrlEncode(string str)
|
||||
{
|
||||
return Base64UrlEncode(Encoding.UTF8.GetBytes(str));
|
||||
}
|
||||
|
||||
// encode bytes into the base64 value
|
||||
private static string Base64UrlEncode(byte[] bytes)
|
||||
{
|
||||
return Convert.ToBase64String(bytes)
|
||||
.TrimEnd('=').Replace('+', '-').Replace('/', '_');
|
||||
}
|
||||
|
||||
// decode a base64 value into the string
|
||||
private static string Base64UrlDecode(string payload)
|
||||
{
|
||||
var b64 = payload.Replace('_', '/').Replace('-', '+');
|
||||
switch (b64.Length%4)
|
||||
{
|
||||
case 2:
|
||||
b64 += "==";
|
||||
break;
|
||||
case 3:
|
||||
b64 += "=";
|
||||
break;
|
||||
}
|
||||
var bytes = Convert.FromBase64String(b64);
|
||||
return Encoding.UTF8.GetString(bytes);
|
||||
return JwtBuilder.Create()
|
||||
.WithAlgorithm(new HMACSHA256Algorithm())
|
||||
.WithSecret(Secret)
|
||||
.MustVerifySignature()
|
||||
.Decode(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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.
|
||||
@ -55,7 +55,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// check if the document token is enabled
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
string token = null;
|
||||
|
||||
@ -92,15 +92,13 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// file saving process
|
||||
public static int processSave(Dictionary<string, object> fileData, string fileName, string userAddress)
|
||||
{
|
||||
if (fileData["url"].Equals(null)) {
|
||||
if (string.IsNullOrEmpty((string)fileData["url"])) {
|
||||
throw new Exception("DownloadUrl is null");
|
||||
}
|
||||
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;
|
||||
@ -169,16 +178,14 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// file force saving process
|
||||
public static int processForceSave(Dictionary<string, object> fileData, string fileName, string userAddress)
|
||||
{
|
||||
if (fileData["url"].Equals(null)) {
|
||||
if ( string.IsNullOrEmpty((string)fileData["url"])) {
|
||||
throw new Exception("DownloadUrl is null");
|
||||
}
|
||||
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
|
||||
|
||||
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);
|
||||
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, false);
|
||||
if (forcesavePath.Equals("")) // create forcesave path if it doesn't exist
|
||||
{
|
||||
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;
|
||||
@ -279,7 +294,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
|
||||
var payloadToken = JwtManager.Encode(payload); // encode a payload object into a header token
|
||||
var bodyToken = JwtManager.Encode(body); // encode body into a body token
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
request.Headers.Add(JWTheader, "Bearer " + payloadToken); // add a header Authorization with a header token and Authorization prefix in it
|
||||
|
||||
body.Add("token", bodyToken);
|
||||
@ -314,26 +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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
@ -67,7 +67,9 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
"Can't mention others in comments",
|
||||
"Can't create new files from the editor",
|
||||
"Can’t see anyone’s information",
|
||||
"Can't rename files from the editor"
|
||||
"Can't rename files from the editor",
|
||||
"Can't view chat",
|
||||
"View file without collaboration",
|
||||
};
|
||||
|
||||
private static List<User> users = new List<User>() {
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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,6 +33,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{
|
||||
public string Mode { get; set; } // editor mode
|
||||
public string Type { get; set; } // editor type
|
||||
public bool IsEnabledDirectUrl { get; set; } // is enabled direct url
|
||||
|
||||
// get file url for Document Server
|
||||
public string FileUri
|
||||
@ -97,6 +98,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
var actionLink = request.GetOrDefault("actionLink", null); // get the action link (comment or bookmark) if it exists
|
||||
var actionData = string.IsNullOrEmpty(actionLink) ? null : jss.DeserializeObject(actionLink); // get action data for the action link
|
||||
|
||||
var directUrl = DocManagerHelper.GetDownloadUrl(FileName, false);
|
||||
var createUrl = DocManagerHelper.GetCreateUrl(FileUtility.GetFileType(FileName));
|
||||
var templatesImageUrl = DocManagerHelper.GetTemplateImageUrl(FileUtility.GetFileType(FileName)); // image url for templates
|
||||
var templates = new List<Dictionary<string, string>>
|
||||
@ -125,6 +127,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{
|
||||
{ "title", FileName },
|
||||
{ "url", DownloadUrl },
|
||||
{ "directUrl", IsEnabledDirectUrl ? directUrl : "" },
|
||||
{ "fileType", ext.Trim('.') },
|
||||
{ "key", Key },
|
||||
{
|
||||
@ -148,6 +151,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{ "modifyFilter", editorsMode != "filter" },
|
||||
{ "modifyContentControl", editorsMode != "blockcontent" },
|
||||
{ "review", canEdit && (editorsMode == "edit" || editorsMode == "review") },
|
||||
{ "chat", !user.id.Equals("uid-0") },
|
||||
{ "reviewGroups", user.reviewGroups },
|
||||
{ "commentGroups", user.commentGroups },
|
||||
{ "userInfoGroups", user.userInfoGroups }
|
||||
@ -162,6 +166,11 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{ "mode", mode },
|
||||
{ "lang", request.Cookies.GetOrDefault("ulang", "en") },
|
||||
{ "callbackUrl", CallbackUrl }, // absolute URL to the document storage service
|
||||
{ "coEditing", editorsMode == "view" && user.id.Equals("uid-0") ?
|
||||
new Dictionary<string, object>{
|
||||
{"mode", "strict"},
|
||||
{"change", false}
|
||||
} : null },
|
||||
{ "createUrl", !user.id.Equals("uid-0") ? createUrl : null },
|
||||
{ "templates", user.templates ? templates : null },
|
||||
{
|
||||
@ -177,9 +186,9 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
// the parameters for the embedded document type
|
||||
"embedded", new Dictionary<string, object>
|
||||
{
|
||||
{ "saveUrl", FileUriUser }, // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
{ "embedUrl", FileUriUser }, // the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
{ "shareUrl", FileUriUser }, // the absolute URL that will allow other users to share this document
|
||||
{ "saveUrl", directUrl }, // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
{ "embedUrl", directUrl }, // the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
{ "shareUrl", directUrl }, // the absolute URL that will allow other users to share this document
|
||||
{ "toolbarDocked", "top" } // the place for the embedded viewer toolbar (top or bottom)
|
||||
}
|
||||
},
|
||||
@ -195,7 +204,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{
|
||||
"goback", new Dictionary<string, object> // settings for the Open file location menu button and upper right corner button
|
||||
{
|
||||
{ "url", url.Action("Index", "Home") } // the absolute URL to the website address which will be opened when clicking the Open file location menu button
|
||||
{ "url", DocManagerHelper.GetServerUrl(false) } // the absolute URL to the website address which will be opened when clicking the Open file location menu button
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -262,17 +271,26 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
dataObj.Add("key", key);
|
||||
// write file url to the data object
|
||||
string prevFileUrl;
|
||||
string directPrevFileUrl;
|
||||
if (Path.IsPathRooted(storagePath) && !string.IsNullOrEmpty(storagePath))
|
||||
{
|
||||
prevFileUrl = i == currentVersion ? DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext)
|
||||
: DocManagerHelper.GetDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""));
|
||||
directPrevFileUrl = i == currentVersion ? DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext, false)
|
||||
: DocManagerHelper.GetDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""), false);
|
||||
}
|
||||
else {
|
||||
prevFileUrl = i == currentVersion ? FileUri
|
||||
: DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext);
|
||||
prevFileUrl = i == currentVersion ? FileUri
|
||||
: DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext);
|
||||
directPrevFileUrl = i == currentVersion ? DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext, false)
|
||||
: DocManagerHelper.GetDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""), false);
|
||||
}
|
||||
|
||||
dataObj.Add("url", prevFileUrl);
|
||||
if (IsEnabledDirectUrl)
|
||||
{
|
||||
dataObj.Add("directUrl", directPrevFileUrl);
|
||||
}
|
||||
dataObj.Add("version", i);
|
||||
if (i > 1) // check if the version number is greater than 1 (the file was modified)
|
||||
{
|
||||
@ -290,7 +308,12 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
obj.Add("user", change.Count > 0 ? change["user"] : null);
|
||||
|
||||
var prev = (Dictionary<string, object>)histData[(i - 2).ToString()]; // get the history data from the previous file version
|
||||
dataObj.Add("previous", new Dictionary<string, object>() { // write information about previous file version to the data object
|
||||
dataObj.Add("previous", IsEnabledDirectUrl ? new Dictionary<string, object>() { // write information about previous file version to the data object with direct url
|
||||
{ "fileType", prev["fileType"] },
|
||||
{ "key", prev["key"] }, // write key and url information about previous file version
|
||||
{ "url", prev["url"] },
|
||||
{ "directUrl", prev["directUrl"] },
|
||||
} : new Dictionary<string, object>() { // write information about previous file version to the data object without direct url
|
||||
{ "fileType", prev["fileType"] },
|
||||
{ "key", prev["key"] }, // write key and url information about previous file version
|
||||
{ "url", prev["url"] },
|
||||
@ -332,6 +355,14 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
Query = "type=assets&fileName=" + HttpUtility.UrlEncode("sample.docx")
|
||||
};
|
||||
|
||||
var directCompareFileUrl = new UriBuilder(DocManagerHelper.GetServerUrl(false))
|
||||
{
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=assets&fileName=" + HttpUtility.UrlEncode("sample.docx")
|
||||
};
|
||||
|
||||
// create an object with the information about the compared file
|
||||
var dataCompareFile = new Dictionary<string, object>
|
||||
{
|
||||
@ -339,6 +370,11 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{ "url", compareFileUrl.ToString() }
|
||||
};
|
||||
|
||||
if (IsEnabledDirectUrl)
|
||||
{
|
||||
dataCompareFile.Add("directUrl", directCompareFileUrl.ToString());
|
||||
}
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
{
|
||||
var compareFileToken = JwtManager.Encode(dataCompareFile); // encode the dataCompareFile object into the token
|
||||
@ -361,6 +397,13 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
+ "Content\\images\\logo.png"
|
||||
};
|
||||
|
||||
var directMailMergeUrl = new UriBuilder(DocManagerHelper.GetServerUrl(false))
|
||||
{
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "Content\\images\\logo.png"
|
||||
};
|
||||
|
||||
// create a logo config
|
||||
var logoConfig = new Dictionary<string, object>
|
||||
{
|
||||
@ -368,6 +411,11 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{ "url", mailMergeUrl.ToString()}
|
||||
};
|
||||
|
||||
if (IsEnabledDirectUrl)
|
||||
{
|
||||
logoConfig.Add("directUrl", directMailMergeUrl.ToString());
|
||||
}
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
{
|
||||
var token = JwtManager.Encode(logoConfig); // encode logoConfig into the token
|
||||
@ -392,6 +440,15 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
Query = "type=csv"
|
||||
};
|
||||
|
||||
var directMailMergeUrl = new UriBuilder(DocManagerHelper.GetServerUrl(false))
|
||||
{
|
||||
Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=csv"
|
||||
};
|
||||
|
||||
// create a mail merge config
|
||||
var mailMergeConfig = new Dictionary<string, object>
|
||||
{
|
||||
@ -399,6 +456,11 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{ "url", mailMergeUrl.ToString()}
|
||||
};
|
||||
|
||||
if (IsEnabledDirectUrl)
|
||||
{
|
||||
mailMergeConfig.Add("directUrl", directMailMergeUrl.ToString());
|
||||
}
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
{
|
||||
var mailmergeToken = JwtManager.Encode(mailMergeConfig); // encode mailMergeConfig into the token
|
||||
|
||||
@ -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,6 +43,9 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="JWT, Version=9.0.0.0, Culture=neutral, PublicKeyToken=6f98bca0f40f2ecf, processorArchitecture=MSIL">
|
||||
<HintPath>packages\JWT.9.0.3\lib\net46\JWT.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
@ -50,49 +53,49 @@
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="Antlr3.Runtime">
|
||||
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework">
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Infrastructure">
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Formatting">
|
||||
<Reference Include="System.Net.Http.Formatting, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Helpers">
|
||||
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http">
|
||||
<Reference Include="System.Web.Http, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.WebHost">
|
||||
<Reference Include="System.Web.Http.WebHost, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.WebHost.5.2.7\lib\net45\System.Web.Http.WebHost.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc">
|
||||
<Reference Include="System.Web.Mvc, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.Mvc.5.2.7\lib\net45\System.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Optimization">
|
||||
<Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Razor">
|
||||
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages">
|
||||
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Deployment">
|
||||
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Razor">
|
||||
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WebGrease">
|
||||
<Reference Include="WebGrease, Version=1.6.5135.21930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
@ -182,10 +185,12 @@
|
||||
<Content Include="assets\AUTHORS.md" />
|
||||
<Content Include="assets\LICENSE" />
|
||||
<Content Include="assets\new\new.docx" />
|
||||
<Content Include="assets\new\new.docxf" />
|
||||
<Content Include="assets\new\new.pptx" />
|
||||
<Content Include="assets\new\new.xlsx" />
|
||||
<Content Include="assets\sample\csv.csv" />
|
||||
<Content Include="assets\sample\sample.docx" />
|
||||
<Content Include="assets\sample\sample.docxf" />
|
||||
<Content Include="assets\sample\sample.pptx" />
|
||||
<Content Include="assets\sample\sample.xlsx" />
|
||||
<None Include="packages.config" />
|
||||
|
||||
@ -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("")]
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
@ -16,11 +16,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
var directUrl;
|
||||
|
||||
if (typeof jQuery != "undefined") {
|
||||
jq = jQuery.noConflict();
|
||||
|
||||
directUrl = getUrlVars()["directUrl"] == "true";
|
||||
|
||||
mustReload = false;
|
||||
|
||||
if (directUrl)
|
||||
jq("#directUrl").prop("checked", directUrl);
|
||||
else
|
||||
directUrl = jq("#directUrl").prop("checked");
|
||||
|
||||
jq("#directUrl").change(function () {
|
||||
window.location = "?directUrl=" + jq(this).prop("checked");
|
||||
});
|
||||
|
||||
jq(function () {
|
||||
jq('#fileupload').fileupload({
|
||||
dataType: 'json',
|
||||
@ -219,7 +232,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEdit:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = UrlEditor + "?fileName=" + fileId;
|
||||
var url = UrlEditor + "?fileName=" + fileId + "&directUrl=" + directUrl;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
@ -227,7 +240,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = UrlEditor + "?editorsMode=view&fileName=" + fileId;
|
||||
var url = UrlEditor + "?editorsMode=view&fileName=" + fileId + "&directUrl=" + directUrl;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
@ -235,7 +248,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = UrlEditor + "?editorsType=embedded&editorsMode=embedded&fileName=" + fileId;
|
||||
var url = UrlEditor + "?editorsType=embedded&editorsMode=embedded&fileName=" + fileId + "&directUrl=" + directUrl;
|
||||
|
||||
jq("#mainProgress").addClass("embedded");
|
||||
jq("#beginEmbedded").addClass("disable");
|
||||
@ -289,6 +302,17 @@ if (typeof jQuery != "undefined") {
|
||||
}
|
||||
};
|
||||
|
||||
function getUrlVars() {
|
||||
var vars = [], hash;
|
||||
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
||||
for (var i = 0; i < hashes.length; i++) {
|
||||
hash = hashes[i].split('=');
|
||||
vars.push(hash[0]);
|
||||
vars[hash[0]] = hash[1];
|
||||
}
|
||||
return vars;
|
||||
};
|
||||
|
||||
var fileList = jq("tr.tableRow");
|
||||
|
||||
var mouseIsOverTooltip = false;
|
||||
@ -299,12 +323,12 @@ if (typeof jQuery != "undefined") {
|
||||
if (hideTooltipTimeout != null) {
|
||||
clearTimeout(hideTooltipTimeout);
|
||||
}
|
||||
jq(".info").on("touchend", function () {
|
||||
jq("#info").on("touchend", function () {
|
||||
showUserTooltip(true);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
jq(".info").mouseover(function (event) {
|
||||
jq("#info").mouseover(function (event) {
|
||||
if (fileList.length > 0) {
|
||||
if (hideTooltipTimeout != null) {
|
||||
clearTimeout(hideTooltipTimeout);
|
||||
@ -328,4 +352,18 @@ if (typeof jQuery != "undefined") {
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
|
||||
jq(".info-tooltip").mouseover(function (event) {
|
||||
var target = event.target;
|
||||
var id = target.dataset.id ? target.dataset.id : target.id;
|
||||
var tooltip = target.dataset.tooltip;
|
||||
|
||||
jq("<div class='tooltip'>" + tooltip + "<div class='arrow'></div></div>").appendTo("body");
|
||||
|
||||
var top = jq("#" + id).offset().top + jq("#" + id).outerHeight() / 2 - jq("div.tooltip").outerHeight() / 2;
|
||||
var left = jq("#" + id).offset().left + jq("#" + id).outerWidth() + 20;
|
||||
jq("div.tooltip").css({ "top": top, "left": left });
|
||||
}).mouseout(function () {
|
||||
jq("div.tooltip").remove();
|
||||
});
|
||||
}
|
||||
@ -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.
|
||||
@ -166,6 +166,7 @@
|
||||
var data = {
|
||||
newfilename: newfilename,
|
||||
dockey: config.document.key,
|
||||
ext: config.document.fileType
|
||||
};
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
|
||||
@ -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.
|
||||
@ -70,7 +70,7 @@
|
||||
<a class="try-editor form" data-type="docxf">Form template</a>
|
||||
</li>
|
||||
</ul>
|
||||
<label class="create-sample">
|
||||
<label class="side-option">
|
||||
<input id="createSample" class="checkbox" type="checkbox" />With sample content
|
||||
</label>
|
||||
</div>
|
||||
@ -86,7 +86,7 @@
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<span class="select-user">Username</span>
|
||||
<img class="info" src="content/images/info.svg" />
|
||||
<img id="info" class="info" src="content/images/info.svg" />
|
||||
<select class="select-user" id="user">
|
||||
<% foreach (User user in Users.getAllUsers())
|
||||
{ %>
|
||||
@ -97,7 +97,10 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<span class="select-user">Language editors interface</span>
|
||||
<span class="select-user">Language</span>
|
||||
<img class="info info-tooltip" data-id="language"
|
||||
data-tooltip="Choose the language for ONLYOFFICE editors interface"
|
||||
src="content/images/info.svg" />
|
||||
<select class="select-user" id="language">
|
||||
<% Dictionary<string, string> languages = DocManagerHelper.GetLanguages();
|
||||
foreach (var lang in languages)
|
||||
@ -107,6 +110,14 @@
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<label class="side-option">
|
||||
<input id="directUrl" type="checkbox" class="checkbox" />Try opening on client
|
||||
<img id="directUrlInfo" class="info info-tooltip" data-id="directUrlInfo" data-tooltip="Some files can be opened in the user's browser without connecting to the document server." src="content/images/info.svg" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -156,51 +167,52 @@
|
||||
<tbody>
|
||||
<% foreach (var storedFile in storedFiles)
|
||||
{
|
||||
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile.Name);
|
||||
var isEnabledDirectUrl = DocManagerHelper.GetDirectUrl();
|
||||
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile.Name);
|
||||
var docType = FileUtility.GetFileType(storedFile.Name).ToString().ToLower();
|
||||
var ext = Path.GetExtension(storedFile.Name).ToLower();
|
||||
var canEdit = DocManagerHelper.EditedExts.Contains(ext);
|
||||
var isFillFormDoc = DocManagerHelper.FillFormExts.Contains(ext);
|
||||
%>
|
||||
|
||||
<tr class="tableRow" title="<%= storedFile.Name %> [<%= DocManagerHelper.GetFileVersion(storedFile.Name, HttpContext.Current.Request.UserHostAddress) %>]">
|
||||
<tr class="tableRow" title="<%= storedFile.Name %> [<%= DocManagerHelper.GetFileVersion(storedFile.Name, HttpContext.Current.Request.UserHostAddress.Replace(':', '_')) %>]">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit <%= docType %>" href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name }) %>" target="_blank">
|
||||
<a class="stored-edit <%= docType %>" href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<span><%= storedFile.Name %></span>
|
||||
</a>
|
||||
</td>
|
||||
<% if (canEdit) { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "edit" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "edit", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/desktop.svg" alt="Open in editor for full size screens" title="Open in editor for full size screens"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "edit" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "edit", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/mobile.svg" alt="Open in editor for mobile devices" title="Open in editor for mobile devices"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "comment" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "comment", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/comment.svg" alt="Open in editor for comment" title="Open in editor for comment"/>
|
||||
</a>
|
||||
</td>
|
||||
<% if (docType == "word") { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "review" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "review", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/review.svg" alt="Open in editor for review" title="Open in editor for review"/>
|
||||
</a>
|
||||
</td>
|
||||
<% } else if (docType == "cell") { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "filter" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "filter", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/filter.svg" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter" />
|
||||
</a>
|
||||
</td>
|
||||
<% } %>
|
||||
<% if (docType == "word") { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "blockcontent" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "blockcontent", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/block-content.svg" alt="Open in editor without content control modification" title="Open in editor without content control modification"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -212,7 +224,7 @@
|
||||
<% } %>
|
||||
<% if (isFillFormDoc) { %>
|
||||
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "fillForms" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "fillForms", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -222,7 +234,7 @@
|
||||
<% } else if (isFillFormDoc) { %>
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "fillForms" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "fillForms", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/mobile-fill-forms.svg" alt="Open in editor for filling in forms for mobile devices" title="Open in editor for filling in forms for mobile devices"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -230,7 +242,7 @@
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "fillForms" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "fillForms", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -238,17 +250,17 @@
|
||||
<td class="contentCells contentCells-shift contentCells-icon contentCellsEmpty" colspan="6"></td>
|
||||
<% } %>
|
||||
<td class="contentCells contentCells-icon firstContentCellViewers">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "view" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "view", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/desktop.svg" alt="Open in viewer for full size screens" title="Open in viewer for full size screens"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "view" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "view", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/mobile.svg" alt="Open in viewer for mobile devices" title="Open in viewer for mobile devices"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon contentCells-shift">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "embedded", editorsMode = "embedded" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "embedded", editorsMode = "embedded", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/embeded.svg" alt="Open in embedded mode" title="Open in embedded mode"/>
|
||||
</a>
|
||||
</td>
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
For more information on how to configure your ASP.NET application, please visit
|
||||
http://go.microsoft.com/fwlink/?LinkId=152368
|
||||
@ -26,11 +26,11 @@
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false" />
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<add name="Access-Control-Allow-Origin" value="*" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<add name="Access-Control-Allow-Origin" value="*" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
<handlers>
|
||||
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
|
||||
<remove name="OPTIONSVerbHandler" />
|
||||
@ -46,13 +46,21 @@
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
|
||||
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
|
||||
@ -63,7 +71,4 @@
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
|
||||
</entityFramework>
|
||||
</configuration>
|
||||
@ -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,25 +461,26 @@ 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 = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
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 (token == null || token.Equals(""))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
var filePath = DocManagerHelper.ForcesavePath(fileName, userAddress, false); // get the path to the force saved document version
|
||||
if (filePath.Equals(""))
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
filePath = DocManagerHelper.StoragePath(fileName, userAddress); // or to the original document
|
||||
}
|
||||
@ -520,14 +521,14 @@ namespace OnlineEditorsExampleMVC
|
||||
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
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 (token == null || token.Equals(""))
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
context.Response.Write("JWT validation failed");
|
||||
@ -575,7 +576,15 @@ namespace OnlineEditorsExampleMVC
|
||||
var jss = new JavaScriptSerializer();
|
||||
var body = jss.Deserialize<Dictionary<string, object>>(fileData);
|
||||
var newFileName = (string) body["newfilename"];
|
||||
var docKey = (string) body["dockey"];
|
||||
var docKey = (string) body["dockey"];
|
||||
|
||||
var origExt = '.' + (string) body["ext"];
|
||||
var curExt = Path.GetExtension(newFileName).ToLower();
|
||||
|
||||
if (string.Compare(origExt, curExt, true) != 0)
|
||||
{
|
||||
newFileName += origExt;
|
||||
}
|
||||
var meta = new Dictionary<string, object>() {
|
||||
{ "title", newFileName }
|
||||
};
|
||||
|
||||
Submodule web/documentserver-example/csharp-mvc/assets updated: 1d601d84c4...1fc823afa9
@ -24,11 +24,15 @@ jQuery.UI - jQuery UI is an open source library of interface components —
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
JWT - JWT (JSON Web Token) Implementation for .NET (Public Domain) (https://github.com/jwt-dotnet/jwt/)
|
||||
License: MIT
|
||||
License File: JWT.license
|
||||
|
||||
Microsoft.Web.Infrastructure - This package contains the Microsoft.Web.Infrastructure assembly that lets you dynamically register HTTP modules at run time. (https://www.microsoft.com/web/webpi/eula/aspnetmvc3update-eula.htm)
|
||||
License: MS-EULA License
|
||||
License File: Microsoft.Web.Infrastructure.license
|
||||
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://licenses.nuget.org/MIT)
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://github.com/JamesNK/Newtonsoft.Json)
|
||||
License: MIT
|
||||
License File: Newtonsoft.Json.license
|
||||
|
||||
|
||||
21
web/documentserver-example/csharp-mvc/licenses/JWT.license
Normal file
21
web/documentserver-example/csharp-mvc/licenses/JWT.license
Normal file
@ -0,0 +1,21 @@
|
||||
# Public Domain
|
||||
|
||||
Written by John Sheehan (http://john-sheehan.com)
|
||||
|
||||
This work is public domain.
|
||||
|
||||
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of his or her rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law.
|
||||
|
||||
For more information, please visit: http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
# MIT
|
||||
|
||||
Copyright (c) 2019 Jwt.Net Maintainers and Contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please visit: https://opensource.org/licenses/MIT
|
||||
@ -1,16 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />
|
||||
<package id="EntityFramework" version="6.4.4" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.CSharp" version="4.7.0" targetFramework="net45" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net45" />
|
||||
<package id="WebGrease" version="1.6.0" targetFramework="net45" />
|
||||
<package id="Antlr" version="3.5.0.2" targetFramework="net48" />
|
||||
<package id="EntityFramework" version="6.4.4" targetFramework="net48" />
|
||||
<package id="JWT" version="9.0.3" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.CSharp" version="4.7.0" targetFramework="net48" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
|
||||
<package id="WebGrease" version="1.6.0" targetFramework="net48" />
|
||||
</packages>
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<appSettings>
|
||||
<clear />
|
||||
<add key="version" value="1.2.0"/>
|
||||
<add key="version" value="1.5.0"/>
|
||||
|
||||
<add key="filesize-max" value="52428800"/>
|
||||
<add key="storage-path" value=""/>
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
<add key="files.docservice.verify-peer-off" value="true"/>
|
||||
|
||||
<add key="files.docservice.languages" value="en:English|az:Azerbaijani|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lv:Latvian|lo:Lao|nb:Norwegian|pl:Polish|pt:Portuguese|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese"/>
|
||||
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (People's Republic of China)|zh-TW:Chinese (Traditional, Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lv:Latvian|lo:Lao|ms:Malay (Malaysia)|nb:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
|
||||
|
||||
<add key="files.docservice.url.site" value="http://documentserver/"/>
|
||||
|
||||
|
||||
@ -19,3 +19,11 @@ License File: jQuery.iframe-transport.license
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
JWT - JWT (JSON Web Token) Implementation for .NET (Public Domain) (https://github.com/jwt-dotnet/jwt/)
|
||||
License: MIT
|
||||
License File: JWT.license
|
||||
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://github.com/JamesNK/Newtonsoft.Json)
|
||||
License: MIT
|
||||
License File: Newtonsoft.Json.license
|
||||
@ -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%;
|
||||
}
|
||||
|
||||
@ -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.
|
||||
@ -167,7 +167,7 @@ label .checkbox {
|
||||
background-image: url("images/file_docxf.svg");
|
||||
}
|
||||
|
||||
.create-sample {
|
||||
.side-option {
|
||||
color: #666666;
|
||||
line-height: 24px;
|
||||
}
|
||||
@ -744,3 +744,28 @@ html {
|
||||
.user-descr > b {
|
||||
margin-left: 25px;
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
background: #FFFFFF;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0px 7px 25px rgba(85, 85, 85, 0.15);
|
||||
color: #666666;
|
||||
line-height: 160%;
|
||||
max-width: 455px;
|
||||
padding: 14px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.tooltip ul {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
border-top: 8px solid transparent;
|
||||
border-bottom: 8px solid transparent;
|
||||
border-right: 8px solid #FFFFFF;
|
||||
left: -4px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
@ -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.
|
||||
@ -73,7 +73,7 @@
|
||||
<a class="try-editor form" data-type="docxf">Form template</a>
|
||||
</li>
|
||||
</ul>
|
||||
<label class="create-sample">
|
||||
<label class="side-option">
|
||||
<input id="createSample" class="checkbox" type="checkbox" />With sample content
|
||||
</label>
|
||||
</div>
|
||||
@ -88,7 +88,7 @@
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<span class="select-user">Username</span>
|
||||
<img class="info" src="app_themes/images/info.svg" />
|
||||
<img id="info" class="info" src="app_themes/images/info.svg" />
|
||||
<select class="select-user" id="user">
|
||||
<% foreach (User user in Users.getAllUsers())
|
||||
{ %>
|
||||
@ -99,7 +99,10 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<span class="select-user">Language editors interface</span>
|
||||
<span class="select-user">Language</span>
|
||||
<img class="info info-tooltip" data-id="language"
|
||||
data-tooltip="Choose the language for ONLYOFFICE editors interface"
|
||||
src="app_themes/images/info.svg" />
|
||||
<select class="select-user" id="language">
|
||||
<% Dictionary<string, string> languages = GetLanguages();
|
||||
foreach (var lang in languages)
|
||||
@ -109,6 +112,14 @@
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<label class="side-option">
|
||||
<input id="directUrl" type="checkbox" class="checkbox" />Try opening on client
|
||||
<img id="directUrlInfo" class="info info-tooltip" data-id="directUrlInfo" data-tooltip="Some files can be opened in the user's browser without connecting to the document server." src="app_themes/images/info.svg" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -158,14 +169,15 @@
|
||||
<tbody>
|
||||
<% foreach (var storedFile in storedFiles)
|
||||
{
|
||||
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile.Name);
|
||||
var directUrlParam = GetDirectUrlParam();
|
||||
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile.Name) + directUrlParam;
|
||||
var ext = Path.GetExtension(storedFile.Name).ToLower();
|
||||
var docType = DocumentType(storedFile.Name);
|
||||
var canEdit = EditedExts.Contains(ext);
|
||||
var isFillFormDoc = FillFormsExts.Contains(ext);
|
||||
%>
|
||||
|
||||
<tr class="tableRow" title="<%= storedFile.Name %> [<%= GetFileVersion(storedFile.Name, HttpContext.Current.Request.UserHostAddress) %>]">
|
||||
<tr class="tableRow" title="<%= storedFile.Name %> [<%= GetFileVersion(storedFile.Name, HttpContext.Current.Request.UserHostAddress.Replace(':','_')) %>]">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit <%= docType %>" href="<%= editUrl %>" target="_blank">
|
||||
<span><%= storedFile.Name %></span>
|
||||
|
||||
@ -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.
|
||||
@ -485,7 +485,7 @@ namespace OnlineEditorsExample
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
fileUrl.Query = "type=download&fileName=" + HttpUtility.UrlEncode(_fileName)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress);
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(CurUserHostAddress(HttpContext.Current.Request.UserHostAddress));
|
||||
|
||||
// get the url to the converted file
|
||||
string newFileUri;
|
||||
@ -626,5 +626,11 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
return languages;
|
||||
}
|
||||
|
||||
public static string GetDirectUrlParam()
|
||||
{
|
||||
string isEnabledDirectUrl = HttpUtility.ParseQueryString(HttpContext.Current.Request.Url.Query).Get("directUrl");
|
||||
return "&directUrl=" + (isEnabledDirectUrl != null ? isEnabledDirectUrl : "false");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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.
|
||||
@ -178,6 +178,7 @@
|
||||
var data = {
|
||||
newfilename: newfilename,
|
||||
dockey: config.document.key,
|
||||
ext: config.document.fileType
|
||||
};
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
|
||||
@ -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.
|
||||
@ -81,7 +81,7 @@ namespace OnlineEditorsExample
|
||||
+ "webeditor.ashx";
|
||||
callbackUrl.Query = "type=track"
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(FileName)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress);
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress));
|
||||
return callbackUrl.ToString();
|
||||
}
|
||||
}
|
||||
@ -100,16 +100,17 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
|
||||
// get url to download a file
|
||||
public static string getDownloadUrl(string fileName)
|
||||
public static string getDownloadUrl(string fileName, Boolean isServer = true)
|
||||
{
|
||||
var downloadUrl = new UriBuilder(_Default.GetServerUrl(true));
|
||||
var userAddress = isServer ? "&userAddress=" + HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress)) : "";
|
||||
var downloadUrl = new UriBuilder(_Default.GetServerUrl(isServer));
|
||||
downloadUrl.Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
downloadUrl.Query = "type=download"
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(fileName)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress);
|
||||
+ userAddress;
|
||||
return downloadUrl.ToString();
|
||||
}
|
||||
|
||||
@ -165,6 +166,7 @@ namespace OnlineEditorsExample
|
||||
var actionLink = Request.GetOrDefault("actionLink", null); // get the action link (comment or bookmark) if it exists
|
||||
var actionData = string.IsNullOrEmpty(actionLink) ? null : jss.DeserializeObject(actionLink); // get action data for the action link
|
||||
|
||||
var directUrl = getDownloadUrl(FileName, false);
|
||||
var createUrl = getCreateUrl(DocumentType, editorsType);
|
||||
var templatesImageUrl = GetTemplateImageUrl(ext); // image url for templates
|
||||
var templates = new List<Dictionary<string, string>>
|
||||
@ -193,6 +195,7 @@ namespace OnlineEditorsExample
|
||||
{
|
||||
{ "title", FileName },
|
||||
{ "url", getDownloadUrl(FileName) },
|
||||
{ "directUrl", IsEnabledDirectUrl() ? directUrl : "" },
|
||||
{ "fileType", ext.Trim('.') },
|
||||
{ "key", Key },
|
||||
{
|
||||
@ -216,6 +219,7 @@ namespace OnlineEditorsExample
|
||||
{ "modifyFilter", editorsMode != "filter" },
|
||||
{ "modifyContentControl", editorsMode != "blockcontent" },
|
||||
{ "review", canEdit && (editorsMode == "edit" || editorsMode == "review") },
|
||||
{ "chat", !user.id.Equals("uid-0") },
|
||||
{ "reviewGroups", user.reviewGroups },
|
||||
{ "commentGroups", user.commentGroups },
|
||||
{ "userInfoGroups", user.userInfoGroups }
|
||||
@ -230,6 +234,11 @@ namespace OnlineEditorsExample
|
||||
{ "mode", mode },
|
||||
{ "lang", Request.Cookies.GetOrDefault("ulang", "en") },
|
||||
{ "callbackUrl", CallbackUrl }, // absolute URL to the document storage service
|
||||
{ "coEditing", editorsMode == "view" && user.id.Equals("uid-0") ?
|
||||
new Dictionary<string, object>{
|
||||
{"mode", "strict"},
|
||||
{"change", false}
|
||||
} : null },
|
||||
{ "createUrl", !user.id.Equals("uid-0") ? createUrl : null },
|
||||
{ "templates", user.templates ? templates : null },
|
||||
{
|
||||
@ -245,9 +254,9 @@ namespace OnlineEditorsExample
|
||||
// the parameters for the embedded document type
|
||||
"embedded", new Dictionary<string, object>
|
||||
{
|
||||
{ "saveUrl", FileUriUser }, // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
{ "embedUrl", FileUriUser }, // the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
{ "shareUrl", FileUriUser }, // the absolute URL that will allow other users to share this document
|
||||
{ "saveUrl", directUrl }, // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
{ "embedUrl", directUrl }, // the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
{ "shareUrl", directUrl }, // the absolute URL that will allow other users to share this document
|
||||
{ "toolbarDocked", "top" } // the place for the embedded viewer toolbar (top or bottom)
|
||||
}
|
||||
},
|
||||
@ -359,13 +368,21 @@ namespace OnlineEditorsExample
|
||||
dataObj.Add("fileType", ext.Replace(".", ""));
|
||||
dataObj.Add("key", key);
|
||||
// write file url to the data object
|
||||
var directPrevFileUrl = i == currentVersion ? _Default.FileUri(FileName, false) : MakePublicHistoryUrl(FileName, i.ToString(), "prev" + ext, false);
|
||||
var prevFileUrl = i == currentVersion ? FileUri : MakePublicHistoryUrl(FileName, i.ToString(), "prev" + ext);
|
||||
if (Path.IsPathRooted(storagePath))
|
||||
{
|
||||
prevFileUrl = i == currentVersion ? getDownloadUrl(FileName) : getDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""));
|
||||
directPrevFileUrl = i == currentVersion ? getDownloadUrl(FileName, false) : getDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""), false);
|
||||
}
|
||||
|
||||
dataObj.Add("url", prevFileUrl); // write file url to the data object
|
||||
|
||||
if (IsEnabledDirectUrl())
|
||||
{
|
||||
dataObj.Add("directUrl", directPrevFileUrl); // write direct url to the data object
|
||||
}
|
||||
|
||||
dataObj.Add("version", i);
|
||||
if (i > 1) // check if the version number is greater than 1 (the file was modified)
|
||||
{
|
||||
@ -383,11 +400,19 @@ namespace OnlineEditorsExample
|
||||
obj.Add("user", change.Count > 0 ? change["user"] : null);
|
||||
|
||||
var prev = (Dictionary<string, object>)histData[(i - 2).ToString()]; // get the history data from the previous file version
|
||||
dataObj.Add("previous", new Dictionary<string, object>() { // write information about previous file version to the data object
|
||||
|
||||
Dictionary<string, object> dataPrev = new Dictionary<string, object>() { // write information about previous file version to the data object
|
||||
{ "fileType", prev["fileType"] },
|
||||
{ "key", prev["key"] }, // write key and url information about previous file version
|
||||
{ "url", prev["url"] },
|
||||
});
|
||||
{ "url", prev["url"] }
|
||||
};
|
||||
|
||||
if (IsEnabledDirectUrl())
|
||||
{
|
||||
dataPrev.Add("directUrl", prev["directUrl"]);
|
||||
}
|
||||
|
||||
dataObj.Add("previous", dataPrev);
|
||||
// write the path to the diff.zip archive with differences in this file version
|
||||
var changesUrl = MakePublicHistoryUrl(FileName, (i - 1).ToString(), "diff.zip");
|
||||
dataObj.Add("changesUrl", changesUrl);
|
||||
@ -420,6 +445,11 @@ namespace OnlineEditorsExample
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "App_Themes\\images\\logo.png";
|
||||
|
||||
var DirectImageUrl = new UriBuilder(_Default.GetServerUrl(false));
|
||||
DirectImageUrl.Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "App_Themes\\images\\logo.png";
|
||||
|
||||
// create a logo config
|
||||
Dictionary<string, object> logoConfig = new Dictionary<string, object>
|
||||
{
|
||||
@ -427,6 +457,11 @@ namespace OnlineEditorsExample
|
||||
{ "url", InsertImageUrl.ToString()}
|
||||
};
|
||||
|
||||
if (IsEnabledDirectUrl())
|
||||
{
|
||||
logoConfig.Add("directUrl", DirectImageUrl.ToString());
|
||||
}
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
{
|
||||
var insImageToken = JwtManager.Encode(logoConfig); // encode logoConfig into the token
|
||||
@ -446,6 +481,12 @@ namespace OnlineEditorsExample
|
||||
+ "webeditor.ashx";
|
||||
compareFileUrl.Query = "type=assets&fileName=" + HttpUtility.UrlEncode("sample.docx");
|
||||
|
||||
var DirectFileUrl = new UriBuilder(_Default.GetServerUrl(false));
|
||||
DirectFileUrl.Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
DirectFileUrl.Query = "type=assets&fileName=" + HttpUtility.UrlEncode("sample.docx");
|
||||
|
||||
// create an object with the information about the compared file
|
||||
Dictionary<string, object> dataCompareFile = new Dictionary<string, object>
|
||||
{
|
||||
@ -453,6 +494,11 @@ namespace OnlineEditorsExample
|
||||
{ "url", compareFileUrl.ToString() }
|
||||
};
|
||||
|
||||
if (IsEnabledDirectUrl())
|
||||
{
|
||||
dataCompareFile.Add("directUrl", DirectFileUrl.ToString());
|
||||
}
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
{
|
||||
var compareFileToken = JwtManager.Encode(dataCompareFile); // encode the dataCompareFile object into the token
|
||||
@ -473,6 +519,13 @@ namespace OnlineEditorsExample
|
||||
+ "webeditor.ashx";
|
||||
mailmergeUrl.Query = "type=csv";
|
||||
|
||||
var DirectMailMergeUrl = new UriBuilder(_Default.GetServerUrl(false));
|
||||
DirectMailMergeUrl.Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
DirectMailMergeUrl.Query = "type=csv";
|
||||
|
||||
// create a mail merge config
|
||||
Dictionary<string, object> mailMergeConfig = new Dictionary<string, object>
|
||||
{
|
||||
@ -480,6 +533,11 @@ namespace OnlineEditorsExample
|
||||
{ "url", mailmergeUrl.ToString() }
|
||||
};
|
||||
|
||||
if (IsEnabledDirectUrl())
|
||||
{
|
||||
mailMergeConfig.Add("directUrl", DirectMailMergeUrl.ToString());
|
||||
}
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
{
|
||||
var mailmergeToken = JwtManager.Encode(mailMergeConfig); // encode mailMergeConfig into the token
|
||||
@ -521,15 +579,16 @@ namespace OnlineEditorsExample
|
||||
|
||||
|
||||
// create the public history url
|
||||
private string MakePublicHistoryUrl(string filename, string version, string file)
|
||||
private string MakePublicHistoryUrl(string filename, string version, string file, Boolean isServer = true)
|
||||
{
|
||||
var fileUrl = new UriBuilder(_Default.GetServerUrl(true));
|
||||
var userAddress = isServer ? "&userAddress=" + HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress)) : "";
|
||||
var fileUrl = new UriBuilder(_Default.GetServerUrl(isServer));
|
||||
fileUrl.Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
fileUrl.Query = "type=downloadhistory&fileName=" + HttpUtility.UrlEncode(filename)
|
||||
+ "&ver=" + version + "&file=" + file
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress);
|
||||
+ userAddress;
|
||||
return fileUrl.ToString();
|
||||
}
|
||||
|
||||
@ -580,5 +639,12 @@ namespace OnlineEditorsExample
|
||||
{ "name", uname }
|
||||
}));
|
||||
}
|
||||
|
||||
// get direct url flag
|
||||
private static bool IsEnabledDirectUrl()
|
||||
{
|
||||
string isEnabledDirectUrl = HttpUtility.ParseQueryString(HttpContext.Current.Request.Url.Query).Get("directUrl");
|
||||
return isEnabledDirectUrl != null ? Convert.ToBoolean(isEnabledDirectUrl) : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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.
|
||||
@ -132,7 +132,7 @@ namespace ASC.Api.DocumentConverter
|
||||
var payloadToken = JwtManager.Encode(payload); // encode the payload object to the payload token
|
||||
var bodyToken = JwtManager.Encode(body); // encode the body object to the body token
|
||||
// create header token
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
request.Headers.Add(JWTheader, "Bearer " + payloadToken); // and add it to the request headers with the Bearer prefix
|
||||
|
||||
body.Add("token", bodyToken);
|
||||
|
||||
@ -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.
|
||||
@ -16,12 +16,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using JWT;
|
||||
using JWT.Algorithms;
|
||||
using JWT.Builder;
|
||||
using JWT.Serializers;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Script.Serialization;
|
||||
|
||||
namespace OnlineEditorsExample
|
||||
{
|
||||
@ -30,31 +30,19 @@ namespace OnlineEditorsExample
|
||||
private static readonly string Secret;
|
||||
public static readonly bool Enabled;
|
||||
|
||||
private static readonly JavaScriptSerializer Serializer;
|
||||
|
||||
static JwtManager()
|
||||
{
|
||||
Secret = WebConfigurationManager.AppSettings["files.docservice.secret"] ?? ""; // get token secret from the config parameters
|
||||
Enabled = !string.IsNullOrEmpty(Secret); // check if the token is enabled
|
||||
Serializer = new JavaScriptSerializer(); // define java script serializer
|
||||
}
|
||||
|
||||
// encode a payload object into a token using a secret key
|
||||
public static string Encode(IDictionary<string, object> payload)
|
||||
{
|
||||
// define the hashing algorithm and the token type
|
||||
var header = new Dictionary<string, object>
|
||||
{
|
||||
{ "alg", "HS256" },
|
||||
{ "typ", "JWT" }
|
||||
};
|
||||
|
||||
// three parts of token
|
||||
var encHeader = Base64UrlEncode(Serializer.Serialize(header)); // header
|
||||
var encPayload = Base64UrlEncode(Serializer.Serialize(payload)); // payload
|
||||
var hashSum = Base64UrlEncode(CalculateHash(encHeader, encPayload)); // signature
|
||||
|
||||
return string.Format("{0}.{1}.{2}", encHeader, encPayload, hashSum);
|
||||
var encoder = new JwtEncoder(new HMACSHA256Algorithm(),
|
||||
new JsonNetSerializer(),
|
||||
new JwtBase64UrlEncoder());
|
||||
return encoder.Encode(payload, Secret);
|
||||
}
|
||||
|
||||
// decode a token into a payload object using a secret key
|
||||
@ -62,52 +50,11 @@ namespace OnlineEditorsExample
|
||||
{
|
||||
if (!Enabled || string.IsNullOrEmpty(token)) return "";
|
||||
|
||||
var split = token.Split('.');
|
||||
if (split.Length != 3) return "";
|
||||
|
||||
var hashSum = Base64UrlEncode(CalculateHash(split[0], split[1])); // get signature
|
||||
if (hashSum != split[2]) return ""; // and check if it is equal to the signature from the token
|
||||
return Base64UrlDecode(split[1]); // decode payload
|
||||
}
|
||||
|
||||
// generate a hash code based on a key using the HMAC method
|
||||
private static byte[] CalculateHash(string encHeader, string encPayload)
|
||||
{
|
||||
using (var hasher = new HMACSHA256(Encoding.UTF8.GetBytes(Secret)))
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(string.Format("{0}.{1}", encHeader, encPayload));
|
||||
return hasher.ComputeHash(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
// encode a string into the base64 value
|
||||
private static string Base64UrlEncode(string str)
|
||||
{
|
||||
return Base64UrlEncode(Encoding.UTF8.GetBytes(str));
|
||||
}
|
||||
|
||||
// encode bytes into the base64 value
|
||||
private static string Base64UrlEncode(byte[] bytes)
|
||||
{
|
||||
return Convert.ToBase64String(bytes)
|
||||
.TrimEnd('=').Replace('+', '-').Replace('/', '_');
|
||||
}
|
||||
|
||||
// decode a base64 value into the string
|
||||
private static string Base64UrlDecode(string payload)
|
||||
{
|
||||
var b64 = payload.Replace('_', '/').Replace('-', '+');
|
||||
switch (b64.Length%4)
|
||||
{
|
||||
case 2:
|
||||
b64 += "==";
|
||||
break;
|
||||
case 3:
|
||||
b64 += "=";
|
||||
break;
|
||||
}
|
||||
var bytes = Convert.FromBase64String(b64);
|
||||
return Encoding.UTF8.GetString(bytes);
|
||||
return JwtBuilder.Create()
|
||||
.WithAlgorithm(new HMACSHA256Algorithm())
|
||||
.WithSecret(Secret)
|
||||
.MustVerifySignature()
|
||||
.Decode(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -23,6 +23,8 @@
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<TargetFrameworkProfile />
|
||||
<Use64BitIISExpress />
|
||||
<UseGlobalApplicationHostFile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@ -44,27 +46,33 @@
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="JWT, Version=9.0.0.0, Culture=neutral, PublicKeyToken=6f98bca0f40f2ecf, processorArchitecture=MSIL">
|
||||
<HintPath>packages\JWT.9.0.3\lib\net46\JWT.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.Web.Infrastructure">
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Helpers">
|
||||
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Razor">
|
||||
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.Web.WebPages">
|
||||
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Deployment">
|
||||
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Razor">
|
||||
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
@ -153,10 +161,12 @@
|
||||
<Content Include="assets\AUTHORS.md" />
|
||||
<Content Include="assets\LICENSE" />
|
||||
<Content Include="assets\new\new.docx" />
|
||||
<Content Include="assets\new\new.docxf" />
|
||||
<Content Include="assets\new\new.pptx" />
|
||||
<Content Include="assets\new\new.xlsx" />
|
||||
<Content Include="assets\sample\csv.csv" />
|
||||
<Content Include="assets\sample\sample.docx" />
|
||||
<Content Include="assets\sample\sample.docxf" />
|
||||
<Content Include="assets\sample\sample.pptx" />
|
||||
<Content Include="assets\sample\sample.xlsx" />
|
||||
<None Include="packages.config" />
|
||||
|
||||
@ -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("")]
|
||||
|
||||
|
||||
@ -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.
|
||||
@ -57,7 +57,7 @@ namespace OnlineEditorsExample
|
||||
// check if the document token is enabled
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
string token = null;
|
||||
|
||||
@ -76,7 +76,7 @@ namespace OnlineEditorsExample
|
||||
context.Response.Write("{\"error\":1,\"message\":\"JWT expected\"}");
|
||||
}
|
||||
|
||||
if (token != null && !token.Equals("")) // invalid signature error
|
||||
if (!string.IsNullOrEmpty(token)) // invalid signature error
|
||||
{
|
||||
fileData = jss.Deserialize<Dictionary<string, object>>(token);
|
||||
if (fileData.ContainsKey("payload"))
|
||||
@ -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
|
||||
|
||||
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));
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(hist))
|
||||
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 = _Default.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;
|
||||
@ -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);
|
||||
if (string.IsNullOrEmpty(forcesavePath)) // create forcesave path if it doesn't exist
|
||||
{
|
||||
forcesavePath = _Default.ForcesavePath(fileName, userAddress, true);
|
||||
}
|
||||
}
|
||||
|
||||
forcesavePath = _Default.ForcesavePath(fileName, userAddress, false);
|
||||
if (forcesavePath.Equals("")) // create forcesave path if it doesn't exist
|
||||
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;
|
||||
@ -282,7 +297,7 @@ namespace OnlineEditorsExample
|
||||
|
||||
var payloadToken = JwtManager.Encode(payload); // encode a payload object into a header token
|
||||
var bodyToken = JwtManager.Encode(body); // encode body into a body token
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
request.Headers.Add(JWTheader, "Bearer " + payloadToken); // add a header Authorization with a header token and Authorization prefix in it
|
||||
|
||||
body.Add("token", bodyToken);
|
||||
@ -317,26 +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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
@ -66,7 +66,9 @@ namespace OnlineEditorsExample
|
||||
"Can't mention others in comments",
|
||||
"Can't create new files from the editor",
|
||||
"Can’t see anyone’s information",
|
||||
"Can't rename files from the editor"
|
||||
"Can't rename files from the editor",
|
||||
"Can't view chat",
|
||||
"View file without collaboration",
|
||||
};
|
||||
|
||||
private static List<User> users = new List<User>() {
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<appSettings configSource="settings.config" />
|
||||
<system.web>
|
||||
@ -9,9 +9,9 @@
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<add name="Access-Control-Allow-Origin" value="*" />
|
||||
</customHeaders>
|
||||
<customHeaders>
|
||||
<add name="Access-Control-Allow-Origin" value="*" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
<security>
|
||||
<requestFiltering>
|
||||
@ -25,4 +25,20 @@
|
||||
</requestFiltering>
|
||||
</security>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@ -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.
|
||||
@ -207,7 +207,7 @@ namespace OnlineEditorsExample
|
||||
try
|
||||
{
|
||||
var fileName = Path.GetFileName(context.Request["fileName"]);
|
||||
var path = _Default.StoragePath(fileName, HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress));
|
||||
var path = _Default.StoragePath(fileName, HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress)));
|
||||
var histDir = _Default.HistoryDir(path);
|
||||
|
||||
if (File.Exists(path)) File.Delete(path); // delete file
|
||||
@ -281,26 +281,26 @@ 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 = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
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 (token == null || token.Equals(""))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
var filePath = _Default.ForcesavePath(fileName, userAddress, false); // get the path to the force saved document version
|
||||
if (filePath.Equals(""))
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
filePath = _Default.StoragePath(fileName, userAddress); // or to the original document
|
||||
}
|
||||
@ -340,14 +340,14 @@ namespace OnlineEditorsExample
|
||||
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
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 (token == null || token.Equals(""))
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
context.Response.Write("JWT validation failed");
|
||||
@ -394,6 +394,15 @@ namespace OnlineEditorsExample
|
||||
var body = jss.Deserialize<Dictionary<string, object>>(fileData);
|
||||
var newFileName = (string) body["newfilename"];
|
||||
var docKey = (string) body["dockey"];
|
||||
|
||||
var origExt = '.' + (string) body["ext"];
|
||||
var curExt = Path.GetExtension(newFileName).ToLower();
|
||||
|
||||
if (string.Compare(origExt, curExt, true) != 0)
|
||||
{
|
||||
newFileName += origExt;
|
||||
}
|
||||
|
||||
var meta = new Dictionary<string, object>() {
|
||||
{ "title", newFileName }
|
||||
};
|
||||
|
||||
Submodule web/documentserver-example/csharp/assets updated: 1d601d84c4...1fc823afa9
@ -19,3 +19,11 @@ License File: jQuery.iframe-transport.license
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
JWT - JWT (JSON Web Token) Implementation for .NET (Public Domain) (https://github.com/jwt-dotnet/jwt/)
|
||||
License: MIT
|
||||
License File: JWT.license
|
||||
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://github.com/JamesNK/Newtonsoft.Json)
|
||||
License: MIT
|
||||
License File: Newtonsoft.Json.license
|
||||
21
web/documentserver-example/csharp/licenses/JWT.license
Normal file
21
web/documentserver-example/csharp/licenses/JWT.license
Normal file
@ -0,0 +1,21 @@
|
||||
# Public Domain
|
||||
|
||||
Written by John Sheehan (http://john-sheehan.com)
|
||||
|
||||
This work is public domain.
|
||||
|
||||
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of his or her rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law.
|
||||
|
||||
For more information, please visit: http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
# MIT
|
||||
|
||||
Copyright (c) 2019 Jwt.Net Maintainers and Contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please visit: https://opensource.org/licenses/MIT
|
||||
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2007 James Newton-King
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
|
||||
<package id="JWT" version="9.0.3" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
|
||||
</packages>
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
@ -16,11 +16,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
var directUrl;
|
||||
|
||||
if (typeof jQuery != "undefined") {
|
||||
jq = jQuery.noConflict();
|
||||
|
||||
directUrl = getUrlVars()["directUrl"] == "true";
|
||||
|
||||
mustReload = false;
|
||||
|
||||
if (directUrl)
|
||||
jq("#directUrl").prop("checked", directUrl);
|
||||
else
|
||||
directUrl = jq("#directUrl").prop("checked");
|
||||
|
||||
jq("#directUrl").change(function () {
|
||||
window.location = "?directUrl=" + jq(this).prop("checked");
|
||||
});
|
||||
|
||||
jq(function () {
|
||||
jq('#fileupload').fileupload({
|
||||
dataType: 'json',
|
||||
@ -219,7 +232,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEdit:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = "doceditor.aspx?fileID=" + fileId;
|
||||
var url = "doceditor.aspx?fileID=" + fileId + "&directUrl=" + directUrl;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
@ -227,7 +240,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = "doceditor.aspx?editorsMode=view&fileID=" + fileId;
|
||||
var url = "doceditor.aspx?editorsMode=view&fileID=" + fileId + "&directUrl=" + directUrl;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
@ -235,7 +248,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = "doceditor.aspx?editorsType=embedded&editorsMode=embedded&fileID=" + fileId;
|
||||
var url = "doceditor.aspx?editorsType=embedded&editorsMode=embedded&fileID=" + fileId + "&directUrl=" + directUrl;
|
||||
|
||||
jq("#mainProgress").addClass("embedded");
|
||||
jq("#beginEmbedded").addClass("disable");
|
||||
@ -288,6 +301,17 @@ if (typeof jQuery != "undefined") {
|
||||
}
|
||||
};
|
||||
|
||||
function getUrlVars() {
|
||||
var vars = [], hash;
|
||||
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
||||
for (var i = 0; i < hashes.length; i++) {
|
||||
hash = hashes[i].split('=');
|
||||
vars.push(hash[0]);
|
||||
vars[hash[0]] = hash[1];
|
||||
}
|
||||
return vars;
|
||||
};
|
||||
|
||||
var fileList = jq("tr.tableRow");
|
||||
|
||||
var mouseIsOverTooltip = false;
|
||||
@ -298,12 +322,12 @@ if (typeof jQuery != "undefined") {
|
||||
if (hideTooltipTimeout != null) {
|
||||
clearTimeout(hideTooltipTimeout);
|
||||
}
|
||||
jq(".info").on("touchend", function () {
|
||||
jq("#info").on("touchend", function () {
|
||||
showUserTooltip(true);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
jq(".info").mouseover(function (event) {
|
||||
jq("#info").mouseover(function (event) {
|
||||
if (fileList.length > 0) {
|
||||
if (hideTooltipTimeout != null) {
|
||||
clearTimeout(hideTooltipTimeout);
|
||||
@ -327,4 +351,18 @@ if (typeof jQuery != "undefined") {
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
|
||||
jq(".info-tooltip").mouseover(function (event) {
|
||||
var target = event.target;
|
||||
var id = target.dataset.id ? target.dataset.id : target.id;
|
||||
var tooltip = target.dataset.tooltip;
|
||||
|
||||
jq("<div class='tooltip'>" + tooltip + "<div class='arrow'></div></div>").appendTo("body");
|
||||
|
||||
var top = jq("#" + id).offset().top + jq("#" + id).outerHeight() / 2 - jq("div.tooltip").outerHeight() / 2;
|
||||
var left = jq("#" + id).offset().left + jq("#" + id).outerWidth() + 20;
|
||||
jq("div.tooltip").css({ "top": top, "left": left });
|
||||
}).mouseout(function () {
|
||||
jq("div.tooltip").remove();
|
||||
});
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<appSettings>
|
||||
<clear />
|
||||
<add key="version" value="1.2.0"/>
|
||||
<add key="version" value="1.5.0"/>
|
||||
|
||||
<add key="filesize-max" value="52428800"/>
|
||||
<add key="storage-path" value=""/>
|
||||
@ -15,7 +15,7 @@
|
||||
<add key="files.docservice.header" value="Authorization" />
|
||||
<add key="files.docservice.verify-peer-off" value="true"/>
|
||||
|
||||
<add key="files.docservice.languages" value="en:English|az:Azerbaijani|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lv:Latvian|lo:Lao|nb:Norwegian|pl:Polish|pt:Portuguese|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese"/>
|
||||
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (People's Republic of China)|zh-TW:Chinese (Traditional, Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lv:Latvian|lo:Lao|ms:Malay (Malaysia)|nb:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
|
||||
|
||||
<add key="files.docservice.url.site" value="http://documentserver/"/>
|
||||
|
||||
|
||||
@ -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
|
||||
```
|
||||
|
||||
@ -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>
|
||||
199
web/documentserver-example/java-spring/checkstyle.xml
Normal file
199
web/documentserver-example/java-spring/checkstyle.xml
Normal 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>
|
||||
17
web/documentserver-example/java-spring/onlyoffice.header
Normal file
17
web/documentserver-example/java-spring/onlyoffice.header
Normal 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.
|
||||
*
|
||||
*/
|
||||
41
web/documentserver-example/java-spring/pom.xml
Executable file → Normal file
41
web/documentserver-example/java-spring/pom.xml
Executable file → Normal 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>
|
||||
@ -48,7 +56,7 @@
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.5</version>
|
||||
<version>2.8.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.inversoft</groupId>
|
||||
@ -61,10 +69,15 @@
|
||||
<version>1.18.20</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.13.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.12.2</version>
|
||||
<version>2.13.4.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.modelmapper</groupId>
|
||||
@ -78,6 +91,30 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>validate</id>
|
||||
<phase>validate</phase>
|
||||
<configuration>
|
||||
<configLocation>checkstyle.xml</configLocation>
|
||||
<failsOnError>true</failsOnError>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
<logViolationsToConsole>true</logViolationsToConsole>
|
||||
<violationSeverity>warning</violationSeverity>
|
||||
<consoleOutput>true</consoleOutput>
|
||||
<includeTestSourceDirectory>true
|
||||
</includeTestSourceDirectory>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@ -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",
|
||||
"Doesn’t belong to any group",
|
||||
"Can review all the changes",
|
||||
@ -42,51 +43,71 @@ public class ExampleData {
|
||||
"Can't mention others in comments",
|
||||
"Can't create new files from the editor",
|
||||
"Can’t see anyone’s information",
|
||||
"Can't rename files from the editor"
|
||||
"Can't rename files from the editor",
|
||||
"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 doesn’t belong to any of the groups",
|
||||
"He can review all the changes",
|
||||
"He can do everything with the comments",
|
||||
"The file favorite state is undefined",
|
||||
"Can create a file from a template with data from the editor",
|
||||
"Can see the information about all users"
|
||||
"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 don’t 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 don’t 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 don’t belong to any group"
|
||||
"Can see the information about users from Group2 and users who don’t 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 isn’t favorite",
|
||||
"He can’t copy data from the file into the clipboard",
|
||||
"He can’t download the file",
|
||||
"He can’t print the file",
|
||||
"Can create a file from an editor",
|
||||
"Can see the information about Group2 users"
|
||||
"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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@ -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,6 @@ import com.onlyoffice.integration.documentserver.models.enums.Action;
|
||||
import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder;
|
||||
import com.onlyoffice.integration.entities.User;
|
||||
import com.onlyoffice.integration.dto.Mentions;
|
||||
import com.onlyoffice.integration.documentserver.models.enums.Language;
|
||||
import com.onlyoffice.integration.documentserver.models.enums.Type;
|
||||
import com.onlyoffice.integration.documentserver.models.filemodel.FileModel;
|
||||
import com.onlyoffice.integration.services.UserServices;
|
||||
@ -41,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
|
||||
@ -53,6 +61,9 @@ public class EditorController {
|
||||
@Value("${files.docservice.url.api}")
|
||||
private String docserviceApiUrl;
|
||||
|
||||
@Value("${files.docservice.languages}")
|
||||
private String langs;
|
||||
|
||||
@Autowired
|
||||
private FileStoragePathBuilder storagePathBuilder;
|
||||
|
||||
@ -73,25 +84,41 @@ 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,
|
||||
@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;
|
||||
Language language = Language.en;
|
||||
Locale locale = new Locale("en");
|
||||
|
||||
if(actionParam != null) action = Action.valueOf(actionParam);
|
||||
if(typeParam != null) type = Type.valueOf(typeParam);
|
||||
if(lang != null) language = Language.valueOf(lang);
|
||||
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) {
|
||||
String[] couple = langAndKey.split(":");
|
||||
if (couple[0].equals(lang)) {
|
||||
String[] langAndCountry = couple[0].split("-");
|
||||
locale = new Locale(langAndCountry[0], langAndCountry.length > 1 ? langAndCountry[1] : "");
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
@ -101,31 +128,47 @@ public class EditorController {
|
||||
.builder()
|
||||
.fileName(fileName)
|
||||
.type(type)
|
||||
.lang(language)
|
||||
.lang(locale.toLanguageTag())
|
||||
.action(action)
|
||||
.user(user)
|
||||
.actionData(actionLink)
|
||||
.isEnableDirectUrl(directUrl)
|
||||
.build()
|
||||
);
|
||||
|
||||
// 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()); // get an image and add it to the model
|
||||
model.addAttribute("dataCompareFile", getCompareFile()); // get a document for comparison and add it to the model
|
||||
model.addAttribute("dataMailMergeRecipients", getMailMerge()); // 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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -134,42 +177,61 @@ public class EditorController {
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private String getInsertImage() { // 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");
|
||||
|
||||
// check if the document token is enabled
|
||||
if(jwtManager.tokenEnabled()){
|
||||
dataInsertImage.put("token", jwtManager.createToken(dataInsertImage)); // create token from the dataInsertImage object
|
||||
if (directUrl) {
|
||||
dataInsertImage.put("directUrl", storagePathBuilder
|
||||
.getServerUrl(false) + "/css/img/logo.png");
|
||||
}
|
||||
|
||||
return objectMapper.writeValueAsString(dataInsertImage).substring(1, objectMapper.writeValueAsString(dataInsertImage).length()-1);
|
||||
// check if the document token is enabled
|
||||
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);
|
||||
}
|
||||
|
||||
// get a document that will be compared with the current document
|
||||
@SneakyThrows
|
||||
private String getCompareFile(){ // 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");
|
||||
}
|
||||
|
||||
// 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(){
|
||||
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");
|
||||
if (directUrl) {
|
||||
dataMailMergeRecipients.put("directUrl", storagePathBuilder.getServerUrl(false) + "/csv");
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
@ -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); // 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,9 +420,19 @@ 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) {
|
||||
curExt = (String) fileUtility.getFileExtension(newfilename);
|
||||
}
|
||||
|
||||
if (origExt.compareTo(curExt) != 0) {
|
||||
newfilename += origExt;
|
||||
}
|
||||
|
||||
HashMap<String, String> meta = new HashMap<>();
|
||||
meta.put("title", newfilename);
|
||||
|
||||
@ -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,7 +77,8 @@ public class IndexController {
|
||||
private String langs;
|
||||
|
||||
@GetMapping("${url.index}")
|
||||
public String index(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<>();
|
||||
@ -76,7 +86,7 @@ public class IndexController {
|
||||
List<Boolean> isFillFormDoc = new ArrayList<>();
|
||||
List<String> langsAndKeys = Arrays.asList(langs.split("\\|"));
|
||||
|
||||
Map<String, String> languages = new HashMap<>();
|
||||
Map<String, String> languages = new LinkedHashMap<>();
|
||||
|
||||
langsAndKeys.forEach((str) -> {
|
||||
String[] couple = str.split(":");
|
||||
@ -86,39 +96,49 @@ 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);
|
||||
model.addAttribute("directUrl", directUrl);
|
||||
|
||||
return "index.html";
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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,25 +76,44 @@ 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(FILE_SAVE_TIMEOUT);
|
||||
InputStream stream = connection.getInputStream(); // get input stream of the file information from the URL
|
||||
|
||||
int statusCode = connection.getResponseCode();
|
||||
if (statusCode != HttpStatus.OK.value()) { // checking status code
|
||||
connection.disconnect();
|
||||
throw new RuntimeException("Document editing service returned status: " + statusCode);
|
||||
}
|
||||
|
||||
if (stream == null) {
|
||||
connection.disconnect();
|
||||
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();
|
||||
@ -96,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) {
|
||||
@ -143,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>();
|
||||
@ -168,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);
|
||||
@ -184,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();
|
||||
|
||||
@ -194,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);
|
||||
@ -272,6 +324,6 @@ public class DefaultCallbackManager implements CallbackManager {
|
||||
}
|
||||
}
|
||||
|
||||
downloadToFile(downloadUri, Path.of(forcesavePath));
|
||||
saveFile(byteArrayFile, Path.of(forcesavePath));
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 filePath = serverPath + "/downloadhistory?fileName=" + URLEncoder.encode(filePathDownload, java.nio.charset.StandardCharsets.UTF_8.toString())
|
||||
+ "&ver=" + version + "&file="+file
|
||||
+ "&userAddress" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
: 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) {
|
||||
String serverPath = storagePathBuilder.getServerUrl(true);
|
||||
public String getDownloadUrl(final String fileName, final Boolean isServer) {
|
||||
String serverPath = storagePathBuilder.getServerUrl(isServer);
|
||||
String storageAddress = storagePathBuilder.getStorageLocation();
|
||||
try
|
||||
{
|
||||
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="
|
||||
+ URLEncoder.encode(storageAddress, 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;
|
||||
|
||||
@ -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); // get URL to download a file
|
||||
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
|
||||
}
|
||||
|
||||
@ -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,15 +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("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
|
||||
@ -104,18 +123,27 @@ 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
|
||||
prevInfo.put("url", prev.get("url"));
|
||||
dataObj.put("previous", prevInfo); // write information about previous file version to the data object
|
||||
if (!document.getDirectUrl().equals("")) {
|
||||
prevInfo.put("directUrl", prev.get("directUrl"));
|
||||
}
|
||||
|
||||
// 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);
|
||||
@ -127,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();
|
||||
}
|
||||
@ -136,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)) {
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
@ -25,6 +25,7 @@ public enum Action {
|
||||
embedded,
|
||||
filter,
|
||||
comment,
|
||||
chat,
|
||||
fillForms,
|
||||
blockcontent
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user