Skip to content

Commit

Permalink
org.springframework.http.HttpMethod is not an Enum in spring 6 and ca…
Browse files Browse the repository at this point in the history
…n't be used as value in Annotation. Replace with org.springframework.web.bind.annotation.RequestMethod.
  • Loading branch information
niklassjo committed Nov 28, 2023
1 parent abaae9b commit b343d51
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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

0 comments on commit b343d51

Please sign in to comment.