Updated to the 0.14.0 generator version

This commit is contained in:
Julien Dubois 2014-05-18 19:14:06 +02:00
parent 5b6df78f8e
commit 09783fd6a1
90 changed files with 3436 additions and 1401 deletions

13
.gitattributes vendored Normal file
View File

@ -0,0 +1,13 @@
# All text files should have the "lf" (Unix) line endings
* text eol=lf
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.java text
*.js text
*.css text
*.html text
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary

View File

@ -9,6 +9,9 @@
"devDatabaseType": "h2Memory",
"prodDatabaseType": "mysql",
"useCompass": false,
"javaVersion": "7"
"javaVersion": "7",
"authenticationType": "cookie",
"databaseType": "sql",
"frontendBuilder": "grunt"
}
}

View File

@ -1,4 +1,4 @@
// Generated on 2014-04-10 using generator-jhipster 0.13.0
// Generated on 2014-05-18 using generator-jhipster 0.14.0
'use strict';
// # Globbing
@ -70,6 +70,13 @@ module.exports = function (grunt) {
https: false,
changeOrigin: false
},
{
context: '/api-docs',
host: 'localhost',
port: 8080,
https: false,
changeOrigin: false
},
{
context: '/console',
host: 'localhost',

View File

@ -2,8 +2,6 @@
"name": "jhipster",
"version": "0.0.0",
"dependencies": {
"atmosphere": "2.1.2",
"jquery-atmosphere": "2.1.2",
"bootstrap-sass": "twbs/bootstrap-sass#~3.1.1",
"modernizr": "2.7.1",
"jquery": "2.0.3",
@ -18,7 +16,7 @@
"angular-translate-loader-static-files": "2.0.0",
"angular-dynamic-locale": "0.1.1",
"angular-i18n": "1.2.5",
"swagger-ui": "2.0.14"
"swagger-ui": "2.0.16"
},
"devDependencies": {
"angular-mocks": "1.2.13",

View File

@ -27,15 +27,16 @@
"grunt-text-replace": "0.3.11",
"grunt-usemin": "2.1.0",
"load-grunt-tasks": "0.4.0",
"time-grunt": "0.2.7" ,
"grunt-karma": "0.8.2",
"time-grunt": "0.2.7",
"event-stream": "3.1.2",
"karma-script-launcher": "0.1.0",
"karma-chrome-launcher": "0.1.2",
"karma-html2js-preprocessor": "0.1.0",
"karma-jasmine": "0.2.2",
"karma-requirejs": "0.2.1",
"karma-phantomjs-launcher": "0.1.2",
"karma": "0.12.1",
"grunt-karma": "0.8.2"
"karma": "0.12.1"
},
"engines": {
"node": ">=0.10.0"

80
pom.xml
View File

@ -9,7 +9,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.1.RELEASE</version>
<version>1.0.2.RELEASE</version>
</parent>
<profiles>
@ -50,6 +50,9 @@
<goals>
<goal>build</goal>
</goals>
<configuration>
<gruntBuildArgs>--force</gruntBuildArgs>
</configuration>
</execution>
</executions>
</plugin>
@ -59,7 +62,7 @@
<configuration>
<filesets>
<fileset>
<directory>dist</directory>
<directory>src/main/webapp/dist</directory>
</fileset>
<fileset>
<directory>.tmp</directory>
@ -89,22 +92,22 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.7</java.version>
<metrics-spring.version>3.0.0-RC4</metrics-spring.version>
<HikariCP.version>1.3.3</HikariCP.version>
<metrics-spring.version>3.0.0</metrics-spring.version>
<HikariCP.version>1.3.8</HikariCP.version>
<commons-lang.version>2.6</commons-lang.version>
<commons-io.version>2.4</commons-io.version>
<javax.inject.version>1</javax.inject.version>
<joda-time-hibernate.version>1.3</joda-time-hibernate.version>
<geronimo-javamail_1.4_mail.version>1.8.3</geronimo-javamail_1.4_mail.version>
<usertype.core.version>3.1.0.CR10</usertype.core.version>
<usertype.core.version>3.2.0.GA</usertype.core.version>
<awaitility.version>1.4.0</awaitility.version>
<json-path.version>0.9.1</json-path.version>
<assertj-core.version>1.5.0</assertj-core.version>
<assertj-core.version>1.6.0</assertj-core.version>
<maven-enforcer-plugin.version>1.3.1</maven-enforcer-plugin.version>
<sonar-maven-plugin.version>2.2</sonar-maven-plugin.version>
<jhipsterloaded.version>0.4</jhipsterloaded.version>
<jhipsterloaded.version>0.7</jhipsterloaded.version>
<liquibase-slf4j.version>1.2.1</liquibase-slf4j.version>
<swagger-springmvc.version>0.8.2</swagger-springmvc.version>
</properties>
<repositories>
@ -196,6 +199,11 @@
<artifactId>metrics-servlet</artifactId>
<version>${codahale-metrics.version}</version>
</dependency>
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-json</artifactId>
<version>${codahale-metrics.version}</version>
</dependency>
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-servlets</artifactId>
@ -240,7 +248,7 @@
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP-agent</artifactId>
<version>1.3.0</version>
<version>${HikariCP.version}</version>
</dependency>
-->
<dependency>
@ -364,7 +372,7 @@
<dependency>
<groupId>com.mangofactory</groupId>
<artifactId>swagger-springmvc</artifactId>
<version>0.8.2</version>
<version>${swagger-springmvc.version}</version>
</dependency>
<!-- Database dependencies-->
@ -490,7 +498,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>copy</id>
@ -515,5 +522,56 @@
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only.
It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<versionRange>
[1.0,)
</versionRange>
<goals>
<goal>copy</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<versionRange>
[1.0,)
</versionRange>
<goals>
<goal>enforce</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@ -24,11 +24,11 @@ public class ApplicationWebXml extends SpringBootServletInitializer {
* Set a default profile if it has not been set.
* <p/>
* <p>
* Please use -Dspring.active.profile=dev
* Please use -Dspring.profiles.active=dev
* </p>
*/
private String addDefaultProfile() {
String profile = System.getProperty("spring.active.profile");
String profile = System.getProperty("spring.profiles.active");
if (profile != null) {
log.info("Running with Spring profile(s) : {}", profile);
return profile;

View File

@ -1,5 +1,6 @@
package com.mycompany.myapp.aop.logging;
import com.mycompany.myapp.config.Constants;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
@ -8,7 +9,9 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import javax.inject.Inject;
import java.util.Arrays;
/**
@ -19,14 +22,21 @@ public class LoggingAspect {
private final Logger log = LoggerFactory.getLogger(this.getClass());
@Inject
private Environment env;
@Pointcut("within(com.mycompany.myapp.repository..*) || within(com.mycompany.myapp.service..*)")
public void loggingPoincut() {}
@AfterThrowing(pointcut = "loggingPoincut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
joinPoint.getSignature().getName(), e.getCause());
if (env.acceptsProfiles(Constants.SPRING_PROFILE_DEVELOPMENT)) {
log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
joinPoint.getSignature().getName(), e.getCause(), e);
} else {
log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
joinPoint.getSignature().getName(), e.getCause());
}
}
@Around("loggingPoincut()")

View File

@ -0,0 +1,91 @@
package com.mycompany.myapp.async;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.task.AsyncTaskExecutor;
public class ExceptionHandlingAsyncTaskExecutor implements AsyncTaskExecutor,
InitializingBean, DisposableBean {
private final Logger log = LoggerFactory.getLogger(ExceptionHandlingAsyncTaskExecutor.class);
private final AsyncTaskExecutor executor;
public ExceptionHandlingAsyncTaskExecutor(AsyncTaskExecutor executor) {
this.executor = executor;
}
@Override
public void execute(Runnable task) {
executor.execute(task);
}
@Override
public void execute(Runnable task, long startTimeout) {
executor.execute(createWrappedRunnable(task), startTimeout);
}
private <T> Callable<T> createCallable(final Callable<T> task) {
return new Callable<T>() {
@Override
public T call() throws Exception {
try {
return task.call();
} catch (Exception e) {
handle(e);
throw e;
}
}
};
}
private Runnable createWrappedRunnable(final Runnable task) {
return new Runnable() {
@Override
public void run() {
try {
task.run();
} catch (Exception e) {
handle(e);
}
}
};
}
protected void handle(Exception e) {
log.error("Caught async exception", e);
}
@Override
public Future<?> submit(Runnable task) {
return executor.submit(createWrappedRunnable(task));
}
@Override
public <T> Future<T> submit(Callable<T> task) {
return executor.submit(createCallable(task));
}
@Override
public void destroy() throws Exception {
if (executor instanceof DisposableBean) {
DisposableBean bean = (DisposableBean) executor;
bean.destroy();
}
}
@Override
public void afterPropertiesSet() throws Exception {
if (executor instanceof InitializingBean) {
InitializingBean bean = (InitializingBean) executor;
bean.afterPropertiesSet();
}
}
}

View File

@ -0,0 +1,4 @@
/**
* Async helpers.
*/
package com.mycompany.myapp.async;

View File

@ -14,6 +14,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import com.mycompany.myapp.async.ExceptionHandlingAsyncTaskExecutor;
@Configuration
@EnableAsync
@EnableScheduling
@ -37,6 +39,6 @@ public class AsyncConfiguration implements AsyncConfigurer, EnvironmentAware {
executor.setMaxPoolSize(propertyResolver.getProperty("maxPoolSize", Integer.class, 50));
executor.setQueueCapacity(propertyResolver.getProperty("queueCapacity", Integer.class, 10000));
executor.setThreadNamePrefix("jhipster-Executor-");
return executor;
return new ExceptionHandlingAsyncTaskExecutor(executor);
}
}

View File

@ -13,8 +13,8 @@ import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.core.env.Environment;
import org.springframework.util.Assert;
import javax.inject.Inject;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.metamodel.EntityType;
@ -60,7 +60,7 @@ public class CacheConfiguration {
for (EntityType<?> entity : entities) {
String name = entity.getName();
if ( name == null ) {
if (name == null || entity.getJavaType() != null) {
name = entity.getJavaType().getName();
}
Assert.notNull(name, "entity cannot exist without a identifier");

View File

@ -14,7 +14,6 @@ import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.inject.Inject;
import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.Arrays;
@ -29,11 +28,11 @@ public class DatabaseConfiguration implements EnvironmentAware {
private RelaxedPropertyResolver propertyResolver;
@Inject
private Environment env;
private Environment environment;
@Override
public void setEnvironment(Environment environment) {
this.environment = environment;
this.propertyResolver = new RelaxedPropertyResolver(environment, "spring.datasource.");
}
@ -43,7 +42,7 @@ public class DatabaseConfiguration implements EnvironmentAware {
if (propertyResolver.getProperty("url") == null && propertyResolver.getProperty("databaseName") == null) {
log.error("Your database connection pool configuration is incorrect! The application" +
"cannot start. Please check your Spring profile, current profiles are: {}",
Arrays.toString(env.getActiveProfiles()));
Arrays.toString(environment.getActiveProfiles()));
throw new ApplicationContextException("Database connection pool is not configured correctly");
}

View File

@ -21,7 +21,7 @@ import javax.inject.Inject;
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Inject
private Environment env;
@ -39,7 +39,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Inject
private UserDetailsService userDetailsService;
@Inject
private RememberMeServices rememberMeServices;
@ -63,10 +63,11 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
.antMatchers("/images/**")
.antMatchers("/scripts/**")
.antMatchers("/styles/**")
.antMatchers("/view/**")
.antMatchers("/views/**")
.antMatchers("/swagger-ui/**")
.antMatchers("/console/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
@ -121,7 +122,6 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
.antMatchers("/env/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/trace*").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/trace/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/swagger-ui/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/api-docs/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/protected/**").authenticated();

View File

@ -102,15 +102,12 @@ public class SwaggerConfiguration implements EnvironmentAware {
return swaggerApiResourceListing;
}
@Bean
/**
* The ApiListingReferenceScanner does most of the work.
* Scans the appropriate spring RequestMappingHandlerMappings
* Applies the correct absolute paths to the generated swagger resources
*/
@Bean
public ApiListingReferenceScanner apiListingReferenceScanner() {
ApiListingReferenceScanner apiListingReferenceScanner = new ApiListingReferenceScanner();
@ -121,8 +118,6 @@ public class SwaggerConfiguration implements EnvironmentAware {
//Excludes any controllers with the supplied annotations
apiListingReferenceScanner.setExcludeAnnotations(springSwaggerConfig.defaultExcludeAnnotations());
//
apiListingReferenceScanner.setResourceGroupingStrategy(springSwaggerConfig.defaultResourceGroupingStrategy());
//Path provider used to generate the appropriate uri's
@ -146,4 +141,4 @@ public class SwaggerConfiguration implements EnvironmentAware {
apiPathProvider.setDefaultSwaggerPathProvider(springSwaggerConfig.defaultSwaggerPathProvider());
return apiPathProvider;
}
}
}

View File

@ -15,7 +15,7 @@ public class AuditEventConverter {
* @param persistentAuditEvents the list to convert
* @return the converted list.
*/
public List<AuditEvent> convertToAuditEvent(List<PersistentAuditEvent> persistentAuditEvents) {
public List<AuditEvent> convertToAuditEvent(Iterable<PersistentAuditEvent> persistentAuditEvents) {
if (persistentAuditEvents == null) {
return Collections.emptyList();
}

View File

@ -2,6 +2,7 @@ package com.mycompany.myapp.config.metrics;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ConnectionCallback;
import org.springframework.jdbc.core.JdbcTemplate;
@ -21,7 +22,7 @@ public class DatabaseHealthCheckIndicator extends HealthCheckIndicator {
public static final String DATABASE_HEALTH_INDICATOR = "database";
private final Logger log = LoggerFactory.getLogger(DatabaseHealthCheckIndicator.class);
private static Map<String, String> queries = new HashMap<>();
static {
@ -41,7 +42,7 @@ public class DatabaseHealthCheckIndicator extends HealthCheckIndicator {
public DatabaseHealthCheckIndicator() {
}
public void setDataSource(DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
}

View File

@ -87,10 +87,6 @@ public abstract class HealthCheckIndicator implements HealthIndicator<Map<String
private String message;
private Throwable exception;
private Result(boolean healthy) {
this.healthy = healthy;
}
public Result(boolean healthy, String message) {
this.healthy = healthy;
this.message = message;

View File

@ -24,10 +24,10 @@ public class JHipsterHealthIndicatorConfiguration implements InitializingBean {
private DatabaseHealthCheckIndicator databaseHealthCheckIndicator = new DatabaseHealthCheckIndicator();
@Bean
public HealthIndicator healthIndicator() {
return new HealthIndicator() {
public HealthIndicator<Map<String, HealthCheckIndicator.Result>> healthIndicator() {
return new HealthIndicator<Map<String, HealthCheckIndicator.Result>>() {
@Override
public Object health() {
public Map<String, HealthCheckIndicator.Result> health() {
Map<String, HealthCheckIndicator.Result> healths = new LinkedHashMap<>();
healths.putAll(javaMailHealthCheckIndicator.health());

View File

@ -1,9 +1,7 @@
package com.mycompany.myapp.domain;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

View File

@ -4,7 +4,6 @@ import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Type;
import org.joda.time.LocalDateTime;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.HashMap;
@ -26,17 +25,15 @@ public class PersistentAuditEvent {
private long id;
@NotNull
@Column(name = "principal")
private String principal;
@Column(name = "event_date")
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
private LocalDateTime auditEventDate;
@Column(name = "event_type")
private String auditEventType;
@ElementCollection
@MapKeyColumn(name="name")
@Column(name="value")

View File

@ -101,7 +101,7 @@ public class User implements Serializable {
public void setAuthorities(Set<Authority> authorities) {
this.authorities = authorities;
}
public Set<PersistentToken> getPersistentTokens() {
return persistentTokens;
}

View File

@ -7,5 +7,4 @@ import org.springframework.data.jpa.repository.JpaRepository;
* Spring Data JPA repository for the Authority entity.
*/
public interface AuthorityRepository extends JpaRepository<Authority, String> {
}

View File

@ -1,58 +0,0 @@
package com.mycompany.myapp.repository;
import com.mycompany.myapp.config.audit.AuditEventConverter;
import com.mycompany.myapp.domain.PersistentAuditEvent;
import org.joda.time.LocalDateTime;
import org.springframework.boot.actuate.audit.AuditEvent;
import org.springframework.boot.actuate.audit.AuditEventRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Repository;
import javax.inject.Inject;
import java.util.Date;
import java.util.List;
/**
* Wraps an implementation of Spring Boot's AuditEventRepository.
*/
@Repository
public class CustomAuditEventRepository {
@Inject
private PersistenceAuditEventRepository persistenceAuditEventRepository;
@Bean
public AuditEventRepository auditEventRepository() {
return new AuditEventRepository() {
@Inject
private AuditEventConverter auditEventConverter;
@Override
public List<AuditEvent> find(String principal, Date after) {
final List<PersistentAuditEvent> persistentAuditEvents;
if (principal == null && after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findAll();
} else if (after == null) {
persistentAuditEvents = persistenceAuditEventRepository.findByPrincipal(principal);
} else {
persistentAuditEvents =
persistenceAuditEventRepository.findByPrincipalAndAuditEventDateGreaterThan(principal, new LocalDateTime(after));
}
return auditEventConverter.convertToAuditEvent(persistentAuditEvents);
}
@Override
public void add(AuditEvent event) {
PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
persistentAuditEvent.setPrincipal(event.getPrincipal());
persistentAuditEvent.setAuditEventType(event.getType());
persistentAuditEvent.setAuditEventDate(new LocalDateTime(event.getTimestamp()));
persistentAuditEvent.setData(auditEventConverter.convertDataToStrings(event.getData()));
persistenceAuditEventRepository.save(persistentAuditEvent);
}
};
}
}

View File

@ -10,12 +10,12 @@ import java.util.List;
/**
* Spring Data JPA repository for the PersistentAuditEvent entity.
*/
public interface PersistenceAuditEventRepository extends JpaRepository<PersistentAuditEvent, String> {
public interface PersistenceAuditEventRepository extends JpaRepository<PersistentAuditEvent, String> {
List<PersistentAuditEvent> findByPrincipal(String principal);
List<PersistentAuditEvent> findByPrincipalAndAuditEventDateGreaterThan(String principal, LocalDateTime after);
@Query("select p from PersistentAuditEvent p where p.auditEventDate >= ?1 and p.auditEventDate <= ?2")
List<PersistentAuditEvent> findByDates(LocalDateTime fromDate, LocalDateTime toDate);
}
}

View File

@ -8,7 +8,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
/**
* Spring Data JPA repository for the User entity.
* Spring Data JPA repository for the PersistentToken entity.
*/
public interface PersistentTokenRepository extends JpaRepository<PersistentToken, String> {

View File

@ -16,11 +16,13 @@ import java.io.IOException;
@Component
public class AjaxLogoutSuccessHandler extends AbstractAuthenticationTargetUrlRequestHandler
implements LogoutSuccessHandler {
@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication)
throws IOException, ServletException {
response.setStatus(HttpServletResponse.SC_OK);
}

View File

@ -73,8 +73,7 @@ public class CustomPersistentRememberMeServices extends
private UserRepository userRepository;
@Inject
public CustomPersistentRememberMeServices(Environment env,
org.springframework.security.core.userdetails.UserDetailsService userDetailsService) {
public CustomPersistentRememberMeServices(Environment env, org.springframework.security.core.userdetails.UserDetailsService userDetailsService) {
super(env.getProperty("jhipster.security.rememberme.key"), userDetailsService);
random = new SecureRandom();
@ -98,7 +97,7 @@ public class CustomPersistentRememberMeServices extends
addCookie(token, request, response);
} catch (DataAccessException e) {
log.error("Failed to update token: ", e);
throw new RememberMeAuthenticationException("Autologin failed due to data access problem: " + e.getMessage());
throw new RememberMeAuthenticationException("Autologin failed due to data access problem", e);
}
return getUserDetailsService().loadUserByUsername(login);
}

View File

@ -38,7 +38,7 @@ public class UserDetailsService implements org.springframework.security.core.use
throw new UsernameNotFoundException("User " + lowercaseLogin + " was not found in the database");
}
Collection<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>();
Collection<GrantedAuthority> grantedAuthorities = new ArrayList<>();
for (Authority authority : userFromDatabase.getAuthorities()) {
GrantedAuthority grantedAuthority = new SimpleGrantedAuthority(authority.getName());
grantedAuthorities.add(grantedAuthority);

View File

@ -12,13 +12,12 @@ import com.mycompany.myapp.web.rest.dto.UserDTO;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
@ -61,19 +60,23 @@ public class AccountResource {
method = RequestMethod.GET,
produces = "application/json")
@Timed
public UserDTO getAccount(HttpServletResponse response) {
public ResponseEntity<UserDTO> getAccount() {
User user = userService.getUserWithAuthorities();
if (user == null) {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return null;
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
List<String> roles = new ArrayList<>();
for (Authority authority : user.getAuthorities()) {
roles.add(authority.getName());
}
return new UserDTO(user.getLogin(), user.getFirstName(), user.getLastName(),
user.getEmail(), roles);
List<String> roles = new ArrayList<>();
for (Authority authority : user.getAuthorities()) {
roles.add(authority.getName());
}
return new ResponseEntity<>(
new UserDTO(
user.getLogin(),
user.getFirstName(),
user.getLastName(),
user.getEmail(),
roles),
HttpStatus.OK);
}
/**
@ -83,7 +86,7 @@ public class AccountResource {
method = RequestMethod.POST,
produces = "application/json")
@Timed
public void saveAccount(@RequestBody UserDTO userDTO) throws IOException {
public void saveAccount(@RequestBody UserDTO userDTO) {
userService.updateUserInformation(userDTO.getFirstName(), userDTO.getLastName(), userDTO.getEmail());
}
@ -94,12 +97,12 @@ public class AccountResource {
method = RequestMethod.POST,
produces = "application/json")
@Timed
public void changePassword(@RequestBody String password, HttpServletResponse response) throws IOException {
if (password == null || password.equals("")) {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "Password should not be empty");
} else {
userService.changePassword(password);
public ResponseEntity<?> changePassword(@RequestBody String password) {
if (StringUtils.isEmpty(password)) {
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
}
userService.changePassword(password);
return new ResponseEntity<>(HttpStatus.OK);
}
/**
@ -109,12 +112,14 @@ public class AccountResource {
method = RequestMethod.GET,
produces = "application/json")
@Timed
public List<PersistentToken> getCurrentSessions(HttpServletResponse response) {
public ResponseEntity<List<PersistentToken>> getCurrentSessions() {
User user = userRepository.findOne(SecurityUtils.getCurrentLogin());
if (user == null) {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
return persistentTokenRepository.findByUser(user);
return new ResponseEntity<>(
persistentTokenRepository.findByUser(user),
HttpStatus.OK);
}
/**
@ -133,15 +138,14 @@ public class AccountResource {
@RequestMapping(value = "/rest/account/sessions/{series}",
method = RequestMethod.DELETE)
@Timed
public void invalidateSession(@PathVariable String series, HttpServletRequest request) throws UnsupportedEncodingException {
public void invalidateSession(@PathVariable String series) throws UnsupportedEncodingException {
String decodedSeries = URLDecoder.decode(series, "UTF-8");
User user = userRepository.findOne(SecurityUtils.getCurrentLogin());
List<PersistentToken> persistentTokens = persistentTokenRepository.findByUser(user);
for (PersistentToken persistentToken : persistentTokens) {
if (StringUtils.equals(persistentToken.getSeries(), decodedSeries)) {
if (StringUtils.equals(persistentToken.getSeries(), decodedSeries)) {
persistentTokenRepository.delete(decodedSeries);
}
}
}
}
}

View File

@ -24,8 +24,7 @@ public class LogsResource {
@Timed
public List<LoggerDTO> getList() {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
List<LoggerDTO> loggers = new ArrayList<LoggerDTO>();
List<LoggerDTO> loggers = new ArrayList<>();
for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
loggers.add(new LoggerDTO(logger));
}

View File

@ -1,9 +1,9 @@
server:
port: 8080
address: localhost
spring:
profiles: dev
datasource:
dataSourceClassName: org.h2.jdbcx.JdbcDataSource
url: jdbc:h2:mem:jhipster
@ -35,8 +35,8 @@ metrics:
jmx.enabled: true
graphite:
enabled: false
host:
port:
host: localhost
port: 2003
cache:
timeToLiveSeconds: 3600

View File

@ -1,9 +1,9 @@
server:
port: 8080
address: localhost
spring:
profiles: prod
datasource:
dataSourceClassName: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
url: jdbc:mysql://localhost:3306/jhipster
@ -37,8 +37,8 @@ metrics:
jmx.enabled: true
graphite:
enabled: false
host:
port:
host: localhost
port: 2003
cache:
timeToLiveSeconds: 3600

View File

@ -26,6 +26,7 @@ spring:
messageSource:
cacheSeconds: 1
swagger:
apiDocsLocation: http://localhost:8080
title: jhipster API

View File

@ -43,7 +43,7 @@
<column name="user_agent" type="varchar(255)"/>
</createTable>
<createTable tableName="HIBERNATE_SEQUENCES">
<createTable tableName="hibernate_sequences">
<column name="sequence_name" type="varchar(255)"/>
<column name="sequence_next_hi_value" type="integer"/>
</createTable>
@ -130,4 +130,18 @@
referencedColumnNames="event_id"
referencedTableName="T_PERSISTENT_AUDIT_EVENT"/>
</changeSet>
<!-- Sample changeSet for creating a new Entity with the entity sub-generator -->
<!--
<changeSet id="100" author="jhipster">
<createTable tableName="T_FOO">
<column name="id" type="varchar(255)">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="sample_text_attribute" type="varchar(50)"/>
<column name="sample_date_attribute" type="date"/>
</createTable>
</changeSet>
-->
</databaseChangeLog>

View File

@ -0,0 +1,5 @@
title = Ваш запрос не может быть обработан
subtitle = Извините, произошла ошибка.
status = Статус:
message = Сообщение:

View File

@ -7,6 +7,7 @@
<Pattern>[%p] %c - %m%n</Pattern>
</encoder>
</appender>
<logger name="javax.activation" level="warn"/>
<logger name="com.mycompany.myapp" level="${logback.loglevel}"/>
<logger name="ch.qos.logback" level="WARN"/>
<logger name="com.codahale.metrics" level="WARN"/>
@ -24,6 +25,8 @@
<logger name="org.springframework.security" level="WARN"/>
<logger name="org.springframework.cache" level="WARN"/>
<logger name="org.thymeleaf" level="WARN"/>
<logger name="com.mangofactory.swagger" level="warn"/>
<logger name="com.wordnik.swagger" level="warn"/>
<logger name="liquibase" level="warn"/>
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
@ -34,4 +37,4 @@
<appender-ref ref="CONSOLE"/>
</root>
</configuration>
</configuration>

View File

@ -1,14 +1,14 @@
{
"name": "swagger-ui",
"homepage": "https://github.com/wordnik/swagger-ui",
"version": "2.0.14",
"_release": "2.0.14",
"version": "2.0.16",
"_release": "2.0.16",
"_resolution": {
"type": "version",
"tag": "v2.0.14",
"commit": "2abdedf01e1bf89380aa393ed9a3fff619931750"
"tag": "v2.0.16",
"commit": "ad6177ed3e7e166a87d3d2ab3c70a64ce6246105"
},
"_source": "git://github.com/wordnik/swagger-ui.git",
"_target": "2.0.14",
"_target": "2.0.16",
"_originalSource": "swagger-ui"
}

View File

@ -65,22 +65,28 @@ task 'dist', 'Build a distribution', ->
throw err if err
fs.unlink 'dist/_swagger-ui.coffee'
console.log ' : Combining with javascript...'
exec 'cat src/main/javascript/doc.js dist/_swagger-ui-templates.js dist/_swagger-ui.js > dist/swagger-ui.js', (err, stdout, stderr) ->
throw err if err
fs.unlink 'dist/_swagger-ui.js'
fs.unlink 'dist/_swagger-ui-templates.js'
console.log ' : Minifying all...'
exec 'java -jar "./bin/yuicompressor-2.4.7.jar" --type js -o ' + 'dist/swagger-ui.min.js ' + 'dist/swagger-ui.js', (err, stdout, stderr) ->
fs.readFile 'package.json', 'utf8', (err, fileContents) ->
obj = JSON.parse(fileContents)
exec 'echo "// swagger-ui.js" > dist/swagger-ui.js'
exec 'echo "// version ' + obj.version + '" >> dist/swagger-ui.js'
exec 'cat src/main/javascript/doc.js dist/_swagger-ui-templates.js dist/_swagger-ui.js >> dist/swagger-ui.js', (err, stdout, stderr) ->
throw err if err
lessc()
fs.unlink 'dist/_swagger-ui.js'
fs.unlink 'dist/_swagger-ui-templates.js'
console.log ' : Minifying all...'
exec 'java -jar "./bin/yuicompressor-2.4.7.jar" --type js -o ' + 'dist/swagger-ui.min.js ' + 'dist/swagger-ui.js', (err, stdout, stderr) ->
throw err if err
lessc()
lessc = ->
# Someone who knows CoffeeScript should make this more Coffee-licious
console.log ' : Compiling LESS...'
less.render fs.readFileSync("src/main/less/screen.less", 'utf8'), (err, css) ->
console.log err
fs.writeFileSync("src/main/html/css/screen.css", css)
less.render fs.readFileSync("src/main/less/reset.less", 'utf8'), (err, css) ->
fs.writeFileSync("src/main/html/css/reset.css", css)
pack()
pack = ->

View File

@ -1,13 +1,20 @@
Swagger UI
==========
# Swagger UI
Swagger UI is part of [Swagger](http://swagger.wordnik.com/) project. The Swagger project allows you to produce, visualize and consume your OWN RESTful services. No proxy or 3rd party services required. Do it your own way.
Swagger UI is part of Swagger project. The Swagger project allows you to produce, visualize and consume your OWN RESTful services. No proxy or 3rd party services required. Do it your own way.
Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically
generate beautiful documentation and sandbox from a [Swagger-compliant](https://github.com/wordnik/swagger-core/wiki) API. Because Swagger UI has no dependencies, you can host it in any server environment, or on your local machine.
generate beautiful documentation and sandbox from a Swagger-compliant API. Because Swagger UI has no dependencies, you can host it in any server environment, or on your local machine.
How to Use It
-------------
## What's Swagger?
The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swager removes the guesswork in calling the service.
Check out [Swagger-Spec](https://github.com/wordnik/swagger-spec) for additional information about the Swagger project, including additional libraries with support for other languages and more.
## How to Use It
### Download
You can use the swagger-ui code AS-IS! No need to build or recompile--just clone this repo and use the pre-built files in the `dist` folder. If you like swagger-ui as-is, stop here.
@ -85,8 +92,7 @@ window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "XXXX"
Note! You can pass multiple header params on a single request, just use unique names for them (`key` is used in the above example).
How to Improve It
-----------------
## How to Improve It
Create your own fork of [wordnik/swagger-ui](https://github.com/wordnik/swagger-ui)
@ -94,8 +100,7 @@ To share your changes, [submit a pull request](https://github.com/wordnik/swagge
Since the javascript files are compiled from coffeescript, please submit changes in the *.coffee files! We have to reject changes only in the .js files as they will be lost on each build of the ui.
License
-------
## License
Copyright 2011-2013 Wordnik, Inc.