automatic project update

This commit is contained in:
Julien Dubois 2016-10-28 14:51:05 +02:00
parent b62fd1d51c
commit f5396338dd
50 changed files with 149 additions and 1756 deletions

32
.gitignore vendored
View File

@ -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

View File

@ -24,7 +24,7 @@
"en"
],
"serverPort": 8080,
"jhipsterVersion": "3.9.1",
"jhipsterVersion": "3.10.0",
"enableSocialSignIn": false,
"useSass": false,
"jhiPrefix": "jhi",

View File

@ -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));

View File

@ -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'),

View File

@ -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",

20
pom.xml
View File

@ -46,7 +46,7 @@
<metrics-spring.version>3.1.3</metrics-spring.version>
<logstash-logback-encoder.version>4.7</logstash-logback-encoder.version>
<run.addResources>false</run.addResources>
<spring-security.version>4.1.0.RELEASE</spring-security.version>
<spring-security.version>4.1.3.RELEASE</spring-security.version>
<springfox.version>2.5.0</springfox.version>
<!-- Sonar properties -->
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
@ -163,6 +163,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>com.mattbertolini</groupId>
<artifactId>liquibase-slf4j</artifactId>
@ -214,7 +219,6 @@
<version>${gatling.version}</version>
<scope>test</scope>
</dependency>
<!-- include netty handler explicitly to overcome dependency mismatch when using cassandra -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
@ -355,16 +359,8 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-cloudfoundry-connector</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-spring-service-connector</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-localconfig-connector</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
</dependency>
<!-- security -->
<dependency>

View File

@ -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<EntityType<?>> 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);
}
}
}

View File

@ -14,7 +14,7 @@ public final class DefaultProfileUtil {
private static final String SPRING_PROFILE_DEFAULT = "spring.profiles.default";
private DefaultProfileUtil(){
private DefaultProfileUtil() {
}
/**

View File

@ -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;
}

View File

@ -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) {
}
}
}

View File

@ -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()

View File

@ -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 {

View File

@ -26,8 +26,6 @@ public interface UserRepository extends JpaRepository<User, Long> {
Optional<User> findOneByLogin(String login);
Optional<User> findOneById(Long userId);
@Query(value = "select distinct user from User user left join fetch user.authorities",
countQuery = "select count(user) from User user")
Page<User> findAllWithAuthorities(Pageable pageable);

View File

@ -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);
}
}

View File

@ -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<String> authorities) {
userRepository
.findOneById(id)
Optional.of(userRepository
.findOne(id))
.ifPresent(u -> {
u.setLogin(login);
u.setFirstName(firstName);

View File

@ -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);
}
}

View File

@ -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<String> 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<UserDTO> 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<String> saveAccount(@Valid @RequestBody UserDTO userDTO) {
Optional<User> 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<List<PersistentToken>> 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<String> finishPasswordReset(@RequestBody KeyAndPasswordVM keyAndPassword) {

View File

@ -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<List<AuditEvent>> getAll(Pageable pageable) throws URISyntaxException {
Page<AuditEvent> 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<List<AuditEvent>> 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<AuditEvent> get(@PathVariable Long id) {
return auditEventService.find(id)
.map((entity) -> new ResponseEntity<>(entity, HttpStatus.OK))

View File

@ -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<BankAccount> 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<BankAccount> 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<BankAccount> 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<BankAccount> 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<Void> deleteBankAccount(@PathVariable Long id) {
log.debug("REST request to delete BankAccount : {}", id);

View File

@ -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<Label> createLabel(@Valid @RequestBody Label label) throws URISyntaxException {
log.debug("REST request to save Label : {}", label);
@ -63,9 +60,7 @@ public class LabelResource {
* or with status 500 (Internal Server Error) if the label couldnt be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@RequestMapping(value = "/labels",
method = RequestMethod.PUT,
produces = MediaType.APPLICATION_JSON_VALUE)
@PutMapping("/labels")
@Timed
public ResponseEntity<Label> updateLabel(@Valid @RequestBody Label label) throws URISyntaxException {
log.debug("REST request to update Label : {}", label);
@ -83,9 +78,7 @@ public class LabelResource {
*
* @return the ResponseEntity with status 200 (OK) and the list of labels in body
*/
@RequestMapping(value = "/labels",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping("/labels")
@Timed
public List<Label> getAllLabels() {
log.debug("REST request to get all Labels");
@ -99,9 +92,7 @@ public class LabelResource {
* @param id the id of the label to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the label, or with status 404 (Not Found)
*/
@RequestMapping(value = "/labels/{id}",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping("/labels/{id}")
@Timed
public ResponseEntity<Label> getLabel(@PathVariable Long id) {
log.debug("REST request to get Label : {}", id);
@ -119,9 +110,7 @@ public class LabelResource {
* @param id the id of the label to delete
* @return the ResponseEntity with status 200 (OK)
*/
@RequestMapping(value = "/labels/{id}",
method = RequestMethod.DELETE,
produces = MediaType.APPLICATION_JSON_VALUE)
@DeleteMapping("/labels/{id}")
@Timed
public ResponseEntity<Void> deleteLabel(@PathVariable Long id) {
log.debug("REST request to delete Label : {}", id);

View File

@ -7,7 +7,6 @@ import ch.qos.logback.classic.LoggerContext;
import com.codahale.metrics.annotation.Timed;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -20,9 +19,7 @@ import java.util.stream.Collectors;
@RequestMapping("/management/jhipster")
public class LogsResource {
@RequestMapping(value = "/logs",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping("/logs")
@Timed
public List<LoggerVM> getList() {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
@ -32,8 +29,7 @@ public class LogsResource {
.collect(Collectors.toList());
}
@RequestMapping(value = "/logs",
method = RequestMethod.PUT)
@PutMapping("/logs")
@ResponseStatus(HttpStatus.NO_CONTENT)
@Timed
public void changeLevel(@RequestBody LoggerVM jsonLogger) {

View File

@ -12,7 +12,6 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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.*;
@ -42,9 +41,7 @@ public class OperationResource {
* @return the ResponseEntity with status 201 (Created) and with body the new operation, or with status 400 (Bad Request) if the operation has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@RequestMapping(value = "/operations",
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping("/operations")
@Timed
public ResponseEntity<Operation> createOperation(@Valid @RequestBody Operation operation) throws URISyntaxException {
log.debug("REST request to save Operation : {}", operation);
@ -66,9 +63,7 @@ public class OperationResource {
* or with status 500 (Internal Server Error) if the operation couldnt be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@RequestMapping(value = "/operations",
method = RequestMethod.PUT,
produces = MediaType.APPLICATION_JSON_VALUE)
@PutMapping("/operations")
@Timed
public ResponseEntity<Operation> updateOperation(@Valid @RequestBody Operation operation) throws URISyntaxException {
log.debug("REST request to update Operation : {}", operation);
@ -88,9 +83,7 @@ public class OperationResource {
* @return the ResponseEntity with status 200 (OK) and the list of operations in body
* @throws URISyntaxException if there is an error to generate the pagination HTTP headers
*/
@RequestMapping(value = "/operations",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping("/operations")
@Timed
public ResponseEntity<List<Operation>> getAllOperations(Pageable pageable)
throws URISyntaxException {
@ -106,9 +99,7 @@ public class OperationResource {
* @param id the id of the operation to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the operation, or with status 404 (Not Found)
*/
@RequestMapping(value = "/operations/{id}",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping("/operations/{id}")
@Timed
public ResponseEntity<Operation> getOperation(@PathVariable Long id) {
log.debug("REST request to get Operation : {}", id);
@ -126,9 +117,7 @@ public class OperationResource {
* @param id the id of the operation to delete
* @return the ResponseEntity with status 200 (OK)
*/
@RequestMapping(value = "/operations/{id}",
method = RequestMethod.DELETE,
produces = MediaType.APPLICATION_JSON_VALUE)
@DeleteMapping("/operations/{id}")
@Timed
public ResponseEntity<Void> deleteOperation(@PathVariable Long id) {
log.debug("REST request to delete Operation : {}", id);

View File

@ -3,10 +3,7 @@ package io.github.jhipster.sample.web.rest;
import io.github.jhipster.sample.config.DefaultProfileUtil;
import io.github.jhipster.sample.config.JHipsterProperties;
import org.springframework.core.env.Environment;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.inject.Inject;
import java.util.ArrayList;
@ -23,9 +20,7 @@ public class ProfileInfoResource {
@Inject
private JHipsterProperties jHipsterProperties;
@RequestMapping(value = "/profile-info",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping("/profile-info")
public ProfileInfoResponse getActiveProfiles() {
return new ProfileInfoResponse(DefaultProfileUtil.getActiveProfiles(env), getRibbonEnv());
}

View File

@ -16,7 +16,6 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.*;
@ -80,9 +79,7 @@ public class UserResource {
* @return the ResponseEntity with status 201 (Created) and with body the new user, or with status 400 (Bad Request) if the login or email is already in use
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@RequestMapping(value = "/users",
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<?> createUser(@RequestBody ManagedUserVM managedUserVM, HttpServletRequest request) throws URISyntaxException {
@ -120,9 +117,7 @@ public class UserResource {
* or with status 400 (Bad Request) if the login or email is already in use,
* or with status 500 (Internal Server Error) if the user couldn't be updated
*/
@RequestMapping(value = "/users",
method = RequestMethod.PUT,
produces = MediaType.APPLICATION_JSON_VALUE)
@PutMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<ManagedUserVM> updateUser(@RequestBody ManagedUserVM managedUserVM) {
@ -151,9 +146,7 @@ public class UserResource {
* @return the ResponseEntity with status 200 (OK) and with body all users
* @throws URISyntaxException if the pagination headers couldn't be generated
*/
@RequestMapping(value = "/users",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping("/users")
@Timed
public ResponseEntity<List<ManagedUserVM>> getAllUsers(Pageable pageable)
throws URISyntaxException {
@ -171,9 +164,7 @@ public class UserResource {
* @param login the login of the user to find
* @return the ResponseEntity with status 200 (OK) and with body the "login" user, or with status 404 (Not Found)
*/
@RequestMapping(value = "/users/{login:" + Constants.LOGIN_REGEX + "}",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping("/users/{login:" + Constants.LOGIN_REGEX + "}")
@Timed
public ResponseEntity<ManagedUserVM> getUser(@PathVariable String login) {
log.debug("REST request to get User : {}", login);
@ -189,9 +180,7 @@ public class UserResource {
* @param login the login of the user to delete
* @return the ResponseEntity with status 200 (OK)
*/
@RequestMapping(value = "/users/{login:" + Constants.LOGIN_REGEX + "}",
method = RequestMethod.DELETE,
produces = MediaType.APPLICATION_JSON_VALUE)
@DeleteMapping("/users/{login:" + Constants.LOGIN_REGEX + "}")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<Void> deleteUser(@PathVariable String login) {

View File

@ -11,7 +11,7 @@ public final class HeaderUtil {
private static final Logger log = LoggerFactory.getLogger(HeaderUtil.class);
private HeaderUtil(){
private HeaderUtil() {
}
public static HttpHeaders createAlert(String message, String param) {

View File

@ -15,7 +15,7 @@ import java.net.URISyntaxException;
*/
public final class PaginationUtil {
private PaginationUtil(){
private PaginationUtil() {
}
public static HttpHeaders generatePaginationHttpHeaders(Page<?> page, String baseUrl)

View File

@ -62,7 +62,6 @@ server:
jhipster:
cache: # Hibernate 2nd level cache, used by CacheConfiguration
timeToLiveSeconds: 3600
ehcache:
maxBytesLocalHeap: 16M
security:

View File

@ -65,7 +65,6 @@ jhipster:
cache: # Used by the CachingHttpHeadersFilter
timeToLiveInDays: 1461
cache: # Hibernate 2nd level cache, used by CacheConfiguration
timeToLiveSeconds: 3600
ehcache:
maxBytesLocalHeap: 256M
security:

View File

@ -44,6 +44,11 @@ security:
basic:
enabled: false
server:
session:
cookie:
http-only: true
# ===================================================================
# JHipster specific properties
# ===================================================================

View File

@ -181,7 +181,6 @@
<th class="text-right" data-translate="metrics.ehcache.hits">Hits</th>
<th class="text-right" data-translate="metrics.ehcache.misses">Misses</th>
<th class="text-right" data-translate="metrics.ehcache.evictioncount">Eviction count</th>
<th class="text-right" data-translate="metrics.ehcache.mean">Mean get time (ms)</th>
</tr>
</thead>
<tbody>
@ -191,7 +190,6 @@
<td class="text-right">{{vm.metrics.gauges[k + '.hits'].value}}</td>
<td class="text-right">{{vm.metrics.gauges[k + '.misses'].value}}</td>
<td class="text-right">{{vm.metrics.gauges[k + '.eviction-count'].value}}</td>
<td class="text-right">{{vm.metrics.gauges[k + '.mean-get-time'].value | number:2}}</td>
</tr>
</tbody>
</table>

View File

@ -8,11 +8,6 @@
httpConfig.$inject = ['$urlRouterProvider', '$httpProvider', 'httpRequestInterceptorCacheBusterProvider', '$urlMatcherFactoryProvider'];
function httpConfig($urlRouterProvider, $httpProvider, httpRequestInterceptorCacheBusterProvider, $urlMatcherFactoryProvider) {
//enable CSRF
$httpProvider.defaults.xsrfCookieName = 'CSRF-TOKEN';
$httpProvider.defaults.xsrfHeaderName = 'X-CSRF-TOKEN';
//Cache everything except rest api requests
httpRequestInterceptorCacheBusterProvider.setMatchlist([/.*api.*/, /.*protected.*/], true);

View File

@ -6,9 +6,9 @@
.factory('authExpiredInterceptor', authExpiredInterceptor);
authExpiredInterceptor.$inject = ['$rootScope', '$q', '$injector', '$document'];
authExpiredInterceptor.$inject = ['$rootScope', '$q', '$injector'];
function authExpiredInterceptor($rootScope, $q, $injector, $document) {
function authExpiredInterceptor($rootScope, $q, $injector) {
var service = {
responseError: responseError
};
@ -28,40 +28,8 @@
}
var LoginService = $injector.get('LoginService');
LoginService.open();
} else if (response.status === 403 && response.config.method !== 'GET' && getCSRF() === '') {
// If the CSRF token expired, then try to get a new CSRF token and retry the old request
var $http = $injector.get('$http');
return $http.get('/').finally(function() { return afterCSRFRenewed(response); });
}
return $q.reject(response);
}
function getCSRF() {
var doc = $document[0];
if (doc) {
var name = 'CSRF-TOKEN=';
var ca = doc.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];