add: using replaceToInnerDocumentServerUrl()

This commit is contained in:
Aleksandr Fedorov
2023-12-18 12:57:32 +03:00
parent 841a4cd47e
commit a763e2b9fe
2 changed files with 13 additions and 0 deletions

View File

@ -446,6 +446,8 @@ public class FileController {
String url = body.getUrl();
url = urlManager.replaceToInnerDocumentServerUrl(url);
return requestManager.executeGetRequest(url, new RequestManager.Callback<String>() {
@Override
public String doWork(final Object response) throws Exception {

View File

@ -23,6 +23,7 @@ import com.onlyoffice.integration.documentserver.managers.history.HistoryManager
import com.onlyoffice.integration.documentserver.storage.FileStorageMutator;
import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder;
import com.onlyoffice.integration.sdk.manager.DocumentManager;
import com.onlyoffice.integration.sdk.manager.UrlManager;
import com.onlyoffice.manager.request.RequestManager;
import com.onlyoffice.model.commandservice.CommandRequest;
import com.onlyoffice.model.commandservice.commandrequest.Command;
@ -70,6 +71,9 @@ public class DefaultCallbackManager implements CallbackManager {
@Autowired
private HistoryManager historyManager;
@Autowired
private UrlManager urlManager;
// download file from url
@SneakyThrows
private byte[] getDownloadFile(final String url) {
@ -132,6 +136,9 @@ public class DefaultCallbackManager implements CallbackManager {
String curExt = documentManager.getExtension(fileName); // get current file extension
String downloadExt = callback.getFiletype(); // get an extension of the downloaded file
downloadUri = urlManager.replaceToInnerDocumentServerUrl(downloadUri);
changesUri = urlManager.replaceToInnerDocumentServerUrl(changesUri);
// todo: Refactoring
// convert downloaded file to the file with the current extension if these extensions aren't equal
if (!curExt.equals(downloadExt)) {
@ -221,6 +228,8 @@ public class DefaultCallbackManager implements CallbackManager {
String curExt = documentManager.getExtension(fileName); // get current file extension
String downloadExt = callback.getFiletype(); // get an extension of the downloaded file
downloadUri = urlManager.replaceToInnerDocumentServerUrl(downloadUri);
Boolean newFileName = false;
// convert downloaded file to the file with the current extension if these extensions aren't equal
@ -277,6 +286,8 @@ public class DefaultCallbackManager implements CallbackManager {
try {
String formsDataUrl = callback.getFormsdataurl();
formsDataUrl = urlManager.replaceToInnerDocumentServerUrl(formsDataUrl);
if (formsDataUrl != null && !formsDataUrl.isEmpty()) {
String formsName = documentManager.getCorrectName(documentManager
.getBaseName(fileName) + ".txt");