Li Yuan 1 anno fa
parent
commit
de231217ef

+ 3 - 2
ibps-provider-root/modules/provider-business/src/main/java/com/onlyoffice/integration/controllers/FileController.java

@@ -352,8 +352,9 @@ public class FileController {
     }
 
     @GetMapping(path = "${url.editor}")
+    @ResponseBody
     // process request to open the editor page
-    public FileModel editor(@RequestParam("fileName") final String fileName,
+    public String editor(@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,
@@ -391,7 +392,7 @@ public class FileController {
                         .build()
         );
 
-        return fileModel;
+        return objectMapper.writeValueAsString(fileModel);
     }
     @GetMapping("/create")
     public String create(@RequestParam("fileExt")

+ 0 - 143
ibps-provider-root/modules/provider-business/src/main/java/com/onlyoffice/integration/controllers/IndexController.java

@@ -1,143 +0,0 @@
-/**
- *
- * (c) Copyright Ascensio System SIA 2024
- *
- * 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.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.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 java.util.*;
-import java.util.stream.Collectors;
-
-@CrossOrigin("*")
-@RequestMapping("/onlyOffice")
-@RestController
-public class IndexController {
-
-    @Autowired
-    private FileStorageMutator storageMutator;
-
-    @Autowired
-    private FileStoragePathBuilder storagePathBuilder;
-
-    @Autowired
-    private FileUtility fileUtility;
-
-    @Autowired
-    private Misc mistUtility;
-
-    @Autowired
-    private UserServices userService;
-
-    @Value("${files.docservice.url.site}")
-    private String docserviceSite;
-
-    @Value("${files.docservice.url.preloader}")
-    private String docservicePreloader;
-
-    @Value("${url.converter}")
-    private String urlConverter;
-
-    @Value("${url.editor}")
-    private String urlEditor;
-
-    @Value("${files.docservice.languages}")
-    private String langs;
-
-    @Value("${server.version}")
-    private String serverVersion;
-
-    @GetMapping("${url.index}")
-    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<>();
-        List<String> versions = new ArrayList<>();
-        List<Boolean> isFillFormDoc = new ArrayList<>();
-        List<String> langsAndKeys = Arrays.asList(langs.split("\\|"));
-
-        Map<String, String> languages = new LinkedHashMap<>();
-
-        langsAndKeys.forEach((str) -> {
-            String[] couple = str.split(":");
-            languages.put(couple[0], couple[1]);
-        });
-
-        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
-                .collect(Collectors.joining());
-
-        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
-            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("files", files);
-        model.addAttribute("docTypes", docTypes);
-        model.addAttribute("filesEditable", filesEditable);
-        model.addAttribute("datadocs", docserviceSite + docservicePreloader);
-        model.addAttribute("tooltip", tooltip);
-        model.addAttribute("users", users);
-        model.addAttribute("languages", languages);
-        model.addAttribute("directUrl", directUrl);
-        model.addAttribute("serverVersion", serverVersion);
-
-        return "index.html";
-    }
-
-    @PostMapping("/config")
-    @ResponseBody
-    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("UrlConverter", urlConverter);
-        configuration.put("UrlEditor", urlEditor);
-
-        return configuration;
-    }
-}

+ 3 - 2
ibps-provider-root/modules/provider-business/src/main/java/com/onlyoffice/integration/documentserver/storage/LocalFileStorage.java

@@ -108,8 +108,9 @@ public class LocalFileStorage implements FileStorageMutator, FileStoragePathBuil
 
     // get the directory of the specified file
     public String getFileLocation(final String fileName) {
-        if (fileName.contains(File.separator)) {
-            return getStorageLocation() + fileName;
+        if (fileName.contains("/")) {
+            return Paths.get(getStorageLocation() + fileName).toString();
+//            return getStorageLocation() + fileName;
         }
         return getStorageLocation() + fileUtility.getFileName(fileName);
     }

+ 3 - 3
ibps-provider-root/modules/provider-business/src/main/resources/config/application-office.yml

@@ -12,11 +12,11 @@ files:
       api: web-apps/apps/api/documents/api.js
       command: coauthoring/CommandService.ashx
       converter: ConvertService.ashx
-      business: http://localhost:5100/ibps/business/v3/onlyOffice
+      business: ${RUNQIAN_SERVER:http://localhost:5100}/ibps/business/v3/onlyOffice
       preloader: web-apps/apps/api/documents/cache-scripts.html
-      site: http://192.168.56.164:9999/
+      site: ${RUNQIAN_SERVER:http://192.168.56.164:9999}/${OFFICE_SERVER_BASE_PATH:word}
     verify-peer-off: true
-  storage: C:\Users\rex\opt\onlyoffice
+  storage: ${OFFICE_STORAGE:/opt/onlyoffice}
   storage.folder: documents
 filesize-max: 5242880
 server: