Skip to content

Commit

Permalink
fix: api reference data (5cbd216)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandrfedorov97 committed Dec 21, 2023
1 parent 15eab17 commit e1019e0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main/java/onlyoffice/OnlyOfficeAPIServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.onlyoffice.manager.settings.SettingsManager;
import com.onlyoffice.manager.security.JwtManager;
import com.onlyoffice.manager.url.UrlManager;
import com.onlyoffice.model.documenteditor.config.document.ReferenceData;
import onlyoffice.sdk.manager.document.DocumentManager;
import onlyoffice.utils.attachment.AttachmentUtil;
import onlyoffice.utils.parsing.ParsingUtil;
Expand Down Expand Up @@ -220,13 +221,14 @@ private void referenceData(final HttpServletRequest request, final HttpServletRe

try {
JSONObject bodyJson = new JSONObject(body);
JSONObject referenceData = new JSONObject();
ReferenceData referenceData = new ReferenceData();
Long attachmentId = null;

if (bodyJson.has("referenceData")) {
referenceData = bodyJson.getJSONObject("referenceData");
if (referenceData.getString("instanceId").equals(sysInfoService.getConfluenceInfo().getBaseUrl())) {
attachmentId = referenceData.getLong("fileKey");
String referenceDataString = bodyJson.getJSONObject("referenceData").toString();
referenceData = objectMapper.readValue(referenceDataString, ReferenceData.class);
if (referenceData.getInstanceId().equals(sysInfoService.getConfluenceInfo().getBaseUrl())) {
attachmentId = Long.valueOf(referenceData.getFileKey());
}
}

Expand All @@ -240,8 +242,8 @@ private void referenceData(final HttpServletRequest request, final HttpServletRe
attachment = attachmentUtil.getAttachmentByName(bodyJson.getString("path"), pageId);
if (attachment != null) {
attachmentId = attachment.getId();
referenceData.put("fileKey", attachment.getId());
referenceData.put("instanceId", sysInfoService.getConfluenceInfo().getBaseUrl());
referenceData.setFileKey(String.valueOf(attachment.getId()));
referenceData.setInstanceId(sysInfoService.getConfluenceInfo().getBaseUrl());
}
}
}
Expand Down

0 comments on commit e1019e0

Please sign in to comment.