Skip to content

Commit

Permalink
ACS-7258 Prepare for ACS 7.4.2 Service Pack (#2517)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikolajbrzezinski authored Mar 22, 2024
1 parent 518058b commit d50e82e
Show file tree
Hide file tree
Showing 18 changed files with 294 additions and 81 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -385,18 +385,24 @@ jobs:
pom-dir: tas-email
- test-name: "WebDAV TAS tests"
pom-dir: tas-webdav
- test-name: "Integration TAS tests"
- test-name: "Integration TAS tests (Java 17)"
pom-dir: tas-integration
- test-name: "Integration TAS tests (Java 11)"
pom-dir: tas-integration
jre-version: 11
env:
REQUIRES_LOCAL_IMAGES: true
steps:
- uses: actions/checkout@v3
- uses: Alfresco/alfresco-build-tools/.github/actions/[email protected]
- uses: Alfresco/alfresco-build-tools/.github/actions/[email protected]
with:
java-version: ${{ matrix.jre-version || '17' }}
- name: "Build"
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
run: |
bash ./scripts/ci/init.sh
export BUILD_OPTIONS="-Ddocker.buildArg.JRE_VERSION=${{ matrix.jre-version }} ${BUILD_OPTIONS}"
bash ./scripts/ci/build.sh
- name: "Set up the environment"
run: |
Expand Down
2 changes: 1 addition & 1 deletion amps/ags/rm-community/rm-community-repo/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SOLR6_TAG=2.0.7-A5
POSTGRES_TAG=14.4
ACTIVEMQ_TAG=5.17.1-jre11-rockylinux8
ACTIVEMQ_TAG=5.17.6-jre17-rockylinux8
4 changes: 2 additions & 2 deletions amps/ags/rm-community/rm-community-repo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@
</run>
</image>
<image>
<name>alfresco/alfresco-activemq:${dependency.activemq.version}-jre11-rockylinux8</name>
<name>alfresco/alfresco-activemq:${dependency.activemq.version}-jre17-rockylinux8</name>
<run>
<ports>
<port>${activemq.port1}:${activemq.port1}</port>
Expand Down Expand Up @@ -507,7 +507,7 @@
</run>
</image>
<image>
<name>alfresco/alfresco-activemq:${dependency.activemq.version}-jre11-rockylinux8</name>
<name>alfresco/alfresco-activemq:${dependency.activemq.version}-jre17-rockylinux8</name>
<run>
<ports>
<port>${activemq.port1}:${activemq.port1}</port>
Expand Down
4 changes: 3 additions & 1 deletion packaging/docker-alfresco/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
ARG JRE_VERSION=17

# Fetch image based on Tomcat 9.0, Java 17 and Rocky Linux 8
# More infos about this image: https://github.com/Alfresco/alfresco-docker-base-tomcat
FROM alfresco/alfresco-base-tomcat:tomcat9-jre17-rockylinux8-202303081618
FROM alfresco/alfresco-base-tomcat:tomcat9-jre${JRE_VERSION}-rockylinux8-202303081618

# Set default docker_context.
ARG resource_path=target
Expand Down
2 changes: 1 addition & 1 deletion packaging/tests/environment/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SOLR6_TAG=2.0.7-A5
POSTGRES_TAG=14.4
ACTIVEMQ_TAG=5.17.1-jre11-rockylinux8
ACTIVEMQ_TAG=5.17.6-jre17-rockylinux8
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@
<dependency.jackson.version>2.15.0-rc1</dependency.jackson.version>
<dependency.cxf.version>3.5.5</dependency.cxf.version>
<dependency.opencmis.version>1.0.0</dependency.opencmis.version>
<dependency.webscripts.version>8.44</dependency.webscripts.version>
<dependency.webscripts.version>8.47</dependency.webscripts.version>
<dependency.bouncycastle.version>1.70</dependency.bouncycastle.version>
<dependency.mockito-core.version>4.9.0</dependency.mockito-core.version>
<dependency.assertj.version>3.24.2</dependency.assertj.version>
<dependency.org-json.version>20230227</dependency.org-json.version>
<dependency.org-json.version>20231013</dependency.org-json.version>
<dependency.commons-dbcp.version>2.9.0</dependency.commons-dbcp.version>
<dependency.commons-io.version>2.11.0</dependency.commons-io.version>
<dependency.gson.version>2.8.9</dependency.gson.version>
Expand All @@ -88,7 +88,7 @@
<dependency.netty.version>4.1.87.Final</dependency.netty.version> <!-- must be in sync with camels transitive dependencies, e.g.: netty-common -->
<dependency.netty.qpid.version>4.1.82.Final</dependency.netty.qpid.version> <!-- must be in sync with camels transitive dependencies: native-unix-common/native-epoll/native-kqueue -->
<dependency.netty-tcnative.version>2.0.56.Final</dependency.netty-tcnative.version> <!-- must be in sync with camels transitive dependencies -->
<dependency.activemq.version>5.17.4</dependency.activemq.version>
<dependency.activemq.version>5.17.6</dependency.activemq.version>
<dependency.apache-compress.version>1.22</dependency.apache-compress.version>
<dependency.apache.taglibs.version>1.2.5</dependency.apache.taglibs.version>
<dependency.awaitility.version>4.2.0</dependency.awaitility.version>
Expand All @@ -111,8 +111,8 @@
<dependency.json-smart.version>2.5.0</dependency.json-smart.version>
<dependency.jakarta-rpc-api.version>1.1.4</dependency.jakarta-rpc-api.version>

<alfresco.googledrive.version>3.4.0</alfresco.googledrive.version>
<alfresco.aos-module.version>1.6.0</alfresco.aos-module.version>
<alfresco.googledrive.version>3.4.2</alfresco.googledrive.version>
<alfresco.aos-module.version>1.6.2</alfresco.aos-module.version>
<alfresco.api-explorer.version>7.4.0</alfresco.api-explorer.version> <!-- Also in alfresco-enterprise-share -->

<alfresco.maven-plugin.version>2.2.0</alfresco.maven-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ public void writeContents(JsonGenerator generator, ObjectMapper objectMapper)
}
catch (ApiException | WebScriptException apiException)
{
renderException(apiException, res, assistant);
renderException(apiException, res, req, assistant);
}
catch (RuntimeException runtimeException)
{
renderException(runtimeException, res, assistant);
renderException(runtimeException, res, req, assistant);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ public void writeContents(JsonGenerator generator, ObjectMapper objectMapper)
}
catch (ApiException | WebScriptException apiException)
{
renderException(apiException, res, assistant);
renderException(apiException, res, req, assistant);
}
catch (RuntimeException runtimeException)
{
renderException(runtimeException, res, assistant);
renderException(runtimeException, res, req, assistant);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected void renderErrorResponse(Match match, Throwable exception, WebScriptRe
else
{
try {
renderException((Exception)exception, response, apiAssistant);
renderException((Exception)exception, response, request, apiAssistant);
} catch (IOException e) {
logger.error("Internal error", e);
throw new WebScriptException("Internal error", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void execute(WebScriptRequest webScriptRequest, WebScriptResponse webScri
renderJsonResponse(webScriptResponse, toRender, assistant.getJsonHelper());

} catch (Exception exception) {
renderException(exception,webScriptResponse,assistant);
renderException(exception,webScriptResponse,webScriptRequest,assistant);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ public void execute(WebScriptRequest webScriptRequest, WebScriptResponse res) th
{
if (exception instanceof QueryParserException)
{
renderException(exception,res,assistant);
renderException(exception,res,webScriptRequest,assistant);
}
else
{
renderException(new WebScriptException(400, exception.getMessage()), res, assistant);
renderException(new WebScriptException(400, exception.getMessage()), res, webScriptRequest, assistant);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,34 @@

package org.alfresco.rest.framework.tools;

import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.alfresco.rest.framework.Api;
import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.rest.framework.core.exceptions.DefaultExceptionResolver;
import org.alfresco.rest.framework.core.exceptions.ErrorResponse;
import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException;
import org.alfresco.rest.framework.jacksonextensions.BeanPropertiesFilter;
import org.alfresco.rest.framework.jacksonextensions.ExecutionResult;
import org.alfresco.rest.framework.jacksonextensions.JacksonHelper;
import org.alfresco.rest.framework.resource.SerializablePagedCollection;
import org.alfresco.rest.framework.resource.content.BinaryResource;
import org.alfresco.rest.framework.resource.content.ContentInfo;
import org.alfresco.rest.framework.resource.content.ContentInfoImpl;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Params;
import org.alfresco.rest.framework.webscripts.WithResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.simple.JSONObject;
import org.springframework.beans.BeanUtils;
import org.springframework.extensions.surf.util.I18NUtil;
import org.springframework.extensions.webscripts.*;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.Description;
import org.springframework.extensions.webscripts.Format;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
import org.springframework.extensions.webscripts.WrappingWebScriptResponse;
import org.springframework.extensions.webscripts.servlet.WebScriptServletResponse;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/*
* Writes to the response
Expand Down Expand Up @@ -193,32 +190,60 @@ default void setResponse(final WebScriptResponse res, WithResponse withResponse)
default void renderErrorResponse(final ErrorResponse errorResponse, final WebScriptResponse res, final JacksonHelper jsonHelper)
throws IOException
{
renderErrorResponse(errorResponse, res, null, jsonHelper);
}

String logId = "";
/**
* Renders a JSON error response
*
* @param errorResponse The error
* @param res web script response
* @param req web script request
* @throws IOException
*/
default void renderErrorResponse(final ErrorResponse errorResponse, final WebScriptResponse res, final WebScriptRequest req,
final JacksonHelper jsonHelper) throws IOException
{
String stackMessage = I18NUtil.getMessage(DefaultExceptionResolver.STACK_MESSAGE_ID);
String logId = org.alfresco.util.GUID.generate();

final ErrorResponse errorToWrite = new ErrorResponse(errorResponse.getErrorKey(), errorResponse.getStatusCode(),
errorResponse.getBriefSummary(), stackMessage, logId, errorResponse.getAdditionalState(),
DefaultExceptionResolver.ERROR_URL);

String reqUrl = (req != null) ? req.getURL() : "unknown";
String userName = AuthenticationUtil.getFullyAuthenticatedUser() != null ? AuthenticationUtil.getFullyAuthenticatedUser()
: "unauthenticated user";

// If internal server error or class in debug then print the stack trace
if (Status.STATUS_INTERNAL_SERVER_ERROR == errorResponse.getStatusCode() || resWriterLogger().isDebugEnabled())
{
logId = org.alfresco.util.GUID.generate();
resWriterLogger().error(logId + " : " + errorResponse.getStackTrace());
resWriterLogger().error("Exception " + errorToWrite.getLogId() + ". Request " + reqUrl + " executed by " + userName
+ " returned status code " + errorResponse.getStatusCode() + " with message: "
+ errorResponse.getBriefSummary() + " - Stack Trace: " + errorResponse.getStackTrace());
}
else
{
resWriterLogger().error("Exception " + errorToWrite.getLogId() + ". Request " + reqUrl + " executed by user "
+ userName + " returned status code " + errorResponse.getStatusCode() + " with message: "
+ errorResponse.getBriefSummary() + " - Increase logging on " + this.getClass().getName()
+ " for stack trace.");
}

String stackMessage = I18NUtil.getMessage(DefaultExceptionResolver.STACK_MESSAGE_ID);

final ErrorResponse errorToWrite = new ErrorResponse(errorResponse.getErrorKey(), errorResponse.getStatusCode(),
errorResponse.getBriefSummary(), stackMessage, logId, errorResponse.getAdditionalState(), DefaultExceptionResolver.ERROR_URL);

setContentInfoOnResponse(res, DEFAULT_JSON_CONTENT);

// Status must be set before the response is written by Jackson (which will by default close and commit the response).
// In a r/w txn, web script buffered responses ensure that it doesn't really matter but for r/o txns this is important.
// Status must be set before the response is written by Jackson (which will by default close and commit the
// response).
// In a r/w txn, web script buffered responses ensure that it doesn't really matter but for r/o txns this is
// important.
res.setStatus(errorToWrite.getStatusCode());

jsonHelper.withWriter(res.getOutputStream(), new JacksonHelper.Writer()
{
@SuppressWarnings("unchecked")
@Override
public void writeContents(JsonGenerator generator, ObjectMapper objectMapper)
throws JsonGenerationException, JsonMappingException, IOException
throws JsonGenerationException, JsonMappingException, IOException
{
JSONObject obj = new JSONObject();
obj.put("error", errorToWrite);
Expand All @@ -236,7 +261,21 @@ public void writeContents(JsonGenerator generator, ObjectMapper objectMapper)
*/
default void renderException(final Exception exception, final WebScriptResponse response, final ApiAssistant assistant) throws IOException
{
renderErrorResponse(assistant.resolveException(exception), response, assistant.getJsonHelper());
renderException(exception, response, null, assistant);
}

/**
* Renders an exception to the output stream as Json.
*
* @param exception
* @param response
* @param request
* @throws IOException
*/
default void renderException(final Exception exception, final WebScriptResponse response, final WebScriptRequest request,
final ApiAssistant assistant) throws IOException
{
renderErrorResponse(assistant.resolveException(exception), response, request, assistant.getJsonHelper());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ public Void doWork() throws Exception
}
catch (ContentIOException cioe)
{
handleContentIOException(res, cioe);
handleContentIOException(res, req, cioe);
}
catch (AlfrescoRuntimeException | ApiException | WebScriptException xception )
{
renderException(xception, res, assistant);
renderException(xception, res, req, assistant);
}
catch (RuntimeException runtimeException)
{
renderException(runtimeException, res, assistant);
renderException(runtimeException, res, req, assistant);
}
finally
{
Expand Down Expand Up @@ -224,17 +224,17 @@ public Object execute() throws Throwable
return toReturn;
}

private void handleContentIOException(final WebScriptResponse res, ContentIOException exception) throws IOException
private void handleContentIOException(final WebScriptResponse res, final WebScriptRequest req, ContentIOException exception) throws IOException
{
// If the Content-Length is not set back to -1 any client will expect to receive binary and will hang until it times out
res.setHeader(HEADER_CONTENT_LENGTH, String.valueOf(-1));
if (exception instanceof ArchivedIOException)
{
renderException(new ArchivedContentException(exception.getMsgId(), exception), res, assistant);
renderException(new ArchivedContentException(exception.getMsgId(), exception), res, req, assistant);
}
else
{
renderException(exception, res, assistant);
renderException(exception, res, req, assistant);
}
}

Expand Down
Loading

0 comments on commit d50e82e

Please sign in to comment.