diff --git a/CHANGELOG.md b/CHANGELOG.md index a4477ae5..f8fc1711 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## 4.4.0 +## Added +- compatible with Confluence 8.6 +- opening documents for viewing by an anonymous user +- edit button in ONLYOFFICE preview macro +- link to docs cloud + ## 4.3.1 ## Changed - vulnerability dependency update diff --git a/pom.xml b/pom.xml index d9968b84..defbaeef 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ 4.0.0 onlyoffice onlyoffice-confluence-plugin - 4.3.1 + 4.4.0 Ascensio System SIA diff --git a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java index 0e51d74c..e62980f8 100644 --- a/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeEditorServlet.java @@ -76,10 +76,6 @@ public OnlyOfficeEditorServlet(final I18nResolver i18n, final UrlManager urlMana @Override public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { - if (!authContext.checkUserAuthorization(request, response)) { - return; - } - ConfluenceUser user = AuthenticatedUserThreadLocal.get(); String attachmentIdString = request.getParameter("attachmentId"); @@ -87,6 +83,10 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re String referer = request.getHeader("referer"); if (attachmentIdString == null || attachmentIdString.isEmpty()) { + if (!authContext.checkUserAuthorization(request, response)) { + return; + } + String fileName = request.getParameter("fileName"); String fileExt = request.getParameter("fileExt"); String pageId = request.getParameter("pageId"); @@ -118,7 +118,7 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re } if (!attachmentUtil.checkAccess(attachmentId, user, false)) { - response.sendRedirect(attachment.getContainer().getUrlPath()); + response.sendRedirect(authContext.getLoginUrl(request)); return; } diff --git a/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java b/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java index 27c0f825..f3df6e47 100644 --- a/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java +++ b/src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java @@ -82,12 +82,12 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re throw new SecurityException("Invalid link token!"); } - String userKeyString = bodyFromToken.getString("userKey"); + String userKeyString = bodyFromToken.has("userKey") ? bodyFromToken.getString("userKey") : null; String attachmentIdString = bodyFromToken.getString("attachmentId"); UserAccessor userAccessor = (UserAccessor) ContainerManager.getComponent("userAccessor"); - UserKey userKey = new UserKey(userKeyString); + UserKey userKey = userKeyString == null || userKeyString.equals("") ? null : new UserKey(userKeyString); ConfluenceUser user = userAccessor.getUserByKey(userKey); Long attachmentId = Long.parseLong(attachmentIdString); diff --git a/src/main/java/onlyoffice/macro/OnlyOfficePreviewMacro.java b/src/main/java/onlyoffice/macro/OnlyOfficePreviewMacro.java index 640e8052..c5502627 100644 --- a/src/main/java/onlyoffice/macro/OnlyOfficePreviewMacro.java +++ b/src/main/java/onlyoffice/macro/OnlyOfficePreviewMacro.java @@ -31,6 +31,7 @@ import com.atlassian.confluence.pages.Attachment; import com.atlassian.confluence.pages.AttachmentManager; import com.atlassian.confluence.plugin.services.VelocityHelperService; +import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; import com.atlassian.confluence.util.HtmlUtil; import onlyoffice.macro.components.ContentResolver; import onlyoffice.managers.config.ConfigManager; @@ -39,6 +40,7 @@ import onlyoffice.model.config.DocumentType; import onlyoffice.model.config.Type; import onlyoffice.model.config.editor.Mode; +import onlyoffice.utils.attachment.AttachmentUtil; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.apache.commons.lang3.StringUtils; @@ -62,18 +64,20 @@ public class OnlyOfficePreviewMacro implements Macro, EditorImagePlaceholder, Re private final ConfigManager configManager; private final UrlManager urlManager; private final DocumentManager documentManager; + private final AttachmentUtil attachmentUtil; public OnlyOfficePreviewMacro(final AttachmentManager attachmentManager, final VelocityHelperService velocityHelperService, final ContentResolver contentResolver, final ConfigManager configManager, final UrlManager urlManager, - final DocumentManager documentManager) { + final DocumentManager documentManager, final AttachmentUtil attachmentUtil) { this.attachmentManager = attachmentManager; this.velocityHelperService = velocityHelperService; this.contentResolver = contentResolver; this.configManager = configManager; this.urlManager = urlManager; this.documentManager = documentManager; + this.attachmentUtil = attachmentUtil; } @Override @@ -110,8 +114,24 @@ public String execute(final Map args, final String s, final Conv height ); + String extension = attachmentUtil.getFileExt(attachment.getId()); + String action = ""; + + final boolean isPreview = conversionContext.getOutputType().equals("preview"); + + if (attachmentUtil.checkAccess(attachment.getId(), AuthenticatedUserThreadLocal.get(), true) + && !isPreview) { + if (documentManager.isEditable(extension)) { + action = "edit"; + } else if (documentManager.isFillForm(extension)) { + action = "fill"; + } + } + final Map context = this.velocityHelperService.createDefaultVelocityContext(); - context.put("id", documentManager.getKeyOfFile(attachment.getId(), true)); + context.put("id", System.currentTimeMillis()); + context.put("attachmentId", attachment.getId()); + context.put("action", action); context.put("docServiceApiUrl", urlManager.getDocServiceApiUrl()); context.put("configAsHtml", config); diff --git a/src/main/java/onlyoffice/managers/auth/AuthContext.java b/src/main/java/onlyoffice/managers/auth/AuthContext.java index c596d50a..7c2b0fed 100644 --- a/src/main/java/onlyoffice/managers/auth/AuthContext.java +++ b/src/main/java/onlyoffice/managers/auth/AuthContext.java @@ -6,4 +6,5 @@ public interface AuthContext { boolean checkUserAuthorization(HttpServletRequest request, HttpServletResponse response) throws IOException; + String getLoginUrl(HttpServletRequest request) throws IOException; } diff --git a/src/main/java/onlyoffice/managers/auth/AuthContextImpl.java b/src/main/java/onlyoffice/managers/auth/AuthContextImpl.java index 1f045205..29595252 100644 --- a/src/main/java/onlyoffice/managers/auth/AuthContextImpl.java +++ b/src/main/java/onlyoffice/managers/auth/AuthContextImpl.java @@ -44,7 +44,7 @@ public boolean checkUserAuthorization(final HttpServletRequest request, final Ht return true; } - private String getLoginUrl(final HttpServletRequest request) throws IOException { + public String getLoginUrl(final HttpServletRequest request) throws IOException { StringBuilder stringBuilder = new StringBuilder(request.getContextPath()); String fullUrl = stringBuilder.append("/login.action?permissionViolation=true&os_destination=") .append("plugins%2Fservlet%2Fonlyoffice%2Fdoceditor").append("?") diff --git a/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java b/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java index 75f552a6..c38e6597 100644 --- a/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java +++ b/src/main/java/onlyoffice/managers/convert/ConvertManagerImpl.java @@ -145,6 +145,9 @@ public String getTargetExt(final String ext) { if (format.getName().equals("docxf") && format.getConvert().contains("oform")) { return "oform"; } + if (format.getName().equals("docx") && format.getConvert().contains("docxf")) { + return "docxf"; + } if (format.getConvert().contains("docx")) { return "docx"; } diff --git a/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java b/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java index 45907c07..3bd4db02 100644 --- a/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java +++ b/src/main/java/onlyoffice/managers/url/UrlManagerImpl.java @@ -89,7 +89,10 @@ public String getFileUri(final Long attachmentId) { ConfluenceUser user = AuthenticatedUserThreadLocal.get(); Map params = new HashMap<>(); - params.put("userKey", user.getKey().getStringValue()); + + if (user != null) { + params.put("userKey", user.getKey().getStringValue()); + } params.put("attachmentId", attachmentId.toString()); params.put("action", "download"); diff --git a/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java b/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java index 985cde21..c29a935c 100644 --- a/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java +++ b/src/main/java/onlyoffice/utils/attachment/AttachmentUtilImpl.java @@ -102,20 +102,12 @@ public Attachment getAttachmentByName(final String fileName, final Long pageId) } public boolean checkAccess(final Long attachmentId, final User user, final boolean forEdit) { - if (user == null) { - return false; - } - Attachment attachment = attachmentManager.getAttachment(attachmentId); return checkAccess(attachment, user, forEdit); } public boolean checkAccess(final Attachment attachment, final User user, final boolean forEdit) { - if (user == null) { - return false; - } - PermissionManager permissionManager = (PermissionManager) ContainerManager.getComponent("permissionManager"); if (forEdit) { diff --git a/src/main/resources/atlassian-plugin-marketing.xml b/src/main/resources/atlassian-plugin-marketing.xml index a93e7646..f5ca4727 100644 --- a/src/main/resources/atlassian-plugin-marketing.xml +++ b/src/main/resources/atlassian-plugin-marketing.xml @@ -1,6 +1,6 @@ - + diff --git a/src/main/resources/atlassian-plugin.xml b/src/main/resources/atlassian-plugin.xml index 6c23883f..d402f3b6 100644 --- a/src/main/resources/atlassian-plugin.xml +++ b/src/main/resources/atlassian-plugin.xml @@ -29,6 +29,9 @@ + + + @@ -42,6 +45,7 @@ page + blogpost diff --git a/src/main/resources/css/banner/banner.css b/src/main/resources/css/banner/banner.css new file mode 100644 index 00000000..c9aa3b9a --- /dev/null +++ b/src/main/resources/css/banner/banner.css @@ -0,0 +1,37 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +.onlyoffice-docs-cloud-banner-main { + align-items: center; + background: url(background.svg) no-repeat; + background-color: #f5f6f8; + display: flex; + height: 135px; + width: 500px; + margin: 30px 0 0; +} + +.onlyoffice-docs-cloud-banner-section { + padding: 0 15px; +} + +.onlyoffice-docs-cloud-banner-image { + background-image: url(logo.svg); + width: 82px; + height: 79px; +} \ No newline at end of file diff --git a/src/main/resources/images/banner/background.svg b/src/main/resources/images/banner/background.svg new file mode 100644 index 00000000..37d53594 --- /dev/null +++ b/src/main/resources/images/banner/background.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/images/banner/logo.svg b/src/main/resources/images/banner/logo.svg new file mode 100644 index 00000000..a72071b5 --- /dev/null +++ b/src/main/resources/images/banner/logo.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/lang-resource.properties b/src/main/resources/lang-resource.properties index ba0dd706..239b65cd 100644 --- a/src/main/resources/lang-resource.properties +++ b/src/main/resources/lang-resource.properties @@ -37,6 +37,8 @@ onlyoffice.configuration.message.error.docservunreachable=ONLYOFFICE cannot be r onlyoffice.configuration.message.error.jsonparse=Server can't read JSON onlyoffice.configuration.message.error.jwterror=Authorization error onlyoffice.configuration.message.error.mixedcontent=Mixed Active Content is not allowed. HTTPS address for Document Server is required. +onlyoffice.configuration.banner.message=Easily launch the editors in the cloud without downloading and installation +onlyoffice.configuration.banner.button=Get Now onlyoffice.editor.editlink=Edit in ONLYOFFICE onlyoffice.editor.viewlink=View in ONLYOFFICE onlyoffice.editor.fillFormlink=Fill in form in ONLYOFFICE diff --git a/src/main/resources/lang-resource_de.properties b/src/main/resources/lang-resource_de.properties index cec5f6d2..6304e810 100644 --- a/src/main/resources/lang-resource_de.properties +++ b/src/main/resources/lang-resource_de.properties @@ -37,6 +37,8 @@ onlyoffice.configuration.message.error.docservunreachable=ONLYOFFICE kann nicht onlyoffice.configuration.message.error.jsonparse=Server kann JSON nicht lesen onlyoffice.configuration.message.error.jwterror=Autorisierungsfehler onlyoffice.configuration.message.error.mixedcontent=Mixed Active Content ist nicht m\u00F6glich. HTTPS-Adresse f\u00FCr Document Server ist erforderlich. +onlyoffice.configuration.banner.message=\u00d6ffnen Sie die Editoren in der Cloud einfach ohne Herunterladen und Installation +onlyoffice.configuration.banner.button=Jetzt erhalten onlyoffice.editor.editlink=Mit ONLYOFFICE bearbeiten onlyoffice.editor.viewlink=Ansicht in ONLYOFFICE onlyoffice.editor.fillFormlink=Formular in ONLYOFFICE ausf\u00fcllen diff --git a/src/main/resources/lang-resource_es.properties b/src/main/resources/lang-resource_es.properties index 2962d9cf..f92dc8e9 100644 --- a/src/main/resources/lang-resource_es.properties +++ b/src/main/resources/lang-resource_es.properties @@ -37,6 +37,8 @@ onlyoffice.configuration.message.error.docservunreachable=No se puede establecer onlyoffice.configuration.message.error.jsonparse=Servidor no puede leer\u00A0JSON onlyoffice.configuration.message.error.jwterror=Error de autorizacion onlyoffice.configuration.message.error.mixedcontent=Contenido Mixto Activo no est\u00E1 permitido. Se requiere la direcci\u00F3n HTTPS para Servidor de Documentos. +onlyoffice.configuration.banner.message=Inicie f\u00e1cilmente los editores en la nube sin tener que descargarlos ni instalarlos +onlyoffice.configuration.banner.button=Obtener ahora onlyoffice.editor.editlink=Editar en ONLYOFFICE onlyoffice.editor.viewlink=Ver en ONLYOFFICE onlyoffice.editor.fillFormlink=Rellenar el formulario en ONLYOFFICE diff --git a/src/main/resources/lang-resource_fr.properties b/src/main/resources/lang-resource_fr.properties index 460337fb..54af5ab6 100644 --- a/src/main/resources/lang-resource_fr.properties +++ b/src/main/resources/lang-resource_fr.properties @@ -37,6 +37,8 @@ onlyoffice.configuration.message.error.docservunreachable=ONLYOFFICE ne peut \u0 onlyoffice.configuration.message.error.jsonparse=Serveur ne peut pas lire JSON onlyoffice.configuration.message.error.jwterror=Erreur d\u2019autorisation onlyoffice.configuration.message.error.mixedcontent=Le contenu mixte actif n\u2019est pas autoris\u00E9. Une adresse HTTPS pour le serveur de document est requise. +onlyoffice.configuration.banner.message=Lancez facilement les \u00e9diteurs dans le cloud sans t\u00e9l\u00e9chargement ni installation +onlyoffice.configuration.banner.button=Ottieni ora onlyoffice.editor.editlink=Modifier dans ONLYOFFICE onlyoffice.editor.viewlink=Voir dans ONLYOFFICE onlyoffice.editor.fillFormlink=Remplir le formulaire dans ONLYOFFICE diff --git a/src/main/resources/lang-resource_it.properties b/src/main/resources/lang-resource_it.properties index 297d65b8..3035f6a5 100644 --- a/src/main/resources/lang-resource_it.properties +++ b/src/main/resources/lang-resource_it.properties @@ -37,6 +37,8 @@ onlyoffice.configuration.message.error.docservunreachable=ONLYOFFICE non pu\u00F onlyoffice.configuration.message.error.jsonparse=Il server non pu\u00F2 leggere JSON onlyoffice.configuration.message.error.jwterror=Errore di autorizzazione onlyoffice.configuration.message.error.mixedcontent=Il contenuto attivo misto non \u00E8 consentito. \u00C8 richiesto l\u2019indirizzo HTTPS per Document Server. +onlyoffice.configuration.banner.message=Avvia facilmente gli editor nel cloud senza scaricarli e installarli +onlyoffice.configuration.banner.button=Ottieni ora onlyoffice.editor.editlink=Modifica in ONLYOFFICE onlyoffice.editor.viewlink=Visualizza in ONLYOFFICE onlyoffice.editor.fillFormlink=Compilare il modulo in ONLYOFFICE diff --git a/src/main/resources/lang-resource_ru.properties b/src/main/resources/lang-resource_ru.properties index f2bd0232..d3399a8d 100644 --- a/src/main/resources/lang-resource_ru.properties +++ b/src/main/resources/lang-resource_ru.properties @@ -37,6 +37,8 @@ onlyoffice.configuration.message.error.docservunreachable=\u041F\u0440\u0438\u04 onlyoffice.configuration.message.error.jsonparse=\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C JSON \u043D\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 onlyoffice.configuration.message.error.jwterror=\u041E\u0448\u0438\u0431\u043A\u0430 \u0430\u0432\u0442\u043E\u0440\u0438\u0437\u0430\u0446\u0438\u0438 onlyoffice.configuration.message.error.mixedcontent=\u0421\u043C\u0435\u0448\u0430\u043D\u043D\u043E\u0435 \u0430\u043A\u0442\u0438\u0432\u043D\u043E\u0435 \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u0435 \u0437\u0430\u043F\u0440\u0435\u0449\u0435\u043D\u043E. \u0414\u043B\u044F \u0421\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u043E\u0432 \u043D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C HTTPS-\u0430\u0434\u0440\u0435\u0441. +onlyoffice.configuration.banner.message=\u041b\u0435\u0433\u043a\u043e\u0020\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0439\u0442\u0435\u0020\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u044b\u0020\u0432\u0020\u043e\u0431\u043b\u0430\u043a\u0435\u0020\u0431\u0435\u0437\u0020\u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f\u0020\u0438\u0020\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 +onlyoffice.configuration.banner.button=\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0020\u0441\u0435\u0439\u0447\u0430\u0441 onlyoffice.editor.editlink=\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0432 ONLYOFFICE onlyoffice.editor.viewlink=\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0432 ONLYOFFICE onlyoffice.editor.fillFormlink=\u0417\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c\u0020\u0444\u043e\u0440\u043c\u0443\u0020\u0432 ONLYOFFICE diff --git a/src/main/resources/templates/configure.vm b/src/main/resources/templates/configure.vm index feb5bf66..15081e2e 100644 --- a/src/main/resources/templates/configure.vm +++ b/src/main/resources/templates/configure.vm @@ -293,5 +293,18 @@ $webResourceManager.requireResource("onlyoffice.onlyoffice-confluence-plugin:onl + + + + + + + ONLYOFFICE Docs Cloud + $i18n.getText('onlyoffice.configuration.banner.message') + + + $i18n.getText('onlyoffice.configuration.banner.button') + +
$i18n.getText('onlyoffice.configuration.banner.message')