From f5396338dd728dd95601c7e1de8915c6dddc91f6 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Fri, 28 Oct 2016 14:51:05 +0200 Subject: [PATCH] automatic project update --- .gitignore | 32 +- .yo-rc.json | 2 +- gulp/inject.js | 1 + gulpfile.js | 2 +- package.json | 2 +- pom.xml | 20 +- .../sample/config/CacheConfiguration.java | 31 +- .../sample/config/DefaultProfileUtil.java | 2 +- .../sample/config/JHipsterProperties.java | 11 - .../sample/config/LoggingConfiguration.java | 45 ++- .../sample/config/SecurityConfiguration.java | 7 +- .../config/apidoc/SwaggerConfiguration.java | 1 + .../sample/repository/UserRepository.java | 2 - .../security/CustomAccessDeniedHandler.java | 56 --- .../jhipster/sample/service/UserService.java | 4 +- .../web/filter/CsrfCookieGeneratorFilter.java | 36 -- .../sample/web/rest/AccountResource.java | 35 +- .../sample/web/rest/AuditResource.java | 11 +- .../sample/web/rest/BankAccountResource.java | 21 +- .../sample/web/rest/LabelResource.java | 21 +- .../sample/web/rest/LogsResource.java | 8 +- .../sample/web/rest/OperationResource.java | 21 +- .../sample/web/rest/ProfileInfoResource.java | 9 +- .../sample/web/rest/UserResource.java | 21 +- .../sample/web/rest/util/HeaderUtil.java | 2 +- .../sample/web/rest/util/PaginationUtil.java | 2 +- src/main/resources/config/application-dev.yml | 1 - .../resources/config/application-prod.yml | 1 - src/main/resources/config/application.yml | 5 + .../webapp/app/admin/metrics/metrics.html | 2 - .../webapp/app/blocks/config/http.config.js | 5 - .../interceptor/auth-expired.interceptor.js | 36 +- .../angular-loading-bar/build/loading-bar.css | 110 ------ .../angular-loading-bar/build/loading-bar.js | 341 ------------------ .../build/loading-bar.min.css | 1 - .../build/loading-bar.min.js | 7 - .../messageformat/bin/messageformat.js | 163 --------- .../bower_components/modernizr/bin/modernizr | 176 --------- .../modernizr/test/node/lib/build.js | 153 -------- .../modernizr/test/node/lib/cli.js | 21 -- .../modernizr/test/node/lib/metadata.js | 212 ----------- .../modernizr/test/node/lib/options.js | 34 -- .../ngInfiniteScroll/.bower.json | 4 +- .../build/ng-infinite-scroll.js | 189 ---------- .../build/ng-infinite-scroll.min.js | 2 - src/main/webapp/i18n/en/metrics.json | 3 +- src/main/webapp/swagger-ui/index.html | 4 +- .../simulations/BankAccountGatlingTest.scala | 10 +- .../simulations/LabelGatlingTest.scala | 10 +- .../simulations/OperationGatlingTest.scala | 10 +- 50 files changed, 149 insertions(+), 1756 deletions(-) delete mode 100644 src/main/java/io/github/jhipster/sample/security/CustomAccessDeniedHandler.java delete mode 100644 src/main/java/io/github/jhipster/sample/web/filter/CsrfCookieGeneratorFilter.java delete mode 100644 src/main/webapp/bower_components/angular-loading-bar/build/loading-bar.css delete mode 100644 src/main/webapp/bower_components/angular-loading-bar/build/loading-bar.js delete mode 100644 src/main/webapp/bower_components/angular-loading-bar/build/loading-bar.min.css delete mode 100644 src/main/webapp/bower_components/angular-loading-bar/build/loading-bar.min.js delete mode 100755 src/main/webapp/bower_components/messageformat/bin/messageformat.js delete mode 100755 src/main/webapp/bower_components/modernizr/bin/modernizr delete mode 100644 src/main/webapp/bower_components/modernizr/test/node/lib/build.js delete mode 100644 src/main/webapp/bower_components/modernizr/test/node/lib/cli.js delete mode 100644 src/main/webapp/bower_components/modernizr/test/node/lib/metadata.js delete mode 100644 src/main/webapp/bower_components/modernizr/test/node/lib/options.js delete mode 100644 src/main/webapp/bower_components/ngInfiniteScroll/build/ng-infinite-scroll.js delete mode 100644 src/main/webapp/bower_components/ngInfiniteScroll/build/ng-infinite-scroll.min.js diff --git a/.gitignore b/.gitignore index c99c1592..b1a99111 100644 --- a/.gitignore +++ b/.gitignore @@ -6,14 +6,14 @@ ###################### # Node ###################### -/node/** -/node_tmp/** -/node_modules/** +node/ +node_tmp/ +node_modules/ ###################### # SASS ###################### -.sass-cache/** +.sass-cache/ ###################### # Eclipse @@ -21,15 +21,15 @@ *.pydevproject .project .metadata -/tmp/** -/tmp/**/* +tmp/ +tmp/**/* *.tmp *.bak *.swp *~.nib local.properties .classpath -.settings/** +.settings/ .loadpath /src/main/resources/rebel.xml @@ -48,7 +48,7 @@ local.properties ###################### # Intellij ###################### -.idea/** +.idea/ *.iml *.iws *.ipr @@ -58,18 +58,18 @@ local.properties ###################### # Visual Studio Code ###################### -.vscode/** +.vscode/ ###################### # Maven ###################### -/log/** -/target/** +log/ +target/ ###################### # Gradle ###################### -.gradle/** +.gradle/ ###################### # Package Files @@ -104,10 +104,10 @@ Desktop.ini ###################### # Directories ###################### -/build/** -/bin/** -/spring_loaded/** -/deploy/** +build/ +bin/ +spring_loaded/ +deploy/ ###################### # Logs diff --git a/.yo-rc.json b/.yo-rc.json index 74b3c639..8a24eaf3 100644 --- a/.yo-rc.json +++ b/.yo-rc.json @@ -24,7 +24,7 @@ "en" ], "serverPort": 8080, - "jhipsterVersion": "3.9.1", + "jhipsterVersion": "3.10.0", "enableSocialSignIn": false, "useSass": false, "jhiPrefix": "jhi", diff --git a/gulp/inject.js b/gulp/inject.js index 30c575b0..1808e31a 100644 --- a/gulp/inject.js +++ b/gulp/inject.js @@ -22,6 +22,7 @@ module.exports = { function app() { return gulp.src(config.app + 'index.html') .pipe(inject(gulp.src(config.app + 'app/**/*.js') + .pipe(plumber({errorHandler: handleErrors})) .pipe(naturalSort()) .pipe(angularFilesort()), {relative: true})) .pipe(gulp.dest(config.app)); diff --git a/gulpfile.js b/gulpfile.js index 45ef5a30..9518772d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,4 +1,4 @@ -// Generated on 2016-10-11 using generator-jhipster 3.9.1 +// Generated on 2016-10-28 using generator-jhipster 3.10.0 'use strict'; var gulp = require('gulp'), diff --git a/package.json b/package.json index 675a3487..d63cfe34 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "eslint-config-angular": "0.5.0", "eslint-plugin-angular": "1.3.1", "event-stream": "3.3.4", - "generator-jhipster": "3.9.1", + "generator-jhipster": "3.10.0", "gulp": "3.9.1", "gulp-angular-filesort": "1.1.1", "gulp-angular-templatecache": "2.0.0", diff --git a/pom.xml b/pom.xml index a19e953e..c9a62494 100644 --- a/pom.xml +++ b/pom.xml @@ -46,7 +46,7 @@ 3.1.3 4.7 false - 4.1.0.RELEASE + 4.1.3.RELEASE 2.5.0 ${project.build.directory}/test-results @@ -163,6 +163,11 @@ + + io.springfox + springfox-bean-validators + ${springfox.version} + com.mattbertolini liquibase-slf4j @@ -214,7 +219,6 @@ ${gatling.version} test - javax.inject javax.inject @@ -355,16 +359,8 @@ - org.springframework.cloud - spring-cloud-cloudfoundry-connector - - - org.springframework.cloud - spring-cloud-spring-service-connector - - - org.springframework.cloud - spring-cloud-localconfig-connector + org.springframework.boot + spring-boot-starter-cloud-connectors diff --git a/src/main/java/io/github/jhipster/sample/config/CacheConfiguration.java b/src/main/java/io/github/jhipster/sample/config/CacheConfiguration.java index a5737ce2..93c325df 100644 --- a/src/main/java/io/github/jhipster/sample/config/CacheConfiguration.java +++ b/src/main/java/io/github/jhipster/sample/config/CacheConfiguration.java @@ -9,16 +9,13 @@ import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.*; import org.springframework.cache.ehcache.EhCacheCacheManager; -import org.springframework.util.Assert; import javax.annotation.PreDestroy; import javax.inject.Inject; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; -import javax.persistence.metamodel.EntityType; -import javax.persistence.metamodel.PluralAttribute; -import java.util.Set; import java.util.SortedSet; +import java.util.stream.Stream; @SuppressWarnings("unused") @Configuration @@ -51,30 +48,12 @@ public class CacheConfiguration { cacheManager = net.sf.ehcache.CacheManager.create(); cacheManager.getConfiguration().setMaxBytesLocalHeap(jHipsterProperties.getCache().getEhcache().getMaxBytesLocalHeap()); log.debug("Registering Ehcache Metrics gauges"); - Set> entities = entityManager.getMetamodel().getEntities(); - for (EntityType entity : entities) { - String name = entity.getName(); - if (name == null || entity.getJavaType() != null) { - name = entity.getJavaType().getName(); - } - Assert.notNull(name, "entity cannot exist without an identifier"); - reconfigureCache(name, jHipsterProperties); - for (PluralAttribute pluralAttribute : entity.getPluralAttributes()) { - reconfigureCache(name + "." + pluralAttribute.getName(), jHipsterProperties); - } - } + Stream.of(cacheManager.getCacheNames()).forEach(name -> { + net.sf.ehcache.Cache cache = cacheManager.getCache(name); + cacheManager.replaceCacheWithDecoratedCache(cache, InstrumentedEhcache.instrument(metricRegistry, cache)); + }); EhCacheCacheManager ehCacheManager = new EhCacheCacheManager(); ehCacheManager.setCacheManager(cacheManager); return ehCacheManager; } - - private void reconfigureCache(String name, JHipsterProperties jHipsterProperties) { - net.sf.ehcache.Cache cache = cacheManager.getCache(name); - if (cache != null) { - cache.getCacheConfiguration().setTimeToLiveSeconds(jHipsterProperties.getCache().getTimeToLiveSeconds()); - net.sf.ehcache.Ehcache decoratedCache = InstrumentedEhcache.instrument(metricRegistry, cache); - cacheManager.replaceCacheWithDecoratedCache(cache, decoratedCache); - } - } - } diff --git a/src/main/java/io/github/jhipster/sample/config/DefaultProfileUtil.java b/src/main/java/io/github/jhipster/sample/config/DefaultProfileUtil.java index 6f12e312..6e47683a 100644 --- a/src/main/java/io/github/jhipster/sample/config/DefaultProfileUtil.java +++ b/src/main/java/io/github/jhipster/sample/config/DefaultProfileUtil.java @@ -14,7 +14,7 @@ public final class DefaultProfileUtil { private static final String SPRING_PROFILE_DEFAULT = "spring.profiles.default"; - private DefaultProfileUtil(){ + private DefaultProfileUtil() { } /** diff --git a/src/main/java/io/github/jhipster/sample/config/JHipsterProperties.java b/src/main/java/io/github/jhipster/sample/config/JHipsterProperties.java index 03356286..51e121da 100644 --- a/src/main/java/io/github/jhipster/sample/config/JHipsterProperties.java +++ b/src/main/java/io/github/jhipster/sample/config/JHipsterProperties.java @@ -124,19 +124,8 @@ public class JHipsterProperties { } public static class Cache { - - private int timeToLiveSeconds = 3600; - private final Ehcache ehcache = new Ehcache(); - public int getTimeToLiveSeconds() { - return timeToLiveSeconds; - } - - public void setTimeToLiveSeconds(int timeToLiveSeconds) { - this.timeToLiveSeconds = timeToLiveSeconds; - } - public Ehcache getEhcache() { return ehcache; } diff --git a/src/main/java/io/github/jhipster/sample/config/LoggingConfiguration.java b/src/main/java/io/github/jhipster/sample/config/LoggingConfiguration.java index cc16a7b8..12359950 100644 --- a/src/main/java/io/github/jhipster/sample/config/LoggingConfiguration.java +++ b/src/main/java/io/github/jhipster/sample/config/LoggingConfiguration.java @@ -1,7 +1,10 @@ package io.github.jhipster.sample.config; import ch.qos.logback.classic.AsyncAppender; +import ch.qos.logback.classic.Level; import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.spi.LoggerContextListener; +import ch.qos.logback.core.spi.ContextAwareBase; import net.logstash.logback.appender.LogstashSocketAppender; import net.logstash.logback.stacktrace.ShortenedThrowableConverter; import org.slf4j.Logger; @@ -32,11 +35,16 @@ public class LoggingConfiguration { @PostConstruct private void init() { if (jHipsterProperties.getLogging().getLogstash().isEnabled()) { - addLogstashAppender(); + addLogstashAppender(context); + + // Add context listener + LogbackLoggerContextListener loggerContextListener = new LogbackLoggerContextListener(); + loggerContextListener.setContext(context); + context.addListener(loggerContextListener); } } - public void addLogstashAppender() { + public void addLogstashAppender(LoggerContext context) { log.info("Initializing Logstash logging"); LogstashSocketAppender logstashAppender = new LogstashSocketAppender(); @@ -67,4 +75,37 @@ public class LoggingConfiguration { context.getLogger("ROOT").addAppender(asyncLogstashAppender); } + + + /** + * Logback configuration is achieved by configuration file and API. + * When configuration file change is detected, the configuration is reset. + * This listener ensures that the programmatic configuration is also re-applied after reset. + */ + class LogbackLoggerContextListener extends ContextAwareBase implements LoggerContextListener { + + @Override + public boolean isResetResistant() { + return true; + } + + @Override + public void onStart(LoggerContext context) { + addLogstashAppender(context); + } + + @Override + public void onReset(LoggerContext context) { + addLogstashAppender(context); + } + + @Override + public void onStop(LoggerContext context) { + } + + @Override + public void onLevelChange(ch.qos.logback.classic.Logger logger, Level level) { + } + } + } diff --git a/src/main/java/io/github/jhipster/sample/config/SecurityConfiguration.java b/src/main/java/io/github/jhipster/sample/config/SecurityConfiguration.java index 623e564f..afc54af7 100644 --- a/src/main/java/io/github/jhipster/sample/config/SecurityConfiguration.java +++ b/src/main/java/io/github/jhipster/sample/config/SecurityConfiguration.java @@ -1,7 +1,6 @@ package io.github.jhipster.sample.config; import io.github.jhipster.sample.security.*; -import io.github.jhipster.sample.web.filter.CsrfCookieGeneratorFilter; import io.github.jhipster.sample.config.JHipsterProperties; import org.springframework.beans.factory.BeanInitializationException; @@ -19,7 +18,7 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.data.repository.query.SecurityEvaluationContextExtension; import org.springframework.security.web.authentication.RememberMeServices; -import org.springframework.security.web.csrf.CsrfFilter; +import org.springframework.security.web.csrf.CookieCsrfTokenRepository; import javax.inject.Inject; @@ -82,10 +81,9 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { protected void configure(HttpSecurity http) throws Exception { http .csrf() + .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) .and() - .addFilterAfter(new CsrfCookieGeneratorFilter(), CsrfFilter.class) .exceptionHandling() - .accessDeniedHandler(new CustomAccessDeniedHandler()) .authenticationEntryPoint(authenticationEntryPoint) .and() .rememberMe() @@ -104,7 +102,6 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { .logout() .logoutUrl("/api/logout") .logoutSuccessHandler(ajaxLogoutSuccessHandler) - .deleteCookies("JSESSIONID", "CSRF-TOKEN") .permitAll() .and() .headers() diff --git a/src/main/java/io/github/jhipster/sample/config/apidoc/SwaggerConfiguration.java b/src/main/java/io/github/jhipster/sample/config/apidoc/SwaggerConfiguration.java index 5c236f5f..50eaae98 100644 --- a/src/main/java/io/github/jhipster/sample/config/apidoc/SwaggerConfiguration.java +++ b/src/main/java/io/github/jhipster/sample/config/apidoc/SwaggerConfiguration.java @@ -28,6 +28,7 @@ import static springfox.documentation.builders.PathSelectors.regex; */ @Configuration @EnableSwagger2 +@Import(springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration.class) @Profile(Constants.SPRING_PROFILE_SWAGGER) public class SwaggerConfiguration { diff --git a/src/main/java/io/github/jhipster/sample/repository/UserRepository.java b/src/main/java/io/github/jhipster/sample/repository/UserRepository.java index 56a38713..7bfdff89 100644 --- a/src/main/java/io/github/jhipster/sample/repository/UserRepository.java +++ b/src/main/java/io/github/jhipster/sample/repository/UserRepository.java @@ -26,8 +26,6 @@ public interface UserRepository extends JpaRepository { Optional findOneByLogin(String login); - Optional findOneById(Long userId); - @Query(value = "select distinct user from User user left join fetch user.authorities", countQuery = "select count(user) from User user") Page findAllWithAuthorities(Pageable pageable); diff --git a/src/main/java/io/github/jhipster/sample/security/CustomAccessDeniedHandler.java b/src/main/java/io/github/jhipster/sample/security/CustomAccessDeniedHandler.java deleted file mode 100644 index 7f9d6bba..00000000 --- a/src/main/java/io/github/jhipster/sample/security/CustomAccessDeniedHandler.java +++ /dev/null @@ -1,56 +0,0 @@ -package io.github.jhipster.sample.security; - -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.security.access.AccessDeniedException; -import org.springframework.security.web.access.AccessDeniedHandler; -import org.springframework.security.web.access.AccessDeniedHandlerImpl; -import org.springframework.security.web.csrf.CsrfException; - -/** - * An implementation of AccessDeniedHandler by wrapping the AccessDeniedHandlerImpl. - * - * In addition to sending a 403 (SC_FORBIDDEN) HTTP error code, it will remove the invalid CSRF cookie from the browser - * side when a CsrfException occurs. In this way the browser side application, e.g. JavaScript code, can - * distinguish the CsrfException from other AccessDeniedExceptions and perform more specific operations. For instance, - * send a GET HTTP method to obtain a new CSRF token. - * - * @see AccessDeniedHandlerImpl - */ -public class CustomAccessDeniedHandler implements AccessDeniedHandler { - - private AccessDeniedHandlerImpl accessDeniedHandlerImpl = new AccessDeniedHandlerImpl(); - - public void handle(HttpServletRequest request, HttpServletResponse response, - AccessDeniedException accessDeniedException) throws IOException, ServletException { - - if (accessDeniedException instanceof CsrfException && !response.isCommitted()) { - // Remove the session cookie so that client knows it's time to obtain a new CSRF token - String pCookieName = "CSRF-TOKEN"; - Cookie cookie = new Cookie(pCookieName, ""); - cookie.setMaxAge(0); - cookie.setHttpOnly(false); - cookie.setPath("/"); - response.addCookie(cookie); - } - - accessDeniedHandlerImpl.handle(request, response, accessDeniedException); - } - - /** - * The error page to use. Must begin with a "/" and is interpreted relative to the current context root. - * - * @param errorPage the dispatcher path to display - * - * @throws IllegalArgumentException if the argument doesn't comply with the above limitations - * @see AccessDeniedHandlerImpl#setErrorPage(String) - */ - public void setErrorPage(String errorPage) { - accessDeniedHandlerImpl.setErrorPage(errorPage); - } -} diff --git a/src/main/java/io/github/jhipster/sample/service/UserService.java b/src/main/java/io/github/jhipster/sample/service/UserService.java index 3827940d..41d1ec7a 100644 --- a/src/main/java/io/github/jhipster/sample/service/UserService.java +++ b/src/main/java/io/github/jhipster/sample/service/UserService.java @@ -150,8 +150,8 @@ public class UserService { public void updateUser(Long id, String login, String firstName, String lastName, String email, boolean activated, String langKey, Set authorities) { - userRepository - .findOneById(id) + Optional.of(userRepository + .findOne(id)) .ifPresent(u -> { u.setLogin(login); u.setFirstName(firstName); diff --git a/src/main/java/io/github/jhipster/sample/web/filter/CsrfCookieGeneratorFilter.java b/src/main/java/io/github/jhipster/sample/web/filter/CsrfCookieGeneratorFilter.java deleted file mode 100644 index 3fbeaf8f..00000000 --- a/src/main/java/io/github/jhipster/sample/web/filter/CsrfCookieGeneratorFilter.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.github.jhipster.sample.web.filter; - -import org.springframework.security.web.csrf.CsrfToken; -import org.springframework.web.filter.OncePerRequestFilter; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Filter used to put the CSRF token generated by Spring Security in a cookie for use by AngularJS. - */ -public class CsrfCookieGeneratorFilter extends OncePerRequestFilter { - - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { - // Spring put the CSRF token in session attribute "_csrf" - CsrfToken csrfToken = (CsrfToken) request.getAttribute("_csrf"); - - // Send the cookie only if the token has changed - String actualToken = request.getHeader("X-CSRF-TOKEN"); - if (actualToken == null || !actualToken.equals(csrfToken.getToken())) { - // Session cookie that will be used by AngularJS - String pCookieName = "CSRF-TOKEN"; - Cookie cookie = new Cookie(pCookieName, csrfToken.getToken()); - cookie.setMaxAge(-1); - cookie.setHttpOnly(false); - cookie.setPath("/"); - response.addCookie(cookie); - } - filterChain.doFilter(request, response); - } -} diff --git a/src/main/java/io/github/jhipster/sample/web/rest/AccountResource.java b/src/main/java/io/github/jhipster/sample/web/rest/AccountResource.java index 5bc81b2d..23cb637e 100644 --- a/src/main/java/io/github/jhipster/sample/web/rest/AccountResource.java +++ b/src/main/java/io/github/jhipster/sample/web/rest/AccountResource.java @@ -58,8 +58,7 @@ public class AccountResource { * @param request the HTTP request * @return the ResponseEntity with status 201 (Created) if the user is registered or 400 (Bad Request) if the login or e-mail is already in use */ - @RequestMapping(value = "/register", - method = RequestMethod.POST, + @PostMapping(path = "/register", produces={MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_PLAIN_VALUE}) @Timed public ResponseEntity registerAccount(@Valid @RequestBody ManagedUserVM managedUserVM, HttpServletRequest request) { @@ -94,9 +93,7 @@ public class AccountResource { * @param key the activation key * @return the ResponseEntity with status 200 (OK) and the activated user in body, or status 500 (Internal Server Error) if the user couldn't be activated */ - @RequestMapping(value = "/activate", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping("/activate") @Timed public ResponseEntity activateAccount(@RequestParam(value = "key") String key) { return userService.activateRegistration(key) @@ -110,9 +107,7 @@ public class AccountResource { * @param request the HTTP request * @return the login if the user is authenticated */ - @RequestMapping(value = "/authenticate", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping("/authenticate") @Timed public String isAuthenticated(HttpServletRequest request) { log.debug("REST request to check if the current user is authenticated"); @@ -124,9 +119,7 @@ public class AccountResource { * * @return the ResponseEntity with status 200 (OK) and the current user in body, or status 500 (Internal Server Error) if the user couldn't be returned */ - @RequestMapping(value = "/account", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping("/account") @Timed public ResponseEntity getAccount() { return Optional.ofNullable(userService.getUserWithAuthorities()) @@ -140,9 +133,7 @@ public class AccountResource { * @param userDTO the current user information * @return the ResponseEntity with status 200 (OK), or status 400 (Bad Request) or 500 (Internal Server Error) if the user couldn't be updated */ - @RequestMapping(value = "/account", - method = RequestMethod.POST, - produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping("/account") @Timed public ResponseEntity saveAccount(@Valid @RequestBody UserDTO userDTO) { Optional existingUser = userRepository.findOneByEmail(userDTO.getEmail()); @@ -165,8 +156,7 @@ public class AccountResource { * @param password the new password * @return the ResponseEntity with status 200 (OK), or status 400 (Bad Request) if the new password is not strong enough */ - @RequestMapping(value = "/account/change_password", - method = RequestMethod.POST, + @PostMapping(path = "/account/change_password", produces = MediaType.TEXT_PLAIN_VALUE) @Timed public ResponseEntity changePassword(@RequestBody String password) { @@ -183,9 +173,7 @@ public class AccountResource { * @return the ResponseEntity with status 200 (OK) and the current open sessions in body, * or status 500 (Internal Server Error) if the current open sessions couldn't be retrieved */ - @RequestMapping(value = "/account/sessions", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping("/account/sessions") @Timed public ResponseEntity> getCurrentSessions() { return userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()) @@ -211,8 +199,7 @@ public class AccountResource { * @param series the series of an existing session * @throws UnsupportedEncodingException if the series couldnt be URL decoded */ - @RequestMapping(value = "/account/sessions/{series}", - method = RequestMethod.DELETE) + @DeleteMapping("/account/sessions/{series}") @Timed public void invalidateSession(@PathVariable String series) throws UnsupportedEncodingException { String decodedSeries = URLDecoder.decode(series, "UTF-8"); @@ -230,8 +217,7 @@ public class AccountResource { * @param request the HTTP request * @return the ResponseEntity with status 200 (OK) if the e-mail was sent, or status 400 (Bad Request) if the e-mail address is not registered */ - @RequestMapping(value = "/account/reset_password/init", - method = RequestMethod.POST, + @PostMapping(path = "/account/reset_password/init", produces = MediaType.TEXT_PLAIN_VALUE) @Timed public ResponseEntity requestPasswordReset(@RequestBody String mail, HttpServletRequest request) { @@ -255,8 +241,7 @@ public class AccountResource { * @return the ResponseEntity with status 200 (OK) if the password has been reset, * or status 400 (Bad Request) or 500 (Internal Server Error) if the password could not be reset */ - @RequestMapping(value = "/account/reset_password/finish", - method = RequestMethod.POST, + @PostMapping(path = "/account/reset_password/finish", produces = MediaType.TEXT_PLAIN_VALUE) @Timed public ResponseEntity finishPasswordReset(@RequestBody KeyAndPasswordVM keyAndPassword) { diff --git a/src/main/java/io/github/jhipster/sample/web/rest/AuditResource.java b/src/main/java/io/github/jhipster/sample/web/rest/AuditResource.java index 47935704..947b9c68 100644 --- a/src/main/java/io/github/jhipster/sample/web/rest/AuditResource.java +++ b/src/main/java/io/github/jhipster/sample/web/rest/AuditResource.java @@ -8,7 +8,6 @@ import org.springframework.boot.actuate.audit.AuditEvent; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import org.springframework.http.HttpStatus; import org.springframework.http.HttpHeaders; @@ -22,7 +21,7 @@ import java.util.List; * REST controller for getting the audit events. */ @RestController -@RequestMapping(value = "/management/jhipster/audits", produces = MediaType.APPLICATION_JSON_VALUE) +@RequestMapping("/management/jhipster/audits") public class AuditResource { private AuditEventService auditEventService; @@ -39,7 +38,7 @@ public class AuditResource { * @return the ResponseEntity with status 200 (OK) and the list of AuditEvents in body * @throws URISyntaxException if there is an error to generate the pagination HTTP headers */ - @RequestMapping(method = RequestMethod.GET) + @GetMapping public ResponseEntity> getAll(Pageable pageable) throws URISyntaxException { Page page = auditEventService.findAll(pageable); HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/audits"); @@ -56,8 +55,7 @@ public class AuditResource { * @throws URISyntaxException if there is an error to generate the pagination HTTP headers */ - @RequestMapping(method = RequestMethod.GET, - params = {"fromDate", "toDate"}) + @GetMapping(params = {"fromDate", "toDate"}) public ResponseEntity> getByDates( @RequestParam(value = "fromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate, @RequestParam(value = "toDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate, @@ -74,8 +72,7 @@ public class AuditResource { * @param id the id of the entity to get * @return the ResponseEntity with status 200 (OK) and the AuditEvent in body, or status 404 (Not Found) */ - @RequestMapping(value = "/{id:.+}", - method = RequestMethod.GET) + @GetMapping("/{id:.+}") public ResponseEntity get(@PathVariable Long id) { return auditEventService.find(id) .map((entity) -> new ResponseEntity<>(entity, HttpStatus.OK)) diff --git a/src/main/java/io/github/jhipster/sample/web/rest/BankAccountResource.java b/src/main/java/io/github/jhipster/sample/web/rest/BankAccountResource.java index 4fe22833..32c2f3d4 100644 --- a/src/main/java/io/github/jhipster/sample/web/rest/BankAccountResource.java +++ b/src/main/java/io/github/jhipster/sample/web/rest/BankAccountResource.java @@ -9,7 +9,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -39,9 +38,7 @@ public class BankAccountResource { * @return the ResponseEntity with status 201 (Created) and with body the new bankAccount, or with status 400 (Bad Request) if the bankAccount has already an ID * @throws URISyntaxException if the Location URI syntax is incorrect */ - @RequestMapping(value = "/bank-accounts", - method = RequestMethod.POST, - produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping("/bank-accounts") @Timed public ResponseEntity createBankAccount(@Valid @RequestBody BankAccount bankAccount) throws URISyntaxException { log.debug("REST request to save BankAccount : {}", bankAccount); @@ -63,9 +60,7 @@ public class BankAccountResource { * or with status 500 (Internal Server Error) if the bankAccount couldnt be updated * @throws URISyntaxException if the Location URI syntax is incorrect */ - @RequestMapping(value = "/bank-accounts", - method = RequestMethod.PUT, - produces = MediaType.APPLICATION_JSON_VALUE) + @PutMapping("/bank-accounts") @Timed public ResponseEntity updateBankAccount(@Valid @RequestBody BankAccount bankAccount) throws URISyntaxException { log.debug("REST request to update BankAccount : {}", bankAccount); @@ -83,9 +78,7 @@ public class BankAccountResource { * * @return the ResponseEntity with status 200 (OK) and the list of bankAccounts in body */ - @RequestMapping(value = "/bank-accounts", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping("/bank-accounts") @Timed public List getAllBankAccounts() { log.debug("REST request to get all BankAccounts"); @@ -99,9 +92,7 @@ public class BankAccountResource { * @param id the id of the bankAccount to retrieve * @return the ResponseEntity with status 200 (OK) and with body the bankAccount, or with status 404 (Not Found) */ - @RequestMapping(value = "/bank-accounts/{id}", - method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping("/bank-accounts/{id}") @Timed public ResponseEntity getBankAccount(@PathVariable Long id) { log.debug("REST request to get BankAccount : {}", id); @@ -119,9 +110,7 @@ public class BankAccountResource { * @param id the id of the bankAccount to delete * @return the ResponseEntity with status 200 (OK) */ - @RequestMapping(value = "/bank-accounts/{id}", - method = RequestMethod.DELETE, - produces = MediaType.APPLICATION_JSON_VALUE) + @DeleteMapping("/bank-accounts/{id}") @Timed public ResponseEntity deleteBankAccount(@PathVariable Long id) { log.debug("REST request to delete BankAccount : {}", id); diff --git a/src/main/java/io/github/jhipster/sample/web/rest/LabelResource.java b/src/main/java/io/github/jhipster/sample/web/rest/LabelResource.java index b498c8c3..3d8eb803 100644 --- a/src/main/java/io/github/jhipster/sample/web/rest/LabelResource.java +++ b/src/main/java/io/github/jhipster/sample/web/rest/LabelResource.java @@ -9,7 +9,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -39,9 +38,7 @@ public class LabelResource { * @return the ResponseEntity with status 201 (Created) and with body the new label, or with status 400 (Bad Request) if the label has already an ID * @throws URISyntaxException if the Location URI syntax is incorrect */ - @RequestMapping(value = "/labels", - method = RequestMethod.POST, - produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping("/labels") @Timed public ResponseEntity