automatic project update

This commit is contained in:
Julien Dubois 2016-07-21 00:15:52 +02:00
parent aff9cc943f
commit f3c367f82c
68 changed files with 456 additions and 267 deletions

View File

@ -1,10 +1,29 @@
language: node_js
node_js:
- "4.4.3"
language: java
jdk:
- oraclejdk8
sudo: false
before_install: npm install -g gulp
cache:
directories:
- node
- node_modules
- $HOME/.m2
env:
- NODE_VERSION=4.4.5
before_install:
- nvm install $NODE_VERSION
- npm install -g npm
- npm install -g bower gulp-cli
- node -v
- npm -v
- bower -v
- gulp -v
- java -version
install: npm install
before_script: gulp build
script:
- ./mvnw clean
- ./mvnw test
- gulp test
- ./mvnw package -Pprod -DskipTests
notifications:
webhooks:
on_success: change # options: [always|never|change] default: always

View File

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

29
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,29 @@
node {
// uncomment these 2 lines and edit the name 'node-4.4.5' according to what you choose in configuration
// def nodeHome = tool name: 'node-4.4.5', type: 'jenkins.plugins.nodejs.tools.NodeJSInstallation'
// env.PATH = "${nodeHome}/bin:${env.PATH}"
stage 'check tools'
sh "node -v"
sh "npm -v"
sh "bower -v"
sh "gulp -v"
stage 'checkout'
checkout scm
stage 'npm install'
sh "npm install"
stage 'clean'
sh "./mvnw clean"
stage 'backend tests'
sh "./mvnw test"
stage 'frontend tests'
sh "gulp test"
stage 'packaging'
sh "./mvnw package -Pprod -DskipTests"
}

View File

@ -40,7 +40,7 @@ these new files.
To ensure everything worked, run:
java -jar target/*.war --spring.profiles.active=prod
java -jar target/*.war
Then navigate to [http://localhost:8080](http://localhost:8080) in your browser.

View File

@ -34,17 +34,17 @@
"angular-mocks": "1.5.5"
},
"overrides": {
"angular" : {
"angular": {
"dependencies": {
"jquery": "2.2.4"
}
},
"angular-cache-buster" : {
"angular-cache-buster": {
"dependencies": {
"angular": "1.5.5"
}
},
"angular-dynamic-locale" : {
"angular-dynamic-locale": {
"dependencies": {
"angular": "1.5.5"
}

View File

@ -10,7 +10,7 @@ var fs = require('fs'),
cssnano = require('gulp-cssnano'),
uglify = require('gulp-uglify'),
useref = require("gulp-useref"),
revReplace = require("gulp-rev-replace")
revReplace = require("gulp-rev-replace"),
plumber = require('gulp-plumber'),
gulpIf = require('gulp-if'),
handleErrors = require('./handleErrors');
@ -47,4 +47,4 @@ module.exports = function() {
.pipe(revReplace({manifest: manifest}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(config.dist));
}
};

View File

@ -57,4 +57,4 @@ module.exports = function () {
});
gulp.start('watch');
}
};

View File

@ -2,34 +2,34 @@
var fs = require('fs');
module.exports = {
module.exports = {
endsWith : endsWith,
parseVersion : parseVersion,
isLintFixed : isLintFixed
}
};
function endsWith(str, suffix) {
return str.indexOf('/', str.length - suffix.length) !== -1;
};
}
var parseString = require('xml2js').parseString;
// return the version number from `pom.xml` file
function parseVersion() {
var version;
var version = null;
var pomXml = fs.readFileSync('pom.xml', 'utf8');
parseString(pomXml, function (err, result) {
if (result.project.version && result.project.version[0]) {
version = result.project.version[0];
} else if (result.project.parent && result.project.parent[0] && result.project.parent[0].version && result.project.parent[0].version[0]) {
version = result.project.parent[0].version[0];
} else {
throw new Error('pom.xml is malformed. No version is defined');
}
});
if (version === null) {
throw new Error('pom.xml is malformed. No version is defined');
}
return version;
}
function isLintFixed(file) {
// Has ESLint fixed the file contents?
return file.eslint !== null && file.eslint.fixed;

View File

@ -1,4 +1,4 @@
// Generated on 2016-06-19 using generator-jhipster 3.4.2
// Generated on 2016-07-20 using generator-jhipster 3.5.0
'use strict';
var gulp = require('gulp'),
@ -8,6 +8,7 @@ var gulp = require('gulp'),
imagemin = require('gulp-imagemin'),
ngConstant = require('gulp-ng-constant'),
rename = require('gulp-rename'),
replace = require('gulp-replace'),
eslint = require('gulp-eslint'),
argv = require('yargs').argv,
gutil = require('gulp-util'),
@ -155,7 +156,7 @@ gulp.task('inject:troubleshoot', function () {
.pipe(gulp.dest(config.app));
});
gulp.task('assets:prod', ['images', 'styles', 'html'], build);
gulp.task('assets:prod', ['images', 'styles', 'html','swagger-ui'], build);
gulp.task('html', function () {
return gulp.src(config.app + 'app/**/*.html')
@ -168,6 +169,22 @@ gulp.task('html', function () {
.pipe(gulp.dest(config.tmp));
});
gulp.task('swagger-ui', function () {
return es.merge(
gulp.src([config.bower + 'swagger-ui/dist/**',
'!' + config.bower + 'swagger-ui/dist/index.html',
'!' + config.bower + 'swagger-ui/dist/swagger-ui.min.js',
'!' + config.bower + 'swagger-ui/dist/swagger-ui.js'])
.pipe(gulp.dest(config.dist + 'swagger-ui/')),
gulp.src(config.app + 'swagger-ui/index.html')
.pipe(replace('../bower_components/swagger-ui/dist/', ''))
.pipe(replace('swagger-ui.js', 'lib/swagger-ui.min.js'))
.pipe(gulp.dest(config.dist + 'swagger-ui/')),
gulp.src(config.bower + 'swagger-ui/dist/swagger-ui.min.js')
.pipe(gulp.dest(config.dist + 'swagger-ui/lib/'))
)
});
gulp.task('ngconstant:dev', function () {
return ngConstant({
name: 'jhipsterSampleApplicationApp',

View File

@ -14,7 +14,7 @@
"eslint-config-angular": "0.5.0",
"eslint-plugin-angular": "1.0.1",
"event-stream": "3.3.2",
"generator-jhipster": "3.4.2",
"generator-jhipster": "3.5.0",
"gulp": "3.9.1",
"gulp-angular-filesort": "1.1.1",
"gulp-angular-templatecache": "1.9.0",
@ -30,10 +30,11 @@
"gulp-inject": "4.1.0",
"gulp-natural-sort": "0.1.1",
"gulp-ng-annotate": "2.0.0",
"gulp-rename": "1.2.2",
"gulp-ng-constant": "1.1.0",
"gulp-notify": "2.2.0",
"gulp-plumber": "1.1.0",
"gulp-rename": "1.2.2",
"gulp-replace": "0.5.4",
"gulp-protractor": "2.4.0",
"gulp-util": "3.0.7",
"gulp-rev": "7.0.0",

18
pom.xml
View File

@ -5,7 +5,7 @@
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>1.3.5.RELEASE</version>
<version>1.3.6.RELEASE</version>
<relativePath/>
</parent>
@ -46,7 +46,7 @@
<logstash-logback-encoder.version>4.6</logstash-logback-encoder.version>
<run.addResources>false</run.addResources>
<spring-security.version>4.1.0.RELEASE</spring-security.version>
<springfox.version>2.4.0</springfox.version>
<springfox.version>2.5.0</springfox.version>
<!-- Sonar properties -->
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
<sonar-maven-plugin.version>3.0.2</sonar-maven-plugin.version>
@ -64,7 +64,7 @@
<sonar.tests>${project.basedir}/src/test/</sonar.tests>
<!-- These remain empty unless the corresponding profile is active -->
<profile.no-liquibase></profile.no-liquibase>
<profile.no-swagger></profile.no-swagger>
<profile.swagger></profile.swagger>
</properties>
@ -526,7 +526,7 @@
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar-maven-plugin.version}</version>
</plugin>
@ -611,7 +611,7 @@
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.5</version>
<version>0.4.10</version>
<configuration>
<imageName>jhipstersampleapplication</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
@ -693,9 +693,9 @@
</properties>
</profile>
<profile>
<id>no-swagger</id>
<id>swagger</id>
<properties>
<profile.no-swagger>,no-swagger</profile.no-swagger>
<profile.swagger>,swagger</profile.swagger>
</properties>
</profile>
<profile>
@ -730,7 +730,7 @@
<!-- log configuration -->
<logback.loglevel>DEBUG</logback.loglevel>
<!-- default Spring profiles -->
<spring.profiles.active>dev${profile.no-liquibase}${profile.no-swagger}</spring.profiles.active>
<spring.profiles.active>dev${profile.no-liquibase}</spring.profiles.active>
</properties>
</profile>
<profile>
@ -829,7 +829,7 @@
<!-- log configuration -->
<logback.loglevel>INFO</logback.loglevel>
<!-- default Spring profiles -->
<spring.profiles.active>prod${profile.no-liquibase}${profile.no-swagger}</spring.profiles.active>
<spring.profiles.active>prod${profile.swagger}${profile.no-liquibase}</spring.profiles.active>
</properties>
</profile>
</profiles>

View File

@ -15,7 +15,7 @@ public final class Constants {
// Spring profile used when deploying to Heroku
public static final String SPRING_PROFILE_HEROKU = "heroku";
// Spring profile used to disable swagger
public static final String SPRING_PROFILE_NO_SWAGGER = "no-swagger";
public static final String SPRING_PROFILE_SWAGGER = "swagger";
// Spring profile used to disable running liquibase
public static final String SPRING_PROFILE_NO_LIQUIBASE = "no-liquibase";

View File

@ -5,7 +5,6 @@ import javax.validation.constraints.NotNull;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.cors.CorsConfiguration;
/**
* Properties specific to JHipster.
*
@ -213,8 +212,6 @@ public class JHipsterProperties {
private String licenseUrl;
private Boolean enabled;
public String getTitle() {
return title;
}
@ -286,14 +283,6 @@ public class JHipsterProperties {
public void setLicenseUrl(String licenseUrl) {
this.licenseUrl = licenseUrl;
}
public Boolean isEnabled() {
return enabled;
}
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
}
public static class Metrics {
@ -322,7 +311,6 @@ public class JHipsterProperties {
return logs;
}
public static class Jmx {
private boolean enabled = true;
@ -475,6 +463,7 @@ public class JHipsterProperties {
}
public static class Ribbon {
private String[] displayOnActiveProfiles;
@ -482,10 +471,9 @@ public class JHipsterProperties {
public String[] getDisplayOnActiveProfiles() {
return displayOnActiveProfiles;
}
public void setDisplayOnActiveProfiles(String[] displayOnActiveProfiles) {
this.displayOnActiveProfiles = displayOnActiveProfiles;
}
}
}
}

View File

@ -1,27 +1,49 @@
package io.github.jhipster.sample.config;
import io.github.jhipster.sample.domain.util.*;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import java.time.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.ZonedDateTimeSerializer;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
@Configuration
public class JacksonConfiguration {
@Bean
Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() {
JavaTimeModule module = new JavaTimeModule();
module.addSerializer(OffsetDateTime.class, JSR310DateTimeSerializer.INSTANCE);
module.addSerializer(ZonedDateTime.class, JSR310DateTimeSerializer.INSTANCE);
module.addSerializer(LocalDateTime.class, JSR310DateTimeSerializer.INSTANCE);
module.addSerializer(Instant.class, JSR310DateTimeSerializer.INSTANCE);
module.addDeserializer(LocalDate.class, JSR310LocalDateDeserializer.INSTANCE);
return new Jackson2ObjectMapperBuilder()
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.findModulesViaServiceLoader(true)
.modulesToInstall(module);
public static final DateTimeFormatter ISO_FIXED_FORMAT =
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").withZone(ZoneId.of("Z"));
public static final DateTimeFormatter ISO_DATE_OPTIONAL_TIME =
new DateTimeFormatterBuilder()
.append(DateTimeFormatter.ISO_LOCAL_DATE)
.optionalStart()
.appendLiteral('T')
.append(DateTimeFormatter.ISO_TIME)
.toFormatter();
@Autowired
private Jackson2ObjectMapperBuilder builder;
//To be replaced by a Jackson2ObjectMapperBuilderCustomizer in Spring-boot 1.4
@PostConstruct
public void postConstruct() {
this.builder.serializers(new ZonedDateTimeSerializer(ISO_FIXED_FORMAT));
//Will not be needed anymore with SB 1.4 (Jackson > 2.7.1)
this.builder.deserializerByType(LocalDate.class, new LocalDateDeserializer(ISO_DATE_OPTIONAL_TIME));
}
@Bean
public ObjectMapper jacksonObjectMapper() {
return this.builder.createXmlMapper(false).build();
}
}

View File

@ -41,7 +41,6 @@ public class LoggingConfiguration {
LogstashSocketAppender logstashAppender = new LogstashSocketAppender();
logstashAppender.setName("LOGSTASH");
logstashAppender.setContext(context);
String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"}";
// Set the Logstash appender config from JHipster properties

View File

@ -17,7 +17,6 @@ import org.springframework.security.core.userdetails.UserDetailsService;
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;
@ -117,7 +116,7 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
.antMatchers("/api/**").authenticated()
.antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/v2/api-docs/**").permitAll()
.antMatchers("/configuration/ui").permitAll()
.antMatchers("/swagger-resources/configuration/ui").permitAll()
.antMatchers("/swagger-ui/index.html").hasAuthority(AuthoritiesConstants.ADMIN);
}

View File

@ -0,0 +1,87 @@
package io.github.jhipster.sample.config.apidoc;
import io.github.jhipster.sample.config.Constants;
import com.fasterxml.classmate.ResolvedType;
import com.fasterxml.classmate.TypeResolver;
import com.google.common.base.Function;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.core.MethodParameter;
import org.springframework.core.annotation.Order;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;
import springfox.documentation.schema.ModelReference;
import springfox.documentation.schema.TypeNameExtractor;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.schema.contexts.ModelContext;
import springfox.documentation.spi.service.ParameterBuilderPlugin;
import springfox.documentation.spi.service.contexts.ParameterContext;
import springfox.documentation.swagger.common.SwaggerPluginSupport;
import java.util.List;
import static com.google.common.collect.Lists.newArrayList;
import static springfox.documentation.schema.ResolvedTypes.modelRefFactory;
import static springfox.documentation.spi.schema.contexts.ModelContext.inputParam;
@Component
@Order(SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER)
@Profile(Constants.SPRING_PROFILE_SWAGGER)
public class PageableParameterBuilderPlugin implements ParameterBuilderPlugin {
private final TypeNameExtractor nameExtractor;
private final TypeResolver resolver;
@Autowired
public PageableParameterBuilderPlugin(TypeNameExtractor nameExtractor, TypeResolver resolver) {
this.nameExtractor = nameExtractor;
this.resolver = resolver;
}
@Override
public boolean supports(DocumentationType delimiter) {
return true;
}
private Function<ResolvedType, ? extends ModelReference>
createModelRefFactory(ParameterContext context) {
ModelContext modelContext = inputParam(context.methodParameter().getParameterType(),
context.getDocumentationType(),
context.getAlternateTypeProvider(),
context.getGenericNamingStrategy(),
context.getIgnorableParameterTypes());
return modelRefFactory(modelContext, nameExtractor);
}
@Override
public void apply(ParameterContext context) {
MethodParameter parameter = context.methodParameter();
Class<?> type = parameter.getParameterType();
if (type != null && Pageable.class.isAssignableFrom(type)) {
Function<ResolvedType, ? extends ModelReference> factory =
createModelRefFactory(context);
ModelReference intModel = factory.apply(resolver.resolve(Integer.TYPE));
ModelReference stringModel = factory.apply(resolver.resolve(List.class, String.class));
List<Parameter> parameters = newArrayList(
context.parameterBuilder()
.parameterType("query").name("page").modelRef(intModel)
.description("Page number of the requested page")
.build(),
context.parameterBuilder()
.parameterType("query").name("size").modelRef(intModel)
.description("Size of a page")
.build(),
context.parameterBuilder()
.parameterType("query").name("sort").modelRef(stringModel).allowMultiple(true)
.description("Sorting criteria in the format: property(,asc|desc). "
+ "Default sort order is ascending. "
+ "Multiple sort criteria are supported.")
.build());
context.getOperationContext().operationBuilder().parameters(parameters);
}
}
}

View File

@ -28,8 +28,7 @@ import static springfox.documentation.builders.PathSelectors.regex;
*/
@Configuration
@EnableSwagger2
@Profile("!" + Constants.SPRING_PROFILE_NO_SWAGGER)
@ConditionalOnProperty(prefix="jhipster.swagger", name="enabled")
@Profile(Constants.SPRING_PROFILE_SWAGGER)
public class SwaggerConfiguration {
private final Logger log = LoggerFactory.getLogger(SwaggerConfiguration.class);
@ -65,7 +64,6 @@ public class SwaggerConfiguration {
.apiInfo(apiInfo)
.forCodeGeneration(true)
.genericModelSubstitutes(ResponseEntity.class)
.ignoredParameterTypes(Pageable.class)
.ignoredParameterTypes(java.sql.Date.class)
.directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
.directModelSubstitute(java.time.ZonedDateTime.class, Date.class)

View File

@ -39,7 +39,7 @@ public class User extends AbstractAuditingEntity implements Serializable {
@JsonIgnore
@NotNull
@Size(min = 60, max = 60)
@Size(min = 60, max = 60)
@Column(name = "password_hash",length = 60)
private String password;

View File

@ -1,25 +0,0 @@
package io.github.jhipster.sample.domain.util;
import java.io.IOException;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
public final class JSR310DateTimeSerializer extends JsonSerializer<TemporalAccessor> {
private static final DateTimeFormatter ISOFormatter =
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").withZone(ZoneId.of("Z"));
public static final JSR310DateTimeSerializer INSTANCE = new JSR310DateTimeSerializer();
private JSR310DateTimeSerializer() {}
@Override
public void serialize(TemporalAccessor value, JsonGenerator generator, SerializerProvider serializerProvider) throws IOException {
generator.writeString(ISOFormatter.format(value));
}
}

View File

@ -1,64 +0,0 @@
package io.github.jhipster.sample.domain.util;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
/**
* Custom Jackson deserializer for transforming a JSON object (using the ISO 8601 date formatwith optional time)
* to a JSR310 LocalDate object.
*/
public class JSR310LocalDateDeserializer extends JsonDeserializer<LocalDate> {
public static final JSR310LocalDateDeserializer INSTANCE = new JSR310LocalDateDeserializer();
private JSR310LocalDateDeserializer() {}
private static final DateTimeFormatter ISO_DATE_OPTIONAL_TIME;
static {
ISO_DATE_OPTIONAL_TIME = new DateTimeFormatterBuilder()
.append(DateTimeFormatter.ISO_LOCAL_DATE)
.optionalStart()
.appendLiteral('T')
.append(DateTimeFormatter.ISO_OFFSET_TIME)
.toFormatter();
}
@Override
public LocalDate deserialize(JsonParser parser, DeserializationContext context) throws IOException {
switch(parser.getCurrentToken()) {
case START_ARRAY:
if(parser.nextToken() == JsonToken.END_ARRAY) {
return null;
}
int year = parser.getIntValue();
parser.nextToken();
int month = parser.getIntValue();
parser.nextToken();
int day = parser.getIntValue();
if(parser.nextToken() != JsonToken.END_ARRAY) {
throw context.wrongTokenException(parser, JsonToken.END_ARRAY, "Expected array to end.");
}
return LocalDate.of(year, month, day);
case VALUE_STRING:
String string = parser.getText().trim();
if(string.length() == 0) {
return null;
}
return LocalDate.parse(string, ISO_DATE_OPTIONAL_TIME);
default:
throw context.wrongTokenException(parser, JsonToken.START_ARRAY, "Expected array or string.");
}
}
}

View File

@ -60,7 +60,7 @@ public final class SecurityUtils {
*
* <p>The name of this method comes from the isUserInRole() method in the Servlet API</p>
*
* @param authority the authorithy to check
* @param authority the authority to check
* @return true if the current user has the authority, false otherwise
*/
public static boolean isCurrentUserInRole(String authority) {

View File

@ -1,4 +1,5 @@
package io.github.jhipster.sample.security;
import io.github.jhipster.sample.domain.User;
import io.github.jhipster.sample.repository.UserRepository;
import org.slf4j.Logger;

View File

@ -15,7 +15,6 @@ import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine;
import javax.inject.Inject;
import javax.mail.internet.MimeMessage;
import java.util.Locale;
@ -30,7 +29,7 @@ import java.util.Locale;
public class MailService {
private final Logger log = LoggerFactory.getLogger(MailService.class);
private static final String USER = "user";
private static final String BASE_URL = "baseUrl";
@ -101,5 +100,4 @@ public class MailService {
String subject = messageSource.getMessage("email.reset.title", null, locale);
sendEmail(user.getEmail(), subject, content, false, true);
}
}

View File

@ -16,7 +16,6 @@ import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.ZonedDateTime;
import javax.inject.Inject;
@ -31,14 +30,13 @@ public class UserService {
private final Logger log = LoggerFactory.getLogger(UserService.class);
@Inject
private PasswordEncoder passwordEncoder;
@Inject
private UserRepository userRepository;
@Inject
private PersistentTokenRepository persistentTokenRepository;

View File

@ -56,7 +56,7 @@ public class AccountResource {
*
* @param managedUserDTO the managed user DTO
* @param request the HTTP request
* @return the ResponseEntity with status 201 (Created) if the user is registred or 400 (Bad Request) if the login or e-mail is already in use
* @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,
@ -228,7 +228,7 @@ public class AccountResource {
*
* @param mail the mail of the user
* @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 registred
* @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,

View File

@ -85,7 +85,7 @@ public class UserResource {
* @param managedUserDTO the user to create
* @param request the HTTP request
* @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 syntaxt is incorrect
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@RequestMapping(value = "/users",
method = RequestMethod.POST,
@ -125,7 +125,7 @@ public class UserResource {
* @param managedUserDTO the user to update
* @return the ResponseEntity with status 200 (OK) and with body the updated user,
* 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 couldnt be updated
* or with status 500 (Internal Server Error) if the user couldn't be updated
*/
@RequestMapping(value = "/users",
method = RequestMethod.PUT,
@ -171,7 +171,7 @@ public class UserResource {
*
* @param pageable the pagination information
* @return the ResponseEntity with status 200 (OK) and with body all users
* @throws URISyntaxException if the pagination headers couldnt be generated
* @throws URISyntaxException if the pagination headers couldn't be generated
*/
@RequestMapping(value = "/users",
method = RequestMethod.GET,

View File

@ -5,7 +5,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* DTO for transfering error message with a list of field errors.
* DTO for transferring error message with a list of field errors.
*/
public class ErrorDTO implements Serializable {

View File

@ -18,7 +18,7 @@ public interface UserMapper {
UserDTO userToUserDTO(User user);
List<UserDTO> usersToUserDTOs(List<User> users);
@Mapping(target = "createdBy", ignore = true)
@Mapping(target = "createdDate", ignore = true)
@Mapping(target = "lastModifiedBy", ignore = true)

View File

@ -6,7 +6,6 @@ import org.springframework.http.HttpHeaders;
/**
* Utility class for HTTP headers creation.
*
*/
public class HeaderUtil {

View File

@ -4,7 +4,6 @@ import org.springframework.data.domain.Page;
import org.springframework.http.HttpHeaders;
import org.springframework.web.util.UriComponentsBuilder;
import java.net.URI;
import java.net.URISyntaxException;
/**
@ -43,7 +42,4 @@ public class PaginationUtil {
private static String generateUri(String baseUrl, int page, int size) throws URISyntaxException {
return UriComponentsBuilder.fromUriString(baseUrl).queryParam("page", page).queryParam("size", size).toUriString();
}
}

View File

@ -17,6 +17,8 @@ spring:
enabled: true
livereload:
enabled: false # we use gulp + BrowserSync for livereload
jackson:
serialization.indent_output: true
datasource:
url: jdbc:h2:mem:jhipstersampleapplication;DB_CLOSE_DELAY=-1
name:
@ -28,7 +30,7 @@ spring:
jpa:
database-platform: io.github.jhipster.sample.domain.util.FixedH2Dialect
database: H2
show_sql: true
show-sql: true
properties:
hibernate.cache.use_second_level_cache: true
hibernate.cache.use_query_cache: false
@ -43,6 +45,8 @@ spring:
cache-seconds: 1
thymeleaf:
cache: false
profiles:
include: swagger # automatically set the 'swagger' profile
liquibase:
contexts: dev
@ -85,5 +89,3 @@ jhipster:
host: localhost
port: 5000
queueSize: 512
swagger: # swagger is enabled. It can be disabled by pasing 'no-swagger' profile at run time as well
enabled: true

View File

@ -31,7 +31,7 @@ spring:
jpa:
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
database: MYSQL
show_sql: false
show-sql: false
properties:
hibernate.cache.use_second_level_cache: true
hibernate.cache.use_query_cache: false
@ -93,5 +93,3 @@ jhipster:
host: localhost
port: 5000
queueSize: 512
swagger: # swagger is disabled. It can be disabled by pasing 'no-swagger' profile at run time as well
enabled: false

View File

@ -25,6 +25,8 @@ spring:
# Otherwise, it will be filled in by maven when building the WAR file
# Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS`
active: #spring.profiles.active#
jackson:
serialization.write_dates_as_timestamps: false
jpa:
open-in-view: false
hibernate:

View File

@ -49,7 +49,7 @@
<constraints nullable="true"/>
</column>
<column name="last_modified_by" type="varchar(50)"/>
<column name="last_modified_date" type="timestamp"/>
<column name="last_modified_date" type="timestamp" defaultValueDate="${now}"/>
</createTable>
<createIndex indexName="idx_user_login"

View File

@ -16,12 +16,12 @@
<addForeignKeyConstraint baseColumnNames="operations_id"
baseTableName="operation_label"
constraintName="fk_operation_label_label_id"
constraintName="fk_operation_label_operations_id"
referencedColumnNames="id"
referencedTableName="operation"/>
<addForeignKeyConstraint baseColumnNames="labels_id"
baseTableName="operation_label"
constraintName="fk_operation_label_operation_id"
constraintName="fk_operation_label_labels_id"
referencedColumnNames="id"
referencedTableName="label"/>

View File

@ -1,5 +1,5 @@
id;login;password_hash;first_name;last_name;email;activated;lang_key;created_by
1;system;$2a$10$mE.qmcV0mFU5NcKh73TZx.z4ueI/.bDWbj0T1BYyqP481kGGarKLG;System;System;system@localhost;true;en;system
2;anonymoususer;$2a$10$j8S5d7Sr7.8VTOYNviDPOeWX8KcYILUVJBsYV83Y5NtECayypx9lO;Anonymous;User;anonymous@localhost;true;en;system
3;admin;$2a$10$gSAhZrxMllrbgj/kkK9UceBPpChGWJA7SYIb1Mqo.n5aNLq1/oRrC;Administrator;Administrator;admin@localhost;true;en;system
4;user;$2a$10$VEjxo0jq2YG9Rbk2HmX9S.k1uZBGYUHdUcid3g/vfiEl7lwWgOH/K;User;User;user@localhost;true;en;system
id;login;password_hash;first_name;last_name;email;activated;lang_key;created_by;last_modified_by
1;system;$2a$10$mE.qmcV0mFU5NcKh73TZx.z4ueI/.bDWbj0T1BYyqP481kGGarKLG;System;System;system@localhost;true;en;system;system
2;anonymoususer;$2a$10$j8S5d7Sr7.8VTOYNviDPOeWX8KcYILUVJBsYV83Y5NtECayypx9lO;Anonymous;User;anonymous@localhost;true;en;system;system
3;admin;$2a$10$gSAhZrxMllrbgj/kkK9UceBPpChGWJA7SYIb1Mqo.n5aNLq1/oRrC;Administrator;Administrator;admin@localhost;true;en;system;system
4;user;$2a$10$VEjxo0jq2YG9Rbk2HmX9S.k1uZBGYUHdUcid3g/vfiEl7lwWgOH/K;User;User;user@localhost;true;en;system;system

1 id login password_hash first_name last_name email activated lang_key created_by last_modified_by
2 1 system $2a$10$mE.qmcV0mFU5NcKh73TZx.z4ueI/.bDWbj0T1BYyqP481kGGarKLG System System system@localhost true en system system
3 2 anonymoususer $2a$10$j8S5d7Sr7.8VTOYNviDPOeWX8KcYILUVJBsYV83Y5NtECayypx9lO Anonymous User anonymous@localhost true en system system
4 3 admin $2a$10$gSAhZrxMllrbgj/kkK9UceBPpChGWJA7SYIb1Mqo.n5aNLq1/oRrC Administrator Administrator admin@localhost true en system system
5 4 user $2a$10$VEjxo0jq2YG9Rbk2HmX9S.k1uZBGYUHdUcid3g/vfiEl7lwWgOH/K User User user@localhost true en system system

View File

@ -5,9 +5,9 @@
.module('jhipsterSampleApplicationApp')
.controller('UserManagementController', UserManagementController);
UserManagementController.$inject = ['Principal', 'User', 'ParseLinks', '$state', 'pagingParams', 'paginationConstants', 'JhiLanguageService'];
UserManagementController.$inject = ['Principal', 'User', 'ParseLinks', 'AlertService', '$state', 'pagingParams', 'paginationConstants', 'JhiLanguageService'];
function UserManagementController(Principal, User, ParseLinks, $state, pagingParams, paginationConstants, JhiLanguageService) {
function UserManagementController(Principal, User, ParseLinks, AlertService, $state, pagingParams, paginationConstants, JhiLanguageService) {
var vm = this;
vm.authorities = ['ROLE_USER', 'ROLE_ADMIN'];
@ -50,7 +50,8 @@
sort: sort()
}, onSuccess, onError);
}
function onSuccess (data, headers) {
function onSuccess(data, headers) {
//hide anonymous user from user management: it's a required user for Spring Security
for (var i in data) {
if (data[i]['login'] === 'anonymoususer') {
@ -63,9 +64,11 @@
vm.page = pagingParams.page;
vm.users = data;
}
function onError (error) {
function onError(error) {
AlertService.error(error.data.message);
}
function clear () {
vm.user = {
id: null, login: null, firstName: null, lastName: null, email: null,
@ -74,6 +77,7 @@
resetKey: null, authorities: null
};
}
function sort () {
var result = [vm.predicate + ',' + (vm.reverse ? 'asc' : 'desc')];
if (vm.predicate !== 'id') {

View File

@ -85,6 +85,8 @@
chr1 = chr2 = chr3 = '';
enc1 = enc2 = enc3 = enc4 = '';
}
return output;
}
}
})();

View File

@ -5,12 +5,13 @@
.module('jhipsterSampleApplicationApp')
.controller('BankAccountDetailController', BankAccountDetailController);
BankAccountDetailController.$inject = ['$scope', '$rootScope', '$stateParams', 'entity', 'BankAccount', 'User', 'Operation'];
BankAccountDetailController.$inject = ['$scope', '$rootScope', '$stateParams', 'previousState', 'entity', 'BankAccount', 'User', 'Operation'];
function BankAccountDetailController($scope, $rootScope, $stateParams, entity, BankAccount, User, Operation) {
function BankAccountDetailController($scope, $rootScope, $stateParams, previousState, entity, BankAccount, User, Operation) {
var vm = this;
vm.bankAccount = entity;
vm.previousState = previousState.name;
var unsubscribe = $rootScope.$on('jhipsterSampleApplicationApp:bankAccountUpdate', function(event, result) {
vm.bankAccount = result;

View File

@ -19,8 +19,13 @@
</dl>
<button type="submit"
onclick="window.history.back()"
ui-sref="{{ vm.previousState }}"
class="btn btn-info">
<span class="glyphicon glyphicon-arrow-left"></span>&nbsp;<span translate="entity.action.back"> Back</span>
</button>
<button type="button" ui-sref="bank-account-detail.edit({id:vm.bankAccount.id})" class="btn btn-primary">
<span class="glyphicon glyphicon-pencil"></span>
<span class="hidden-xs hidden-sm" translate="entity.action.edit"> Edit</span>
</button>
</div>

View File

@ -52,9 +52,42 @@
}],
entity: ['$stateParams', 'BankAccount', function($stateParams, BankAccount) {
return BankAccount.get({id : $stateParams.id}).$promise;
}],
previousState: ["$state", function ($state) {
var currentStateData = {
name: $state.current.name || 'bank-account',
params: $state.params,
url: $state.href($state.current.name, $state.params)
};
return currentStateData;
}]
}
})
.state('bank-account-detail.edit', {
parent: 'bank-account-detail',
url: '/detail/edit',
data: {
authorities: ['ROLE_USER']
},
onEnter: ['$stateParams', '$state', '$uibModal', function($stateParams, $state, $uibModal) {
$uibModal.open({
templateUrl: 'app/entities/bank-account/bank-account-dialog.html',
controller: 'BankAccountDialogController',
controllerAs: 'vm',
backdrop: 'static',
size: 'lg',
resolve: {
entity: ['BankAccount', function(BankAccount) {
return BankAccount.get({id : $stateParams.id}).$promise;
}]
}
}).result.then(function() {
$state.go('^', {}, { reload: false });
}, function() {
$state.go('^');
});
}]
})
.state('bank-account.new', {
parent: 'bank-account',
url: '/new',