From 8e0f21dbee1f02f0aeeb270311ea06023ad8e5ed Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 21 Mar 2023 16:13:49 +0300 Subject: [PATCH 01/98] removed: properties from EditorServlet # Conflicts: # src/main/java/onlyoffice/OnlyOfficeEditorServlet.java --- src/main/java/onlyoffice/OnlyOfficeEditorServlet.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java index 5cf05e8b..cac7db6b 100644 --- a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java @@ -49,13 +49,11 @@ import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; -import java.util.Properties; public class OnlyOfficeEditorServlet extends HttpServlet { private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeEditorServlet"); private final long serialVersionUID = 1L; - private Properties properties; @ComponentImport private final LocaleManager localeManager; @@ -99,8 +97,6 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re apiUrl = ""; } - properties = configurationManager.getProperties(); - String type = ""; String callbackUrl = ""; String fileUrl = ""; @@ -189,7 +185,7 @@ private String getTemplate(final Long attachmentId, final String type, final Str String documentType = documentManager.getDocType(docExt); Long pageId = attachmentUtil.getAttachmentPageId(attachmentId); - config.put("docserviceApiUrl", apiUrl + properties.getProperty("files.docservice.url.api")); + config.put("docserviceApiUrl", apiUrl + configurationManager.getProperty("files.docservice.url.api")); config.put("errorMessage", errorMessage); config.put("docTitle", docTitle); config.put("favicon", webResourceUrlProvider.getStaticPluginResourceUrl( From 9c9ac77947aab1e701e83d03755b6d7dbfe21616 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 21 Mar 2023 10:59:26 +0300 Subject: [PATCH 02/98] added: referenceData object to config --- src/main/java/onlyoffice/OnlyOfficeEditorServlet.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java index cac7db6b..22825692 100644 --- a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java @@ -21,6 +21,7 @@ import com.atlassian.confluence.languages.LocaleManager; import com.atlassian.confluence.pages.BlogPost; import com.atlassian.confluence.renderer.radeox.macros.MacroUtils; +import com.atlassian.confluence.status.service.SystemInformationService; import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.user.ConfluenceUser; import com.atlassian.confluence.util.velocity.VelocityUtils; @@ -59,6 +60,8 @@ public class OnlyOfficeEditorServlet extends HttpServlet { private final LocaleManager localeManager; @ComponentImport private final WebResourceUrlProvider webResourceUrlProvider; + @ComponentImport + private final SystemInformationService sysInfoService; private final JwtManager jwtManager; private final UrlManager urlManager; @@ -71,6 +74,7 @@ public class OnlyOfficeEditorServlet extends HttpServlet { @Inject public OnlyOfficeEditorServlet(final LocaleManager localeManager, final WebResourceUrlProvider webResourceUrlProvider, + final SystemInformationService sysInfoService, final UrlManager urlManager, final JwtManager jwtManager, final ConfigurationManager configurationManager, final AuthContext authContext, final DocumentManager documentManager, @@ -83,6 +87,7 @@ public OnlyOfficeEditorServlet(final LocaleManager localeManager, this.authContext = authContext; this.documentManager = documentManager; this.attachmentUtil = attachmentUtil; + this.sysInfoService = sysInfoService; } @Override @@ -199,6 +204,7 @@ private String getTemplate(final Long attachmentId, final String type, final Str JSONObject editorConfigObject = new JSONObject(); JSONObject userObject = new JSONObject(); JSONObject permObject = new JSONObject(); + JSONObject referenceData = new JSONObject(); JSONObject customizationObject = new JSONObject(); JSONObject gobackObject = new JSONObject(); @@ -214,8 +220,12 @@ private String getTemplate(final Long attachmentId, final String type, final Str documentObject.put("fileType", docExt); documentObject.put("key", key); documentObject.put("permissions", permObject); + documentObject.put("referenceData", referenceData); responseJson.put("editorConfig", editorConfigObject); + referenceData.put("fileKey", attachmentId); + referenceData.put("instanceId", sysInfoService.getConfluenceInfo().getServerId()); + if (canEdit && callbackUrl != null && !callbackUrl.isEmpty()) { permObject.put("edit", true); editorConfigObject.put("mode", "edit"); From 839e7bdddb14226ec8048ad76bfcbe063281e979 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 21 Mar 2023 11:00:42 +0300 Subject: [PATCH 03/98] added: api reference-data --- .../java/onlyoffice/OnlyOfficeAPIServlet.java | 82 ++++++++++++++++++- .../utils/attachment/AttachmentUtil.java | 4 + .../utils/attachment/AttachmentUtilImpl.java | 25 ++++++ 3 files changed, 108 insertions(+), 3 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java index 17ef7f15..1cc86d8c 100644 --- a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java @@ -18,8 +18,11 @@ package onlyoffice; +import com.atlassian.confluence.pages.Attachment; +import com.atlassian.confluence.status.service.SystemInformationService; import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.user.ConfluenceUser; +import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; import com.google.gson.Gson; import onlyoffice.managers.configuration.ConfigurationManager; import onlyoffice.managers.document.DocumentManager; @@ -57,6 +60,9 @@ public class OnlyOfficeAPIServlet extends HttpServlet { private static final long serialVersionUID = 1L; private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeAPIServlet"); + @ComponentImport + private final SystemInformationService sysInfoService; + private final JwtManager jwtManager; private final DocumentManager documentManager; @@ -66,9 +72,11 @@ public class OnlyOfficeAPIServlet extends HttpServlet { private final ConfigurationManager configurationManager; @Inject - public OnlyOfficeAPIServlet(final JwtManager jwtManager, final DocumentManager documentManager, - final AttachmentUtil attachmentUtil, final ParsingUtil parsingUtil, - final UrlManager urlManager, final ConfigurationManager configurationManager) { + public OnlyOfficeAPIServlet(final SystemInformationService sysInfoService, final JwtManager jwtManager, + final DocumentManager documentManager, final AttachmentUtil attachmentUtil, + final ParsingUtil parsingUtil, final UrlManager urlManager, + final ConfigurationManager configurationManager) { + this.sysInfoService = sysInfoService; this.jwtManager = jwtManager; this.documentManager = documentManager; this.attachmentUtil = attachmentUtil; @@ -89,6 +97,9 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r case "attachment-data": attachmentData(request, response); break; + case "reference-data": + referenceData(request, response); + break; default: response.sendError(HttpServletResponse.SC_NOT_FOUND); return; @@ -207,4 +218,69 @@ private void attachmentData(final HttpServletRequest request, final HttpServletR throw new IOException(e.getMessage()); } } + + private void referenceData(final HttpServletRequest request, final HttpServletResponse response) + throws IOException { + ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + + if (user == null) { + response.sendError(HttpServletResponse.SC_UNAUTHORIZED); + return; + } + + InputStream requestStream = request.getInputStream(); + String body = parsingUtil.getBody(requestStream); + + try { + JSONObject bodyJson = new JSONObject(body); + JSONObject referenceData = new JSONObject(); + Long attachmentId = null; + + if (bodyJson.has("referenceData")) { + referenceData = bodyJson.getJSONObject("referenceData"); + attachmentId = referenceData.getLong("fileKey"); + } + + if (attachmentUtil.getAttachment(attachmentId) == null) { + String pageIdString = request.getParameter("pageId"); + + if (pageIdString != null && !pageIdString.isEmpty()) { + Long pageId = Long.parseLong(pageIdString); + Attachment attachment = attachmentUtil.getAttachmentByName(bodyJson.getString("path"), pageId); + if (attachment != null) { + attachmentId = attachment.getId(); + referenceData.put("fileKey", attachment.getId()); + referenceData.put("instanceId", sysInfoService.getConfluenceInfo().getServerId()); + } + } + } + + if (attachmentUtil.getAttachment(attachmentId) == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + return; + } + + if (!attachmentUtil.checkAccess(attachmentId, user, false)) { + response.sendError(HttpServletResponse.SC_FORBIDDEN); + return; + } + + JSONObject responseJson = new JSONObject(); + + responseJson.put("fileType", attachmentUtil.getFileExt(attachmentId)); + responseJson.put("path", attachmentUtil.getFileName(attachmentId)); + responseJson.put("referenceData", referenceData); + responseJson.put("url", urlManager.getFileUri(attachmentId)); + + if (jwtManager.jwtEnabled()) { + responseJson.put("token", jwtManager.createToken(responseJson)); + } + + response.setContentType("application/json"); + PrintWriter writer = response.getWriter(); + writer.write(responseJson.toString()); + } catch (Exception e) { + throw new IOException(e.getMessage(), e); + } + } } diff --git a/src/main/java/onlyoffice/utils/attachment/AttachmentUtil.java b/src/main/java/onlyoffice/utils/attachment/AttachmentUtil.java index b6167905..b92f3a38 100644 --- a/src/main/java/onlyoffice/utils/attachment/AttachmentUtil.java +++ b/src/main/java/onlyoffice/utils/attachment/AttachmentUtil.java @@ -12,6 +12,10 @@ import java.util.List; public interface AttachmentUtil extends Serializable { + Attachment getAttachment(Long attachmentId); + + Attachment getAttachmentByName(String fileName, Long pageId); + boolean checkAccess(Long attachmentId, User user, boolean forEdit); boolean checkAccess(Attachment attachment, User user, boolean forEdit); diff --git a/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java b/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java index eb3c690e..95a234d9 100644 --- a/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java +++ b/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java @@ -19,6 +19,7 @@ package onlyoffice.utils.attachment; import com.atlassian.confluence.content.ContentProperties; +import com.atlassian.confluence.core.ContentEntityManager; import com.atlassian.confluence.core.ContentEntityObject; import com.atlassian.confluence.pages.Attachment; import com.atlassian.confluence.pages.AttachmentManager; @@ -87,6 +88,30 @@ public AttachmentUtilImpl(final AttachmentManager attachmentManager, final Trans this.bootstrapManager = bootstrapManager; } + public Attachment getAttachment(final Long attachmentId) { + try { + return attachmentManager.getAttachment(attachmentId); + } catch (NullPointerException e) { + return null; + } + } + + public Attachment getAttachmentByName(final String fileName, final Long pageId) { + ContentEntityManager contentEntityManager = + (ContentEntityManager) ContainerManager.getComponent("contentEntityManager"); + ContentEntityObject contentEntityObject = contentEntityManager.getById(pageId); + + List attachments = attachmentManager.getLatestVersionsOfAttachments(contentEntityObject); + + for (Attachment attachment : attachments) { + if (attachment.getFileName().equals(fileName)) { + return attachment; + } + } + + return null; + } + public boolean checkAccess(final Long attachmentId, final User user, final boolean forEdit) { if (user == null) { return false; From 9a99df134587092ab8ef9573c2e1c5f3aa86c5d3 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 21 Mar 2023 11:01:36 +0300 Subject: [PATCH 04/98] added: event onRequestReferenceData --- .../onlyoffice/OnlyOfficeEditorServlet.java | 1 + .../onlyoffice/managers/url/UrlManager.java | 2 ++ .../managers/url/UrlManagerImpl.java | 6 ++++++ src/main/resources/templates/editor.vm | 20 +++++++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java index 22825692..41bc6fa9 100644 --- a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java @@ -282,6 +282,7 @@ private String getTemplate(final Long attachmentId, final String type, final Str config.put("historyDataUriAsHtml", urlManager.getHistoryDataUri(attachmentId)); config.put("attachmentDataAsHtml", urlManager.getAttachmentDataUri()); config.put("saveAsUriAsHtml", urlManager.getSaveAsUri()); + config.put("referenceDataUriAsHtml", urlManager.getReferenceDataUri(pageId)); config.put("insertImageTypesAsHtml", new JSONArray(documentManager.getInsertImageTypes()).toString()); config.put("compareFileTypesAsHtml", new JSONArray(documentManager.getCompareFileTypes()).toString()); config.put("mailMergeTypesAsHtml", new JSONArray(documentManager.getMailMergeTypes()).toString()); diff --git a/src/main/java/onlyoffice/managers/url/UrlManager.java b/src/main/java/onlyoffice/managers/url/UrlManager.java index cb9e68ab..2c803f87 100644 --- a/src/main/java/onlyoffice/managers/url/UrlManager.java +++ b/src/main/java/onlyoffice/managers/url/UrlManager.java @@ -20,6 +20,8 @@ public interface UrlManager extends Serializable { String getSaveAsUri(); + String getReferenceDataUri(Long pageId); + String getCallbackUrl(Long attachmentId); String getGobackUrl(Long attachmentId, HttpServletRequest request); diff --git a/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java b/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java index 5fbbc94f..f8a6d74d 100644 --- a/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java +++ b/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java @@ -130,6 +130,12 @@ public String getSaveAsUri() { return saveAsUri; } + public String getReferenceDataUri(final Long pageId) { + String referenceDataUri = getConfluenceBaseUrl() + apiServlet + "?type=reference-data&pageId=" + pageId; + + return referenceDataUri; + } + public String getCallbackUrl(final Long attachmentId) { String hash = documentManager.createHash(Long.toString(attachmentId)); diff --git a/src/main/resources/templates/editor.vm b/src/main/resources/templates/editor.vm index 51695923..3f74a57f 100644 --- a/src/main/resources/templates/editor.vm +++ b/src/main/resources/templates/editor.vm @@ -319,6 +319,25 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl docEditor.setActionLink(createActionLink(location.href, actionData)); }; + var onRequestReferenceData = function(event) { + var xhr = new XMLHttpRequest(); + xhr.open("POST", "${referenceDataUriAsHtml}"); + xhr.send(JSON.stringify(event.data)); + + xhr.onreadystatechange = function() { + if (xhr.readyState != 4) return; + if (xhr.status == 200) { + docEditor.setReferenceData(JSON.parse(xhr.responseText)); + } else if (xhr.status == 403) { + docEditor.setReferenceData({error: "$i18n.getText('operation.forbidden.message')"}); + } else if (xhr.status == 404) { + docEditor.setReferenceData({error: "$i18n.getText('title.attachment.not.found')"}); + } else { + docEditor.setReferenceData({error: "$i18n.getText('dialog.error.unknown.title')"}); + } + } + }; + var connectEditor = function () { if (typeof DocsAPI === "undefined") { alert("$i18n.getText('onlyoffice.editor.message.docs-api-undefined')"); @@ -342,6 +361,7 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl "onRequestCompareFile": onRequestCompareFile, "onRequestMailMergeRecipients": onRequestMailMergeRecipients, "onMakeActionLink": onMakeActionLink, + "onRequestReferenceData": onRequestReferenceData }, }; From f3829b78367402811bd4925e8829a4421ab18ba9 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 21 Mar 2023 11:03:05 +0300 Subject: [PATCH 05/98] reference-data to changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8975bc55..fdd20c37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## +## Added +- referenceData + ## 4.2.0 ## Changed - compatible with Confluence 8.1.1 From 5500350e3be8b4f04ea3561d29ce458d355f1279 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 22 Mar 2023 15:33:14 +0300 Subject: [PATCH 06/98] changed: referenceData, baseUrl instead serverId --- src/main/java/onlyoffice/OnlyOfficeAPIServlet.java | 2 +- src/main/java/onlyoffice/OnlyOfficeEditorServlet.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java index 1cc86d8c..dbf70d71 100644 --- a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java @@ -250,7 +250,7 @@ private void referenceData(final HttpServletRequest request, final HttpServletRe if (attachment != null) { attachmentId = attachment.getId(); referenceData.put("fileKey", attachment.getId()); - referenceData.put("instanceId", sysInfoService.getConfluenceInfo().getServerId()); + referenceData.put("instanceId", sysInfoService.getConfluenceInfo().getBaseUrl()); } } } diff --git a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java index 41bc6fa9..dd9b7430 100644 --- a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java @@ -224,7 +224,7 @@ private String getTemplate(final Long attachmentId, final String type, final Str responseJson.put("editorConfig", editorConfigObject); referenceData.put("fileKey", attachmentId); - referenceData.put("instanceId", sysInfoService.getConfluenceInfo().getServerId()); + referenceData.put("instanceId", sysInfoService.getConfluenceInfo().getBaseUrl()); if (canEdit && callbackUrl != null && !callbackUrl.isEmpty()) { permObject.put("edit", true); From dc5726a6a912b706dd619a15e401bf806d5079a4 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 22 Mar 2023 15:45:18 +0300 Subject: [PATCH 07/98] moved: init components to atlassian-plugin.xml --- .../java/onlyoffice/OnlyOfficeAPIServlet.java | 6 --- .../onlyoffice/OnlyOfficeConfServlet.java | 8 ---- .../onlyoffice/OnlyOfficeConvertServlet.java | 6 +-- .../onlyoffice/OnlyOfficeEditorServlet.java | 9 +---- .../OnlyOfficeFileProviderServlet.java | 2 - .../onlyoffice/OnlyOfficeHistoryServlet.java | 7 +--- .../onlyoffice/OnlyOfficeSaveFileServlet.java | 3 -- .../conditions/IsOfficeFileAttachment.java | 2 - .../IsOfficeFileConvertAttachment.java | 2 - .../conditions/IsOfficePageAttachments.java | 3 -- .../previews/plugin/OnlyofficeButton.java | 5 --- .../onlyoffice/managers/auth/AuthContext.java | 9 +++++ .../auth/AuthContextImpl.java} | 8 ++-- .../ConfigurationManagerImpl.java | 6 --- .../managers/convert/ConvertManagerImpl.java | 9 ----- .../document/DocumentManagerImpl.java | 16 ++------ .../managers/jwt/JwtManagerImpl.java | 12 ------ .../managers/url/UrlManagerImpl.java | 12 ------ .../utils/attachment/AttachmentUtilImpl.java | 11 ------ .../utils/parsing/ParsingUtilImpl.java | 4 -- src/main/resources/atlassian-plugin.xml | 39 +++++++++++++++++++ 21 files changed, 58 insertions(+), 121 deletions(-) create mode 100644 src/main/java/onlyoffice/managers/auth/AuthContext.java rename src/main/java/onlyoffice/{AuthContext.java => managers/auth/AuthContextImpl.java} (94%) diff --git a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java index dbf70d71..a3252689 100644 --- a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java @@ -22,7 +22,6 @@ import com.atlassian.confluence.status.service.SystemInformationService; import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.user.ConfluenceUser; -import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; import com.google.gson.Gson; import onlyoffice.managers.configuration.ConfigurationManager; import onlyoffice.managers.document.DocumentManager; @@ -42,7 +41,6 @@ import org.json.JSONArray; import org.json.JSONObject; -import javax.inject.Inject; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -60,18 +58,14 @@ public class OnlyOfficeAPIServlet extends HttpServlet { private static final long serialVersionUID = 1L; private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeAPIServlet"); - @ComponentImport private final SystemInformationService sysInfoService; - private final JwtManager jwtManager; private final DocumentManager documentManager; - private final AttachmentUtil attachmentUtil; private final ParsingUtil parsingUtil; private final UrlManager urlManager; private final ConfigurationManager configurationManager; - @Inject public OnlyOfficeAPIServlet(final SystemInformationService sysInfoService, final JwtManager jwtManager, final DocumentManager documentManager, final AttachmentUtil attachmentUtil, final ParsingUtil parsingUtil, final UrlManager urlManager, diff --git a/src/main/java/onlyoffice/OnlyOfficeConfServlet.java b/src/main/java/onlyoffice/OnlyOfficeConfServlet.java index 09c73e85..89fa9483 100644 --- a/src/main/java/onlyoffice/OnlyOfficeConfServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeConfServlet.java @@ -21,7 +21,6 @@ import com.atlassian.confluence.renderer.radeox.macros.MacroUtils; import com.atlassian.confluence.setup.settings.SettingsManager; import com.atlassian.confluence.util.velocity.VelocityUtils; -import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; import com.atlassian.sal.api.pluginsettings.PluginSettings; import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; import com.atlassian.sal.api.user.UserManager; @@ -42,7 +41,6 @@ import org.json.JSONArray; import org.json.JSONObject; -import javax.inject.Inject; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -58,18 +56,12 @@ public class OnlyOfficeConfServlet extends HttpServlet { private final long serialVersionUID = 1L; private static final int ERROR_INVALID_TOKEN = 6; - @ComponentImport private final UserManager userManager; - @ComponentImport private final PluginSettingsFactory pluginSettingsFactory; - private final JwtManager jwtManager; private final ConfigurationManager configurationManager; - private final ParsingUtil parsingUtil; - - @Inject public OnlyOfficeConfServlet(final UserManager userManager, final PluginSettingsFactory pluginSettingsFactory, final JwtManager jwtManager, final ConfigurationManager configurationManager, final ParsingUtil parsingUtil) { diff --git a/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java b/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java index f5d1a245..eb87c179 100644 --- a/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java @@ -24,7 +24,7 @@ import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.user.ConfluenceUser; import com.atlassian.confluence.util.velocity.VelocityUtils; -import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; +import onlyoffice.managers.auth.AuthContext; import onlyoffice.managers.configuration.ConfigurationManager; import onlyoffice.managers.convert.ConvertManager; import onlyoffice.managers.document.DocumentManager; @@ -40,7 +40,6 @@ import org.apache.log4j.Logger; import org.json.JSONObject; -import javax.inject.Inject; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -57,16 +56,13 @@ public class OnlyOfficeConvertServlet extends HttpServlet { private static final long serialVersionUID = 1L; private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeConvertServlet"); - @ComponentImport private final AttachmentManager attachmentManager; - private final AttachmentUtil attachmentUtil; private final ConvertManager convertManager; private final AuthContext authContext; private final DocumentManager documentManager; private final ConfigurationManager configurationManager; - @Inject public OnlyOfficeConvertServlet(final AttachmentManager attachmentManager, final AttachmentUtil attachmentUtil, final ConvertManager convertManager, final AuthContext authContext, final DocumentManager documentManager, diff --git a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java index dd9b7430..5509545f 100644 --- a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java @@ -25,9 +25,9 @@ import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.user.ConfluenceUser; import com.atlassian.confluence.util.velocity.VelocityUtils; -import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; import com.atlassian.plugin.webresource.UrlMode; import com.atlassian.plugin.webresource.WebResourceUrlProvider; +import onlyoffice.managers.auth.AuthContext; import onlyoffice.managers.configuration.ConfigurationManager; import onlyoffice.managers.document.DocumentManager; import onlyoffice.managers.jwt.JwtManager; @@ -38,7 +38,6 @@ import org.json.JSONArray; import org.json.JSONObject; -import javax.inject.Inject; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -55,12 +54,8 @@ public class OnlyOfficeEditorServlet extends HttpServlet { private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeEditorServlet"); private final long serialVersionUID = 1L; - - @ComponentImport private final LocaleManager localeManager; - @ComponentImport private final WebResourceUrlProvider webResourceUrlProvider; - @ComponentImport private final SystemInformationService sysInfoService; private final JwtManager jwtManager; @@ -70,8 +65,6 @@ public class OnlyOfficeEditorServlet extends HttpServlet { private final DocumentManager documentManager; private final AttachmentUtil attachmentUtil; - - @Inject public OnlyOfficeEditorServlet(final LocaleManager localeManager, final WebResourceUrlProvider webResourceUrlProvider, final SystemInformationService sysInfoService, diff --git a/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java b/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java index 37644c51..4c29b3e1 100644 --- a/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java @@ -24,7 +24,6 @@ import org.apache.log4j.LogManager; import org.apache.log4j.Logger; -import javax.inject.Inject; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -42,7 +41,6 @@ public class OnlyOfficeFileProviderServlet extends HttpServlet { private final JwtManager jwtManager; private final DocumentManager documentManager; - @Inject public OnlyOfficeFileProviderServlet(final AttachmentUtil attachmentUtil, final JwtManager jwtManager, final DocumentManager documentManager) { this.attachmentUtil = attachmentUtil; diff --git a/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java b/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java index 531fb2a5..e04c977d 100644 --- a/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java @@ -26,9 +26,9 @@ import com.atlassian.confluence.user.ConfluenceUser; import com.atlassian.confluence.user.ConfluenceUserPreferences; import com.atlassian.confluence.user.UserAccessor; -import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; import com.atlassian.spring.container.ContainerManager; import com.google.gson.Gson; +import onlyoffice.managers.auth.AuthContext; import onlyoffice.managers.document.DocumentManager; import onlyoffice.managers.jwt.JwtManager; import onlyoffice.managers.url.UrlManager; @@ -39,7 +39,6 @@ import org.json.JSONException; import org.json.JSONObject; -import javax.inject.Inject; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -59,11 +58,8 @@ public class OnlyOfficeHistoryServlet extends HttpServlet { private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeHistoryServlet"); private static final int BUFFER_SIZE = 10240; - @ComponentImport private final LocaleManager localeManager; - @ComponentImport private final FormatSettingsManager formatSettingsManager; - private final AuthContext authContext; private final DocumentManager documentManager; private final AttachmentUtil attachmentUtil; @@ -71,7 +67,6 @@ public class OnlyOfficeHistoryServlet extends HttpServlet { private final JwtManager jwtManager; private final ParsingUtil parsingUtil; - @Inject public OnlyOfficeHistoryServlet(final LocaleManager localeManager, final FormatSettingsManager formatSettingsManager, final AuthContext authContext, final DocumentManager documentManager, diff --git a/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java b/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java index ddcc34c2..bea56d47 100644 --- a/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java @@ -41,7 +41,6 @@ import org.json.JSONException; import org.json.JSONObject; -import javax.inject.Inject; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -67,14 +66,12 @@ public class OnlyOfficeSaveFileServlet extends HttpServlet { private final JwtManager jwtManager; private final DocumentManager documentManager; - private final AttachmentUtil attachmentUtil; private final ParsingUtil parsingUtil; private final UrlManager urlManager; private final ConfigurationManager configurationManager; private final ConvertManager convertManager; - @Inject public OnlyOfficeSaveFileServlet(final JwtManager jwtManager, final DocumentManager documentManager, final AttachmentUtil attachmentUtil, final ParsingUtil parsingUtil, final UrlManager urlManager, final ConfigurationManager configurationManager, diff --git a/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java b/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java index d2dfbbe9..82b08188 100644 --- a/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java +++ b/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java @@ -26,7 +26,6 @@ import onlyoffice.managers.document.DocumentManager; import onlyoffice.utils.attachment.AttachmentUtil; -import javax.inject.Inject; import java.util.Map; public class IsOfficeFileAttachment implements Condition { @@ -35,7 +34,6 @@ public class IsOfficeFileAttachment implements Condition { private DocumentManager documentManager; private AttachmentUtil attachmentUtil; - @Inject public IsOfficeFileAttachment(final DocumentManager documentManager, final AttachmentUtil attachmentUtil) { this.documentManager = documentManager; this.attachmentUtil = attachmentUtil; diff --git a/src/main/java/onlyoffice/conditions/IsOfficeFileConvertAttachment.java b/src/main/java/onlyoffice/conditions/IsOfficeFileConvertAttachment.java index 3161b1bd..28affb0e 100644 --- a/src/main/java/onlyoffice/conditions/IsOfficeFileConvertAttachment.java +++ b/src/main/java/onlyoffice/conditions/IsOfficeFileConvertAttachment.java @@ -27,7 +27,6 @@ import onlyoffice.managers.document.DocumentManager; import onlyoffice.utils.attachment.AttachmentUtil; -import javax.inject.Inject; import java.util.Map; public class IsOfficeFileConvertAttachment implements Condition { @@ -38,7 +37,6 @@ public class IsOfficeFileConvertAttachment implements Condition { private final AttachmentUtil attachmentUtil; private final ConvertManager convertManager; - @Inject public IsOfficeFileConvertAttachment(final DocumentManager documentManager, final AttachmentUtil attachmentUtil, final ConvertManager convertManager) { this.documentManager = documentManager; diff --git a/src/main/java/onlyoffice/conditions/IsOfficePageAttachments.java b/src/main/java/onlyoffice/conditions/IsOfficePageAttachments.java index 7bbfedc5..6e91f96a 100644 --- a/src/main/java/onlyoffice/conditions/IsOfficePageAttachments.java +++ b/src/main/java/onlyoffice/conditions/IsOfficePageAttachments.java @@ -25,7 +25,6 @@ import com.atlassian.plugin.web.Condition; import onlyoffice.utils.attachment.AttachmentUtil; -import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; import java.util.Map; import java.util.regex.Matcher; @@ -33,10 +32,8 @@ public class IsOfficePageAttachments implements Condition { private String pageAttachments = "viewpageattachments.action"; - private final AttachmentUtil attachmentUtil; - @Inject public IsOfficePageAttachments(final AttachmentUtil attachmentUtil) { this.attachmentUtil = attachmentUtil; } diff --git a/src/main/java/onlyoffice/conditions/confluence/previews/plugin/OnlyofficeButton.java b/src/main/java/onlyoffice/conditions/confluence/previews/plugin/OnlyofficeButton.java index 0dd7929d..d733a350 100644 --- a/src/main/java/onlyoffice/conditions/confluence/previews/plugin/OnlyofficeButton.java +++ b/src/main/java/onlyoffice/conditions/confluence/previews/plugin/OnlyofficeButton.java @@ -22,13 +22,11 @@ import com.atlassian.confluence.pages.AttachmentManager; import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.user.ConfluenceUser; -import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; import onlyoffice.managers.document.DocumentManager; import onlyoffice.utils.attachment.AttachmentUtil; import onlyoffice.utils.parsing.ParsingUtil; import org.json.JSONObject; -import javax.inject.Inject; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; @@ -38,14 +36,11 @@ import java.io.PrintWriter; public class OnlyofficeButton extends HttpServlet { - @ComponentImport private AttachmentManager attachmentManager; - private final ParsingUtil parsingUtil; private final AttachmentUtil attachmentUtil; private final DocumentManager documentManager; - @Inject public OnlyofficeButton(final AttachmentManager attachmentManager, final ParsingUtil parsingUtil, final AttachmentUtil attachmentUtil, final DocumentManager documentManager) { this.attachmentManager = attachmentManager; diff --git a/src/main/java/onlyoffice/managers/auth/AuthContext.java b/src/main/java/onlyoffice/managers/auth/AuthContext.java new file mode 100644 index 00000000..814ad83e --- /dev/null +++ b/src/main/java/onlyoffice/managers/auth/AuthContext.java @@ -0,0 +1,9 @@ +package onlyoffice.managers.auth; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public interface AuthContext { + boolean checkUserAuthorisation(HttpServletRequest request, HttpServletResponse response) throws IOException; +} diff --git a/src/main/java/onlyoffice/AuthContext.java b/src/main/java/onlyoffice/managers/auth/AuthContextImpl.java similarity index 94% rename from src/main/java/onlyoffice/AuthContext.java rename to src/main/java/onlyoffice/managers/auth/AuthContextImpl.java index 0e90fce2..93f22e3b 100644 --- a/src/main/java/onlyoffice/AuthContext.java +++ b/src/main/java/onlyoffice/managers/auth/AuthContextImpl.java @@ -16,21 +16,19 @@ * */ -package onlyoffice; +package onlyoffice.managers.auth; import com.atlassian.confluence.util.GeneralUtil; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; -import javax.inject.Named; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.security.Principal; -@Named -public class AuthContext { - private final Logger log = LogManager.getLogger("onlyoffice.AuthContext"); +public class AuthContextImpl implements AuthContext { + private final Logger log = LogManager.getLogger("onlyoffice.managers.auth.AuthContext"); public boolean checkUserAuthorisation(final HttpServletRequest request, final HttpServletResponse response) throws IOException { diff --git a/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java b/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java index a3fbc83e..cb1a5460 100644 --- a/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java +++ b/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java @@ -30,9 +30,6 @@ import org.apache.log4j.LogManager; import org.apache.log4j.Logger; -import javax.enterprise.inject.Default; -import javax.inject.Inject; -import javax.inject.Named; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLSession; import java.io.IOException; @@ -54,8 +51,6 @@ import java.util.Properties; import java.util.concurrent.TimeUnit; -@Named -@Default public class ConfigurationManagerImpl implements ConfigurationManager { private final Logger log = LogManager.getLogger("onlyoffice.managers.configuration.ConfigurationManager"); private final PluginSettings pluginSettings; @@ -65,7 +60,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager { private final String pluginDemoNameStart = "onlyoffice.demoStart"; private Map demoData; - @Inject public ConfigurationManagerImpl(final PluginSettingsFactory pluginSettingsFactory) { pluginSettings = pluginSettingsFactory.createGlobalSettings(); diff --git a/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java b/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java index 7d729de8..7d53b421 100644 --- a/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java +++ b/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java @@ -20,7 +20,6 @@ import com.atlassian.confluence.languages.LocaleManager; import com.atlassian.confluence.user.ConfluenceUser; -import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; import onlyoffice.managers.configuration.ConfigurationManager; import onlyoffice.managers.document.DocumentManager; import onlyoffice.managers.jwt.JwtManager; @@ -37,28 +36,20 @@ import org.apache.log4j.Logger; import org.json.JSONObject; -import javax.enterprise.inject.Default; -import javax.inject.Inject; -import javax.inject.Named; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.List; -@Named -@Default public class ConvertManagerImpl implements ConvertManager { private final Logger log = LogManager.getLogger("onlyoffice.managers.convert.ConvertManager"); - @ComponentImport private final LocaleManager localeManager; - private final UrlManager urlManager; private final JwtManager jwtManager; private final ConfigurationManager configurationManager; private final DocumentManager documentManager; - @Inject public ConvertManagerImpl(final UrlManager urlManager, final JwtManager jwtManager, final ConfigurationManager configurationManager, final DocumentManager documentManager, final LocaleManager localeManager) { diff --git a/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java b/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java index d970b1a4..983b6941 100644 --- a/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java +++ b/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java @@ -26,7 +26,6 @@ import com.atlassian.confluence.pages.AttachmentManager; import com.atlassian.confluence.user.ConfluenceUser; import com.atlassian.plugin.PluginAccessor; -import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; import com.atlassian.sal.api.message.I18nResolver; import com.atlassian.spring.container.ContainerManager; import onlyoffice.managers.configuration.ConfigurationManager; @@ -35,9 +34,6 @@ import org.apache.log4j.LogManager; import org.apache.log4j.Logger; -import javax.enterprise.inject.Default; -import javax.inject.Inject; -import javax.inject.Named; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -50,8 +46,6 @@ import java.util.Map; import java.util.regex.Pattern; -@Named -@Default public class DocumentManagerImpl implements DocumentManager { private final Logger log = LogManager.getLogger("onlyoffice.managers.document.DocumentManager"); private static final String USER_AGENT_MOBILE = "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec" @@ -61,15 +55,13 @@ public class DocumentManagerImpl implements DocumentManager { private static final int DEFAULT_MAX_FILE_SIZE = 5242880; private static final int MAX_KEY_LENGTH = 20; - @ComponentImport - private final I18nResolver i18n; + private final I18nResolver i18nResolver; private final ConfigurationManager configurationManager; private final AttachmentUtil attachmentUtil; - @Inject - public DocumentManagerImpl(final I18nResolver i18n, final ConfigurationManager configurationManager, + public DocumentManagerImpl(final I18nResolver i18nResolver, final ConfigurationManager configurationManager, final AttachmentUtil attachmentUtil) { - this.i18n = i18n; + this.i18nResolver = i18nResolver; this.configurationManager = configurationManager; this.attachmentUtil = attachmentUtil; } @@ -199,7 +191,7 @@ public Long createDemo(final String fileName, final String fileExt, final Long p fileExt == null || !fileExt.equals("xlsx") && !fileExt.equals("pptx") && !fileExt.equals("docxf") ? "docx" : fileExt.trim(); String name = fileName == null || fileName.equals("") - ? i18n.getText("onlyoffice.editor.dialog.filecreate." + extension) : fileName; + ? i18nResolver.getText("onlyoffice.editor.dialog.filecreate." + extension) : fileName; InputStream demoFile = getDemoFile(user, extension); diff --git a/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java b/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java index 5dcfe9a9..ff66aced 100644 --- a/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java +++ b/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java @@ -19,7 +19,6 @@ package onlyoffice.managers.jwt; import com.atlassian.config.ApplicationConfiguration; -import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; import com.atlassian.sal.api.pluginsettings.PluginSettings; import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; import onlyoffice.managers.configuration.ConfigurationManager; @@ -27,31 +26,20 @@ import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; -import javax.enterprise.inject.Default; -import javax.inject.Inject; -import javax.inject.Named; import java.util.Base64; import java.util.Base64.Encoder; -@Named -@Default public class JwtManagerImpl implements JwtManager { private static final int NUMBER_PARTS_TOKEN = 3; - @ComponentImport - private final PluginSettingsFactory pluginSettingsFactory; - @ComponentImport private final ApplicationConfiguration applicationConfiguration; - private final ConfigurationManager configurationManager; private final PluginSettings settings; - @Inject public JwtManagerImpl(final PluginSettingsFactory pluginSettingsFactory, final ApplicationConfiguration applicationConfiguration, final ConfigurationManager configurationManager) { - this.pluginSettingsFactory = pluginSettingsFactory; settings = pluginSettingsFactory.createGlobalSettings(); this.applicationConfiguration = applicationConfiguration; this.configurationManager = configurationManager; diff --git a/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java b/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java index f8a6d74d..15af5342 100644 --- a/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java +++ b/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java @@ -22,7 +22,6 @@ import com.atlassian.confluence.pages.AttachmentManager; import com.atlassian.confluence.setup.settings.SettingsManager; import com.atlassian.confluence.util.GeneralUtil; -import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; import com.atlassian.sal.api.pluginsettings.PluginSettings; import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; import com.atlassian.spring.container.ContainerManager; @@ -31,13 +30,8 @@ import org.apache.log4j.LogManager; import org.apache.log4j.Logger; -import javax.enterprise.inject.Default; -import javax.inject.Inject; -import javax.inject.Named; import javax.servlet.http.HttpServletRequest; -@Named -@Default public class UrlManagerImpl implements UrlManager { private final Logger log = LogManager.getLogger("onlyoffice.managers.url.UrlManager"); private final String docEditorServlet = "plugins/servlet/onlyoffice/doceditor"; @@ -46,19 +40,13 @@ public class UrlManagerImpl implements UrlManager { private final String fileProviderServlet = "plugins/servlet/onlyoffice/file-provider"; private final String apiServlet = "plugins/servlet/onlyoffice/api"; - @ComponentImport - private final PluginSettingsFactory pluginSettingsFactory; - @ComponentImport private final SettingsManager settingsManager; - private final PluginSettings pluginSettings; private final ConfigurationManager configurationManager; private final DocumentManager documentManager; - @Inject public UrlManagerImpl(final PluginSettingsFactory pluginSettingsFactory, final SettingsManager settingsManager, final ConfigurationManager configurationManager, final DocumentManager documentManager) { - this.pluginSettingsFactory = pluginSettingsFactory; this.settingsManager = settingsManager; this.configurationManager = configurationManager; this.documentManager = documentManager; diff --git a/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java b/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java index 95a234d9..d87784aa 100644 --- a/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java +++ b/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java @@ -31,7 +31,6 @@ import com.atlassian.confluence.setup.BootstrapManager; import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.user.ConfluenceUser; -import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; import com.atlassian.sal.api.transaction.TransactionCallback; import com.atlassian.sal.api.transaction.TransactionTemplate; import com.atlassian.spring.container.ContainerManager; @@ -47,9 +46,6 @@ import org.apache.log4j.LogManager; import org.apache.log4j.Logger; -import javax.enterprise.inject.Default; -import javax.inject.Inject; -import javax.inject.Named; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; @@ -59,25 +55,18 @@ import java.util.Date; import java.util.List; -@Named -@Default public class AttachmentUtilImpl implements AttachmentUtil { private final Logger log = LogManager.getLogger("onlyoffice.utils.attachment.AttachmentUtil"); private static final HierarchicalContentFileSystemHelper FILE_SYSTEM_HELPER = new HierarchicalContentFileSystemHelper(); - @ComponentImport private final AttachmentManager attachmentManager; - @ComponentImport private final TransactionTemplate transactionTemplate; - @ComponentImport private final PageManager pageManager; - @ComponentImport private final BootstrapManager bootstrapManager; private final ConfigurationManager configurationManager; - @Inject public AttachmentUtilImpl(final AttachmentManager attachmentManager, final TransactionTemplate transactionTemplate, final ConfigurationManager configurationManager, final PageManager pageManager, final BootstrapManager bootstrapManager) { diff --git a/src/main/java/onlyoffice/utils/parsing/ParsingUtilImpl.java b/src/main/java/onlyoffice/utils/parsing/ParsingUtilImpl.java index b8222dc7..3e8bf310 100644 --- a/src/main/java/onlyoffice/utils/parsing/ParsingUtilImpl.java +++ b/src/main/java/onlyoffice/utils/parsing/ParsingUtilImpl.java @@ -1,12 +1,8 @@ package onlyoffice.utils.parsing; -import javax.enterprise.inject.Default; -import javax.inject.Named; import java.io.InputStream; import java.util.Scanner; -@Named -@Default public class ParsingUtilImpl implements ParsingUtil { public String getBody(final InputStream stream) { Scanner scanner = null; diff --git a/src/main/resources/atlassian-plugin.xml b/src/main/resources/atlassian-plugin.xml index 5f53366c..f2280f9b 100644 --- a/src/main/resources/atlassian-plugin.xml +++ b/src/main/resources/atlassian-plugin.xml @@ -132,6 +132,45 @@ onlyoffice-doceditor + + onlyoffice.managers.auth.AuthContext + + + onlyoffice.managers.configuration.ConfigurationManager + + + onlyoffice.managers.convert.ConvertManager + + + onlyoffice.managers.document.DocumentManager + + + onlyoffice.managers.jwt.JwtManager + + + onlyoffice.managers.url.UrlManager + + + onlyoffice.utils.attachment.AttachmentUtil + + + onlyoffice.utils.parsing.ParsingUtil + + + + + + + + + + + + + + + + A full-featured editor for the most known formats of text documents, spreadsheets and presentations that can open these types of documents for editing or preview. /onlyoffice/doceditor From e81afc3cc67fe06fa86e133631398b1dc638b186 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 22 Mar 2023 15:59:30 +0300 Subject: [PATCH 08/98] removed: unused dependencies --- 3rd-Party.license | 28 ----------------- licenses/3rd-Party.license | 28 ----------------- pom.xml | 61 +------------------------------------- 3 files changed, 1 insertion(+), 116 deletions(-) diff --git a/3rd-Party.license b/3rd-Party.license index b6f1b966..23ecc3de 100644 --- a/3rd-Party.license +++ b/3rd-Party.license @@ -1,30 +1,6 @@ Confluence ONLYOFFICE integration app uses code from the following 3rd party projects: -atlassian-plugins-osgi-testrunner - Atlassian Plugins TestRunner (https://maven.atlassian.com/public/licenses/license.txt) -License: The 3-Clause BSD License -License File: atlassian-plugins-osgi-testrunner.license - -atlassian-spring-scanner-annotation - Atlassian Spring Scanner Annotations (https://www.apache.org/licenses/LICENSE-2.0) -License: Apache 2.0 -License File: atlassian-spring-scanner-annotation.license - -commons-collections - Types that extend and augment the Java Collections Framework. (https://www.apache.org/licenses/LICENSE-2.0) -License: Apache 2.0 -License File: commons-collections.license - -commons-httpclient - The HttpClient component supports the client-side of RFC 1945 (HTTP/1.0) and RFC 2616 (HTTP/1.1) , several related specifications (RFC 2109 (Cookies) , RFC 2617 (HTTP Authentication) , etc.), and provides a framework by which new request types (methods) or HTTP extensions can be created easily. (https://www.apache.org/licenses/LICENSE-2.0) -License: Apache 2.0 -License File: commons-httpclient.license - -javax.inject - The javax.inject API (https://www.apache.org/licenses/LICENSE-2.0) -License: Apache 2.0 -License File: javax.inject.license - -javax.enterprise.cdi-api - Contexts and Dependency Injection for Java (https://github.com/eclipse-ee4j/cdi/blob/master/LICENSE.txt) -License: Apache 2.0 -License File javax.enterprise.cdi-api.license - javax.servlet-api - Java Servlet API (https://opensource.org/licenses/CDDL-1.0 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) License: CDDL, GPL 2.0 License File: javax.servlet-api.license @@ -32,7 +8,3 @@ License File: javax.servlet-api.license JSON - JSON is a light-weight, language independent, data interchange format. See http://www.JSON.org/ The files in this package implement JSON encoders/decoders in Java. It also includes the capability to convert between JSON and XML, HTTP headers, Cookies, and CDL. This is a reference implementation. (http://json.org/license.html) License: JSON License File: JSON.license - -SAL API - A plugin that provides API for Shared Application Access Layer (https://opensource.org/licenses/BSD-3-Clause) -License: The 3-Clause BSD License -License File: SAL API.license diff --git a/licenses/3rd-Party.license b/licenses/3rd-Party.license index b6f1b966..23ecc3de 100644 --- a/licenses/3rd-Party.license +++ b/licenses/3rd-Party.license @@ -1,30 +1,6 @@ Confluence ONLYOFFICE integration app uses code from the following 3rd party projects: -atlassian-plugins-osgi-testrunner - Atlassian Plugins TestRunner (https://maven.atlassian.com/public/licenses/license.txt) -License: The 3-Clause BSD License -License File: atlassian-plugins-osgi-testrunner.license - -atlassian-spring-scanner-annotation - Atlassian Spring Scanner Annotations (https://www.apache.org/licenses/LICENSE-2.0) -License: Apache 2.0 -License File: atlassian-spring-scanner-annotation.license - -commons-collections - Types that extend and augment the Java Collections Framework. (https://www.apache.org/licenses/LICENSE-2.0) -License: Apache 2.0 -License File: commons-collections.license - -commons-httpclient - The HttpClient component supports the client-side of RFC 1945 (HTTP/1.0) and RFC 2616 (HTTP/1.1) , several related specifications (RFC 2109 (Cookies) , RFC 2617 (HTTP Authentication) , etc.), and provides a framework by which new request types (methods) or HTTP extensions can be created easily. (https://www.apache.org/licenses/LICENSE-2.0) -License: Apache 2.0 -License File: commons-httpclient.license - -javax.inject - The javax.inject API (https://www.apache.org/licenses/LICENSE-2.0) -License: Apache 2.0 -License File: javax.inject.license - -javax.enterprise.cdi-api - Contexts and Dependency Injection for Java (https://github.com/eclipse-ee4j/cdi/blob/master/LICENSE.txt) -License: Apache 2.0 -License File javax.enterprise.cdi-api.license - javax.servlet-api - Java Servlet API (https://opensource.org/licenses/CDDL-1.0 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) License: CDDL, GPL 2.0 License File: javax.servlet-api.license @@ -32,7 +8,3 @@ License File: javax.servlet-api.license JSON - JSON is a light-weight, language independent, data interchange format. See http://www.JSON.org/ The files in this package implement JSON encoders/decoders in Java. It also includes the capability to convert between JSON and XML, HTTP headers, Cookies, and CDL. This is a reference implementation. (http://json.org/license.html) License: JSON License File: JSON.license - -SAL API - A plugin that provides API for Shared Application Access Layer (https://opensource.org/licenses/BSD-3-Clause) -License: The 3-Clause BSD License -License File: SAL API.license diff --git a/pom.xml b/pom.xml index 075aa43c..03a66d10 100644 --- a/pom.xml +++ b/pom.xml @@ -17,22 +17,6 @@ Confluence ONLYOFFICE integration app Confluence ONLYOFFICE integration app allows you to work on all kinds of office documents within Confluence using ONLYOFFICE Online Editors with the enhanced formatting toolset. View, create and co-edit the documents in real-time. atlassian-plugin - - - - commons-httpclient - commons-httpclient - 3.1 - provided - - - commons-collections - commons-collections - 3.2.2 - provided - - - @@ -41,18 +25,6 @@ ${confluence.version} provided - - com.atlassian.plugin - atlassian-spring-scanner-annotation - ${atlassian.spring.scanner.version} - provided - - - com.atlassian.plugins - atlassian-plugins-osgi-testrunner - ${plugin.testrunner.version} - test - javax.servlet javax.servlet-api @@ -65,22 +37,6 @@ 20090211 provided - - com.atlassian.sal - sal-api - 2.0.17 - provided - - - javax.inject - javax.inject - 1 - - - javax.enterprise - cdi-api - 1.0 - @@ -127,22 +83,6 @@ - - com.atlassian.plugin - atlassian-spring-scanner-maven-plugin - ${atlassian.spring.scanner.version} - - - - atlassian-spring-scanner - - process-classes - - - - false - - org.apache.maven.plugins maven-compiler-plugin @@ -151,6 +91,7 @@ 8 + org.apache.maven.plugins maven-checkstyle-plugin From 6a0d736e585508d105a3617601c9884b608e1e14 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 22 Mar 2023 16:00:48 +0300 Subject: [PATCH 09/98] updated: versions dependencies --- pom.xml | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/pom.xml b/pom.xml index 03a66d10..6f2d4aad 100644 --- a/pom.xml +++ b/pom.xml @@ -28,13 +28,13 @@ javax.servlet javax.servlet-api - 3.1.0 + 4.0.1 provided org.json json - 20090211 + 20230227 provided @@ -43,7 +43,7 @@ com.atlassian.maven.plugins - maven-confluence-plugin + confluence-maven-plugin ${amps.version} true @@ -55,37 +55,13 @@ ${confluence.version} ${confluence.data.version} false - false - false - - ${atlassian.plugin.key} - - - - onlyoffice, - com.atlassian.confluence.pages, - com.atlassian.confluence.renderer, - com.atlassian.confluence.setup, - com.atlassian.confluence.spaces, - com.atlassian.spring.container, - javax.servlet,javax.servlet.http";version="1.0.0", - * - - - - - * - - - * - - -com.atlassian.plugin.spring.scanner.annotation.* org.apache.maven.plugins maven-compiler-plugin + 3.11.0 8 8 @@ -152,11 +128,10 @@ 8.0.1 8.0.1 - 6.3.21 - 1.2.3 - 2.2.3 + 8.10.0 ${project.groupId}.${project.artifactId} + UTF-8 From 607ce9668bad016cf2cf920785db2a0aff7594d7 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 22 Mar 2023 13:02:33 +0300 Subject: [PATCH 10/98] changed: create jwt with com.auth0.java-jwt --- pom.xml | 10 +++ .../OnlyOfficeFileProviderServlet.java | 6 +- .../onlyoffice/OnlyOfficeSaveFileServlet.java | 9 +-- .../onlyoffice/managers/jwt/JwtManager.java | 2 +- .../managers/jwt/JwtManagerImpl.java | 61 +++++++++---------- 5 files changed, 48 insertions(+), 40 deletions(-) diff --git a/pom.xml b/pom.xml index 6f2d4aad..c755b27a 100644 --- a/pom.xml +++ b/pom.xml @@ -37,6 +37,16 @@ 20230227 provided + + com.auth0 + java-jwt + 4.0.0 + + + com.fasterxml.jackson.core + jackson-databind + 2.13.3 + diff --git a/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java b/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java index 4c29b3e1..98d11a0a 100644 --- a/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java @@ -62,8 +62,10 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re throw new SecurityException("Expected JWT"); } - if (!jwtManager.verify(token)) { - throw new SecurityException("JWT verification failed"); + try { + String payload = jwtManager.verify(token); + } catch (Exception e) { + throw new SecurityException("JWT verification failed!"); } } diff --git a/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java b/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java index bea56d47..f1eb24ea 100644 --- a/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java @@ -51,7 +51,6 @@ import java.io.InputStream; import java.io.PrintWriter; import java.io.StringWriter; -import java.util.Base64; public class OnlyOfficeSaveFileServlet extends HttpServlet { private static final long serialVersionUID = 1L; @@ -132,6 +131,7 @@ private void processData(final String attachmentIdString, final HttpServletReque if (jwtManager.jwtEnabled()) { String token = jsonObj.optString("token"); + String payload = null; Boolean inBody = true; if (token == null || token == "") { @@ -147,12 +147,13 @@ private void processData(final String attachmentIdString, final HttpServletReque throw new SecurityException("Try save without JWT"); } - if (!jwtManager.verify(token)) { + try { + payload = jwtManager.verify(token); + } catch (Exception e) { throw new SecurityException("Try save with wrong JWT"); } - JSONObject bodyFromToken = new JSONObject( - new String(Base64.getUrlDecoder().decode(token.split("\\.")[1]), "UTF-8")); + JSONObject bodyFromToken = new JSONObject(payload); if (inBody) { jsonObj = bodyFromToken; diff --git a/src/main/java/onlyoffice/managers/jwt/JwtManager.java b/src/main/java/onlyoffice/managers/jwt/JwtManager.java index a7ba7de7..ae7fe5c2 100644 --- a/src/main/java/onlyoffice/managers/jwt/JwtManager.java +++ b/src/main/java/onlyoffice/managers/jwt/JwtManager.java @@ -9,7 +9,7 @@ public interface JwtManager extends Serializable { String createToken(JSONObject payload) throws Exception; - Boolean verify(String token); + String verify(String token); String getJwtHeader(); } diff --git a/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java b/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java index ff66aced..90912656 100644 --- a/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java +++ b/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java @@ -21,17 +21,21 @@ import com.atlassian.config.ApplicationConfiguration; import com.atlassian.sal.api.pluginsettings.PluginSettings; import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; +import com.auth0.jwt.JWT; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.fasterxml.jackson.databind.ObjectMapper; import onlyoffice.managers.configuration.ConfigurationManager; import org.json.JSONObject; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import java.util.Base64; -import java.util.Base64.Encoder; +import java.util.Map; public class JwtManagerImpl implements JwtManager { - private static final int NUMBER_PARTS_TOKEN = 3; + private static final long ACCEPT_LEEWAY = 3; private final ApplicationConfiguration applicationConfiguration; private final ConfigurationManager configurationManager; @@ -51,42 +55,28 @@ public Boolean jwtEnabled() { } public String createToken(final JSONObject payload) throws Exception { - JSONObject header = new JSONObject(); - header.put("alg", "HS256"); - header.put("typ", "JWT"); + Algorithm algorithm = Algorithm.HMAC256(getJwtSecret()); - Encoder enc = Base64.getUrlEncoder(); + ObjectMapper objectMapper = new ObjectMapper(); + Map payloadMap = objectMapper.readValue(payload.toString(), Map.class); - String encHeader = enc.encodeToString(header.toString().getBytes("UTF-8")) - .replace("=", ""); - String encPayload = enc.encodeToString(payload.toString().getBytes("UTF-8")) - .replace("=", ""); + String token = JWT.create() + .withPayload(payloadMap) + .sign(algorithm); - String hash = calculateHash(encHeader, encPayload); - - return encHeader + "." + encPayload + "." + hash; + return token; } - public Boolean verify(final String token) { - if (!jwtEnabled()) { - return false; - } - - String[] jwt = token.split("\\."); - if (jwt.length != NUMBER_PARTS_TOKEN) { - return false; - } - - try { - String hash = calculateHash(jwt[0], jwt[1]); - if (!hash.equals(jwt[2])) { - return false; - } - } catch (Exception ex) { - return false; - } - - return true; + public String verify(final String token) { + Algorithm algorithm = Algorithm.HMAC256(getJwtSecret()); + Base64.Decoder decoder = Base64.getUrlDecoder(); + + DecodedJWT jwt = JWT.require(algorithm) + .acceptLeeway(ACCEPT_LEEWAY) + .build() + .verify(token); + + return new String(decoder.decode(jwt.getPayload())); } public String getJwtHeader() { @@ -112,4 +102,9 @@ private Mac getHasher() throws Exception { return sha256; } + + private String getJwtSecret() { + return configurationManager.demoActive() + ? configurationManager.getDemo("secret") : (String) settings.get("onlyoffice.jwtSecret"); + } } From d2c65a7fcbc28d2485bc5fe3b204538905de121c Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 22 Mar 2023 17:39:48 +0300 Subject: [PATCH 11/98] added: jwt for fileUrl and callbackUrl --- .../OnlyOfficeFileProviderServlet.java | 35 +++++++-- .../onlyoffice/OnlyOfficeSaveFileServlet.java | 55 +++++++------- .../onlyoffice/managers/jwt/JwtManager.java | 9 ++- .../managers/jwt/JwtManagerImpl.java | 71 ++++++++++--------- .../managers/url/UrlManagerImpl.java | 29 ++++++-- 5 files changed, 125 insertions(+), 74 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java b/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java index 98d11a0a..2eecd20a 100644 --- a/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java @@ -18,11 +18,16 @@ package onlyoffice; +import com.atlassian.confluence.user.ConfluenceUser; +import com.atlassian.confluence.user.UserAccessor; +import com.atlassian.sal.api.user.UserKey; +import com.atlassian.spring.container.ContainerManager; import onlyoffice.managers.document.DocumentManager; import onlyoffice.managers.jwt.JwtManager; import onlyoffice.utils.attachment.AttachmentUtil; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; +import org.json.JSONObject; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -69,12 +74,34 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re } } - String vkey = request.getParameter("vkey"); - log.info("vkey = " + vkey); - String attachmentIdString = documentManager.readHash(vkey); + String token = request.getParameter("token"); + String payload = null; + try { + payload = jwtManager.verifyInternalToken(token); + } catch (Exception e) { + throw new SecurityException("Invalid link token!"); + } + + JSONObject bodyFromToken = new JSONObject(payload); + String userKeyString = bodyFromToken.getString("userKey"); + String attachmentIdString = bodyFromToken.getString("attachmentId"); + + UserAccessor userAccessor = (UserAccessor) ContainerManager.getComponent("userAccessor"); + + UserKey userKey = new UserKey(userKeyString); + ConfluenceUser user = userAccessor.getUserByKey(userKey); Long attachmentId = Long.parseLong(attachmentIdString); - log.info("attachmentId " + attachmentId); + + if (attachmentUtil.getAttachment(attachmentId) == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + return; + } + + if (!attachmentUtil.checkAccess(attachmentId, user, false)) { + response.sendError(HttpServletResponse.SC_FORBIDDEN); + return; + } String contentType = attachmentUtil.getMediaType(attachmentId); response.setContentType(contentType); diff --git a/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java b/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java index f1eb24ea..bb364288 100644 --- a/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java @@ -20,6 +20,7 @@ import com.atlassian.confluence.user.ConfluenceUser; import com.atlassian.confluence.user.UserAccessor; +import com.atlassian.sal.api.user.UserKey; import com.atlassian.spring.container.ContainerManager; import onlyoffice.managers.configuration.ConfigurationManager; import onlyoffice.managers.convert.ConvertManager; @@ -38,7 +39,6 @@ import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.json.JSONArray; -import org.json.JSONException; import org.json.JSONObject; import javax.servlet.ServletException; @@ -89,13 +89,33 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r throws ServletException, IOException { response.setContentType("text/plain; charset=utf-8"); - String vkey = request.getParameter("vkey"); - log.info("vkey = " + vkey); - String attachmentIdString = documentManager.readHash(vkey); + String token = request.getParameter("token"); + String payload = null; + + try { + payload = jwtManager.verifyInternalToken(token); + } catch (Exception e) { + throw new SecurityException("Invalid link token!"); + } + + JSONObject bodyFromToken = new JSONObject(payload); + String userKeyString = bodyFromToken.getString("userKey"); + String attachmentIdString = bodyFromToken.getString("attachmentId"); + + UserAccessor userAccessor = (UserAccessor) ContainerManager.getComponent("userAccessor"); + + UserKey userKey = new UserKey(userKeyString); + ConfluenceUser user = userAccessor.getUserByKey(userKey); + Long attachmentId = Long.parseLong(attachmentIdString); + + if (attachmentUtil.getAttachment(attachmentId) == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + return; + } String error = ""; try { - processData(attachmentIdString, request); + processData(attachmentId, user, request); } catch (Exception e) { error = e.getMessage(); } @@ -111,16 +131,12 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r log.info("error = " + error); } - private void processData(final String attachmentIdString, final HttpServletRequest request) throws Exception { - log.info("attachmentId = " + attachmentIdString); + private void processData(final Long attachmentId, final ConfluenceUser user, final HttpServletRequest request) + throws Exception { + log.info("attachmentId = " + attachmentId.toString()); InputStream requestStream = request.getInputStream(); - if (attachmentIdString.isEmpty()) { - throw new IllegalArgumentException("attachmentId is empty"); - } try { - Long attachmentId = Long.parseLong(attachmentIdString); - String body = parsingUtil.getBody(requestStream); log.info("body = " + body); if (body.isEmpty()) { @@ -164,8 +180,6 @@ private void processData(final String attachmentIdString, final HttpServletReque long status = jsonObj.getLong("status"); log.info("status = " + status); - - ConfluenceUser user = getConfluenceUserFromJSON(jsonObj); log.info("user = " + user); if (status == STATUS_EDITING) { @@ -310,17 +324,4 @@ private void saveAttachmentFromUrl(final Long attachmentId, final String downloa } } } - - private ConfluenceUser getConfluenceUserFromJSON(final JSONObject jsonObj) throws JSONException { - ConfluenceUser confluenceUser = null; - if (jsonObj.has("users")) { - JSONArray users = jsonObj.getJSONArray("users"); - if (users.length() > 0) { - String userName = users.getString(0); - UserAccessor userAccessor = (UserAccessor) ContainerManager.getComponent("userAccessor"); - confluenceUser = userAccessor.getUserByName(userName); - } - } - return confluenceUser; - } } diff --git a/src/main/java/onlyoffice/managers/jwt/JwtManager.java b/src/main/java/onlyoffice/managers/jwt/JwtManager.java index ae7fe5c2..985c8e62 100644 --- a/src/main/java/onlyoffice/managers/jwt/JwtManager.java +++ b/src/main/java/onlyoffice/managers/jwt/JwtManager.java @@ -3,13 +3,18 @@ import org.json.JSONObject; import java.io.Serializable; +import java.util.Map; public interface JwtManager extends Serializable { - Boolean jwtEnabled(); - String createToken(JSONObject payload) throws Exception; String verify(String token); + String createInternalToken(Map payloadMap); + + String verifyInternalToken(String token); + + Boolean jwtEnabled(); + String getJwtHeader(); } diff --git a/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java b/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java index 90912656..2b538145 100644 --- a/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java +++ b/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java @@ -19,6 +19,7 @@ package onlyoffice.managers.jwt; import com.atlassian.config.ApplicationConfiguration; +import com.atlassian.confluence.status.service.SystemInformationService; import com.atlassian.sal.api.pluginsettings.PluginSettings; import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; import com.auth0.jwt.JWT; @@ -28,8 +29,6 @@ import onlyoffice.managers.configuration.ConfigurationManager; import org.json.JSONObject; -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; import java.util.Base64; import java.util.Map; @@ -38,45 +37,42 @@ public class JwtManagerImpl implements JwtManager { private static final long ACCEPT_LEEWAY = 3; private final ApplicationConfiguration applicationConfiguration; + private final SystemInformationService systemInformationService; private final ConfigurationManager configurationManager; private final PluginSettings settings; public JwtManagerImpl(final PluginSettingsFactory pluginSettingsFactory, final ApplicationConfiguration applicationConfiguration, + final SystemInformationService systemInformationService, final ConfigurationManager configurationManager) { settings = pluginSettingsFactory.createGlobalSettings(); this.applicationConfiguration = applicationConfiguration; + this.systemInformationService = systemInformationService; this.configurationManager = configurationManager; } - public Boolean jwtEnabled() { - return configurationManager.demoActive() || settings.get("onlyoffice.jwtSecret") != null - && !((String) settings.get("onlyoffice.jwtSecret")).isEmpty(); - } - public String createToken(final JSONObject payload) throws Exception { - Algorithm algorithm = Algorithm.HMAC256(getJwtSecret()); - ObjectMapper objectMapper = new ObjectMapper(); Map payloadMap = objectMapper.readValue(payload.toString(), Map.class); - String token = JWT.create() - .withPayload(payloadMap) - .sign(algorithm); - - return token; + return createToken(payloadMap, getJwtSecret()); } public String verify(final String token) { - Algorithm algorithm = Algorithm.HMAC256(getJwtSecret()); - Base64.Decoder decoder = Base64.getUrlDecoder(); + return verifyToken(token, getJwtSecret()); + } - DecodedJWT jwt = JWT.require(algorithm) - .acceptLeeway(ACCEPT_LEEWAY) - .build() - .verify(token); + public String createInternalToken(final Map payloadMap) { + return createToken(payloadMap, systemInformationService.getConfluenceInfo().getServerId()); + } - return new String(decoder.decode(jwt.getPayload())); + public String verifyInternalToken(final String token) { + return verifyToken(token, systemInformationService.getConfluenceInfo().getServerId()); + } + + public Boolean jwtEnabled() { + return configurationManager.demoActive() || settings.get("onlyoffice.jwtSecret") != null + && !((String) settings.get("onlyoffice.jwtSecret")).isEmpty(); } public String getJwtHeader() { @@ -86,25 +82,30 @@ public String getJwtHeader() { return header == null || header.isEmpty() ? "Authorization" : header; } - private String calculateHash(final String header, final String payload) throws Exception { - Mac hasher = getHasher(); - return Base64.getUrlEncoder().encodeToString(hasher.doFinal((header + "." + payload).getBytes("UTF-8"))) - .replace("=", ""); + private String getJwtSecret() { + return configurationManager.demoActive() + ? configurationManager.getDemo("secret") : (String) settings.get("onlyoffice.jwtSecret"); } - private Mac getHasher() throws Exception { - String jwts = configurationManager.demoActive() - ? configurationManager.getDemo("secret") : (String) settings.get("onlyoffice.jwtSecret"); + private String createToken(final Map payloadMap, final String key) { + Algorithm algorithm = Algorithm.HMAC256(key); - Mac sha256 = Mac.getInstance("HmacSHA256"); - SecretKeySpec secretKey = new SecretKeySpec(jwts.getBytes("UTF-8"), "HmacSHA256"); - sha256.init(secretKey); + String token = JWT.create() + .withPayload(payloadMap) + .sign(algorithm); - return sha256; + return token; } - private String getJwtSecret() { - return configurationManager.demoActive() - ? configurationManager.getDemo("secret") : (String) settings.get("onlyoffice.jwtSecret"); + private String verifyToken(final String token, final String key) { + Algorithm algorithm = Algorithm.HMAC256(key); + Base64.Decoder decoder = Base64.getUrlDecoder(); + + DecodedJWT jwt = JWT.require(algorithm) + .acceptLeeway(ACCEPT_LEEWAY) + .build() + .verify(token); + + return new String(decoder.decode(jwt.getPayload())); } } diff --git a/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java b/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java index 15af5342..8d85196b 100644 --- a/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java +++ b/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java @@ -21,16 +21,21 @@ import com.atlassian.confluence.pages.Attachment; import com.atlassian.confluence.pages.AttachmentManager; import com.atlassian.confluence.setup.settings.SettingsManager; +import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; +import com.atlassian.confluence.user.ConfluenceUser; import com.atlassian.confluence.util.GeneralUtil; import com.atlassian.sal.api.pluginsettings.PluginSettings; import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; import com.atlassian.spring.container.ContainerManager; import onlyoffice.managers.configuration.ConfigurationManager; import onlyoffice.managers.document.DocumentManager; +import onlyoffice.managers.jwt.JwtManager; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Map; public class UrlManagerImpl implements UrlManager { private final Logger log = LogManager.getLogger("onlyoffice.managers.url.UrlManager"); @@ -44,12 +49,15 @@ public class UrlManagerImpl implements UrlManager { private final PluginSettings pluginSettings; private final ConfigurationManager configurationManager; private final DocumentManager documentManager; + private final JwtManager jwtManager; public UrlManagerImpl(final PluginSettingsFactory pluginSettingsFactory, final SettingsManager settingsManager, - final ConfigurationManager configurationManager, final DocumentManager documentManager) { + final ConfigurationManager configurationManager, final DocumentManager documentManager, + final JwtManager jwtManager) { this.settingsManager = settingsManager; this.configurationManager = configurationManager; this.documentManager = documentManager; + this.jwtManager = jwtManager; pluginSettings = pluginSettingsFactory.createGlobalSettings(); } @@ -74,10 +82,14 @@ public String getInnerDocEditorUrl() { } public String getFileUri(final Long attachmentId) { - String hash = documentManager.createHash(Long.toString(attachmentId)); + ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + + Map params = new HashMap<>(); + params.put("userKey", user.getKey().getStringValue()); + params.put("attachmentId", attachmentId.toString()); - String fileUri = getConfluenceBaseUrl() + fileProviderServlet + "?vkey=" + GeneralUtil.urlEncode(hash); - log.info("fileUrl " + fileUri); + String fileUri = + getConfluenceBaseUrl() + fileProviderServlet + "?token=" + jwtManager.createInternalToken(params); return fileUri; } @@ -125,9 +137,14 @@ public String getReferenceDataUri(final Long pageId) { } public String getCallbackUrl(final Long attachmentId) { - String hash = documentManager.createHash(Long.toString(attachmentId)); + ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + + Map params = new HashMap<>(); + params.put("userKey", user.getKey().getStringValue()); + params.put("attachmentId", attachmentId.toString()); - String callbackUrl = getConfluenceBaseUrl() + callbackServlet + "?vkey=" + GeneralUtil.urlEncode(hash); + String callbackUrl = + getConfluenceBaseUrl() + callbackServlet + "?token=" + jwtManager.createInternalToken(params); log.info("callbackUrl " + callbackUrl); return callbackUrl; From a4cb35dbf7d01546504401f4084d5f9e64790bf0 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 6 Apr 2023 17:30:08 +0300 Subject: [PATCH 12/98] added: onlyoffice-docs-formats.json --- .../resources/onlyoffice-docs-formats.json | 389 ++++++++++++++++++ 1 file changed, 389 insertions(+) create mode 100644 src/main/resources/onlyoffice-docs-formats.json diff --git a/src/main/resources/onlyoffice-docs-formats.json b/src/main/resources/onlyoffice-docs-formats.json new file mode 100644 index 00000000..068c86ea --- /dev/null +++ b/src/main/resources/onlyoffice-docs-formats.json @@ -0,0 +1,389 @@ +[ + { + "name": "djvu", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": [], + "mime": "image/vnd.djvu" + }, + { + "name": "doc", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], + "mime": "application/vnd.ms-word" + }, + { + "name": "docm", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": ["docx", "docxf", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], + "mime": "application/vnd.ms-word.document.macroEnabled.12" + }, + { + "name": "docx", + "type": "word", + "edit": true, + "fill": false, + "editable": false, + "convert": ["docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], + "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.document" + }, + { + "name": "docxf", + "type": "word", + "edit": true, + "fill": false, + "editable": false, + "convert": ["docx", "oform", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], + "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf" + }, + { + "name": "oform", + "type": "word", + "edit": false, + "fill": true, + "editable": false, + "convert": ["pdf"], + "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform" + }, + { + "name": "dot", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], + "mime": "application/msword" + }, + { + "name": "dotm", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": ["docx", "docxf", "docm", "dotx", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], + "mime": "application/vnd.ms-word.template.macroEnabled.12" + }, + { + "name": "dotx", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": ["docx", "docxf", "docm", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], + "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.template" + }, + { + "name": "epub", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": ["docx", "docxf", "docm", "dotx", "dotm", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], + "mime": "application/epub+zip" + }, + { + "name": "fb2", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], + "mime": "text/fb2+xml" + }, + { + "name": "fodt", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], + "mime": "application/vnd.oasis.opendocument.text" + }, + { + "name": "html", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], + "mime": "text/html" + }, + { + "name": "mht", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], + "mime": "multipart/related" + }, + { + "name": "odt", + "type": "word", + "edit": false, + "fill": false, + "editable": true, + "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "ott", "pdf", "pdfa", "rtf", "txt"], + "mime": "application/vnd.oasis.opendocument.text" + }, + { + "name": "ott", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "pdf", "pdfa", "rtf", "txt"], + "mime": "application/vnd.oasis.opendocument.text-template" + }, + { + "name": "pdf", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": [], + "mime": "application/pdf" + }, + { + "name": "rtf", + "type": "word", + "edit": false, + "fill": false, + "editable": true, + "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "txt"], + "mime": "text/rtf" + }, + { + "name": "txt", + "type": "word", + "edit": false, + "fill": false, + "editable": true, + "convert": [], + "mime": "text/plain" + }, + { + "name": "xps", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": ["pdf", "pdfa"], + "mime": "application/vnd.ms-xpsdocument" + }, + { + "name": "oxps", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": ["pdf", "pdfa"], + "mime": "application/oxps" + }, + { + "name": "xml", + "type": "word", + "edit": false, + "fill": false, + "editable": false, + "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], + "mime": "application/xml" + }, + { + "name": "csv", + "type": "cell", + "edit": false, + "fill": false, + "editable": true, + "convert": [], + "mime": "text/csv" + }, + { + "name": "fods", + "type": "cell", + "edit": false, + "fill": false, + "editable": false, + "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], + "mime": "application/vnd.oasis.opendocument.spreadsheet" + }, + { + "name": "ods", + "type": "cell", + "edit": false, + "fill": false, + "editable": true, + "convert": ["xlsx", "csv", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], + "mime": "application/vnd.oasis.opendocument.spreadsheet" + }, + { + "name": "ots", + "type": "cell", + "edit": false, + "fill": false, + "editable": false, + "convert": ["xlsx", "csv", "ods", "pdf", "pdfa", "xltx", "xlsm", "xltm"], + "mime": "application/vnd.oasis.opendocument.spreadsheet-template" + }, + { + "name": "xls", + "type": "cell", + "edit": false, + "fill": false, + "editable": false, + "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], + "mime": "application/vnd.ms-excel" + }, + { + "name": "xlsm", + "type": "cell", + "edit": false, + "fill": false, + "editable": false, + "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xltm"], + "mime": "application/vnd.ms-excel.sheet.macroEnabled.12" + }, + { + "name": "xlsx", + "type": "cell", + "edit": true, + "fill": false, + "editable": false, + "convert": ["csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], + "mime": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" + }, + { + "name": "xlt", + "type": "cell", + "edit": false, + "fill": false, + "editable": false, + "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], + "mime": "application/vnd.ms-excel" + }, + { + "name": "xltm", + "type": "cell", + "edit": false, + "fill": false, + "editable": false, + "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm"], + "mime": "application/vnd.ms-excel.template.macroenabled.12" + }, + { + "name": "fodp", + "type": "slide", + "edit": false, + "fill": false, + "editable": false, + "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], + "mime": "application/vnd.oasis.opendocument.presentation" + }, + { + "name": "odp", + "type": "slide", + "edit": false, + "fill": false, + "editable": true, + "convert": ["pptx", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], + "mime": "application/vnd.oasis.opendocument.presentation" + }, + { + "name": "otp", + "type": "slide", + "edit": false, + "fill": false, + "editable": false, + "convert": ["pptx", "odp", "pdf", "pdfa", "potx", "pptm", "potm"], + "mime": "application/vnd.oasis.opendocument.presentation-template" + }, + { + "name": "pot", + "type": "slide", + "edit": false, + "fill": false, + "editable": false, + "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], + "mime": "application/vnd.ms-powerpoint" + }, + { + "name": "potm", + "type": "slide", + "edit": false, + "fill": false, + "editable": false, + "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm"], + "mime": "application/vnd.ms-powerpoint.template.macroEnabled.12" + }, + { + "name": "potx", + "type": "slide", + "edit": false, + "fill": false, + "editable": false, + "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "pptm", "potm"], + "mime": "application/vnd.openxmlformats-officedocument.presentationml.template" + }, + { + "name": "pps", + "type": "slide", + "edit": false, + "fill": false, + "editable": false, + "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], + "mime": "application/vnd.ms-powerpoint" + }, + { + "name": "ppsm", + "type": "slide", + "edit": false, + "fill": false, + "editable": false, + "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], + "mime": "application/vnd.ms-powerpoint.slideshow.macroenabled.12" + }, + { + "name": "ppsx", + "type": "slide", + "edit": false, + "fill": false, + "editable": false, + "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], + "mime": "application/vnd.openxmlformats-officedocument.presentationml.slideshow" + }, + { + "name": "ppt", + "type": "slide", + "edit": false, + "fill": false, + "editable": false, + "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], + "mime": "application/vnd.ms-powerpoint" + }, + { + "name": "pptm", + "type": "slide", + "edit": false, + "fill": false, + "editable": false, + "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "potm"], + "mime": "application/vnd.ms-powerpoint.presentation.macroenabled.12" + }, + { + "name": "pptx", + "type": "slide", + "edit": true, + "fill": false, + "editable": false, + "convert": ["odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], + "mime": "application/vnd.openxmlformats-officedocument.presentationml.presentation" + } +] \ No newline at end of file From b01471dbc476e4bc9777553d2408e4246ff0b620 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 6 Apr 2023 17:36:28 +0300 Subject: [PATCH 13/98] added: models Format and Type --- src/main/java/onlyoffice/model/Format.java | 88 ++++++++++++++++++++++ src/main/java/onlyoffice/model/Type.java | 30 ++++++++ 2 files changed, 118 insertions(+) create mode 100644 src/main/java/onlyoffice/model/Format.java create mode 100644 src/main/java/onlyoffice/model/Type.java diff --git a/src/main/java/onlyoffice/model/Format.java b/src/main/java/onlyoffice/model/Format.java new file mode 100644 index 00000000..8b239523 --- /dev/null +++ b/src/main/java/onlyoffice/model/Format.java @@ -0,0 +1,88 @@ +/** + * + * (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 onlyoffice.model; + +import java.util.List; + +public class Format { + private String name; + private Type type; + private boolean edit; + private boolean fill; + private boolean editable; + private List convert; + private String mime; + + public String getName() { + return name; + } + + public Type getType() { + return type; + } + + public boolean isEdit() { + return edit; + } + + public boolean isFill() { + return fill; + } + + public boolean isEditable() { + return editable; + } + + public List getConvert() { + return convert; + } + + public String getMime() { + return mime; + } + + public void setName(final String name) { + this.name = name; + } + + public void setType(final Type type) { + this.type = type; + } + + public void setEdit(final boolean edit) { + this.edit = edit; + } + + public void setFill(final boolean fill) { + this.fill = fill; + } + + public void setEditable(final boolean editable) { + this.editable = editable; + } + + public void setConvert(final List convert) { + this.convert = convert; + } + + public void setMime(final String mime) { + this.mime = mime; + } + +} diff --git a/src/main/java/onlyoffice/model/Type.java b/src/main/java/onlyoffice/model/Type.java new file mode 100644 index 00000000..a787d4c2 --- /dev/null +++ b/src/main/java/onlyoffice/model/Type.java @@ -0,0 +1,30 @@ +/** + * + * (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 onlyoffice.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum Type { + @JsonProperty("word") + WORD, + @JsonProperty("cell") + CELL, + @JsonProperty("slide") + SLIDE +} From ae298283d3361daa9d770d49101a02941c59805a Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 7 Apr 2023 10:29:25 +0300 Subject: [PATCH 14/98] refactoring: action instead edit, fill, editable params --- src/main/java/onlyoffice/model/Format.java | 28 +-- .../resources/onlyoffice-docs-formats.json | 172 +++++------------- 2 files changed, 48 insertions(+), 152 deletions(-) diff --git a/src/main/java/onlyoffice/model/Format.java b/src/main/java/onlyoffice/model/Format.java index 8b239523..cea7302e 100644 --- a/src/main/java/onlyoffice/model/Format.java +++ b/src/main/java/onlyoffice/model/Format.java @@ -23,9 +23,7 @@ public class Format { private String name; private Type type; - private boolean edit; - private boolean fill; - private boolean editable; + private String action; private List convert; private String mime; @@ -37,16 +35,8 @@ public Type getType() { return type; } - public boolean isEdit() { - return edit; - } - - public boolean isFill() { - return fill; - } - - public boolean isEditable() { - return editable; + public String getAction() { + return action; } public List getConvert() { @@ -65,16 +55,8 @@ public void setType(final Type type) { this.type = type; } - public void setEdit(final boolean edit) { - this.edit = edit; - } - - public void setFill(final boolean fill) { - this.fill = fill; - } - - public void setEditable(final boolean editable) { - this.editable = editable; + public void setAction(final String action) { + this.action = action; } public void setConvert(final List convert) { diff --git a/src/main/resources/onlyoffice-docs-formats.json b/src/main/resources/onlyoffice-docs-formats.json index 068c86ea..17e6e0fd 100644 --- a/src/main/resources/onlyoffice-docs-formats.json +++ b/src/main/resources/onlyoffice-docs-formats.json @@ -2,387 +2,301 @@ { "name": "djvu", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": [], "mime": "image/vnd.djvu" }, { "name": "doc", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.ms-word" }, { "name": "docm", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["docx", "docxf", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.ms-word.document.macroEnabled.12" }, { "name": "docx", "type": "word", - "edit": true, - "fill": false, - "editable": false, + "action": "edit", "convert": ["docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }, { "name": "docxf", "type": "word", - "edit": true, - "fill": false, - "editable": false, + "action": "edit", "convert": ["docx", "oform", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf" }, { "name": "oform", "type": "word", - "edit": false, - "fill": true, - "editable": false, + "action": "fill", "convert": ["pdf"], "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform" }, { "name": "dot", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/msword" }, { "name": "dotm", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["docx", "docxf", "docm", "dotx", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.ms-word.template.macroEnabled.12" }, { "name": "dotx", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["docx", "docxf", "docm", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.template" }, { "name": "epub", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["docx", "docxf", "docm", "dotx", "dotm", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/epub+zip" }, { "name": "fb2", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "text/fb2+xml" }, { "name": "fodt", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.oasis.opendocument.text" }, { "name": "html", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "text/html" }, { "name": "mht", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "multipart/related" }, { "name": "odt", "type": "word", - "edit": false, - "fill": false, - "editable": true, + "action": "editable", "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.oasis.opendocument.text" }, { "name": "ott", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.oasis.opendocument.text-template" }, { "name": "pdf", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": [], "mime": "application/pdf" }, { "name": "rtf", "type": "word", - "edit": false, - "fill": false, - "editable": true, + "action": "editable", "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "txt"], "mime": "text/rtf" }, { "name": "txt", "type": "word", - "edit": false, - "fill": false, - "editable": true, + "action": "editable", "convert": [], "mime": "text/plain" }, { "name": "xps", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["pdf", "pdfa"], "mime": "application/vnd.ms-xpsdocument" }, { "name": "oxps", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["pdf", "pdfa"], "mime": "application/oxps" }, { "name": "xml", "type": "word", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/xml" }, { "name": "csv", "type": "cell", - "edit": false, - "fill": false, - "editable": true, + "action": "editable", "convert": [], "mime": "text/csv" }, { "name": "fods", "type": "cell", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.oasis.opendocument.spreadsheet" }, { "name": "ods", "type": "cell", - "edit": false, - "fill": false, - "editable": true, + "action": "editable", "convert": ["xlsx", "csv", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.oasis.opendocument.spreadsheet" }, { "name": "ots", "type": "cell", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["xlsx", "csv", "ods", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.oasis.opendocument.spreadsheet-template" }, { "name": "xls", "type": "cell", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.ms-excel" }, { "name": "xlsm", "type": "cell", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xltm"], "mime": "application/vnd.ms-excel.sheet.macroEnabled.12" }, { "name": "xlsx", "type": "cell", - "edit": true, - "fill": false, - "editable": false, + "action": "edit", "convert": ["csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }, { "name": "xlt", "type": "cell", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.ms-excel" }, { "name": "xltm", "type": "cell", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm"], "mime": "application/vnd.ms-excel.template.macroenabled.12" }, { "name": "fodp", "type": "slide", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.oasis.opendocument.presentation" }, { "name": "odp", "type": "slide", - "edit": false, - "fill": false, - "editable": true, + "action": "editable", "convert": ["pptx", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.oasis.opendocument.presentation" }, { "name": "otp", "type": "slide", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["pptx", "odp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.oasis.opendocument.presentation-template" }, { "name": "pot", "type": "slide", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.ms-powerpoint" }, { "name": "potm", "type": "slide", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm"], "mime": "application/vnd.ms-powerpoint.template.macroEnabled.12" }, { "name": "potx", "type": "slide", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "pptm", "potm"], "mime": "application/vnd.openxmlformats-officedocument.presentationml.template" }, { "name": "pps", "type": "slide", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.ms-powerpoint" }, { "name": "ppsm", "type": "slide", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.ms-powerpoint.slideshow.macroenabled.12" }, { "name": "ppsx", "type": "slide", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.openxmlformats-officedocument.presentationml.slideshow" }, { "name": "ppt", "type": "slide", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.ms-powerpoint" }, { "name": "pptm", "type": "slide", - "edit": false, - "fill": false, - "editable": false, + "action": "view", "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "potm"], "mime": "application/vnd.ms-powerpoint.presentation.macroenabled.12" }, { "name": "pptx", "type": "slide", - "edit": true, - "fill": false, - "editable": false, + "action": "edit", "convert": ["odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.openxmlformats-officedocument.presentationml.presentation" } From a429bf372abce522dfa15d79ff3e430105512bbe Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 7 Apr 2023 10:30:46 +0300 Subject: [PATCH 15/98] changed: methods work with formats --- .../configuration/ConfigurationManager.java | 7 +- .../ConfigurationManagerImpl.java | 39 ++++++---- .../document/DocumentManagerImpl.java | 74 +++++++++++++------ 3 files changed, 79 insertions(+), 41 deletions(-) diff --git a/src/main/java/onlyoffice/managers/configuration/ConfigurationManager.java b/src/main/java/onlyoffice/managers/configuration/ConfigurationManager.java index c40a3d35..4d18f508 100644 --- a/src/main/java/onlyoffice/managers/configuration/ConfigurationManager.java +++ b/src/main/java/onlyoffice/managers/configuration/ConfigurationManager.java @@ -1,5 +1,6 @@ package onlyoffice.managers.configuration; +import onlyoffice.model.Format; import org.apache.http.impl.client.CloseableHttpClient; import java.io.IOException; @@ -29,11 +30,9 @@ public interface ConfigurationManager extends Serializable { String getStringPluginSetting(String key, String defaultValue); - List getDefaultEditingTypes(); - - List getFillFormTypes(); - Map getCustomizableEditingTypes(); CloseableHttpClient getHttpClient() throws Exception; + + List getSupportedFormats(); } diff --git a/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java b/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java index cb1a5460..db89e39c 100644 --- a/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java +++ b/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java @@ -20,6 +20,9 @@ import com.atlassian.sal.api.pluginsettings.PluginSettings; import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import onlyoffice.model.Format; import org.apache.http.client.config.RequestConfig; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.impl.client.CloseableHttpClient; @@ -41,7 +44,6 @@ import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Date; @@ -56,6 +58,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager { private final PluginSettings pluginSettings; private final String configurationPath = "onlyoffice-config.properties"; + private final String formatsPath = "onlyoffice-docs-formats.json"; private final String pluginDemoName = "onlyoffice.demo"; private final String pluginDemoNameStart = "onlyoffice.demoStart"; private Map demoData; @@ -164,19 +167,9 @@ public String getStringPluginSetting(final String key, final String defaultValue return setting; } - public List getDefaultEditingTypes() { - String editableTypes = getProperty("docservice.type.edit"); - return new ArrayList<>(Arrays.asList(editableTypes.split("\\|"))); - } - - public List getFillFormTypes() { - String editableTypes = getProperty("docservice.type.fill-form"); - return new ArrayList<>(Arrays.asList(editableTypes.split("\\|"))); - } - public Map getCustomizableEditingTypes() { Map customizableEditingTypes = new HashMap<>(); - List editingTypes = null; + List editingTypes; String editingTypesString = (String) pluginSettings.get("onlyoffice.editingTypes"); @@ -187,10 +180,12 @@ public Map getCustomizableEditingTypes() { editingTypes = Arrays.asList("csv", "txt"); } - List availableTypes = Arrays.asList(getProperty("docservice.type.edit.customizable").split("\\|")); + List formats = this.getSupportedFormats(); - for (String type : availableTypes) { - customizableEditingTypes.put(type, editingTypes.contains(type)); + for (Format format : formats) { + if (format.getAction().equals("editable")) { + customizableEditingTypes.put(format.getName(), editingTypes.contains(format.getName())); + } } return customizableEditingTypes; @@ -230,5 +225,19 @@ public boolean verify(final String hostname, final SSLSession session) { return httpClient; } + + public List getSupportedFormats() { + InputStream inputStream = getClass().getClassLoader().getResourceAsStream(formatsPath); + + ObjectMapper objectMapper = new ObjectMapper(); + List formats = null; + try { + formats = objectMapper.readValue(inputStream, new TypeReference>() { }); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + + return formats; + } } diff --git a/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java b/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java index 983b6941..405d1311 100644 --- a/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java +++ b/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java @@ -29,6 +29,8 @@ import com.atlassian.sal.api.message.I18nResolver; import com.atlassian.spring.container.ContainerManager; import onlyoffice.managers.configuration.ConfigurationManager; +import onlyoffice.model.Format; +import onlyoffice.model.Type; import onlyoffice.utils.attachment.AttachmentUtil; import org.apache.commons.codec.binary.Hex; import org.apache.log4j.LogManager; @@ -40,6 +42,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.security.MessageDigest; +import java.util.ArrayList; import java.util.Arrays; import java.util.Base64; import java.util.List; @@ -205,19 +208,15 @@ public Long createDemo(final String fileName, final String fileExt, final Long p } public String getDocType(final String ext) { - List wordFormats = Arrays.asList(configurationManager.getProperty("docservice.type.word").split("\\|")); - List cellFormats = Arrays.asList(configurationManager.getProperty("docservice.type.cell").split("\\|")); - List slideFormats = - Arrays.asList(configurationManager.getProperty("docservice.type.slide").split("\\|")); + List supportedFormats = configurationManager.getSupportedFormats(); - if (wordFormats.contains(ext)) { - return "word"; - } - if (cellFormats.contains(ext)) { - return "cell"; - } - if (slideFormats.contains(ext)) { - return "slide"; + for (Format format : supportedFormats) { + if (format.getName().equals(ext)) { + + String type = format.getType().name().toLowerCase(); + + return type; + } } return null; @@ -243,23 +242,36 @@ public String getEditorType(final String userAgent) { } } - public boolean isEditable(final String fileExtension) { - List editingTypes = configurationManager.getDefaultEditingTypes(); + public boolean isEditable(final String ext) { + List supportedFormats = configurationManager.getSupportedFormats(); + + for (Format format : supportedFormats) { + if (format.getName().equals(ext) && format.getAction().equals("edit")) { + return true; + } + } Map customizableEditingTypes = configurationManager.getCustomizableEditingTypes(); for (Map.Entry customizableEditingType : customizableEditingTypes.entrySet()) { - if (customizableEditingType.getValue()) { - editingTypes.add(customizableEditingType.getKey()); + if (customizableEditingType.getKey().equals(ext) && customizableEditingType.getValue()) { + return true; } } - return editingTypes.contains(fileExtension); + return false; } - public boolean isFillForm(final String fileExtension) { - List fillFormTypes = configurationManager.getFillFormTypes(); - return configurationManager.getFillFormTypes().contains(fileExtension); + public boolean isFillForm(final String ext) { + List supportedFormats = configurationManager.getSupportedFormats(); + + for (Format format : supportedFormats) { + if (format.getName().equals(ext) && format.getAction().equals("fill")) { + return true; + } + } + + return false; } public boolean isViewable(final String fileExtension) { @@ -272,10 +284,28 @@ public List getInsertImageTypes() { } public List getCompareFileTypes() { - return Arrays.asList(configurationManager.getProperty("docservice.type.word").split("\\|")); + List supportedFormats = configurationManager.getSupportedFormats(); + List result = new ArrayList<>(); + + for (Format format : supportedFormats) { + if (format.getType().equals(Type.WORD)) { + result.add(format.getName()); + } + } + + return result; } public List getMailMergeTypes() { - return Arrays.asList(configurationManager.getProperty("docservice.type.cell").split("\\|")); + List supportedFormats = configurationManager.getSupportedFormats(); + List result = new ArrayList<>(); + + for (Format format : supportedFormats) { + if (format.getType().equals(Type.CELL)) { + result.add(format.getName()); + } + } + + return result; } } From 2770a73dc820dfe2dc3c488184b7eaf39ca286c5 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 7 Apr 2023 14:24:47 +0300 Subject: [PATCH 16/98] changed: convert methods work with formats --- .../onlyoffice/OnlyOfficeConvertServlet.java | 7 +- .../IsOfficeFileConvertAttachment.java | 2 +- .../managers/convert/ConvertManager.java | 10 +-- .../managers/convert/ConvertManagerImpl.java | 80 +++++++++++-------- 4 files changed, 55 insertions(+), 44 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java b/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java index eb87c179..619d7414 100644 --- a/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java @@ -95,7 +95,7 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re Long pageId = attachment.getContainer().getId(); String fileName = attachment.getFileName(); String ext = attachment.getFileExtension(); - String newExt = convertManager.convertsTo(ext); + String newExt = convertManager.getTargetExt(ext); String title = fileName.substring(0, fileName.lastIndexOf(".")); if (pageIdString != null && !pageIdString.isEmpty()) { @@ -159,10 +159,11 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r pageId = attachment.getContainer().getId(); } + String convertToExt = convertManager.getTargetExt(ext); + if (attachmentUtil.checkAccess(attachmentId, user, false) && attachmentUtil.checkAccessCreate(user, pageId)) { - if (convertManager.isConvertable(ext)) { - String convertToExt = convertManager.convertsTo(ext); + if (convertToExt != null) { json = convertManager.convert(attachmentId, ext, convertToExt, user); if (json.has("endConvert") && json.getBoolean("endConvert")) { diff --git a/src/main/java/onlyoffice/conditions/IsOfficeFileConvertAttachment.java b/src/main/java/onlyoffice/conditions/IsOfficeFileConvertAttachment.java index 28affb0e..140bb73f 100644 --- a/src/main/java/onlyoffice/conditions/IsOfficeFileConvertAttachment.java +++ b/src/main/java/onlyoffice/conditions/IsOfficeFileConvertAttachment.java @@ -65,7 +65,7 @@ public boolean shouldDisplay(final Map context) { ConfluenceUser user = AuthenticatedUserThreadLocal.get(); boolean accessEdit = attachmentUtil.checkAccess(attachment, user, true); - if (!accessEdit || !convertManager.isConvertable(ext) || ext.equals("docx")) { + if (!accessEdit || convertManager.getTargetExt(ext) == null || ext.equals("docx")) { return false; } diff --git a/src/main/java/onlyoffice/managers/convert/ConvertManager.java b/src/main/java/onlyoffice/managers/convert/ConvertManager.java index 3f46c383..f0d04656 100644 --- a/src/main/java/onlyoffice/managers/convert/ConvertManager.java +++ b/src/main/java/onlyoffice/managers/convert/ConvertManager.java @@ -2,16 +2,16 @@ import com.atlassian.confluence.user.ConfluenceUser; import org.json.JSONObject; - +import java.util.List; import java.io.Serializable; public interface ConvertManager extends Serializable { - boolean isConvertable(String ext); - - String convertsTo(String ext); - JSONObject convert(Long attachmentId, String ext, String convertToExt, ConfluenceUser user) throws Exception; JSONObject convert(Long attachmentId, String currentExt, String convertToExt, String url, String region, boolean async) throws Exception; + + String getTargetExt(String ext); + + List getTargetExtList(String ext); } diff --git a/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java b/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java index 7d53b421..3f5ac1b4 100644 --- a/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java +++ b/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java @@ -24,6 +24,7 @@ import onlyoffice.managers.document.DocumentManager; import onlyoffice.managers.jwt.JwtManager; import onlyoffice.managers.url.UrlManager; +import onlyoffice.model.Format; import org.apache.commons.io.IOUtils; import org.apache.http.HttpException; import org.apache.http.HttpStatus; @@ -38,7 +39,6 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; -import java.util.Arrays; import java.util.List; public class ConvertManagerImpl implements ConvertManager { @@ -60,38 +60,6 @@ public ConvertManagerImpl(final UrlManager urlManager, final JwtManager jwtManag this.localeManager = localeManager; } - public boolean isConvertable(final String ext) { - String convertableTypes = configurationManager.getProperty("docservice.type.convert"); - if (convertableTypes == null) { - return false; - } - List exts = Arrays.asList(convertableTypes.split("\\|")); - return exts.contains(ext); - } - - public String convertsTo(final String ext) { - String docType = documentManager.getDocType(ext); - if (docType != null) { - if (ext.equals("docx")) { - return "docxf"; - } - if (ext.equals("docxf")) { - return "oform"; - } - - if (docType.equals("word")) { - return "docx"; - } - if (docType.equals("cell")) { - return "xlsx"; - } - if (docType.equals("slide")) { - return "pptx"; - } - } - return null; - } - public JSONObject convert(final Long attachmentId, final String ext, final String convertToExt, final ConfluenceUser user) throws Exception { String url = urlManager.getFileUri(attachmentId); @@ -152,7 +120,49 @@ public JSONObject convert(final Long attachmentId, final String currentExt, fina } } - private String trimDot(final String input) { - return input.startsWith(".") ? input.substring(1) : input; + public String getTargetExt(final String ext) { + List supportedFormats = configurationManager.getSupportedFormats(); + + for (Format format : supportedFormats) { + if (format.getName().equals(ext)) { + switch (format.getType()) { + case WORD: + if (format.getName().equals("docxf") && format.getConvert().contains("oform")) { + return "oform"; + } + if (format.getConvert().contains("docx")) { + return "docx"; + } + break; + case CELL: + if (format.getConvert().contains("xlsx")) { + return "xlsx"; + } + break; + case SLIDE: + if (format.getConvert().contains("pptx")) { + return "pptx"; + } + break; + default: + break; + } + } + } + + return null; } + + public List getTargetExtList(final String ext) { + List supportedFormats = configurationManager.getSupportedFormats(); + + for (Format format : supportedFormats) { + if (format.getName().equals(ext)) { + return format.getConvert(); + } + } + + return null; + } + } From edc6ac39ec579a5ac32c560f4161528b309e09f9 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 7 Apr 2023 14:25:06 +0300 Subject: [PATCH 17/98] updated: onlyoffice-docs-formats.json --- .../resources/onlyoffice-docs-formats.json | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/main/resources/onlyoffice-docs-formats.json b/src/main/resources/onlyoffice-docs-formats.json index 17e6e0fd..8d1fdf30 100644 --- a/src/main/resources/onlyoffice-docs-formats.json +++ b/src/main/resources/onlyoffice-docs-formats.json @@ -2,301 +2,301 @@ { "name": "djvu", "type": "word", - "action": "view", + "actions": ["view"], "convert": [], "mime": "image/vnd.djvu" }, { "name": "doc", "type": "word", - "action": "view", + "actions": ["view"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.ms-word" }, { "name": "docm", "type": "word", - "action": "view", + "actions": ["view", "edit"], "convert": ["docx", "docxf", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.ms-word.document.macroEnabled.12" }, { "name": "docx", "type": "word", - "action": "edit", + "actions": ["view", "edit", "fill"], "convert": ["docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }, { "name": "docxf", "type": "word", - "action": "edit", + "actions": ["view", "edit"], "convert": ["docx", "oform", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf" }, { "name": "oform", "type": "word", - "action": "fill", + "actions": ["view", "fill"], "convert": ["pdf"], "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform" }, { "name": "dot", "type": "word", - "action": "view", + "actions": ["view"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/msword" }, { "name": "dotm", "type": "word", - "action": "view", + "actions": ["view", "edit"], "convert": ["docx", "docxf", "docm", "dotx", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.ms-word.template.macroEnabled.12" }, { "name": "dotx", "type": "word", - "action": "view", + "actions": ["view", "edit"], "convert": ["docx", "docxf", "docm", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.template" }, { "name": "epub", "type": "word", - "action": "view", + "actions": ["view", "edit"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/epub+zip" }, { "name": "fb2", "type": "word", - "action": "view", + "actions": ["view", "edit"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "text/fb2+xml" }, { "name": "fodt", "type": "word", - "action": "view", + "actions": ["view"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.oasis.opendocument.text" }, { "name": "html", "type": "word", - "action": "view", + "actions": ["view", "edit"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "text/html" }, { "name": "mht", "type": "word", - "action": "view", + "actions": ["view"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "multipart/related" }, { "name": "odt", "type": "word", - "action": "editable", + "actions": ["view", "edit"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.oasis.opendocument.text" }, { "name": "ott", "type": "word", - "action": "view", + "actions": ["view", "edit"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.oasis.opendocument.text-template" }, { "name": "pdf", "type": "word", - "action": "view", + "actions": ["view"], "convert": [], "mime": "application/pdf" }, { "name": "rtf", "type": "word", - "action": "editable", + "actions": ["view", "true"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "txt"], "mime": "text/rtf" }, { "name": "txt", "type": "word", - "action": "editable", + "actions": ["view", "true"], "convert": [], "mime": "text/plain" }, { "name": "xps", "type": "word", - "action": "view", + "actions": ["view"], "convert": ["pdf", "pdfa"], "mime": "application/vnd.ms-xpsdocument" }, { "name": "oxps", "type": "word", - "action": "view", + "actions": ["view"], "convert": ["pdf", "pdfa"], "mime": "application/oxps" }, { "name": "xml", "type": "word", - "action": "view", + "actions": ["view"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/xml" }, { "name": "csv", "type": "cell", - "action": "editable", + "actions": ["view", "edit"], "convert": [], "mime": "text/csv" }, { "name": "fods", "type": "cell", - "action": "view", + "actions": ["view"], "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.oasis.opendocument.spreadsheet" }, { "name": "ods", "type": "cell", - "action": "editable", + "actions": ["view", "edit"], "convert": ["xlsx", "csv", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.oasis.opendocument.spreadsheet" }, { "name": "ots", "type": "cell", - "action": "view", + "actions": ["view", "edit"], "convert": ["xlsx", "csv", "ods", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.oasis.opendocument.spreadsheet-template" }, { "name": "xls", "type": "cell", - "action": "view", + "actions": ["view"], "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.ms-excel" }, { "name": "xlsm", "type": "cell", - "action": "view", + "actions": ["view", "edit"], "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xltm"], "mime": "application/vnd.ms-excel.sheet.macroEnabled.12" }, { "name": "xlsx", "type": "cell", - "action": "edit", + "actions": ["view", "edit"], "convert": ["csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" }, { "name": "xlt", "type": "cell", - "action": "view", + "actions": ["view"], "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.ms-excel" }, { "name": "xltm", "type": "cell", - "action": "view", + "actions": ["view", "edit"], "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm"], "mime": "application/vnd.ms-excel.template.macroenabled.12" }, { "name": "fodp", "type": "slide", - "action": "view", + "actions": ["view"], "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.oasis.opendocument.presentation" }, { "name": "odp", "type": "slide", - "action": "editable", + "actions": ["view", "edit"], "convert": ["pptx", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.oasis.opendocument.presentation" }, { "name": "otp", "type": "slide", - "action": "view", + "actions": ["view", "edit"], "convert": ["pptx", "odp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.oasis.opendocument.presentation-template" }, { "name": "pot", "type": "slide", - "action": "view", + "actions": ["view"], "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.ms-powerpoint" }, { "name": "potm", "type": "slide", - "action": "view", + "actions": ["view", "edit"], "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm"], "mime": "application/vnd.ms-powerpoint.template.macroEnabled.12" }, { "name": "potx", "type": "slide", - "action": "view", + "actions": ["view", "edit"], "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "pptm", "potm"], "mime": "application/vnd.openxmlformats-officedocument.presentationml.template" }, { "name": "pps", "type": "slide", - "action": "view", + "actions": ["view"], "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.ms-powerpoint" }, { "name": "ppsm", "type": "slide", - "action": "view", + "actions": ["view", "edit"], "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.ms-powerpoint.slideshow.macroenabled.12" }, { "name": "ppsx", "type": "slide", - "action": "view", + "actions": ["view", "edit"], "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.openxmlformats-officedocument.presentationml.slideshow" }, { "name": "ppt", "type": "slide", - "action": "view", + "actions": ["view"], "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.ms-powerpoint" }, { "name": "pptm", "type": "slide", - "action": "view", + "actions": ["view", "edit"], "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "potm"], "mime": "application/vnd.ms-powerpoint.presentation.macroenabled.12" }, { "name": "pptx", "type": "slide", - "action": "edit", + "actions": ["view", "edit"], "convert": ["odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.openxmlformats-officedocument.presentationml.presentation" } From 1227fb45f50b99f99538273a3808c024b0f649f0 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 10 Apr 2023 13:31:13 +0300 Subject: [PATCH 18/98] updated: onlyoffice-docs-formats.json --- .../resources/onlyoffice-docs-formats.json | 162 ++++++++++++++---- 1 file changed, 130 insertions(+), 32 deletions(-) diff --git a/src/main/resources/onlyoffice-docs-formats.json b/src/main/resources/onlyoffice-docs-formats.json index 8d1fdf30..91461d29 100644 --- a/src/main/resources/onlyoffice-docs-formats.json +++ b/src/main/resources/onlyoffice-docs-formats.json @@ -9,7 +9,7 @@ { "name": "doc", "type": "word", - "actions": ["view"], + "actions": ["view", "edit"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.ms-word" }, @@ -44,7 +44,7 @@ { "name": "dot", "type": "word", - "actions": ["view"], + "actions": ["view", "edit"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/msword" }, @@ -65,52 +65,73 @@ { "name": "epub", "type": "word", - "actions": ["view", "edit"], + "actions": ["view", "lossy-edit"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/epub+zip" }, { "name": "fb2", "type": "word", - "actions": ["view", "edit"], + "actions": ["view", "lossy-edit"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "text/fb2+xml" }, { "name": "fodt", "type": "word", - "actions": ["view"], + "actions": ["view", "edit"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.oasis.opendocument.text" }, { - "name": "html", + "name": "htm", "type": "word", "actions": ["view", "edit"], + "convert": [], + "mime": null + }, + { + "name": "html", + "type": "word", + "actions": ["view", "lossy-edit"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "text/html" }, { "name": "mht", "type": "word", - "actions": ["view"], - "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], - "mime": "multipart/related" + "actions": ["view", "edit"], + "convert": [], + "mime": null }, { - "name": "odt", + "name": "mhtml", "type": "word", "actions": ["view", "edit"], + "convert": [], + "mime": null + }, + { + "name": "odt", + "type": "word", + "actions": ["view", "lossy-edit"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.oasis.opendocument.text" }, { "name": "ott", "type": "word", - "actions": ["view", "edit"], + "actions": ["view", "lossy-edit"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "pdf", "pdfa", "rtf", "txt"], "mime": "application/vnd.oasis.opendocument.text-template" }, + { + "name": "oxps", + "type": "word", + "actions": ["view"], + "convert": ["pdf", "pdfa"], + "mime": "application/oxps" + }, { "name": "pdf", "type": "word", @@ -121,73 +142,122 @@ { "name": "rtf", "type": "word", - "actions": ["view", "true"], + "actions": ["view", "lossy-edit"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "txt"], "mime": "text/rtf" }, + { + "name": "stw", + "type": "word", + "actions": ["view", "edit"], + "convert": [], + "mime": null + }, + { + "name": "sxw", + "type": "word", + "actions": ["view", "edit"], + "convert": [], + "mime": null + }, { "name": "txt", "type": "word", - "actions": ["view", "true"], + "actions": ["view", "lossy-true"], "convert": [], "mime": "text/plain" }, { - "name": "xps", + "name": "wps", "type": "word", - "actions": ["view"], - "convert": ["pdf", "pdfa"], - "mime": "application/vnd.ms-xpsdocument" + "actions": ["view", "edit"], + "convert": [], + "mime": null }, { - "name": "oxps", + "name": "wpt", + "type": "word", + "actions": ["view", "edit"], + "convert": [], + "mime": null + }, + { + "name": "xps", "type": "word", "actions": ["view"], "convert": ["pdf", "pdfa"], - "mime": "application/oxps" + "mime": "application/vnd.ms-xpsdocument" }, { "name": "xml", "type": "word", - "actions": ["view"], + "actions": ["view", "edit"], "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], "mime": "application/xml" }, { "name": "csv", "type": "cell", - "actions": ["view", "edit"], + "actions": ["view", "lossy-edit"], "convert": [], "mime": "text/csv" }, + { + "name": "et", + "type": "cell", + "actions": ["view", "edit"], + "convert": [], + "mime": null + }, + { + "name": "ett", + "type": "cell", + "actions": ["view", "edit"], + "convert": [], + "mime": null + }, { "name": "fods", "type": "cell", - "actions": ["view"], + "actions": ["view", "edit"], "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.oasis.opendocument.spreadsheet" }, { "name": "ods", "type": "cell", - "actions": ["view", "edit"], + "actions": ["view", "lossy-edit"], "convert": ["xlsx", "csv", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.oasis.opendocument.spreadsheet" }, { "name": "ots", "type": "cell", - "actions": ["view", "edit"], + "actions": ["view", "lossy-edit"], "convert": ["xlsx", "csv", "ods", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.oasis.opendocument.spreadsheet-template" }, + { + "name": "sxc", + "type": "cell", + "actions": ["view", "edit"], + "convert": [], + "mime": null + }, { "name": "xls", "type": "cell", - "actions": ["view"], + "actions": ["view", "edit"], "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.ms-excel" }, + { + "name": "xlsb", + "type": "cell", + "actions": ["view", "edit"], + "convert": [], + "mime": null + }, { "name": "xlsm", "type": "cell", @@ -205,7 +275,7 @@ { "name": "xlt", "type": "cell", - "actions": ["view"], + "actions": ["view", "edit"], "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], "mime": "application/vnd.ms-excel" }, @@ -216,31 +286,52 @@ "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm"], "mime": "application/vnd.ms-excel.template.macroenabled.12" }, + { + "name": "xltx", + "type": "cell", + "actions": ["view", "edit"], + "convert": [], + "mime": null + }, + { + "name": "dps", + "type": "slide", + "actions": ["view", "edit"], + "convert": [], + "mime": null + }, + { + "name": "dpt", + "type": "slide", + "actions": ["view", "edit"], + "convert": [], + "mime": null + }, { "name": "fodp", "type": "slide", - "actions": ["view"], + "actions": ["view", "edit"], "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.oasis.opendocument.presentation" }, { "name": "odp", "type": "slide", - "actions": ["view", "edit"], + "actions": ["view", "lossy-edit"], "convert": ["pptx", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.oasis.opendocument.presentation" }, { "name": "otp", "type": "slide", - "actions": ["view", "edit"], + "actions": ["view", "lossy-edit"], "convert": ["pptx", "odp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.oasis.opendocument.presentation-template" }, { "name": "pot", "type": "slide", - "actions": ["view"], + "actions": ["view", "edit"], "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.ms-powerpoint" }, @@ -261,7 +352,7 @@ { "name": "pps", "type": "slide", - "actions": ["view"], + "actions": ["view", "edit"], "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.ms-powerpoint" }, @@ -282,7 +373,7 @@ { "name": "ppt", "type": "slide", - "actions": ["view"], + "actions": ["view", "edit"], "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.ms-powerpoint" }, @@ -299,5 +390,12 @@ "actions": ["view", "edit"], "convert": ["odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], "mime": "application/vnd.openxmlformats-officedocument.presentationml.presentation" + }, + { + "name": "sxi", + "type": "slide", + "actions": ["view", "edit"], + "convert": [], + "mime": null } ] \ No newline at end of file From b01b4b55e94407a8f8b3d6d803606c61560e24e9 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 10 Apr 2023 14:36:32 +0300 Subject: [PATCH 19/98] fix (1227fb45f50b99f99538273a3808c024b0f649f0) --- src/main/resources/onlyoffice-docs-formats.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/onlyoffice-docs-formats.json b/src/main/resources/onlyoffice-docs-formats.json index 91461d29..0255618b 100644 --- a/src/main/resources/onlyoffice-docs-formats.json +++ b/src/main/resources/onlyoffice-docs-formats.json @@ -163,7 +163,7 @@ { "name": "txt", "type": "word", - "actions": ["view", "lossy-true"], + "actions": ["view", "lossy-edit"], "convert": [], "mime": "text/plain" }, From eeb5d2c4ff6dda6449872a7b11afd9f68bed5dd4 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 10 Apr 2023 14:56:00 +0300 Subject: [PATCH 20/98] changed for new onlyoffice-docs-formats.json --- .../managers/document/DocumentManagerImpl.java | 15 +++++++++++---- src/main/java/onlyoffice/model/Format.java | 10 +++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java b/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java index 405d1311..e8afb098 100644 --- a/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java +++ b/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java @@ -246,7 +246,7 @@ public boolean isEditable(final String ext) { List supportedFormats = configurationManager.getSupportedFormats(); for (Format format : supportedFormats) { - if (format.getName().equals(ext) && format.getAction().equals("edit")) { + if (format.getName().equals(ext) && format.getActions().contains("edit")) { return true; } } @@ -266,7 +266,7 @@ public boolean isFillForm(final String ext) { List supportedFormats = configurationManager.getSupportedFormats(); for (Format format : supportedFormats) { - if (format.getName().equals(ext) && format.getAction().equals("fill")) { + if (format.getName().equals(ext) && format.getActions().contains("fill")) { return true; } } @@ -275,8 +275,15 @@ public boolean isFillForm(final String ext) { } public boolean isViewable(final String fileExtension) { - String docType = getDocType(fileExtension); - return docType != null; + List supportedFormats = configurationManager.getSupportedFormats(); + + for (Format format : supportedFormats) { + if (format.getName().equals(fileExtension) && format.getActions().contains("view")) { + return true; + } + } + + return false; } public List getInsertImageTypes() { diff --git a/src/main/java/onlyoffice/model/Format.java b/src/main/java/onlyoffice/model/Format.java index cea7302e..58d1d71b 100644 --- a/src/main/java/onlyoffice/model/Format.java +++ b/src/main/java/onlyoffice/model/Format.java @@ -23,7 +23,7 @@ public class Format { private String name; private Type type; - private String action; + private List actions; private List convert; private String mime; @@ -35,8 +35,8 @@ public Type getType() { return type; } - public String getAction() { - return action; + public List getActions() { + return actions; } public List getConvert() { @@ -55,8 +55,8 @@ public void setType(final Type type) { this.type = type; } - public void setAction(final String action) { - this.action = action; + public void setAction(final List actions) { + this.actions = actions; } public void setConvert(final List convert) { From c957cd7fc72439f4899a2e6d398c5eddb50c3816 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 10 Apr 2023 14:56:36 +0300 Subject: [PATCH 21/98] changed init formats --- .../ConfigurationManagerImpl.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java b/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java index db89e39c..e17a5dc7 100644 --- a/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java +++ b/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java @@ -61,7 +61,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager { private final String formatsPath = "onlyoffice-docs-formats.json"; private final String pluginDemoName = "onlyoffice.demo"; private final String pluginDemoNameStart = "onlyoffice.demoStart"; + private Map demoData; + private List supportedFormats; public ConfigurationManagerImpl(final PluginSettingsFactory pluginSettingsFactory) { pluginSettings = pluginSettingsFactory.createGlobalSettings(); @@ -71,6 +73,15 @@ public ConfigurationManagerImpl(final PluginSettingsFactory pluginSettingsFactor demoData.put("header", "AuthorizationJWT"); demoData.put("secret", "sn2puSUF7muF5Jas"); demoData.put("trial", "30"); + + InputStream inputStream = getClass().getClassLoader().getResourceAsStream(formatsPath); + + ObjectMapper objectMapper = new ObjectMapper(); + try { + supportedFormats = objectMapper.readValue(inputStream, new TypeReference>() { }); + } catch (IOException e) { + log.error(e.getMessage(), e); + } } public Properties getProperties() throws IOException { @@ -183,7 +194,7 @@ public Map getCustomizableEditingTypes() { List formats = this.getSupportedFormats(); for (Format format : formats) { - if (format.getAction().equals("editable")) { + if (format.getActions().contains("lossy-edit")) { customizableEditingTypes.put(format.getName(), editingTypes.contains(format.getName())); } } @@ -227,17 +238,7 @@ public boolean verify(final String hostname, final SSLSession session) { } public List getSupportedFormats() { - InputStream inputStream = getClass().getClassLoader().getResourceAsStream(formatsPath); - - ObjectMapper objectMapper = new ObjectMapper(); - List formats = null; - try { - formats = objectMapper.readValue(inputStream, new TypeReference>() { }); - } catch (IOException e) { - log.error(e.getMessage(), e); - } - - return formats; + return supportedFormats; } } From c8842d4760ac24d94ea18ddbbeee60a2a79b4516 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 10 Apr 2023 14:57:25 +0300 Subject: [PATCH 22/98] dont show button fill for docx --- src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java b/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java index 82b08188..e72562c7 100644 --- a/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java +++ b/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java @@ -66,7 +66,7 @@ public boolean shouldDisplay(final Map context) { if (forEdit) { if (form) { - if (accessEdit && documentManager.isFillForm(ext)) { + if (accessEdit && documentManager.isFillForm(ext) && !ext.equals("docx")) { return true; } } else { From 124e733c77f2da5ed48cb4bb92c276a321b77a0d Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 10 Apr 2023 14:57:48 +0300 Subject: [PATCH 23/98] removed unused props --- src/main/resources/onlyoffice-config.properties | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/main/resources/onlyoffice-config.properties b/src/main/resources/onlyoffice-config.properties index d6f0f33f..2aa3d542 100644 --- a/src/main/resources/onlyoffice-config.properties +++ b/src/main/resources/onlyoffice-config.properties @@ -5,15 +5,3 @@ files.docservice.secret=Vskoproizvolny Salt par Chivreski files.docservice.url.api=web-apps/apps/api/documents/api.js files.docservice.url.convert=ConvertService.ashx - -docservice.type.word=doc|docx|docm|dot|dotx|dotm|odt|fodt|ott|rtf|txt|html|htm|mht|pdf|djvu|fb2|epub|xps|docxf|oform -docservice.type.cell=xls|xlsx|xlsm|xlt|xltx|xltm|ods|fods|ots|csv -docservice.type.slide=pps|ppsx|ppsm|ppt|pptx|pptm|pot|potx|potm|odp|fodp|otp - -docservice.type.edit=docx|xlsx|pptx|docxf -docservice.type.edit.customizable=csv|odp|ods|odt|rtf|txt - -docservice.type.fill-form=oform - -docservice.type.convert=doc|docm|dot|dotx|epub|htm|html|odp|ods|odt|otp|ots|ott|pot|potm|potx|pps|ppsm|ppsx|ppt|\ - pptm|rtf|xls|xlsm|xlt|xltm|xltx|docx|docxf From 567b618944043595e44f6278c5e5f74ef905be43 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 10 Apr 2023 14:58:11 +0300 Subject: [PATCH 24/98] added info about formats on settings page --- .../onlyoffice/OnlyOfficeConfServlet.java | 1 + src/main/resources/templates/configure.vm | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/main/java/onlyoffice/OnlyOfficeConfServlet.java b/src/main/java/onlyoffice/OnlyOfficeConfServlet.java index 89fa9483..86781e94 100644 --- a/src/main/java/onlyoffice/OnlyOfficeConfServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeConfServlet.java @@ -134,6 +134,7 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re contextMap.put("docserviceDemoAvailable", demoAvailable); contextMap.put("pathApiUrl", configurationManager.getProperty("files.docservice.url.api")); contextMap.put("defaultCustomizableEditingTypes", defaultCustomizableEditingTypes); + contextMap.put("supportedFormats", configurationManager.getSupportedFormats()); writer.write(getTemplate(contextMap)); } diff --git a/src/main/resources/templates/configure.vm b/src/main/resources/templates/configure.vm index feb5bf66..4b4a84ea 100644 --- a/src/main/resources/templates/configure.vm +++ b/src/main/resources/templates/configure.vm @@ -293,5 +293,32 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl + +
+

About app:

+
+

Supported formats:

+
+ For viewing: +
+
Word: #foreach($format in $supportedFormats) #if($format.type == "WORD" && $format.actions.contains("view")) ${format.name} #end #end
+
Cell: #foreach($format in $supportedFormats) #if($format.type == "CELL" && $format.actions.contains("view")) ${format.name} #end #end
+
Slide: #foreach($format in $supportedFormats) #if($format.type == "SLIDE" && $format.actions.contains("view")) ${format.name} #end #end
+
+ For editing: +
+
Word: #foreach($format in $supportedFormats) #if($format.type == "WORD" && $format.actions.contains("edit")) ${format.name} #end #end
+
Cell: #foreach($format in $supportedFormats) #if($format.type == "CELL" && $format.actions.contains("edit")) ${format.name} #end #end
+
Slide: #foreach($format in $supportedFormats) #if($format.type == "SLIDE" && $format.actions.contains("edit")) ${format.name} #end #end
+
+ For editing with possible loss of information: +
+
Word: #foreach($format in $supportedFormats) #if($format.type == "WORD" && $format.actions.contains("lossy-edit")) ${format.name} #end #end
+
Cell: #foreach($format in $supportedFormats) #if($format.type == "CELL" && $format.actions.contains("lossy-edit")) ${format.name} #end #end
+
Slide: #foreach($format in $supportedFormats) #if($format.type == "SLIDE" && $format.actions.contains("lossy-edit")) ${format.name} #end #end
+
+
+
+
From ed69298e71cfd571081d78505cd5e5fd4de526fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Apr 2023 17:04:47 +0000 Subject: [PATCH 25/98] Bump json from 20090211 to 20230227 Bumps [json](https://github.com/douglascrockford/JSON-java) from 20090211 to 20230227. - [Release notes](https://github.com/douglascrockford/JSON-java/releases) - [Changelog](https://github.com/stleary/JSON-java/blob/master/docs/RELEASES.md) - [Commits](https://github.com/douglascrockford/JSON-java/commits) --- updated-dependencies: - dependency-name: org.json:json dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 075aa43c..d7af9f3b 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ org.json json - 20090211 + 20230227 provided From a535121bc108b50f53941091b3d77e1e50bcf2d9 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 26 Apr 2023 17:33:36 +0300 Subject: [PATCH 26/98] delete submodule documents --- .gitmodules | 4 ---- src/main/resources/app_data | 1 - 2 files changed, 5 deletions(-) delete mode 100644 .gitmodules delete mode 160000 src/main/resources/app_data diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 5db5fbe9..00000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "src/main/resources/app_data"] - path = src/main/resources/app_data - url = https://github.com/ONLYOFFICE/document-templates - branch = main/new diff --git a/src/main/resources/app_data b/src/main/resources/app_data deleted file mode 160000 index 4b96e283..00000000 --- a/src/main/resources/app_data +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4b96e283924e0481299b6400520829649634c23e From de8d4437c646be8f6753f0801e3a2dbc3c870575 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 26 Apr 2023 17:39:00 +0300 Subject: [PATCH 27/98] added submodule document-templates --- .gitmodules | 4 ++++ src/main/resources/app_data/document-templates | 1 + 2 files changed, 5 insertions(+) create mode 100644 .gitmodules create mode 160000 src/main/resources/app_data/document-templates diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..632babf0 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "src/main/resources/app_data/document-templates"] + path = src/main/resources/app_data/document-templates + url = https://github.com/ONLYOFFICE/document-templates + branch = main/new diff --git a/src/main/resources/app_data/document-templates b/src/main/resources/app_data/document-templates new file mode 160000 index 00000000..cb2c06ed --- /dev/null +++ b/src/main/resources/app_data/document-templates @@ -0,0 +1 @@ +Subproject commit cb2c06ed33655b0dd09a47b8852f7391edad18ac From 52bc9c8385ed45d47e71d25563a971010b4f8884 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 26 Apr 2023 17:43:05 +0300 Subject: [PATCH 28/98] added submodule document-formats --- .gitmodules | 4 ++++ src/main/resources/app_data/document-formats | 1 + 2 files changed, 5 insertions(+) create mode 160000 src/main/resources/app_data/document-formats diff --git a/.gitmodules b/.gitmodules index 632babf0..fe80f429 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,3 +2,7 @@ path = src/main/resources/app_data/document-templates url = https://github.com/ONLYOFFICE/document-templates branch = main/new +[submodule "src/main/resources/app_data/document-formats"] + path = src/main/resources/app_data/document-formats + url = https://github.com/ONLYOFFICE/document-formats + branch = master diff --git a/src/main/resources/app_data/document-formats b/src/main/resources/app_data/document-formats new file mode 160000 index 00000000..0acf5358 --- /dev/null +++ b/src/main/resources/app_data/document-formats @@ -0,0 +1 @@ +Subproject commit 0acf5358aafa95de4ac887a8af7d2ff49f48e001 From 1ca47b410fb5c05a1a0f920a954bba7d06a93a64 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 26 Apr 2023 17:46:13 +0300 Subject: [PATCH 29/98] fixed paths for submodules --- .../managers/configuration/ConfigurationManagerImpl.java | 2 +- .../java/onlyoffice/managers/document/DocumentManagerImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java b/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java index e17a5dc7..acdd8cf4 100644 --- a/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java +++ b/src/main/java/onlyoffice/managers/configuration/ConfigurationManagerImpl.java @@ -58,7 +58,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager { private final PluginSettings pluginSettings; private final String configurationPath = "onlyoffice-config.properties"; - private final String formatsPath = "onlyoffice-docs-formats.json"; + private final String formatsPath = "app_data/document-formats/onlyoffice-docs-formats.json"; private final String pluginDemoName = "onlyoffice.demo"; private final String pluginDemoNameStart = "onlyoffice.demoStart"; diff --git a/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java b/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java index e8afb098..7a99d15f 100644 --- a/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java +++ b/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java @@ -178,7 +178,7 @@ private InputStream getDemoFile(final ConfluenceUser user, final String fileExt) LocaleManager localeManager = (LocaleManager) ContainerManager.getComponent("localeManager"); PluginAccessor pluginAccessor = (PluginAccessor) ContainerManager.getComponent("pluginAccessor"); - String pathToDemoFile = "app_data/" + localeManager.getLocale(user).toString().replace("_", "-"); + String pathToDemoFile = "app_data/document-templates/" + localeManager.getLocale(user).toString().replace("_", "-"); if (pluginAccessor.getDynamicResourceAsStream(pathToDemoFile) == null) { pathToDemoFile = "app_data/en-US"; From fcc6e7e4304e3e747f23293a6a92036b6f19cec7 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 27 Apr 2023 10:06:05 +0300 Subject: [PATCH 30/98] array mime --- .../document/DocumentManagerImpl.java | 5 +- src/main/java/onlyoffice/model/Format.java | 6 +- src/main/resources/app_data/document-formats | 2 +- .../resources/onlyoffice-docs-formats.json | 401 ------------------ 4 files changed, 8 insertions(+), 406 deletions(-) delete mode 100644 src/main/resources/onlyoffice-docs-formats.json diff --git a/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java b/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java index 7a99d15f..e89b506b 100644 --- a/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java +++ b/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java @@ -178,7 +178,10 @@ private InputStream getDemoFile(final ConfluenceUser user, final String fileExt) LocaleManager localeManager = (LocaleManager) ContainerManager.getComponent("localeManager"); PluginAccessor pluginAccessor = (PluginAccessor) ContainerManager.getComponent("pluginAccessor"); - String pathToDemoFile = "app_data/document-templates/" + localeManager.getLocale(user).toString().replace("_", "-"); + String pathToDemoFile = "app_data/document-templates/" + localeManager + .getLocale(user) + .toString() + .replace("_", "-"); if (pluginAccessor.getDynamicResourceAsStream(pathToDemoFile) == null) { pathToDemoFile = "app_data/en-US"; diff --git a/src/main/java/onlyoffice/model/Format.java b/src/main/java/onlyoffice/model/Format.java index 58d1d71b..55893459 100644 --- a/src/main/java/onlyoffice/model/Format.java +++ b/src/main/java/onlyoffice/model/Format.java @@ -25,7 +25,7 @@ public class Format { private Type type; private List actions; private List convert; - private String mime; + private List mime; public String getName() { return name; @@ -43,7 +43,7 @@ public List getConvert() { return convert; } - public String getMime() { + public List getMime() { return mime; } @@ -63,7 +63,7 @@ public void setConvert(final List convert) { this.convert = convert; } - public void setMime(final String mime) { + public void setMime(final List mime) { this.mime = mime; } diff --git a/src/main/resources/app_data/document-formats b/src/main/resources/app_data/document-formats index 0acf5358..cc675f0f 160000 --- a/src/main/resources/app_data/document-formats +++ b/src/main/resources/app_data/document-formats @@ -1 +1 @@ -Subproject commit 0acf5358aafa95de4ac887a8af7d2ff49f48e001 +Subproject commit cc675f0f3a4c26ddc0721038542c8b88451aa1c8 diff --git a/src/main/resources/onlyoffice-docs-formats.json b/src/main/resources/onlyoffice-docs-formats.json deleted file mode 100644 index 0255618b..00000000 --- a/src/main/resources/onlyoffice-docs-formats.json +++ /dev/null @@ -1,401 +0,0 @@ -[ - { - "name": "djvu", - "type": "word", - "actions": ["view"], - "convert": [], - "mime": "image/vnd.djvu" - }, - { - "name": "doc", - "type": "word", - "actions": ["view", "edit"], - "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], - "mime": "application/vnd.ms-word" - }, - { - "name": "docm", - "type": "word", - "actions": ["view", "edit"], - "convert": ["docx", "docxf", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], - "mime": "application/vnd.ms-word.document.macroEnabled.12" - }, - { - "name": "docx", - "type": "word", - "actions": ["view", "edit", "fill"], - "convert": ["docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], - "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.document" - }, - { - "name": "docxf", - "type": "word", - "actions": ["view", "edit"], - "convert": ["docx", "oform", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], - "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf" - }, - { - "name": "oform", - "type": "word", - "actions": ["view", "fill"], - "convert": ["pdf"], - "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform" - }, - { - "name": "dot", - "type": "word", - "actions": ["view", "edit"], - "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], - "mime": "application/msword" - }, - { - "name": "dotm", - "type": "word", - "actions": ["view", "edit"], - "convert": ["docx", "docxf", "docm", "dotx", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], - "mime": "application/vnd.ms-word.template.macroEnabled.12" - }, - { - "name": "dotx", - "type": "word", - "actions": ["view", "edit"], - "convert": ["docx", "docxf", "docm", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], - "mime": "application/vnd.openxmlformats-officedocument.wordprocessingml.template" - }, - { - "name": "epub", - "type": "word", - "actions": ["view", "lossy-edit"], - "convert": ["docx", "docxf", "docm", "dotx", "dotm", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], - "mime": "application/epub+zip" - }, - { - "name": "fb2", - "type": "word", - "actions": ["view", "lossy-edit"], - "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], - "mime": "text/fb2+xml" - }, - { - "name": "fodt", - "type": "word", - "actions": ["view", "edit"], - "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], - "mime": "application/vnd.oasis.opendocument.text" - }, - { - "name": "htm", - "type": "word", - "actions": ["view", "edit"], - "convert": [], - "mime": null - }, - { - "name": "html", - "type": "word", - "actions": ["view", "lossy-edit"], - "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], - "mime": "text/html" - }, - { - "name": "mht", - "type": "word", - "actions": ["view", "edit"], - "convert": [], - "mime": null - }, - { - "name": "mhtml", - "type": "word", - "actions": ["view", "edit"], - "convert": [], - "mime": null - }, - { - "name": "odt", - "type": "word", - "actions": ["view", "lossy-edit"], - "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "ott", "pdf", "pdfa", "rtf", "txt"], - "mime": "application/vnd.oasis.opendocument.text" - }, - { - "name": "ott", - "type": "word", - "actions": ["view", "lossy-edit"], - "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "pdf", "pdfa", "rtf", "txt"], - "mime": "application/vnd.oasis.opendocument.text-template" - }, - { - "name": "oxps", - "type": "word", - "actions": ["view"], - "convert": ["pdf", "pdfa"], - "mime": "application/oxps" - }, - { - "name": "pdf", - "type": "word", - "actions": ["view"], - "convert": [], - "mime": "application/pdf" - }, - { - "name": "rtf", - "type": "word", - "actions": ["view", "lossy-edit"], - "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "txt"], - "mime": "text/rtf" - }, - { - "name": "stw", - "type": "word", - "actions": ["view", "edit"], - "convert": [], - "mime": null - }, - { - "name": "sxw", - "type": "word", - "actions": ["view", "edit"], - "convert": [], - "mime": null - }, - { - "name": "txt", - "type": "word", - "actions": ["view", "lossy-edit"], - "convert": [], - "mime": "text/plain" - }, - { - "name": "wps", - "type": "word", - "actions": ["view", "edit"], - "convert": [], - "mime": null - }, - { - "name": "wpt", - "type": "word", - "actions": ["view", "edit"], - "convert": [], - "mime": null - }, - { - "name": "xps", - "type": "word", - "actions": ["view"], - "convert": ["pdf", "pdfa"], - "mime": "application/vnd.ms-xpsdocument" - }, - { - "name": "xml", - "type": "word", - "actions": ["view", "edit"], - "convert": ["docx", "docxf", "docm", "dotx", "dotm", "epub", "fb2", "html", "odt", "ott", "pdf", "pdfa", "rtf", "txt"], - "mime": "application/xml" - }, - { - "name": "csv", - "type": "cell", - "actions": ["view", "lossy-edit"], - "convert": [], - "mime": "text/csv" - }, - { - "name": "et", - "type": "cell", - "actions": ["view", "edit"], - "convert": [], - "mime": null - }, - { - "name": "ett", - "type": "cell", - "actions": ["view", "edit"], - "convert": [], - "mime": null - }, - { - "name": "fods", - "type": "cell", - "actions": ["view", "edit"], - "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], - "mime": "application/vnd.oasis.opendocument.spreadsheet" - }, - { - "name": "ods", - "type": "cell", - "actions": ["view", "lossy-edit"], - "convert": ["xlsx", "csv", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], - "mime": "application/vnd.oasis.opendocument.spreadsheet" - }, - { - "name": "ots", - "type": "cell", - "actions": ["view", "lossy-edit"], - "convert": ["xlsx", "csv", "ods", "pdf", "pdfa", "xltx", "xlsm", "xltm"], - "mime": "application/vnd.oasis.opendocument.spreadsheet-template" - }, - { - "name": "sxc", - "type": "cell", - "actions": ["view", "edit"], - "convert": [], - "mime": null - }, - { - "name": "xls", - "type": "cell", - "actions": ["view", "edit"], - "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], - "mime": "application/vnd.ms-excel" - }, - { - "name": "xlsb", - "type": "cell", - "actions": ["view", "edit"], - "convert": [], - "mime": null - }, - { - "name": "xlsm", - "type": "cell", - "actions": ["view", "edit"], - "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xltm"], - "mime": "application/vnd.ms-excel.sheet.macroEnabled.12" - }, - { - "name": "xlsx", - "type": "cell", - "actions": ["view", "edit"], - "convert": ["csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], - "mime": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" - }, - { - "name": "xlt", - "type": "cell", - "actions": ["view", "edit"], - "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm", "xltm"], - "mime": "application/vnd.ms-excel" - }, - { - "name": "xltm", - "type": "cell", - "actions": ["view", "edit"], - "convert": ["xlsx", "csv", "ods", "ots", "pdf", "pdfa", "xltx", "xlsm"], - "mime": "application/vnd.ms-excel.template.macroenabled.12" - }, - { - "name": "xltx", - "type": "cell", - "actions": ["view", "edit"], - "convert": [], - "mime": null - }, - { - "name": "dps", - "type": "slide", - "actions": ["view", "edit"], - "convert": [], - "mime": null - }, - { - "name": "dpt", - "type": "slide", - "actions": ["view", "edit"], - "convert": [], - "mime": null - }, - { - "name": "fodp", - "type": "slide", - "actions": ["view", "edit"], - "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], - "mime": "application/vnd.oasis.opendocument.presentation" - }, - { - "name": "odp", - "type": "slide", - "actions": ["view", "lossy-edit"], - "convert": ["pptx", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], - "mime": "application/vnd.oasis.opendocument.presentation" - }, - { - "name": "otp", - "type": "slide", - "actions": ["view", "lossy-edit"], - "convert": ["pptx", "odp", "pdf", "pdfa", "potx", "pptm", "potm"], - "mime": "application/vnd.oasis.opendocument.presentation-template" - }, - { - "name": "pot", - "type": "slide", - "actions": ["view", "edit"], - "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], - "mime": "application/vnd.ms-powerpoint" - }, - { - "name": "potm", - "type": "slide", - "actions": ["view", "edit"], - "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm"], - "mime": "application/vnd.ms-powerpoint.template.macroEnabled.12" - }, - { - "name": "potx", - "type": "slide", - "actions": ["view", "edit"], - "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "pptm", "potm"], - "mime": "application/vnd.openxmlformats-officedocument.presentationml.template" - }, - { - "name": "pps", - "type": "slide", - "actions": ["view", "edit"], - "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], - "mime": "application/vnd.ms-powerpoint" - }, - { - "name": "ppsm", - "type": "slide", - "actions": ["view", "edit"], - "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], - "mime": "application/vnd.ms-powerpoint.slideshow.macroenabled.12" - }, - { - "name": "ppsx", - "type": "slide", - "actions": ["view", "edit"], - "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], - "mime": "application/vnd.openxmlformats-officedocument.presentationml.slideshow" - }, - { - "name": "ppt", - "type": "slide", - "actions": ["view", "edit"], - "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], - "mime": "application/vnd.ms-powerpoint" - }, - { - "name": "pptm", - "type": "slide", - "actions": ["view", "edit"], - "convert": ["pptx", "odp", "otp", "pdf", "pdfa", "potx", "potm"], - "mime": "application/vnd.ms-powerpoint.presentation.macroenabled.12" - }, - { - "name": "pptx", - "type": "slide", - "actions": ["view", "edit"], - "convert": ["odp", "otp", "pdf", "pdfa", "potx", "pptm", "potm"], - "mime": "application/vnd.openxmlformats-officedocument.presentationml.presentation" - }, - { - "name": "sxi", - "type": "slide", - "actions": ["view", "edit"], - "convert": [], - "mime": null - } -] \ No newline at end of file From 68bb02c5a92ab66a2ddbe222bbd9cb567a7973a7 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 27 Apr 2023 11:49:29 +0300 Subject: [PATCH 31/98] fix: extractDependencies warning --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index c755b27a..afc5891b 100644 --- a/pom.xml +++ b/pom.xml @@ -65,6 +65,7 @@ ${confluence.version} ${confluence.data.version} false + false
From 846c0f95ba9b9a0e4bd5f16b1ad65dbe8685608e Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 27 Apr 2023 13:05:59 +0300 Subject: [PATCH 32/98] fix: changelog reference-data --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdd20c37..70396ad8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## ## Added -- referenceData +- Paste Special to add a link between files ## 4.2.0 ## Changed From 13757dd6bb5d72ac320faa63b3877dbf1409b7f6 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 12 May 2023 09:48:56 +0300 Subject: [PATCH 33/98] added check instanceId --- src/main/java/onlyoffice/OnlyOfficeAPIServlet.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java index dbf70d71..3ad17004 100644 --- a/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeAPIServlet.java @@ -238,15 +238,19 @@ private void referenceData(final HttpServletRequest request, final HttpServletRe if (bodyJson.has("referenceData")) { referenceData = bodyJson.getJSONObject("referenceData"); - attachmentId = referenceData.getLong("fileKey"); + if (referenceData.getString("instanceId").equals(sysInfoService.getConfluenceInfo().getBaseUrl())) { + attachmentId = referenceData.getLong("fileKey"); + } } - if (attachmentUtil.getAttachment(attachmentId) == null) { + Attachment attachment = attachmentUtil.getAttachment(attachmentId); + + if (attachment == null) { String pageIdString = request.getParameter("pageId"); if (pageIdString != null && !pageIdString.isEmpty()) { Long pageId = Long.parseLong(pageIdString); - Attachment attachment = attachmentUtil.getAttachmentByName(bodyJson.getString("path"), pageId); + attachment = attachmentUtil.getAttachmentByName(bodyJson.getString("path"), pageId); if (attachment != null) { attachmentId = attachment.getId(); referenceData.put("fileKey", attachment.getId()); @@ -255,7 +259,7 @@ private void referenceData(final HttpServletRequest request, final HttpServletRe } } - if (attachmentUtil.getAttachment(attachmentId) == null) { + if (attachment == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } From 25b2062934c0e0fcd89f78fe9c5b133a3aa2f1fa Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Sun, 28 May 2023 12:58:52 +0500 Subject: [PATCH 34/98] remove licenses (e81afc3cc67fe06fa86e133631398b1dc638b186) --- licenses/SAL API.license | 12 -- .../atlassian-plugins-osgi-testrunner.license | 12 -- ...tlassian-spring-scanner-annotation.license | 202 ------------------ licenses/commons-collections.license | 202 ------------------ licenses/commons-httpclient.license | 202 ------------------ licenses/javax.enterprise.cdi-api.license | 201 ----------------- licenses/javax.inject.license | 202 ------------------ 7 files changed, 1033 deletions(-) delete mode 100644 licenses/SAL API.license delete mode 100644 licenses/atlassian-plugins-osgi-testrunner.license delete mode 100644 licenses/atlassian-spring-scanner-annotation.license delete mode 100644 licenses/commons-collections.license delete mode 100644 licenses/commons-httpclient.license delete mode 100644 licenses/javax.enterprise.cdi-api.license delete mode 100644 licenses/javax.inject.license diff --git a/licenses/SAL API.license b/licenses/SAL API.license deleted file mode 100644 index ae69751d..00000000 --- a/licenses/SAL API.license +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (c) , -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/licenses/atlassian-plugins-osgi-testrunner.license b/licenses/atlassian-plugins-osgi-testrunner.license deleted file mode 100644 index ae69751d..00000000 --- a/licenses/atlassian-plugins-osgi-testrunner.license +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (c) , -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/licenses/atlassian-spring-scanner-annotation.license b/licenses/atlassian-spring-scanner-annotation.license deleted file mode 100644 index d6456956..00000000 --- a/licenses/atlassian-spring-scanner-annotation.license +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/licenses/commons-collections.license b/licenses/commons-collections.license deleted file mode 100644 index d6456956..00000000 --- a/licenses/commons-collections.license +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/licenses/commons-httpclient.license b/licenses/commons-httpclient.license deleted file mode 100644 index d6456956..00000000 --- a/licenses/commons-httpclient.license +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/licenses/javax.enterprise.cdi-api.license b/licenses/javax.enterprise.cdi-api.license deleted file mode 100644 index 56ee3c8c..00000000 --- a/licenses/javax.enterprise.cdi-api.license +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. \ No newline at end of file diff --git a/licenses/javax.inject.license b/licenses/javax.inject.license deleted file mode 100644 index d6456956..00000000 --- a/licenses/javax.inject.license +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. From c8bc846b90625c001a7ca2ab79480d736f72edfa Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 29 May 2023 09:17:53 +0300 Subject: [PATCH 35/98] fix typo in AuthContext --- src/main/java/onlyoffice/OnlyOfficeConvertServlet.java | 4 ++-- src/main/java/onlyoffice/OnlyOfficeEditorServlet.java | 2 +- src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java | 4 ++-- src/main/java/onlyoffice/managers/auth/AuthContext.java | 2 +- src/main/java/onlyoffice/managers/auth/AuthContextImpl.java | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java b/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java index eb87c179..14b82446 100644 --- a/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java @@ -78,7 +78,7 @@ public OnlyOfficeConvertServlet(final AttachmentManager attachmentManager, final @Override public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { - if (!authContext.checkUserAuthorisation(request, response)) { + if (!authContext.checkUserAuthorization(request, response)) { return; } String pageIdString = request.getParameter("pageId"); @@ -123,7 +123,7 @@ private String getTemplate(final Map map) throws UnsupportedEnco @Override public void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { - if (!authContext.checkUserAuthorisation(request, response)) { + if (!authContext.checkUserAuthorization(request, response)) { return; } diff --git a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java index 5509545f..ea495679 100644 --- a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java @@ -86,7 +86,7 @@ public OnlyOfficeEditorServlet(final LocaleManager localeManager, @Override public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { - if (!authContext.checkUserAuthorisation(request, response)) { + if (!authContext.checkUserAuthorization(request, response)) { return; } diff --git a/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java b/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java index e04c977d..f5081e21 100644 --- a/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeHistoryServlet.java @@ -146,7 +146,7 @@ private void getAttachmentDiff(final HttpServletRequest request, final HttpServl private void getAttachmentHistoryInfo(final HttpServletRequest request, final HttpServletResponse response) throws IOException { - if (!authContext.checkUserAuthorisation(request, response)) { + if (!authContext.checkUserAuthorization(request, response)) { return; } @@ -220,7 +220,7 @@ private void getAttachmentHistoryInfo(final HttpServletRequest request, final Ht private void getAttachmentHistoryData(final HttpServletRequest request, final HttpServletResponse response) throws IOException { - if (!authContext.checkUserAuthorisation(request, response)) { + if (!authContext.checkUserAuthorization(request, response)) { return; } diff --git a/src/main/java/onlyoffice/managers/auth/AuthContext.java b/src/main/java/onlyoffice/managers/auth/AuthContext.java index 814ad83e..c596d50a 100644 --- a/src/main/java/onlyoffice/managers/auth/AuthContext.java +++ b/src/main/java/onlyoffice/managers/auth/AuthContext.java @@ -5,5 +5,5 @@ import java.io.IOException; public interface AuthContext { - boolean checkUserAuthorisation(HttpServletRequest request, HttpServletResponse response) throws IOException; + boolean checkUserAuthorization(HttpServletRequest request, HttpServletResponse response) throws IOException; } diff --git a/src/main/java/onlyoffice/managers/auth/AuthContextImpl.java b/src/main/java/onlyoffice/managers/auth/AuthContextImpl.java index 93f22e3b..1f045205 100644 --- a/src/main/java/onlyoffice/managers/auth/AuthContextImpl.java +++ b/src/main/java/onlyoffice/managers/auth/AuthContextImpl.java @@ -30,7 +30,7 @@ public class AuthContextImpl implements AuthContext { private final Logger log = LogManager.getLogger("onlyoffice.managers.auth.AuthContext"); - public boolean checkUserAuthorisation(final HttpServletRequest request, final HttpServletResponse response) + public boolean checkUserAuthorization(final HttpServletRequest request, final HttpServletResponse response) throws IOException { Principal principal = request.getUserPrincipal(); if (principal == null) { From b7ee49ef39bb84b84962d8a2c3a12a3e113b032e Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 29 May 2023 09:46:54 +0300 Subject: [PATCH 36/98] added: 3rd-party.license files --- 3rd-Party.license | 8 + licenses/3rd-Party.license | 8 + licenses/com.auth0.java-jwt.license | 21 ++ ...rxml.jackson.core.jackson-databind.license | 202 ++++++++++++++++++ 4 files changed, 239 insertions(+) create mode 100644 licenses/com.auth0.java-jwt.license create mode 100644 licenses/com.fasterxml.jackson.core.jackson-databind.license diff --git a/3rd-Party.license b/3rd-Party.license index 23ecc3de..5569e79c 100644 --- a/3rd-Party.license +++ b/3rd-Party.license @@ -1,6 +1,14 @@ Confluence ONLYOFFICE integration app uses code from the following 3rd party projects: +com.auth0.java-jwt - Java implementation of JSON Web Token (JWT) (https://github.com/auth0/java-jwt/blob/master/LICENSE) +License: MIT License +License File: com.auth0.java-jwt.license + +com.fasterxml.jackson.core.jackson-databind - General data-binding functionality for Jackson: works on core streaming API (https://github.com/FasterXML/jackson-databind/blob/2.16/LICENSE) +License: Apache License 2.0 +License File: com.fasterxml.jackson.core.jackson-databind.license + javax.servlet-api - Java Servlet API (https://opensource.org/licenses/CDDL-1.0 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) License: CDDL, GPL 2.0 License File: javax.servlet-api.license diff --git a/licenses/3rd-Party.license b/licenses/3rd-Party.license index 23ecc3de..5569e79c 100644 --- a/licenses/3rd-Party.license +++ b/licenses/3rd-Party.license @@ -1,6 +1,14 @@ Confluence ONLYOFFICE integration app uses code from the following 3rd party projects: +com.auth0.java-jwt - Java implementation of JSON Web Token (JWT) (https://github.com/auth0/java-jwt/blob/master/LICENSE) +License: MIT License +License File: com.auth0.java-jwt.license + +com.fasterxml.jackson.core.jackson-databind - General data-binding functionality for Jackson: works on core streaming API (https://github.com/FasterXML/jackson-databind/blob/2.16/LICENSE) +License: Apache License 2.0 +License File: com.fasterxml.jackson.core.jackson-databind.license + javax.servlet-api - Java Servlet API (https://opensource.org/licenses/CDDL-1.0 https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) License: CDDL, GPL 2.0 License File: javax.servlet-api.license diff --git a/licenses/com.auth0.java-jwt.license b/licenses/com.auth0.java-jwt.license new file mode 100644 index 00000000..72de587f --- /dev/null +++ b/licenses/com.auth0.java-jwt.license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Auth0, Inc. (http://auth0.com) + +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. \ No newline at end of file diff --git a/licenses/com.fasterxml.jackson.core.jackson-databind.license b/licenses/com.fasterxml.jackson.core.jackson-databind.license new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/licenses/com.fasterxml.jackson.core.jackson-databind.license @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. From 509d82020ed3ef36e0ef0d93edbe45710e7dda7e Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 30 May 2023 12:16:13 +0300 Subject: [PATCH 37/98] fix generate secret for internal token --- .../managers/jwt/JwtManagerImpl.java | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java b/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java index 2b538145..c0b64532 100644 --- a/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java +++ b/src/main/java/onlyoffice/managers/jwt/JwtManagerImpl.java @@ -19,7 +19,6 @@ package onlyoffice.managers.jwt; import com.atlassian.config.ApplicationConfiguration; -import com.atlassian.confluence.status.service.SystemInformationService; import com.atlassian.sal.api.pluginsettings.PluginSettings; import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; import com.auth0.jwt.JWT; @@ -31,23 +30,22 @@ import java.util.Base64; import java.util.Map; +import java.util.Random; public class JwtManagerImpl implements JwtManager { private static final long ACCEPT_LEEWAY = 3; + private static final int PLUGIN_SECRET_LENGTH = 32; private final ApplicationConfiguration applicationConfiguration; - private final SystemInformationService systemInformationService; private final ConfigurationManager configurationManager; private final PluginSettings settings; public JwtManagerImpl(final PluginSettingsFactory pluginSettingsFactory, final ApplicationConfiguration applicationConfiguration, - final SystemInformationService systemInformationService, final ConfigurationManager configurationManager) { settings = pluginSettingsFactory.createGlobalSettings(); this.applicationConfiguration = applicationConfiguration; - this.systemInformationService = systemInformationService; this.configurationManager = configurationManager; } @@ -63,11 +61,11 @@ public String verify(final String token) { } public String createInternalToken(final Map payloadMap) { - return createToken(payloadMap, systemInformationService.getConfluenceInfo().getServerId()); + return createToken(payloadMap, getPluginSecret()); } public String verifyInternalToken(final String token) { - return verifyToken(token, systemInformationService.getConfluenceInfo().getServerId()); + return verifyToken(token, getPluginSecret()); } public Boolean jwtEnabled() { @@ -108,4 +106,24 @@ private String verifyToken(final String token, final String key) { return new String(decoder.decode(jwt.getPayload())); } + + private String getPluginSecret() { + if (settings.get("onlyoffice.plugin-secret") == null || settings.get("onlyoffice.plugin-secret").equals("")) { + Random random = new Random(); + char[] numbersAndLetters = ("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ").toCharArray(); + + char[] randBuffer = new char[PLUGIN_SECRET_LENGTH]; + for (int i = 0; i < randBuffer.length; i++) { + randBuffer[i] = numbersAndLetters[random.nextInt(numbersAndLetters.length)]; + } + + String secret = new String(randBuffer); + + settings.put("onlyoffice.plugin-secret", secret); + + return secret; + } else { + return (String) settings.get("onlyoffice.plugin-secret"); + } + } } From e813c1430ab50f6a9e98a2df3657105c99a7c754 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 30 May 2023 12:31:53 +0300 Subject: [PATCH 38/98] added: check if the token belongs to the action --- .../java/onlyoffice/OnlyOfficeFileProviderServlet.java | 9 +++++++-- src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java | 9 +++++++-- .../java/onlyoffice/managers/url/UrlManagerImpl.java | 2 ++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java b/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java index 2eecd20a..ab6150d6 100644 --- a/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java @@ -75,15 +75,20 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re } String token = request.getParameter("token"); - String payload = null; + String payload; + JSONObject bodyFromToken; try { payload = jwtManager.verifyInternalToken(token); + bodyFromToken = new JSONObject(payload); + + if (!bodyFromToken.getString("action").equals("download")) { + throw new SecurityException(); + } } catch (Exception e) { throw new SecurityException("Invalid link token!"); } - JSONObject bodyFromToken = new JSONObject(payload); String userKeyString = bodyFromToken.getString("userKey"); String attachmentIdString = bodyFromToken.getString("attachmentId"); diff --git a/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java b/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java index bb364288..f58b0c44 100644 --- a/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java @@ -90,15 +90,20 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r response.setContentType("text/plain; charset=utf-8"); String token = request.getParameter("token"); - String payload = null; + String payload; + JSONObject bodyFromToken; try { payload = jwtManager.verifyInternalToken(token); + bodyFromToken = new JSONObject(payload); + + if (!bodyFromToken.getString("action").equals("callback")) { + throw new SecurityException(); + } } catch (Exception e) { throw new SecurityException("Invalid link token!"); } - JSONObject bodyFromToken = new JSONObject(payload); String userKeyString = bodyFromToken.getString("userKey"); String attachmentIdString = bodyFromToken.getString("attachmentId"); diff --git a/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java b/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java index 8d85196b..ab79b620 100644 --- a/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java +++ b/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java @@ -87,6 +87,7 @@ public String getFileUri(final Long attachmentId) { Map params = new HashMap<>(); params.put("userKey", user.getKey().getStringValue()); params.put("attachmentId", attachmentId.toString()); + params.put("action", "download"); String fileUri = getConfluenceBaseUrl() + fileProviderServlet + "?token=" + jwtManager.createInternalToken(params); @@ -142,6 +143,7 @@ public String getCallbackUrl(final Long attachmentId) { Map params = new HashMap<>(); params.put("userKey", user.getKey().getStringValue()); params.put("attachmentId", attachmentId.toString()); + params.put("action", "callback"); String callbackUrl = getConfluenceBaseUrl() + callbackServlet + "?token=" + jwtManager.createInternalToken(params); From 251b17bc5a29c6e4ffd9b6ec12114e9c0c1c4bd3 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 30 May 2023 12:33:00 +0300 Subject: [PATCH 39/98] removed: unused dependencies --- .../java/onlyoffice/OnlyOfficeFileProviderServlet.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java b/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java index ab6150d6..27c0f825 100644 --- a/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java @@ -22,11 +22,8 @@ import com.atlassian.confluence.user.UserAccessor; import com.atlassian.sal.api.user.UserKey; import com.atlassian.spring.container.ContainerManager; -import onlyoffice.managers.document.DocumentManager; import onlyoffice.managers.jwt.JwtManager; import onlyoffice.utils.attachment.AttachmentUtil; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; import org.json.JSONObject; import javax.servlet.ServletException; @@ -39,18 +36,14 @@ public class OnlyOfficeFileProviderServlet extends HttpServlet { private static final long serialVersionUID = 1L; - private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeFileProviderServlet"); private static final int BUFFER_SIZE = 10240; private final AttachmentUtil attachmentUtil; private final JwtManager jwtManager; - private final DocumentManager documentManager; - public OnlyOfficeFileProviderServlet(final AttachmentUtil attachmentUtil, final JwtManager jwtManager, - final DocumentManager documentManager) { + public OnlyOfficeFileProviderServlet(final AttachmentUtil attachmentUtil, final JwtManager jwtManager) { this.attachmentUtil = attachmentUtil; this.jwtManager = jwtManager; - this.documentManager = documentManager; } @Override From 9891c86995efd2b08819303d8875137b402b5ed1 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 31 May 2023 10:56:36 +0300 Subject: [PATCH 40/98] revert (567b618944043595e44f6278c5e5f74ef905be43) --- .../onlyoffice/OnlyOfficeConfServlet.java | 1 - src/main/resources/templates/configure.vm | 27 ------------------- 2 files changed, 28 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeConfServlet.java b/src/main/java/onlyoffice/OnlyOfficeConfServlet.java index 86781e94..89fa9483 100644 --- a/src/main/java/onlyoffice/OnlyOfficeConfServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeConfServlet.java @@ -134,7 +134,6 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re contextMap.put("docserviceDemoAvailable", demoAvailable); contextMap.put("pathApiUrl", configurationManager.getProperty("files.docservice.url.api")); contextMap.put("defaultCustomizableEditingTypes", defaultCustomizableEditingTypes); - contextMap.put("supportedFormats", configurationManager.getSupportedFormats()); writer.write(getTemplate(contextMap)); } diff --git a/src/main/resources/templates/configure.vm b/src/main/resources/templates/configure.vm index 4b4a84ea..feb5bf66 100644 --- a/src/main/resources/templates/configure.vm +++ b/src/main/resources/templates/configure.vm @@ -293,32 +293,5 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl - -
-

About app:

-
-

Supported formats:

-
- For viewing: -
-
Word: #foreach($format in $supportedFormats) #if($format.type == "WORD" && $format.actions.contains("view")) ${format.name} #end #end
-
Cell: #foreach($format in $supportedFormats) #if($format.type == "CELL" && $format.actions.contains("view")) ${format.name} #end #end
-
Slide: #foreach($format in $supportedFormats) #if($format.type == "SLIDE" && $format.actions.contains("view")) ${format.name} #end #end
-
- For editing: -
-
Word: #foreach($format in $supportedFormats) #if($format.type == "WORD" && $format.actions.contains("edit")) ${format.name} #end #end
-
Cell: #foreach($format in $supportedFormats) #if($format.type == "CELL" && $format.actions.contains("edit")) ${format.name} #end #end
-
Slide: #foreach($format in $supportedFormats) #if($format.type == "SLIDE" && $format.actions.contains("edit")) ${format.name} #end #end
-
- For editing with possible loss of information: -
-
Word: #foreach($format in $supportedFormats) #if($format.type == "WORD" && $format.actions.contains("lossy-edit")) ${format.name} #end #end
-
Cell: #foreach($format in $supportedFormats) #if($format.type == "CELL" && $format.actions.contains("lossy-edit")) ${format.name} #end #end
-
Slide: #foreach($format in $supportedFormats) #if($format.type == "SLIDE" && $format.actions.contains("lossy-edit")) ${format.name} #end #end
-
-
-
-
From c3ace15c15671745d01fb830b8830d437209114c Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 31 May 2023 10:58:30 +0300 Subject: [PATCH 41/98] revert (c8842d4760ac24d94ea18ddbbeee60a2a79b4516) --- src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java b/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java index e72562c7..82b08188 100644 --- a/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java +++ b/src/main/java/onlyoffice/conditions/IsOfficeFileAttachment.java @@ -66,7 +66,7 @@ public boolean shouldDisplay(final Map context) { if (forEdit) { if (form) { - if (accessEdit && documentManager.isFillForm(ext) && !ext.equals("docx")) { + if (accessEdit && documentManager.isFillForm(ext)) { return true; } } else { From 10a98e8e447d710a757f1871954f86ab40b415ab Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 31 May 2023 12:05:48 +0300 Subject: [PATCH 42/98] update submodule document-formats --- src/main/resources/app_data/document-formats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/app_data/document-formats b/src/main/resources/app_data/document-formats index cc675f0f..eb04cbd1 160000 --- a/src/main/resources/app_data/document-formats +++ b/src/main/resources/app_data/document-formats @@ -1 +1 @@ -Subproject commit cc675f0f3a4c26ddc0721038542c8b88451aa1c8 +Subproject commit eb04cbd1e0f99362c3bd01b11f5d6af6d742cd18 From 3e7c25433bef1d459579eb0a13ea8daaa52023a0 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 31 May 2023 12:22:47 +0300 Subject: [PATCH 43/98] update submodule document-formats --- src/main/resources/app_data/document-formats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/app_data/document-formats b/src/main/resources/app_data/document-formats index eb04cbd1..c8096be5 160000 --- a/src/main/resources/app_data/document-formats +++ b/src/main/resources/app_data/document-formats @@ -1 +1 @@ -Subproject commit eb04cbd1e0f99362c3bd01b11f5d6af6d742cd18 +Subproject commit c8096be5a4e6511ff06ed476d2e3279ad0eaacad From bca5d0d1ae8be55e6648a55cf01aff6318a1089c Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 2 Jun 2023 14:09:24 +0300 Subject: [PATCH 44/98] update submodule document-formats --- src/main/resources/app_data/document-formats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/app_data/document-formats b/src/main/resources/app_data/document-formats index c8096be5..577c50f8 160000 --- a/src/main/resources/app_data/document-formats +++ b/src/main/resources/app_data/document-formats @@ -1 +1 @@ -Subproject commit c8096be5a4e6511ff06ed476d2e3279ad0eaacad +Subproject commit 577c50f89233b59d8079f359f50c08dda6250e70 From a751d9ba49c63bc57c09d40be90981671687a4b4 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 9 Jun 2023 14:14:14 +0300 Subject: [PATCH 45/98] si-LK empty files --- src/main/resources/app_data/document-templates | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/app_data/document-templates b/src/main/resources/app_data/document-templates index cb2c06ed..f00ab3a3 160000 --- a/src/main/resources/app_data/document-templates +++ b/src/main/resources/app_data/document-templates @@ -1 +1 @@ -Subproject commit cb2c06ed33655b0dd09a47b8852f7391edad18ac +Subproject commit f00ab3a3efe6e2f8542ba026d1fc1d72df7dfd5f From 75190ddda36a22749a4d6e42022ac690c37adeae Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 27 Jan 2023 12:15:06 +0300 Subject: [PATCH 46/98] improved: ConvertManager added title # Conflicts: # src/main/java/onlyoffice/OnlyOfficeSaveFileServlet.java # src/main/java/onlyoffice/managers/convert/ConvertManager.java # src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java --- .../onlyoffice/OnlyOfficeConvertServlet.java | 2 +- .../managers/convert/ConvertManager.java | 4 ++-- .../managers/convert/ConvertManagerImpl.java | 22 +++++++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java b/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java index 56d3a2d1..a88c5b25 100644 --- a/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeConvertServlet.java @@ -164,7 +164,7 @@ public void doPost(final HttpServletRequest request, final HttpServletResponse r if (attachmentUtil.checkAccess(attachmentId, user, false) && attachmentUtil.checkAccessCreate(user, pageId)) { if (convertToExt != null) { - json = convertManager.convert(attachmentId, ext, convertToExt, user); + json = convertManager.convert(attachmentId, ext, convertToExt, user, null); if (json.has("endConvert") && json.getBoolean("endConvert")) { String newFileName = documentManager.getCorrectName(title, convertToExt, pageId); diff --git a/src/main/java/onlyoffice/managers/convert/ConvertManager.java b/src/main/java/onlyoffice/managers/convert/ConvertManager.java index f0d04656..a0ab7d57 100644 --- a/src/main/java/onlyoffice/managers/convert/ConvertManager.java +++ b/src/main/java/onlyoffice/managers/convert/ConvertManager.java @@ -6,10 +6,10 @@ import java.io.Serializable; public interface ConvertManager extends Serializable { - JSONObject convert(Long attachmentId, String ext, String convertToExt, ConfluenceUser user) throws Exception; + JSONObject convert(Long attachmentId, String ext, String convertToExt, ConfluenceUser user, String title) throws Exception; JSONObject convert(Long attachmentId, String currentExt, String convertToExt, String url, String region, - boolean async) throws Exception; + boolean async, String title) throws Exception; String getTargetExt(String ext); diff --git a/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java b/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java index 3f5ac1b4..8a97c918 100644 --- a/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java +++ b/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java @@ -61,14 +61,14 @@ public ConvertManagerImpl(final UrlManager urlManager, final JwtManager jwtManag } public JSONObject convert(final Long attachmentId, final String ext, final String convertToExt, - final ConfluenceUser user) throws Exception { + final ConfluenceUser user, final String title) throws Exception { String url = urlManager.getFileUri(attachmentId); String region = localeManager.getLocale(user).toLanguageTag(); - return convert(attachmentId, ext, convertToExt, url, region, true); + return convert(attachmentId, ext, convertToExt, url, region, true, title); } public JSONObject convert(final Long attachmentId, final String currentExt, final String convertToExt, - final String url, final String region, final boolean async) throws Exception { + final String url, final String region, final boolean async, final String title) throws Exception { try (CloseableHttpClient httpClient = configurationManager.getHttpClient()) { JSONObject body = new JSONObject(); body.put("async", async); @@ -78,10 +78,12 @@ public JSONObject convert(final Long attachmentId, final String currentExt, fina body.put("key", documentManager.getKeyOfFile(attachmentId)); body.put("url", url); body.put("region", region); + body.put("title", title); StringEntity requestEntity = new StringEntity(body.toString(), ContentType.APPLICATION_JSON); - HttpPost request = new HttpPost(urlManager.getInnerDocEditorUrl() - + configurationManager.getProperties().getProperty("files.docservice.url.convert")); + String conversionServiceUrl =urlManager.getInnerDocEditorUrl() + configurationManager.getProperties().getProperty("files.docservice.url.convert"); + + HttpPost request = new HttpPost(conversionServiceUrl); request.setEntity(requestEntity); request.setHeader("Accept", "application/json"); @@ -96,26 +98,28 @@ public JSONObject convert(final Long attachmentId, final String currentExt, fina } log.debug("Sending POST to Docserver: " + body.toString()); + JSONObject callBackJson = new JSONObject(); try (CloseableHttpResponse response = httpClient.execute(request)) { int status = response.getStatusLine().getStatusCode(); if (status != HttpStatus.SC_OK) { - throw new HttpException("Docserver returned code " + status); + log.error("Conversion service returned code " + status + ". URL: " + conversionServiceUrl); + callBackJson.put("error", -10); } else { InputStream is = response.getEntity().getContent(); String content = IOUtils.toString(is, StandardCharsets.UTF_8); log.debug("Docserver returned: " + content); - JSONObject callBackJson = null; + try { callBackJson = new JSONObject(content); } catch (Exception e) { throw new Exception("Couldn't convert JSON from docserver: " + e.getMessage()); } - - return callBackJson; } + + return callBackJson; } } } From 58628ac4ed5197648d17e51be67ae93b07f08c18 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 27 Jan 2023 12:17:51 +0300 Subject: [PATCH 47/98] added: download-as action # Conflicts: # src/main/java/onlyoffice/managers/document/DocumentManager.java # src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java --- .../onlyoffice/action/DownloadAsAction.java | 154 ++++++++++++++++++ .../IsOfficeFileDownloadAsAttachment.java | 70 ++++++++ .../managers/document/DocumentManager.java | 2 + .../document/DocumentManagerImpl.java | 12 ++ src/main/resources/atlassian-plugin.xml | 33 ++++ .../resources/js/onlyoffice-download-as.js | 154 ++++++++++++++++++ src/main/resources/lang-resource.properties | 16 ++ .../resources/onlyoffice-config.properties | 1 + src/main/resources/templates/download-as.vm | 47 ++++++ 9 files changed, 489 insertions(+) create mode 100644 src/main/java/onlyoffice/action/DownloadAsAction.java create mode 100644 src/main/java/onlyoffice/conditions/IsOfficeFileDownloadAsAttachment.java create mode 100644 src/main/resources/js/onlyoffice-download-as.js create mode 100644 src/main/resources/templates/download-as.vm diff --git a/src/main/java/onlyoffice/action/DownloadAsAction.java b/src/main/java/onlyoffice/action/DownloadAsAction.java new file mode 100644 index 00000000..5e8a682e --- /dev/null +++ b/src/main/java/onlyoffice/action/DownloadAsAction.java @@ -0,0 +1,154 @@ +/** + * + * (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 onlyoffice.action; + +import com.atlassian.confluence.core.ConfluenceActionSupport; +import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; +import com.atlassian.xwork.HttpMethod; +import com.atlassian.xwork.PermittedMethods; +import com.opensymphony.webwork.ServletActionContext; +import onlyoffice.managers.convert.ConvertManager; +import onlyoffice.utils.attachment.AttachmentUtil; +import com.atlassian.confluence.user.ConfluenceUser; +import org.apache.commons.lang3.StringUtils; +import org.json.JSONObject; + +import javax.inject.Inject; +import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; +import java.util.List; + +public class DownloadAsAction extends ConfluenceActionSupport { + + private AttachmentUtil attachmentUtil; + private ConvertManager convertManager; + + private String attachmentId; + private String fileName; + private String targetFileType; + private static final char[] INVALID_CHARS; + + @Inject + public DownloadAsAction(final AttachmentUtil attachmentUtil, final ConvertManager convertManager) { + this.attachmentUtil = attachmentUtil; + this.convertManager = convertManager; + } + + @PermittedMethods({ HttpMethod.GET }) + public String doDefault() { return ConfluenceActionSupport.INPUT; } + + @Override + public void validate() { + super.validate(); + + Long attachmentId = Long.parseLong(this.attachmentId); + String ext = attachmentUtil.getFileExt(attachmentId); + + if (!attachmentUtil.checkAccess(attachmentId, getAuthenticatedUser(), false)) { + addActionError(getText("onlyoffice.connector.dialog.conversion.message.error.permission")); + ServletActionContext.getResponse().setStatus(403); + return; + } + + if (fileName == null || fileName.isEmpty()) { + addActionError(getText("onlyoffice.connector.error.Unknown")); + ServletActionContext.getResponse().setStatus(400); + } + + if (StringUtils.containsAny((CharSequence)this.fileName, DownloadAsAction.INVALID_CHARS)) { + addActionError(getText("filename.contain.invalid.character")); + ServletActionContext.getResponse().setStatus(400); + } + + if (targetFileType == null || targetFileType.isEmpty()) { + addActionError(getText("onlyoffice.connector.error.Unknown")); + ServletActionContext.getResponse().setStatus(400); + return; + } + + if (convertManager.getTargetExtList(ext) == null || + convertManager.getTargetExtList(ext).isEmpty() || + !convertManager.getTargetExtList(ext).contains(targetFileType) + ) { + addActionError(getText("onlyoffice.connector.error.Unknown")); + ServletActionContext.getResponse().setStatus(415); + } + } + + @PermittedMethods({ HttpMethod.POST }) + public String execute() throws Exception { + Long attachmentId = Long.parseLong(this.attachmentId); + String ext = attachmentUtil.getFileExt(attachmentId); + String targetExt = convertManager.getTargetExt(ext); + + if (!this.targetFileType.isEmpty()) { + targetExt = this.targetFileType; + } + + ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + + JSONObject convertResult = convertManager.convert(attachmentId, ext, targetExt, user, this.fileName + "." + targetExt); + HttpServletResponse response = ServletActionContext.getResponse(); + response.setContentType("application/json"); + PrintWriter writer = response.getWriter(); + writer.write(convertResult.toString()); + response.setStatus(200); + return "none"; + } + + public void setAttachmentId(String attachmentId) { + this.attachmentId = attachmentId; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public void setTargetFileType(String targetFileType) { + this.targetFileType = targetFileType; + } + + public String getAttachmentId() { + return attachmentId; + } + + public String getFileName() { + Long attachmentId = Long.parseLong(this.attachmentId); + String fileName = attachmentUtil.getFileName(attachmentId); + + return fileName.substring(0, fileName.lastIndexOf(".")); + } + + public String getFileType() { + Long attachmentId = Long.parseLong(this.attachmentId); + return attachmentUtil.getFileExt(attachmentId); + } + + public String getTargetFileType() { + return convertManager.getTargetExt(getFileType()); + } + + public List getTargetFileTypeList() { + return convertManager.getTargetExtList(getFileType()); + } + + static { + INVALID_CHARS = new char[] { '\\', '/', '\"', ':', '?', '*', '<', '|', '>' }; + } +} diff --git a/src/main/java/onlyoffice/conditions/IsOfficeFileDownloadAsAttachment.java b/src/main/java/onlyoffice/conditions/IsOfficeFileDownloadAsAttachment.java new file mode 100644 index 00000000..a83e8191 --- /dev/null +++ b/src/main/java/onlyoffice/conditions/IsOfficeFileDownloadAsAttachment.java @@ -0,0 +1,70 @@ +/** + * + * (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 onlyoffice.conditions; + +import com.atlassian.confluence.pages.Attachment; +import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; +import com.atlassian.confluence.user.ConfluenceUser; +import com.atlassian.plugin.PluginParseException; +import com.atlassian.plugin.web.Condition; +import onlyoffice.managers.convert.ConvertManager; +import onlyoffice.managers.document.DocumentManager; +import onlyoffice.utils.attachment.AttachmentUtil; + +import javax.inject.Inject; +import java.util.Map; + +public class IsOfficeFileDownloadAsAttachment implements Condition { + + private final DocumentManager documentManager; + private final AttachmentUtil attachmentUtil; + private final ConvertManager convertManager; + + @Inject + public IsOfficeFileDownloadAsAttachment(DocumentManager documentManager, AttachmentUtil attachmentUtil, + ConvertManager convertManager) { + this.documentManager = documentManager; + this.attachmentUtil = attachmentUtil; + this.convertManager = convertManager; + } + + @Override + public void init(Map map) throws PluginParseException { + } + + @Override + public boolean shouldDisplay(Map map) { + Attachment attachment = (Attachment) map.get("attachment"); + + if (attachment == null) { + return false; + } + + String ext = attachment.getFileExtension(); + + if (attachment.getFileSize() > documentManager.getConvertationFileSizeMax()) { + return false; + } + + ConfluenceUser user = AuthenticatedUserThreadLocal.get(); + boolean access = attachmentUtil.checkAccess(attachment, user, false); + + return access && convertManager.getTargetExtList(ext).size() != 0; + } +} diff --git a/src/main/java/onlyoffice/managers/document/DocumentManager.java b/src/main/java/onlyoffice/managers/document/DocumentManager.java index a5920720..889df905 100644 --- a/src/main/java/onlyoffice/managers/document/DocumentManager.java +++ b/src/main/java/onlyoffice/managers/document/DocumentManager.java @@ -9,6 +9,8 @@ public interface DocumentManager extends Serializable { long getMaxFileSize(); + long getConvertationFileSizeMax(); + String getKeyOfFile(Long attachmentId); String createHash(String str); diff --git a/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java b/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java index e89b506b..b8b1e36c 100644 --- a/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java +++ b/src/main/java/onlyoffice/managers/document/DocumentManagerImpl.java @@ -91,6 +91,18 @@ public String getKeyOfFile(final Long attachmentId) { return key; } + public long getConvertationFileSizeMax() { + long size; + try { + String filesizeMax = configurationManager.getProperty("convertation-filesize-max"); + size = Long.parseLong(filesizeMax); + } catch (Exception ex) { + size = 0; + } + + return size > 0 ? size : 5 * 1024 * 1024; + } + private String generateRevisionId(final String expectedKey) { String result = expectedKey; diff --git a/src/main/resources/atlassian-plugin.xml b/src/main/resources/atlassian-plugin.xml index f2280f9b..bad611d9 100644 --- a/src/main/resources/atlassian-plugin.xml +++ b/src/main/resources/atlassian-plugin.xml @@ -29,6 +29,16 @@ + + com.atlassian.auiplugin:ajs + com.atlassian.auiplugin:dialog2 + + + + + page + + com.atlassian.auiplugin:ajs @@ -131,6 +141,13 @@ onlyoffice-doceditor + + + Link and text for this link used to where a document is available for download in various formats. + onlyoffice.managers.auth.AuthContext @@ -203,4 +220,20 @@ Conditions for displaying ONLYOFFICE button in confluence preview. /onlyoffice/confluence/previews/plugin/access
+ + + + + /templates/download-as.vm + /templates/download-as.vm + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/js/onlyoffice-download-as.js b/src/main/resources/js/onlyoffice-download-as.js new file mode 100644 index 00000000..a0f4f255 --- /dev/null +++ b/src/main/resources/js/onlyoffice-download-as.js @@ -0,0 +1,154 @@ +(function ($) { + const dialogId = "#onlyoffice-download-as-dialog"; + const buttonCloseId = "#dialog-close-button"; + const buttonDownloadAsId = "#dialog-download-as-button"; + + $(function () { + AJS.$(".onlyoffice-download-as-action").unbind("click"); + AJS.$(".onlyoffice-download-as-action").bind("click", function (e) { + e.preventDefault(); + + var link = AJS.$(this); + + AJS.$.get(link.attr('href'), function (response) { + AJS.$('.aui-page-panel').after(response); + AJS.dialog2(dialogId).show(); + + Confluence.Binder.autocompletePage(AJS.$("#onlyoffice-download-as-binder")); + $(".aui-message-context").html(""); + + AJS.$(buttonCloseId).bind("click", function (e) { + e.preventDefault(); + AJS.dialog2(dialogId).hide(); + }); + + AJS.$(buttonDownloadAsId).bind("click", function (e) { + e.preventDefault(); + downloadAsAction(); + }); + }); + + return false; + }); + }); + + function downloadAsAction(url) { + var actionUrl = Confluence.getBaseUrl() + "/" + $(dialogId).find("form").attr("action"); + var data = { + "fileName": $(dialogId).find("#file-name").val(), + "targetFileType": $(dialogId).find("#target-file-type").val() + }; + + $(dialogId).find(buttonDownloadAsId)[0].busy(); + $(dialogId + " form").find("input,select").not(".disabled").attr("disabled","disabled"); + + conversionRequest( + actionUrl, + data, + function(response) { + $("#onlyoffice-download-as-iframe").remove(); + $("body").append(""); + $("#onlyoffice-download-as-iframe").attr("src", response.fileUrl); + AJS.dialog2(dialogId).hide(); + }, + function(errorMessage) { + $(dialogId).find(buttonDownloadAsId)[0].idle(); + $(".aui-message-context").html("
" + errorMessage + "
"); + $(dialogId + " form").find("input,select").not(".disabled").attr("disabled", null); + } + ) + } + + function conversionRequest(url, data, onSuccess, onError) { + if ($(dialogId).length <= 0) return; + + if (data.fileName == "") { + onError(AJS.I18n.getText("fileName.required")); + return; + } + + if (/[\/:*?"<>|]/.test(data.fileName)) { + onError(AJS.I18n.getText("filename.contain.invalid.character")); + return; + } + + $.ajax({ + type: "POST", + url: url, + data: data, + success: function (response) { + if (response.error) { + var errorMessage = getErrorMessage(response); + onError(errorMessage); + return; + } + + if (response.endConvert) { + onSuccess(response); + } else { + setTimeout(function() { + conversionRequest(url, data, onSuccess, onError); + }, 1000); + } + }, + error: function (xhr) { + if (xhr.status == 403) { + onError(AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.permission")); + } else { + onError(AJS.I18n.getText("onlyoffice.connector.error.Unknown")); + } + } + }); + } + + function getErrorMessage(response) { + var errorMessage; + var servicePrefix = false; + + switch (response.error) { + case -1: + errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.unknown"); + servicePrefix = true; + break; + case -2: + errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.timeout"); + servicePrefix = true; + break; + case -3: + errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.conversion"); + servicePrefix = true; + break; + case -4: + errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.download"); + servicePrefix = true; + break; + case -5: + errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.password"); + servicePrefix = true; + break; + case -6: + errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.database"); + servicePrefix = true; + break; + case -7: + errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.input"); + servicePrefix = true; + break; + case -8: + errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.token"); + servicePrefix = true; + break; + case -10: + errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.not-reached"); + break; + default: + errorMessage = AJS.I18n.getText("onlyoffice.connector.error.Unknown"); + } + + if (servicePrefix) { + errorMessage = AJS.I18n.getText("onlyoffice.connector.dialog.conversion.message.error.service-prefix").replace("$", errorMessage); + } + + return errorMessage; + } +})(AJS.$); \ No newline at end of file diff --git a/src/main/resources/lang-resource.properties b/src/main/resources/lang-resource.properties index 20ab32ab..c3a4c78f 100644 --- a/src/main/resources/lang-resource.properties +++ b/src/main/resources/lang-resource.properties @@ -60,3 +60,19 @@ onlyoffice.convert.link=Convert using ONLYOFFICE onlyoffice.convert.label=Converting {0} to {1}.. onlyoffice.convert.message.error=Error\: onlyoffice.form.create.link=Create form using ONLYOFFICE +onlyoffice.connector.download-as.link=Download As +onlyoffice.connector.dialog.conversion.header.title=Download As with ONLYOFFICE +onlyoffice.connector.dialog.conversion.field.current-type=Current type +onlyoffice.connector.dialog.conversion.field.target-type=Target type +onlyoffice.connector.dialog.conversion.message.error.service-prefix=ONLYOFFICE conversion service returned error ($). +onlyoffice.connector.dialog.conversion.message.error.unknown=Unknown error +onlyoffice.connector.dialog.conversion.message.error.timeout=Conversion timeout error +onlyoffice.connector.dialog.conversion.message.error.conversion=Conversion error +onlyoffice.connector.dialog.conversion.message.error.download=Error while downloading the document file to be converted +onlyoffice.connector.dialog.conversion.message.error.password=Incorrect password +onlyoffice.connector.dialog.conversion.message.error.database=Error while accessing the conversion result database +onlyoffice.connector.dialog.conversion.message.error.input=Input error +onlyoffice.connector.dialog.conversion.message.error.token=Invalid token +onlyoffice.connector.dialog.conversion.message.error.not-reached=ONLYOFFICE Conversion service cannot be reached. Please contact admin. +onlyoffice.connector.dialog.conversion.message.error.permission=User does not have rights to perform this operation. +onlyoffice.connector.error.Unknown=An unknown error occurred during the operation. \ No newline at end of file diff --git a/src/main/resources/onlyoffice-config.properties b/src/main/resources/onlyoffice-config.properties index 2aa3d542..c147f0df 100644 --- a/src/main/resources/onlyoffice-config.properties +++ b/src/main/resources/onlyoffice-config.properties @@ -1,4 +1,5 @@ filesize-max=104857600 +convertation-filesize-max=26214400 timeout=60 files.docservice.secret=Vskoproizvolny Salt par Chivreski diff --git a/src/main/resources/templates/download-as.vm b/src/main/resources/templates/download-as.vm new file mode 100644 index 00000000..969a4d0a --- /dev/null +++ b/src/main/resources/templates/download-as.vm @@ -0,0 +1,47 @@ + From a8b5abcf3b30eb1f4f95a635520fd449a2a05231 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 27 Jan 2023 13:02:48 +0300 Subject: [PATCH 48/98] translations for download-as-action --- src/main/resources/lang-resource.properties | 2 +- src/main/resources/lang-resource_de.properties | 17 +++++++++++++++++ src/main/resources/lang-resource_es.properties | 17 +++++++++++++++++ src/main/resources/lang-resource_fr.properties | 17 +++++++++++++++++ src/main/resources/lang-resource_it.properties | 17 +++++++++++++++++ src/main/resources/lang-resource_ru.properties | 16 ++++++++++++++++ 6 files changed, 85 insertions(+), 1 deletion(-) diff --git a/src/main/resources/lang-resource.properties b/src/main/resources/lang-resource.properties index c3a4c78f..714056f8 100644 --- a/src/main/resources/lang-resource.properties +++ b/src/main/resources/lang-resource.properties @@ -75,4 +75,4 @@ onlyoffice.connector.dialog.conversion.message.error.input=Input error onlyoffice.connector.dialog.conversion.message.error.token=Invalid token onlyoffice.connector.dialog.conversion.message.error.not-reached=ONLYOFFICE Conversion service cannot be reached. Please contact admin. onlyoffice.connector.dialog.conversion.message.error.permission=User does not have rights to perform this operation. -onlyoffice.connector.error.Unknown=An unknown error occurred during the operation. \ No newline at end of file +onlyoffice.connector.error.Unknown=An unknown error occurred during the operation. diff --git a/src/main/resources/lang-resource_de.properties b/src/main/resources/lang-resource_de.properties index 68f9032f..7320db6c 100644 --- a/src/main/resources/lang-resource_de.properties +++ b/src/main/resources/lang-resource_de.properties @@ -54,8 +54,25 @@ onlyoffice.editor.dialog.create.form.button.create-blank=Leere Datei erstellen onlyoffice.editor.dialog.create.form.message.error=Die ausgew\u00e4hlte Datei ist nicht im DOCX-Format onlyoffice.editor.message.demo=Du verwendest den \u00f6ffentlichen Demo ONLYOFFICE Document Server. Bitte benutze ihn nicht zum Speichern von Deinen privaten sensiblen Daten. onlyoffice.editor.message.docs-api-undefined=ONLYOFFICE kann nicht erreicht werden. Bitte kontaktieren Sie Ihren Administrator. +onlyoffice.editor.message.docs-api-unsupported= onlyoffice.editor.message.forms.error.version=F\u00fcr Online-Arbeit mit Formularen ist Version 7.0 von ONLYOFFICE Docs erforderlich. onlyoffice.convert.link=Mit ONLYOFFICE konvertieren onlyoffice.convert.label=Konvertieren von {0} in {1}.. onlyoffice.convert.message.error=Fehler\: onlyoffice.form.create.link=Formular in ONLYOFFICE erstellen +onlyoffice.connector.download-as.link= +onlyoffice.connector.dialog.conversion.header.title= +onlyoffice.connector.dialog.conversion.field.current-type=Originalformat +onlyoffice.connector.dialog.conversion.field.target-type=Ausgabeformat +onlyoffice.connector.dialog.conversion.message.error.service-prefix=Der ONLYOFFICE-Konvertierungsdienst hat einen Fehler zur\u00fcckgegeben ($). +onlyoffice.connector.dialog.conversion.message.error.unknown=Unbekannter Fehler +onlyoffice.connector.dialog.conversion.message.error.timeout=Timeout-Fehler bei der Konvertierung +onlyoffice.connector.dialog.conversion.message.error.conversion=Fehler bei der Umwandlung +onlyoffice.connector.dialog.conversion.message.error.download=Fehler beim Herunterladen der Datei, die konvertiert werden muss +onlyoffice.connector.dialog.conversion.message.error.password=Ung\u00fcltiges Passwort +onlyoffice.connector.dialog.conversion.message.error.database=Fehler beim Zugriff auf die Datenbank der Ergebnisse der Konvertierung +onlyoffice.connector.dialog.conversion.message.error.input=Eingabefehler +onlyoffice.connector.dialog.conversion.message.error.token=Ung\u00fcltiges Token +onlyoffice.connector.dialog.conversion.message.error.not-reached=Der ONLYOFFICE-Konvertierungsdienst ist nicht erreichbar. Bitte kontaktieren Sie den Administrator. +onlyoffice.connector.dialog.conversion.message.error.permission=Benutzer hat keine Berechtigungen, diesen Vorgang auszuf\u00fchren. +onlyoffice.connector.error.Unknown=Ein unbekannter Fehler ist w\u00e4hrend des Vorgangs aufgetreten. diff --git a/src/main/resources/lang-resource_es.properties b/src/main/resources/lang-resource_es.properties index c69f591c..9abb2788 100644 --- a/src/main/resources/lang-resource_es.properties +++ b/src/main/resources/lang-resource_es.properties @@ -54,8 +54,25 @@ onlyoffice.editor.dialog.create.form.button.create-blank=Crear desde cero onlyoffice.editor.dialog.create.form.message.error=El archivo seleccionado no es de formato DOCX onlyoffice.editor.message.demo=Est\u00e1s usando el ONLYOFFICE Document Server de demostraci\u00f3n. Por favor, no almacenes tus datos confidenciales aqu\u00ed. onlyoffice.editor.message.docs-api-undefined=No se puede establecer contacto con ONLYOFFICE. Por favor, p\u00f3ngase en contacto con el administrador. +onlyoffice.editor.message.docs-api-unsupported= onlyoffice.editor.message.forms.error.version=Por favor, actualice ONLYOFFICE Docs a la versi\u00f3n 7.0 para poder trabajar con formularios rellenables en l\u00ednea. onlyoffice.convert.link=Convierta usando ONLYOFFICE onlyoffice.convert.label=Convirtiendo {0} a {1}.. onlyoffice.convert.message.error=Error\: onlyoffice.form.create.link=Crear formulario utilizando ONLYOFFICE +onlyoffice.connector.download-as.link= +onlyoffice.connector.dialog.conversion.header.title= +onlyoffice.connector.dialog.conversion.field.current-type=Tipo presente +onlyoffice.connector.dialog.conversion.field.target-type=Tipo di obiettivo +onlyoffice.connector.dialog.conversion.message.error.service-prefix=El servicio de conversi\u00f3n de ONLYOFFICE devolvi\u00f3 un error ($). +onlyoffice.connector.dialog.conversion.message.error.unknown=Error desconocido +onlyoffice.connector.dialog.conversion.message.error.timeout=Error de tiempo de espera +onlyoffice.connector.dialog.conversion.message.error.conversion=Error de conversi\u00f3n +onlyoffice.connector.dialog.conversion.message.error.download=Error al descargar el archivo para su conversi\u00f3n +onlyoffice.connector.dialog.conversion.message.error.password=Contrase\u00f1a incorrecta +onlyoffice.connector.dialog.conversion.message.error.database=Error al acceder la base de datos de resultados de conversi\u00f3n +onlyoffice.connector.dialog.conversion.message.error.input=Error de entrada +onlyoffice.connector.dialog.conversion.message.error.token=Token inv\u00e1lido +onlyoffice.connector.dialog.conversion.message.error.not-reached=No se puede acceder al servicio de conversi\u00f3n de ONLYOFFICE. Por favor, p\u00f3ngase en contacto con el administrador. +onlyoffice.connector.dialog.conversion.message.error.permission=El usuario no tiene derechos a realizar esta operaci\u00f3n. +onlyoffice.connector.error.Unknown=Se produjo un error desconocido durante la operaci\u00f3n. diff --git a/src/main/resources/lang-resource_fr.properties b/src/main/resources/lang-resource_fr.properties index e9aaf60e..0c7e5c1b 100644 --- a/src/main/resources/lang-resource_fr.properties +++ b/src/main/resources/lang-resource_fr.properties @@ -54,8 +54,25 @@ onlyoffice.editor.dialog.create.form.button.create-blank=Cr\u00e9er \u00e0 parti onlyoffice.editor.dialog.create.form.message.error=Le fichier s\u00e9lectionn\u00e9 n'est pas au format DOCX onlyoffice.editor.message.demo=Vous utilisez la version d\u00e9mo de ONLYOFFICE Document Server, propos\u00e9e \u00e0 des fins de tests. Veuillez ne pas stocker vos donn\u00e9es confidentielles. onlyoffice.editor.message.docs-api-undefined=ONLYOFFICE ne peut \u00eatre atteint. Veuillez contacter l'administration. +onlyoffice.editor.message.docs-api-unsupported= onlyoffice.editor.message.forms.error.version=Veuillez mettre \u00e0 jour ONLYOFFICE Docs vers la version 7.0 pour travailler sur les formulaires \u00e0 remplir en ligne. onlyoffice.convert.link=Convertir en utilisant ONLYOFFICE onlyoffice.convert.label=Conversion de {0} en {1}.. onlyoffice.convert.message.error=Erreur\: onlyoffice.form.create.link=Cr\u00e9er un formulaire avec ONLYOFFICE +onlyoffice.connector.download-as.link= +onlyoffice.connector.dialog.conversion.header.title= +onlyoffice.connector.dialog.conversion.field.current-type=Type actuel +onlyoffice.connector.dialog.conversion.field.target-type=Type de cible +onlyoffice.connector.dialog.conversion.message.error.service-prefix=Le service de conversion ONLYOFFICE a renvoy\u00e9 une erreur ($). +onlyoffice.connector.dialog.conversion.message.error.unknown=Erreur inconnue +onlyoffice.connector.dialog.conversion.message.error.timeout=Erreur de d\u00e9lai d'attente +onlyoffice.connector.dialog.conversion.message.error.conversion=Erreur de conversion +onlyoffice.connector.dialog.conversion.message.error.download=Erreur lors du t\u00e9l\u00e9chargement du fichier \u00e0 convertir +onlyoffice.connector.dialog.conversion.message.error.password=Mot de passe incorrect +onlyoffice.connector.dialog.conversion.message.error.database=Erreur lors de l'acc\u00e8s \u00e0 la base de donn\u00e9es des r\u00e9sultats de la conversion +onlyoffice.connector.dialog.conversion.message.error.input=Erreur de saisie +onlyoffice.connector.dialog.conversion.message.error.token=Jeton invalide +onlyoffice.connector.dialog.conversion.message.error.not-reached=Le service de conversion ONLYOFFICE n'est pas accessible. Veuillez contacter l'administration. +onlyoffice.connector.dialog.conversion.message.error.permission=L'utilisateur n'a pas le droit d'effectuer cette op\u00e9ration. +onlyoffice.connector.error.Unknown=Une erreur inconnue s'est produite pendant l'op\u00E9ration. diff --git a/src/main/resources/lang-resource_it.properties b/src/main/resources/lang-resource_it.properties index bd7abd9e..b04d9c4e 100644 --- a/src/main/resources/lang-resource_it.properties +++ b/src/main/resources/lang-resource_it.properties @@ -54,8 +54,25 @@ onlyoffice.editor.dialog.create.form.button.create-blank=Creare da vuoto onlyoffice.editor.dialog.create.form.message.error=Il file selezionato non \u00e8 in formato DOCX onlyoffice.editor.message.demo=Stai utilizzando la versione demo pubblica di ONLYOFFICE Document Server. Non memorizzare dati sensibili privati. onlyoffice.editor.message.docs-api-undefined=ONLYOFFICE non pu\u00f2 essere raggiunto. Ti preghiamo di contattare l'amministratore. +onlyoffice.editor.message.docs-api-unsupported= onlyoffice.editor.message.forms.error.version=Si prega di aggiornare ONLYOFFICE Docs alla versione 7.0 per lavorare su moduli compilabili online. onlyoffice.convert.link=Converti utilizzando ONLYOFFICE onlyoffice.convert.label=Conversione di {0} in {1} .. onlyoffice.convert.message.error=Errore\: onlyoffice.form.create.link=Creare modulo utilizzando ONLYOFFICE +onlyoffice.connector.download-as.link= +onlyoffice.connector.dialog.conversion.header.title= +onlyoffice.connector.dialog.conversion.field.current-type=Tipo presente +onlyoffice.connector.dialog.conversion.field.target-type=Tipo di obiettivo +onlyoffice.connector.dialog.conversion.message.error.service-prefix=Il servizio di conversione ONLYOFFICE ha restituito un errore ($). +onlyoffice.connector.dialog.conversion.message.error.unknown=Errore sconosciuto +onlyoffice.connector.dialog.conversion.message.error.timeout=Errore di timeout per la conversione +onlyoffice.connector.dialog.conversion.message.error.conversion=Errore di conversione +onlyoffice.connector.dialog.conversion.message.error.download=Errore di download del documento da convertire +onlyoffice.connector.dialog.conversion.message.error.password=Password errata +onlyoffice.connector.dialog.conversion.message.error.database=Errore durante l'accesso al database dei risultati di conversione +onlyoffice.connector.dialog.conversion.message.error.input=Errore di input +onlyoffice.connector.dialog.conversion.message.error.token=Token non valido +onlyoffice.connector.dialog.conversion.message.error.not-reached=Il servizio di conversione ONLYOFFICE non \u00e8 raggiungibile. Ti preghiamo di contattare l'amministratore. +onlyoffice.connector.dialog.conversion.message.error.permission=L'utente non ha i diritti per eseguire questa operazione. +onlyoffice.connector.error.Unknown=Si \u00e8 verificato un errore sconosciuto durante l'operazione. diff --git a/src/main/resources/lang-resource_ru.properties b/src/main/resources/lang-resource_ru.properties index f4cd2af0..3feadbd3 100644 --- a/src/main/resources/lang-resource_ru.properties +++ b/src/main/resources/lang-resource_ru.properties @@ -60,3 +60,19 @@ onlyoffice.convert.link=\u041A\u043E\u043D\u0432\u0435\u0440\u0442\u0438\u0440\u onlyoffice.convert.label=\u041A\u043E\u043D\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044F {0} \u0432 {1}.. onlyoffice.convert.message.error=\u041E\u0448\u0438\u0431\u043A\u0430\: onlyoffice.form.create.link=\u0421\u043e\u0437\u0434\u0430\u0442\u044c\u0020\u0444\u043e\u0440\u043c\u0443\u002c\u0020\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f ONLYOFFICE +onlyoffice.connector.download-as.link= +onlyoffice.connector.dialog.conversion.header.title= +onlyoffice.connector.dialog.conversion.field.current-type=\u0422\u0435\u043a\u0443\u0449\u0438\u0439\u0020\u0442\u0438\u043f +onlyoffice.connector.dialog.conversion.field.target-type=\u0426\u0435\u043b\u0435\u0432\u043e\u0439\u0020\u0442\u0438\u043f +onlyoffice.connector.dialog.conversion.message.error.service-prefix=\u0421\u0435\u0440\u0432\u0438\u0441\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438\u0020\u004f\u004e\u004c\u0059\u004f\u0046\u0046\u0049\u0043\u0045\u0020\u0432\u0435\u0440\u043d\u0443\u043b\u0020\u043e\u0448\u0438\u0431\u043a\u0443 ($). +onlyoffice.connector.dialog.conversion.message.error.unknown=\u041d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f\u0020\u043e\u0448\u0438\u0431\u043a\u0430 +onlyoffice.connector.dialog.conversion.message.error.timeout=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u0432\u0440\u0435\u043c\u0435\u043d\u0438\u0020\u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 +onlyoffice.connector.dialog.conversion.message.error.conversion=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 +onlyoffice.connector.dialog.conversion.message.error.download=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u043f\u0440\u0438\u0020\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435\u0020\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0020\u0434\u043b\u044f\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438. +onlyoffice.connector.dialog.conversion.message.error.password=\u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439\u0020\u043f\u0430\u0440\u043e\u043b\u044c +onlyoffice.connector.dialog.conversion.message.error.database=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u043f\u0440\u0438\u0020\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u0020\u043a\u0020\u0431\u0430\u0437\u0435\u0020\u0434\u0430\u043d\u043d\u044b\u0445\u0020\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 +onlyoffice.connector.dialog.conversion.message.error.input=\u041e\u0448\u0438\u0431\u043a\u0430\u0020\u0432\u0432\u043e\u0434\u0430 +onlyoffice.connector.dialog.conversion.message.error.token=\u041d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439\u0020\u0442\u043e\u043a\u0435\u043d +onlyoffice.connector.dialog.conversion.message.error.not-reached=\u0421\u0435\u0440\u0432\u0438\u0441\u0020\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 ONLYOFFICE \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d. \u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430\u002c\u0020\u0441\u0432\u044f\u0436\u0438\u0442\u0435\u0441\u044c\u0020\u0441\u0020\u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u043e\u043c\u002e. +onlyoffice.connector.dialog.conversion.message.error.permission=\u0020\u043d\u0435\u0442\u0020\u043f\u0440\u0430\u0432\u0020\u043d\u0430\u0020\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u0020\u044d\u0442\u043e\u0439\u0020\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. +onlyoffice.connector.error.Unknown=\u0412\u0020\u0445\u043e\u0434\u0435\u0020\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438\u0020\u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430\u0020\u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f\u0020\u043e\u0448\u0438\u0431\u043a\u0430. From b33243510d52c33908817c54a142b971ee991d1c Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 27 Jan 2023 13:03:24 +0300 Subject: [PATCH 49/98] weight for download-as link --- src/main/resources/atlassian-plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/atlassian-plugin.xml b/src/main/resources/atlassian-plugin.xml index bad611d9..ac2a0880 100644 --- a/src/main/resources/atlassian-plugin.xml +++ b/src/main/resources/atlassian-plugin.xml @@ -141,7 +141,7 @@ onlyoffice-doceditor - + Link and text for this link used to where a document is available for download in various formats.