Skip to content

Commit

Permalink
Merge pull request 'feature/confluence-9' from feature/confluence-9 i…
Browse files Browse the repository at this point in the history
  • Loading branch information
LinneyS committed Nov 1, 2024
2 parents 62016f4 + 2fd493c commit cc15a13
Show file tree
Hide file tree
Showing 42 changed files with 138 additions and 573 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
echo "version=$(awk '/<version>/,/<\/version>/' pom.xml | head -n 1 | sed 's/^[[:space:]]*//g' | sed -n 's:.*<version>\(.*\)</version>.*:\1:p')" >> $GITHUB_OUTPUT
echo "artifact=$(awk '/<artifactId>/,/<\/artifactId>/' pom.xml | head -n 1 | sed 's/^[[:space:]]*//g' | sed -n 's:.*<artifactId>\(.*\)</artifactId>.*:\1:p')" >> $GITHUB_OUTPUT
id: info
- name: Install Java 11
- name: Install Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'
- name: Build Artifact
run: |
cd ${{ github.workspace }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Java 11
- name: Install Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'
- name: Run Checkstyle Checks
run: |
cd ${{ github.workspace }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
echo "version=$(awk '/<version>/,/<\/version>/' pom.xml | head -n 1 | sed 's/^[[:space:]]*//g' | sed -n 's:.*<version>\(.*\)</version>.*:\1:p')" >> $GITHUB_OUTPUT
echo "artifact=$(awk '/<artifactId>/,/<\/artifactId>/' pom.xml | head -n 1 | sed 's/^[[:space:]]*//g' | sed -n 's:.*<artifactId>\(.*\)</artifactId>.*:\1:p')" >> $GITHUB_OUTPUT
id: info
- name: Install Java 11
- name: Install Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'
- name: Build Artifact
run: |
cd ${{ github.workspace }}
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## 6.1.0
## Added
- compatible with Confluence 9.*

## Changed
- forcesave is no longer supported
- history highlighting is no longer supported

## 5.1.0
## Added
- compatible with Confluence 8.9.7
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>onlyoffice</groupId>
<artifactId>onlyoffice-confluence-plugin</artifactId>
<version>5.1.0</version>
<version>6.1.0</version>

<organization>
<name>Ascensio System SIA</name>
Expand Down Expand Up @@ -165,8 +165,8 @@
</pluginRepositories>

<properties>
<confluence.version>8.0.1</confluence.version>
<confluence.data.version>8.0.1</confluence.data.version>
<confluence.version>9.0.2</confluence.version>
<confluence.data.version>9.0.2</confluence.data.version>
<amps.version>8.10.0</amps.version>
<!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/onlyoffice/OnlyOfficeAPIServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.atlassian.confluence.user.actions.ProfilePictureInfo;
import com.atlassian.sal.api.user.UserKey;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.onlyoffice.manager.request.RequestManager;
import com.onlyoffice.manager.settings.SettingsManager;
import com.onlyoffice.manager.security.JwtManager;
Expand All @@ -40,8 +39,8 @@
import onlyoffice.utils.parsing.ParsingUtil;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONObject;

Expand Down Expand Up @@ -188,7 +187,6 @@ private void attachmentData(final HttpServletRequest request, final HttpServletR
JSONArray attachments = bodyJson.getJSONArray("attachments");

List<Object> responseJson = new ArrayList<>();
Gson gson = new Gson();

for (int i = 0; i < attachments.length(); i++) {
Long attachmentId = attachments.getLong(i);
Expand All @@ -214,7 +212,7 @@ private void attachmentData(final HttpServletRequest request, final HttpServletR

response.setContentType("application/json");
PrintWriter writer = response.getWriter();
writer.write(gson.toJson(responseJson));
writer.write(objectMapper.writeValueAsString(responseJson));
} catch (Exception e) {
throw new IOException(e.getMessage());
}
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/onlyoffice/OnlyOfficeConfServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

package onlyoffice;

import com.atlassian.confluence.plugin.services.VelocityHelperService;
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.sal.api.user.UserManager;
import com.atlassian.spring.container.ContainerManager;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -32,8 +32,8 @@
import onlyoffice.sdk.manager.url.UrlManager;
import onlyoffice.sdk.service.SettingsValidationService;
import onlyoffice.utils.parsing.ParsingUtil;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
Expand All @@ -53,17 +53,20 @@ public class OnlyOfficeConfServlet extends HttpServlet {

private final long serialVersionUID = 1L;

private final VelocityHelperService velocityHelperService;

private final UserManager userManager;
private final com.onlyoffice.manager.settings.SettingsManager settingsManager;
private final DocumentManager documentManager;
private final ParsingUtil parsingUtil;
private final SettingsValidationService settingsValidationService;

public OnlyOfficeConfServlet(final UserManager userManager,
public OnlyOfficeConfServlet(final VelocityHelperService velocityHelperService, final UserManager userManager,
final com.onlyoffice.manager.settings.SettingsManager settingsManager,
final DocumentManager documentManager, final UrlManager urlManager,
final ParsingUtil parsingUtil,
final SettingsValidationService settingsValidationService) {
this.velocityHelperService = velocityHelperService;
this.userManager = userManager;
this.settingsManager = settingsManager;
this.documentManager = documentManager;
Expand Down Expand Up @@ -130,7 +133,7 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re
}

private String getTemplate(final Map<String, Object> map) throws UnsupportedEncodingException {
return VelocityUtils.getRenderedTemplate("templates/configure.vm", map);
return velocityHelperService.getRenderedTemplate("templates/configure.vm", map);
}

@Override
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/onlyoffice/OnlyOfficeConvertServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import com.atlassian.confluence.languages.LocaleManager;
import com.atlassian.confluence.pages.Attachment;
import com.atlassian.confluence.pages.AttachmentManager;
import com.atlassian.confluence.plugin.services.VelocityHelperService;
import com.atlassian.confluence.renderer.radeox.macros.MacroUtils;
import com.atlassian.confluence.user.AuthenticatedUserThreadLocal;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.util.velocity.VelocityUtils;
import com.onlyoffice.manager.request.RequestManager;
import com.onlyoffice.model.common.CommonResponse;
import com.onlyoffice.model.common.Format;
Expand All @@ -37,8 +37,8 @@
import onlyoffice.utils.attachment.AttachmentUtil;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONObject;

import javax.servlet.ServletException;
Expand All @@ -56,6 +56,7 @@ public class OnlyOfficeConvertServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private final Logger log = LogManager.getLogger("onlyoffice.OnlyOfficeConvertServlet");

private final VelocityHelperService velocityHelperService;
private final LocaleManager localeManager;
private final AttachmentManager attachmentManager;
private final AttachmentUtil attachmentUtil;
Expand All @@ -64,10 +65,12 @@ public class OnlyOfficeConvertServlet extends HttpServlet {
private final DocumentManager documentManager;
private final RequestManager requestManager;

public OnlyOfficeConvertServlet(final LocaleManager localeManager, final AttachmentManager attachmentManager,
public OnlyOfficeConvertServlet(final VelocityHelperService velocityHelperService,
final LocaleManager localeManager, final AttachmentManager attachmentManager,
final AttachmentUtil attachmentUtil, final ConvertService convertService,
final AuthContext authContext, final DocumentManager documentManager,
final RequestManager requestManager) {
this.velocityHelperService = velocityHelperService;
this.localeManager = localeManager;
this.attachmentManager = attachmentManager;
this.attachmentUtil = attachmentUtil;
Expand Down Expand Up @@ -134,7 +137,7 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re
}

private String getTemplate(final Map<String, Object> map) throws UnsupportedEncodingException {
return VelocityUtils.getRenderedTemplate("templates/convert.vm", map);
return velocityHelperService.getRenderedTemplate("templates/convert.vm", map);
}

@Override
Expand Down Expand Up @@ -257,7 +260,7 @@ public Long doWork(final Object response) throws Exception {
copy.setMediaType(documentManager.getMimeType(newName));

attachmentManager.saveAttachment(copy, null, inputStream);
attachmentUtil.setCollaborativeEditingKey(copy.getLatestVersionId(), null);
// attachmentUtil.setCollaborativeEditingKey(copy.getLatestVersionId(), null);

return copy.getLatestVersionId();
}
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/onlyoffice/OnlyOfficeEditorServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

import com.atlassian.confluence.languages.LocaleManager;
import com.atlassian.confluence.pages.BlogPost;
import com.atlassian.confluence.plugin.services.VelocityHelperService;
import com.atlassian.confluence.renderer.radeox.macros.MacroUtils;
import com.atlassian.confluence.user.AuthenticatedUserThreadLocal;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.util.velocity.VelocityUtils;
import com.atlassian.sal.api.message.I18nResolver;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
Expand All @@ -41,8 +41,8 @@
import onlyoffice.sdk.manager.security.JwtManager;
import onlyoffice.sdk.manager.url.UrlManager;
import onlyoffice.utils.attachment.AttachmentUtil;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONObject;

Expand Down Expand Up @@ -70,13 +70,15 @@ public class OnlyOfficeEditorServlet extends HttpServlet {
private final ConfigService configService;
private final SettingsManager settingsManager;
private final JwtManager jwtManager;
private final VelocityHelperService velocityHelperService;

private final LocaleManager localeManager;

public OnlyOfficeEditorServlet(final I18nResolver i18n, final UrlManager urlManager, final AuthContext authContext,
final DocumentManager documentManager, final AttachmentUtil attachmentUtil,
final ConfigService configService, final SettingsManager settingsManager,
final JwtManager jwtManager, final LocaleManager localeManager) {
final JwtManager jwtManager, final LocaleManager localeManager,
final VelocityHelperService velocityHelperService) {
this.i18n = i18n;
this.urlManager = urlManager;
this.authContext = authContext;
Expand All @@ -86,6 +88,7 @@ public OnlyOfficeEditorServlet(final I18nResolver i18n, final UrlManager urlMana
this.settingsManager = settingsManager;
this.jwtManager = jwtManager;
this.localeManager = localeManager;
this.velocityHelperService = velocityHelperService;
}

@Override
Expand Down Expand Up @@ -222,7 +225,7 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re

response.setContentType("text/html;charset=UTF-8");
PrintWriter writer = response.getWriter();
writer.write(VelocityUtils.getRenderedTemplate("templates/editor.vm", context));
writer.write(velocityHelperService.getRenderedTemplate("templates/editor.vm", context));

} catch (Exception e) {
throw new ServletException(e.getMessage(), e);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/onlyoffice/OnlyOfficeFileProviderServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package onlyoffice;

import com.atlassian.annotations.security.UnrestrictedAccess;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.UserAccessor;
import com.atlassian.sal.api.user.UserKey;
Expand Down Expand Up @@ -52,6 +53,7 @@ public OnlyOfficeFileProviderServlet(final AttachmentUtil attachmentUtil, final
}

@Override
@UnrestrictedAccess
public void doGet(final HttpServletRequest request, final HttpServletResponse response)
throws ServletException, IOException {
if (settingsManager.isSecurityEnabled()) {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/onlyoffice/OnlyOfficeFormatsServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

package onlyoffice;

import com.google.gson.Gson;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.onlyoffice.model.common.Format;
import onlyoffice.sdk.manager.document.DocumentManager;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
Expand All @@ -38,6 +38,8 @@ public class OnlyOfficeFormatsServlet extends HttpServlet {

private final DocumentManager documentManager;

private final ObjectMapper objectMapper = new ObjectMapper();

public OnlyOfficeFormatsServlet(final DocumentManager documentManager) {
this.documentManager = documentManager;
}
Expand All @@ -53,10 +55,8 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re
}
}

Gson gson = new Gson();

response.setContentType("application/json");
PrintWriter writer = response.getWriter();
writer.write(gson.toJson(result));
writer.write(objectMapper.writeValueAsString(result));
}
}
Loading

0 comments on commit cc15a13

Please sign in to comment.