Skip to content

Commit

Permalink
Feature/acs 23 (#29)
Browse files Browse the repository at this point in the history
* Add build profile for ACS community-23.1.0. Use jakarta.servlet instead of javax.servlet.

* CommonsMultipartResolver removed in spring 6, use StandardServletMultipartResolver instead.

* org.springframework.http.HttpMethod is not an Enum in spring 6 and can't be used as value in Annotation. Replace with org.springframework.web.bind.annotation.RequestMethod.

* - upgrade of testing libraries
- removing jakarta servlet-api incompatible profiles
- version bump to 9.0.0? should we use 23.x to make it easier to follow alfresco versions?

* CI should only build 23.1.0 for because of the jakarta incompatibility

* upgrading GH actions as CI seems to fail

* testing temurin GH java setup

* GH java-setup v3 for all

* adapting plugin versions and mvn central deploy from github actions

* adapting CI and readme

* adapting CI

* adapting CI

* adapting CI

* ossrh publishing

* ossrh publishing

* updating gpg version + skiping tests for publishing

---------

Co-authored-by: Niklas Sjöström <[email protected]>
  • Loading branch information
dgradecak and niklassjo authored Jun 12, 2024
1 parent 611a7e5 commit be3b058
Show file tree
Hide file tree
Showing 24 changed files with 104 additions and 157 deletions.
26 changes: 10 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ name: build
on:
push:
pull_request:

jobs:
compile:
name: "compile"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v1
- uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
java-version: 17
- name: Build with Maven
run: ./mvnw compile

Expand All @@ -24,22 +25,15 @@ jobs:
strategy:
matrix:
include:
- alfresco-version: 6.1.2-ga
experimental: false
- alfresco-version: 6.2.0-ga
experimental: false
- alfresco-version: 7.1.0.1
experimental: false
- alfresco-version: 7.2.0
experimental: false
- alfresco-version: 7.3.0
- alfresco-version: 23.1.0
experimental: false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v1
- uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
java-version: 17
- name: Run tests
run: ./mvnw test -Pcommunity-${{ matrix.alfresco-version }}
28 changes: 28 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: publish
on:
release:
types: [created]

jobs:
publish:
name: "Publishing to Maven central"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Publish package
run: ./mvnw deploy -DaltDeploymentRepository=ossrh::https://oss.sonatype.org/service/local/staging/deploy/maven2 -DskipTests=true
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ local
*.log
*.log.*

private-key.gpg
private-key.gpg
*.factorypath
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Profiles
-
We are using profiles to test against different Alfresco versions. If no configured Maven profiles are provided the default will be used and is specified by <activeByDefault>true</activeByDefault> in the pom.xml

example: mvn package -Pcommunity-7.2.0
example: mvn package -Pcommunity-23.1.0

Testing
-
Expand Down
2 changes: 1 addition & 1 deletion alfresco-mvc-aop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<parent>
<groupId>com.gradecak.alfresco-mvc</groupId>
<version>8.0.0</version>
<version>9.0.0</version>
<artifactId>alfresco-mvc-parent</artifactId>
<relativePath>../</relativePath>
</parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import javax.transaction.SystemException;
import jakarta.transaction.SystemException;

import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.gradecak.alfresco.mvc.service;

import javax.transaction.SystemException;
import jakarta.transaction.SystemException;

import org.alfresco.model.ContentModel;
import org.alfresco.service.ServiceRegistry;
Expand Down
2 changes: 1 addition & 1 deletion alfresco-mvc-aop/src/test/resources/test-aop-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<context:property-placeholder location="values.properties" />

<bean id="ServiceRegistry" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.service.ServiceRegistry" />
<constructor-arg value="org.alfresco.service.ServiceRegistry" type="java.lang.Class"/>
</bean>

<import resource="classpath:com/gradecak/alfresco-mvc/alfresco-mvc-aop.xml" />
Expand Down
2 changes: 1 addition & 1 deletion alfresco-mvc-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<parent>
<groupId>com.gradecak.alfresco-mvc</groupId>
<version>8.0.0</version>
<version>9.0.0</version>
<artifactId>alfresco-mvc-parent</artifactId>
<relativePath>../</relativePath>
</parent>
Expand Down
6 changes: 3 additions & 3 deletions alfresco-mvc-rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<parent>
<groupId>com.gradecak.alfresco-mvc</groupId>
<version>8.0.0</version>
<version>9.0.0</version>
<artifactId>alfresco-mvc-parent</artifactId>
<relativePath>../</relativePath>
</parent>
Expand All @@ -17,8 +17,8 @@

<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.gradecak.alfresco.mvc.rest;

import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

import org.alfresco.rest.framework.resource.parameters.Params;
import org.alfresco.rest.framework.resource.parameters.Params.RecognizedParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.lang.annotation.Target;

import org.springframework.context.annotation.Import;
import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.context.WebApplicationContext;

import com.gradecak.alfresco.mvc.rest.config.AlfrescoRestRegistrar;
Expand All @@ -40,7 +40,7 @@
public @interface AlfrescoDispatcherWebscript {
String name() default "alfresco-mvc.mvc";

HttpMethod[] httpMethods() default { HttpMethod.GET, HttpMethod.POST, HttpMethod.DELETE, HttpMethod.PUT };
RequestMethod[] httpMethods() default { RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE, RequestMethod.PUT };

Class<?> servletContext();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.http.HttpMethod;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.context.WebApplicationContext;

import com.gradecak.alfresco.mvc.rest.annotation.AlfrescoDispatcherWebscript;
Expand Down Expand Up @@ -79,7 +80,7 @@ private void processDispatcherWebscript(AnnotationAttributes webscriptAttributes
.get("servletConfigOptions");
Class<? extends WebApplicationContext> servletContextClass = webscriptAttributes
.getClass("servletContextClass");
HttpMethod[] httpMethods = (HttpMethod[]) webscriptAttributes.get("httpMethods");
RequestMethod[] httpRequestMethods = (RequestMethod[]) webscriptAttributes.get("httpMethods");
boolean inheritGlobalProperties = (Boolean) webscriptAttributes.get("inheritGlobalProperties");

GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
Expand All @@ -94,8 +95,8 @@ private void processDispatcherWebscript(AnnotationAttributes webscriptAttributes

registry.registerBeanDefinition(webscript, beanDefinition);

for (HttpMethod httpMethod : httpMethods) {
registry.registerAlias(webscript, getWebscriptName(webscript, httpMethod));
for (RequestMethod httpRequestMethod : httpRequestMethods) {
registry.registerAlias(webscript, getWebscriptName(webscript, httpRequestMethod.asHttpMethod()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.springframework.lang.Nullable;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.multipart.support.StandardServletMultipartResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.fasterxml.jackson.databind.DeserializationFeature;
Expand Down Expand Up @@ -83,9 +83,7 @@ public MultipartResolver multipartResolver() {
}

protected MultipartResolver createMultipartResolver() {
CommonsMultipartResolver resolver = new CommonsMultipartResolver();
resolver.setMaxUploadSize(-1);
resolver.setDefaultEncoding("utf-8");
StandardServletMultipartResolver resolver = new StandardServletMultipartResolver();
return resolver;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequestWrapper;
import jakarta.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.io.IOException;
import java.util.Map;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;

import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,10 @@ public void when_alfrescoMvcDispatcherServletConfigOptionsWithSuffix_expect_suff
.getBean(DispatcherServlet.class);
Assertions.assertNotNull(dispatcherServlet);

MockHttpServletResponse res = mockWebscript.withControllerMapping("/test/withsufix.test").execute();
MockHttpServletResponse res = mockWebscript.withControllerMapping("test/withsufix.test").execute();
Assertions.assertEquals(HttpStatus.OK.value(), res.getStatus());

String contentAsString = res.getContentAsString();
Assertions.assertEquals("withsufix", contentAsString);
}
//
// @Test
// public void when_alfrescoMvcDispatcherServletConfigOptionsWithoutSuffix_expect_ok() throws Exception {
// DispatcherServlet dispatcherServlet = dispatcherWebscript.getDispatcherServlet().getWebApplicationContext()
// .getBean(DispatcherServlet.class);
// Assertions.assertNotNull(dispatcherServlet);
//
// MockHttpServletResponse res = mockWebscript.withControllerMapping("/test/withoutsufix").execute();
// Assertions.assertEquals(HttpStatus.OK.value(), res.getStatus());
//
// String contentAsString = res.getContentAsString();
// Assertions.assertEquals("withoutsufix", contentAsString);
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,35 +59,13 @@ public void before() throws Exception {
mockWebscript.newRequest();
}

/**
* @deprecated as of Spring 5.2.4. See class-level note in
* {@link RequestMappingHandlerMapping} on the deprecation of path
* extension config options. As there is no replacement for this
* method, in Spring 5.2.x it is necessary to set it to
* {@code false}. In Spring 5.3 the default changes to {@code false}
* and use of this property becomes unnecessary.
*/
// @Deprecated
// @Test
// public void when_alfrescoMvcDispatcherServletConfigOptionsWithSuffix_expect_suffixHandledAndOk() throws Exception {
// DispatcherServlet dispatcherServlet = dispatcherWebscript.getDispatcherServlet().getWebApplicationContext()
// .getBean(DispatcherServlet.class);
// Assertions.assertNotNull(dispatcherServlet);
//
// MockHttpServletResponse res = mockWebscript.withControllerMapping("/test/withsufix.test").execute();
// Assertions.assertEquals(HttpStatus.OK.value(), res.getStatus());
//
// String contentAsString = res.getContentAsString();
// Assertions.assertEquals("withsufix", contentAsString);
// }

@Test
public void when_alfrescoMvcDispatcherServletConfigOptionsWithoutSuffix_expect_ok() throws Exception {
DispatcherServlet dispatcherServlet = dispatcherWebscript.getDispatcherServlet().getWebApplicationContext()
.getBean(DispatcherServlet.class);
Assertions.assertNotNull(dispatcherServlet);

MockHttpServletResponse res = mockWebscript.withControllerMapping("/test/withoutsufix").execute();
MockHttpServletResponse res = mockWebscript.withControllerMapping("test/withoutsufix").execute();
Assertions.assertEquals(HttpStatus.OK.value(), res.getStatus());

String contentAsString = res.getContentAsString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.List;
import java.util.Map;

import javax.servlet.http.Cookie;
import jakarta.servlet.http.Cookie;

import org.alfresco.service.namespace.NamespaceService;
import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -187,7 +187,7 @@ public void when_wrongHttpMethodWithRequiredParam_failMethodNotAllowed() throws
MockHttpServletResponse res = mockWebscript.withPostRequest().withParameters(ImmutableMap.of("id", "testId"))
.withControllerMapping("test/get").execute();
Assertions.assertEquals(res.getStatus(), HttpStatus.METHOD_NOT_ALLOWED.value());
Assertions.assertEquals("Request method 'POST' not supported", res.getErrorMessage());
Assertions.assertEquals("Method 'POST' is not supported.", res.getErrorMessage());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.io.IOException;
import java.util.Map;

import javax.servlet.http.Cookie;
import jakarta.servlet.http.Cookie;

import org.springframework.extensions.webscripts.AbstractWebScript;
import org.springframework.extensions.webscripts.Container;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Map;
import java.util.Map.Entry;

import javax.servlet.http.Cookie;
import jakarta.servlet.http.Cookie;

import org.springframework.extensions.webscripts.AbstractWebScript;
import org.springframework.extensions.webscripts.Match;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
</bean>

<bean id="ServiceRegistry" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.service.ServiceRegistry" />
<constructor-arg value="org.alfresco.service.ServiceRegistry" type="java.lang.Class"/>
</bean>

<bean id="NamespaceService" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.service.namespace.NamespaceService" />
<constructor-arg value="org.alfresco.service.namespace.NamespaceService" type="java.lang.Class"/>
</bean>


<bean id="webscriptHelper" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.alfresco.rest.framework.webscripts.ResourceWebScriptHelper" />
<constructor-arg value="org.alfresco.rest.framework.webscripts.ResourceWebScriptHelper" type="java.lang.Class"/>
</bean>

<!-- bean class="org.springframework.mock.web.MockServletContext" id="mockServletContext" />
Expand Down
Loading

0 comments on commit be3b058

Please sign in to comment.