-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change Jax-Rs for Spring Rest / Mvc Add Swagger dependencies
- Loading branch information
1 parent
88cdfe3
commit 04fa580
Showing
47 changed files
with
817 additions
and
786 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
eclipse.preferences.version=1 | ||
encoding//src/main/java=UTF-8 | ||
encoding//src/main/resources=UTF-8 | ||
encoding//src/test/java=UTF-8 | ||
encoding//src/test/resources=UTF-8 | ||
encoding/<project>=UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.apt.aptEnabled=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore | ||
org.eclipse.jdt.core.compiler.processAnnotations=disabled | ||
org.eclipse.jdt.core.compiler.release=disabled | ||
org.eclipse.jdt.core.compiler.source=1.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...pp/src/main/java/org/georchestra/cadastrapp/configuration/CadastrappControllerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.georchestra.cadastrapp.configuration; | ||
|
||
import javax.servlet.ServletContext; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.ServletRegistration; | ||
|
||
import org.springframework.web.WebApplicationInitializer; | ||
import org.springframework.web.context.ContextLoaderListener; | ||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; | ||
import org.springframework.web.context.support.GenericWebApplicationContext; | ||
import org.springframework.web.servlet.DispatcherServlet; | ||
|
||
public class CadastrappControllerConfig implements WebApplicationInitializer { | ||
|
||
@Override | ||
public void onStartup(ServletContext sc) throws ServletException { | ||
AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); | ||
|
||
root.refresh(); | ||
root.setServletContext(sc); | ||
|
||
sc.addListener(new ContextLoaderListener(root)); | ||
|
||
DispatcherServlet dv = new DispatcherServlet(new GenericWebApplicationContext()); | ||
|
||
ServletRegistration.Dynamic appServlet = sc.addServlet("cadastrapp", dv); | ||
appServlet.setLoadOnStartup(1); | ||
appServlet.addMapping("/services/*"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,13 @@ | |
import org.springframework.beans.BeansException; | ||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; | ||
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; | ||
|
||
/** | ||
* | ||
* CadastrappPlaceHolder | ||
* | ||
* @author Pierre Jégo / [email protected] | ||
* | ||
*/ | ||
public class CadastrappPlaceHolder extends PropertyPlaceholderConfigurer { | ||
|
||
private static Map<String, String> propertiesMap; | ||
|
40 changes: 40 additions & 0 deletions
40
cadastrapp/src/main/java/org/georchestra/cadastrapp/configuration/SwaggerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.georchestra.cadastrapp.configuration; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import io.swagger.annotations.Contact; | ||
import springfox.documentation.builders.ApiInfoBuilder; | ||
import springfox.documentation.builders.PathSelectors; | ||
import springfox.documentation.builders.RequestHandlerSelectors; | ||
import springfox.documentation.service.ApiInfo; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; | ||
|
||
@Configuration | ||
@EnableSwagger2WebMvc | ||
public class SwaggerConfig { | ||
|
||
@Bean | ||
public Docket api(){ | ||
return new Docket(DocumentationType.SWAGGER_2) | ||
.select() | ||
.apis(RequestHandlerSelectors.any()) | ||
.paths(PathSelectors.regex("/api/.*")) | ||
.build() | ||
.apiInfo(apiInfo()); | ||
} | ||
|
||
private ApiInfo apiInfo() { | ||
return new ApiInfoBuilder() | ||
.title("TITLE") | ||
.description("DESCRIPTION") | ||
.version("VERSION") | ||
.termsOfServiceUrl("http://terms-of-services.url") | ||
.license("LICENSE") | ||
.licenseUrl("http://url-to-license.com") | ||
.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
* | ||
* Context listener specific for cadastrapp | ||
* | ||
* @author pierrejego | ||
* @author Pierre Jégo / [email protected] | ||
* | ||
*/ | ||
public class CadastrappContextListener implements ServletContextListener{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
cadastrapp/src/main/java/org/georchestra/cadastrapp/providers/CadastrappInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.georchestra.cadastrapp.providers; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.slf4j.MDC; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.servlet.HandlerInterceptor; | ||
import org.springframework.web.servlet.ModelAndView; | ||
|
||
/** | ||
* Log all request | ||
* @author Pierre Jégo | ||
* | ||
*/ | ||
@Component | ||
public class CadastrappInterceptor implements HandlerInterceptor { | ||
|
||
final Logger logger = LoggerFactory.getLogger(CadastrappInterceptor.class); | ||
|
||
@Override | ||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) | ||
throws Exception { | ||
|
||
String rolesList = request.getHeader("sec-roles"); | ||
String userName = request.getHeader("sec-username"); | ||
MDC.put("user", userName); | ||
MDC.put("roles", rolesList); | ||
MDC.put("uri", request.getRequestURI()); | ||
|
||
logger.info("Incoming request"); | ||
|
||
if(logger.isDebugEnabled()){ | ||
logger.debug("Parameter list : " + StringUtils.join(request.getParameterMap())); | ||
} | ||
return true; | ||
} | ||
|
||
|
||
@Override | ||
public void postHandle( HttpServletRequest request, HttpServletResponse response, | ||
Object handler, ModelAndView modelAndView) throws Exception { | ||
|
||
logger.info("Response"); | ||
MDC.remove("user"); | ||
MDC.remove("roles"); | ||
MDC.remove("uri"); | ||
} | ||
|
||
} |
Oops, something went wrong.