automatic project update

This commit is contained in:
Julien Dubois 2016-05-06 17:35:29 +02:00
parent b3955466eb
commit f5a4295b13
83 changed files with 643 additions and 364 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@
# Node
######################
/node/**
/node_tmp/**
/node_modules/**
######################

View File

@ -1,6 +1,6 @@
language: node_js
node_js:
- "0.12"
- "4.4.3"
sudo: false
before_install: npm install -g gulp
install: npm install

View File

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

View File

@ -39,6 +39,16 @@
"jquery": "2.2.2"
}
},
"angular-cache-buster" : {
"dependencies": {
"angular": "1.5.2"
}
},
"angular-dynamic-locale" : {
"dependencies": {
"angular": "1.5.2"
}
},
"bootstrap": {
"main": [
"dist/css/bootstrap.css"

View File

@ -44,7 +44,7 @@ module.exports = function() {
.pipe(gulpIf('*.css', cssTask()))
.pipe(gulpIf('*.html', htmlmin({collapseWhitespace: true})))
.pipe(gulpIf('**/*.!(html)', rev()))
.pipe(revReplace({manifest}))
.pipe(revReplace({manifest: manifest}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(config.dist));
}

View File

@ -1,4 +1,4 @@
// Generated on 2016-05-06 using generator-jhipster 3.1.0
// Generated on 2016-05-06 using generator-jhipster 3.2.0
'use strict';
var gulp = require('gulp'),
@ -14,7 +14,6 @@ var gulp = require('gulp'),
es = require('event-stream'),
flatten = require('gulp-flatten'),
del = require('del'),
wiredep = require('wiredep').stream,
runSequence = require('run-sequence'),
browserSync = require('browser-sync'),
KarmaServer = require('karma').Server,
@ -22,7 +21,9 @@ var gulp = require('gulp'),
changed = require('gulp-changed'),
gulpIf = require('gulp-if'),
inject = require('gulp-inject'),
angularFilesort = require('gulp-angular-filesort');
angularFilesort = require('gulp-angular-filesort'),
naturalSort = require('gulp-natural-sort'),
bowerFiles = require('main-bower-files');
var handleErrors = require('./gulp/handleErrors'),
serve = require('./gulp/serve'),
@ -102,44 +103,57 @@ gulp.task('styles', [], function () {
.pipe(browserSync.reload({stream: true}));
});
gulp.task('inject', function () {
gulp.task('inject', ['inject:dep', 'inject:app']);
gulp.task('inject:dep', ['inject:test', 'inject:vendor']);
gulp.task('inject:app', function () {
return gulp.src(config.app + 'index.html')
.pipe(inject(gulp.src(config.app + 'app/**/*.js').pipe(angularFilesort()), {relative: true}))
.pipe(inject(gulp.src(config.app + 'app/**/*.js')
.pipe(naturalSort())
.pipe(angularFilesort()), {relative: true}))
.pipe(gulp.dest(config.app));
});
gulp.task('wiredep', ['wiredep:test', 'wiredep:app']);
gulp.task('wiredep:app', function () {
gulp.task('inject:vendor', function () {
var stream = gulp.src(config.app + 'index.html')
.pipe(plumber({errorHandler: handleErrors}))
.pipe(wiredep())
.pipe(inject(gulp.src(bowerFiles(), {read: false}), {
name: 'bower',
relative: true
}))
.pipe(gulp.dest(config.app));
return stream;
});
gulp.task('wiredep:test', function () {
gulp.task('inject:test', function () {
return gulp.src(config.test + 'karma.conf.js')
.pipe(plumber({errorHandler: handleErrors}))
.pipe(wiredep({
ignorePath: /\.\.\/\.\.\//, // remove ../../ from paths of injected JavaScript files
devDependencies: true,
fileTypes: {
js: {
block: /(([\s\t]*)\/\/\s*bower:*(\S*))(\n|\r|.)*?(\/\/\s*endbower)/gi,
detect: {
js: /'(.*\.js)'/gi
},
replace: {
js: '\'src/{{filePath}}\','
}
}
.pipe(inject(gulp.src(bowerFiles({includeDev: true, filter: ['**/*.js']}), {read: false}), {
starttag: '// bower:js',
endtag: '// endbower',
transform: function (filepath) {
return '\'' + filepath.substring(1, filepath.length) + '\',';
}
}))
.pipe(gulp.dest(config.test));
});
gulp.task('inject:troubleshoot', function () {
/* this task removes the troubleshooting content from index.html*/
return gulp.src(config.app + 'index.html')
.pipe(plumber({errorHandler: handleErrors}))
/* having empty src as we dont have to read any files*/
.pipe(inject(gulp.src('', {read: false}), {
starttag: '<!-- inject:troubleshoot -->',
removeTags: true,
transform: function () {
return '<!-- Angular views -->';
}
}))
.pipe(gulp.dest(config.app));
});
gulp.task('assets:prod', ['images', 'styles', 'html'], build);
gulp.task('html', function () {
@ -167,8 +181,8 @@ gulp.task('ngconstant:dev', function () {
' {%= __ngModule %}\n' +
'})();\n',
constants: {
ENV: 'dev',
VERSION: util.parseVersion()
VERSION: util.parseVersion(),
DEBUG_INFO_ENABLED: true
}
})
.pipe(gulp.dest(config.app + 'app/'));
@ -188,8 +202,8 @@ gulp.task('ngconstant:prod', function () {
' {%= __ngModule %}\n' +
'})();\n',
constants: {
ENV: 'prod',
VERSION: util.parseVersion()
VERSION: util.parseVersion(),
DEBUG_INFO_ENABLED: false
}
})
.pipe(gulp.dest(config.app + 'app/'));
@ -215,7 +229,7 @@ gulp.task('eslint:fix', function () {
.pipe(gulpIf(util.isLintFixed, gulp.dest(config.app + 'app')));
});
gulp.task('test', ['wiredep:test', 'ngconstant:dev'], function (done) {
gulp.task('test', ['inject:test', 'ngconstant:dev'], function (done) {
new KarmaServer({
configFile: __dirname + '/' + config.test + 'karma.conf.js',
singleRun: true
@ -246,12 +260,12 @@ gulp.task('watch', function () {
gulp.watch(['gulpfile.js', 'pom.xml'], ['ngconstant:dev']);
gulp.watch(config.app + 'content/css/**/*.css', ['styles']);
gulp.watch(config.app + 'content/images/**', ['images']);
gulp.watch(config.app + 'app/**/*.js', ['inject']);
gulp.watch(config.app + 'app/**/*.js', ['inject:app']);
gulp.watch([config.app + '*.html', config.app + 'app/**', config.app + 'i18n/**']).on('change', browserSync.reload);
});
gulp.task('install', function () {
runSequence(['wiredep', 'ngconstant:dev'], 'languages', 'inject');
runSequence(['inject:dep', 'ngconstant:dev'], 'languages', 'inject:app', 'inject:troubleshoot');
});
gulp.task('serve', function () {
@ -259,7 +273,7 @@ gulp.task('serve', function () {
});
gulp.task('build', ['clean'], function (cb) {
runSequence(['copy', 'wiredep:app', 'ngconstant:prod', 'languages'], 'inject', 'assets:prod', cb);
runSequence(['copy', 'inject:vendor', 'ngconstant:prod', 'languages'], 'inject:app', 'inject:troubleshoot', 'assets:prod', cb);
});
gulp.task('default', ['serve']);

View File

@ -8,25 +8,27 @@
"src/main/webapp/bower_components"
],
"devDependencies": {
"browser-sync": "2.11.2",
"bower": "1.7.9",
"browser-sync": "2.12.5",
"del": "2.2.0",
"eslint-config-angular": "0.5.0",
"eslint-plugin-angular": "1.0.0",
"eslint-plugin-angular": "1.0.1",
"event-stream": "3.3.2",
"generator-jhipster": "3.1.0",
"generator-jhipster": "3.2.0",
"gulp": "3.9.1",
"gulp-angular-filesort": "1.1.1",
"gulp-angular-templatecache": "1.8.0",
"gulp-autoprefixer": "3.1.0",
"gulp-changed": "1.3.0",
"gulp-cssnano": "2.1.1",
"gulp-cssnano": "2.1.2",
"gulp-eslint": "2.0.0",
"gulp-flatten": "0.2.0",
"gulp-footer": "1.0.5",
"gulp-htmlmin": "1.3.0",
"gulp-if": "2.0.0",
"gulp-imagemin": "2.4.0",
"gulp-inject": "3.0.0",
"gulp-inject": "4.0.0",
"gulp-natural-sort": "0.1.1",
"gulp-ng-annotate": "2.0.0",
"gulp-ng-constant-fork": "0.4.1",
"gulp-notify": "2.2.0",
@ -37,7 +39,7 @@
"gulp-rev-replace": "0.4.3",
"gulp-sourcemaps": "1.6.0",
"gulp-uglify": "1.5.3",
"gulp-useref": "3.0.7",
"gulp-useref": "3.1.0",
"jasmine-core": "2.4.1",
"jasmine-reporters": "2.1.1",
"karma": "0.13.22",
@ -48,16 +50,16 @@
"karma-phantomjs-launcher": "1.0.0",
"karma-script-launcher": "0.2.0",
"lazypipe": "1.0.1",
"lodash": "4.6.1",
"lodash": "4.11.1",
"main-bower-files": "2.11.1",
"map-stream": "0.0.6",
"phantomjs-prebuilt": "2.1.7",
"protractor": "3.2.2",
"protractor": "3.3.0",
"protractor-jasmine2-screenshot-reporter": "0.3.1",
"proxy-middleware": "0.15.0",
"run-sequence": "1.1.5",
"wiredep": "4.0.0",
"xml2js": "0.4.16",
"yargs": "4.3.2"
"yargs": "4.6.0"
},
"engines": {
"node": "^4.3"

70
pom.xml
View File

@ -38,6 +38,7 @@
<awaitility.version>1.7.0</awaitility.version>
<commons-io.version>2.4</commons-io.version>
<commons-lang.version>2.6</commons-lang.version>
<frontend-maven-plugin.version>1.0</frontend-maven-plugin.version>
<gatling.version>2.1.7</gatling.version>
<gatling-maven-plugin.version>2.1.7</gatling-maven-plugin.version>
<hibernate.version>4.3.11.Final</hibernate.version>
@ -128,7 +129,6 @@
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate4</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
@ -636,7 +636,7 @@
jacoco-maven-plugin
</artifactId>
<versionRange>
[0.7.4,)
${jacoco-maven-plugin.version}
</versionRange>
<goals>
<goal>prepare-agent</goal>
@ -648,15 +648,18 @@
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.github.trecloux</groupId>
<groupId>com.github.eirslett</groupId>
<artifactId>
yeoman-maven-plugin
frontend-maven-plugin
</artifactId>
<versionRange>
[0.5,)
${frontend-maven-plugin.version}
</versionRange>
<goals>
<goal>build</goal>
<goal>install-node-and-npm</goal>
<goal>npm</goal>
<goal>bower</goal>
<goal>gulp</goal>
</goals>
</pluginExecutionFilter>
<action>
@ -716,25 +719,58 @@
<build>
<plugins>
<plugin>
<groupId>com.github.trecloux</groupId>
<artifactId>yeoman-maven-plugin</artifactId>
<version>0.5</version>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>run-frontend-build</id>
<phase>generate-resources</phase>
<id>install node and npm</id>
<goals>
<goal>build</goal>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<buildTool>gulp</buildTool>
<buildArgs>build --no-notification</buildArgs>
<nodeVersion>v4.4.3</nodeVersion>
<npmVersion>3.8.3</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>bower install</id>
<goals>
<goal>bower</goal>
</goals>
<configuration>
<arguments>install --no-color</arguments>
</configuration>
</execution>
<execution>
<id>gulp build</id>
<goals>
<goal>gulp</goal>
</goals>
<configuration>
<arguments>build --no-notification</arguments>
</configuration>
</execution>
<execution>
<id>gulp test</id>
<goals>
<goal>gulp</goal>
</goals>
<phase>test</phase>
<configuration>
<arguments>test --no-notification</arguments>
</configuration>
</execution>
</executions>
<configuration>
<yeomanProjectDirectory>${project.basedir}</yeomanProjectDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>

View File

@ -46,12 +46,12 @@ public class SampleApplicationApp {
log.info("Running with Spring profile(s) : {}", Arrays.toString(env.getActiveProfiles()));
Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
if (activeProfiles.contains(Constants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(Constants.SPRING_PROFILE_PRODUCTION)) {
log.error("You have misconfigured your application! " +
"It should not run with both the 'dev' and 'prod' profiles at the same time.");
log.error("You have misconfigured your application! It should not run " +
"with both the 'dev' and 'prod' profiles at the same time.");
}
if (activeProfiles.contains(Constants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(Constants.SPRING_PROFILE_CLOUD)) {
log.error("You have misconfigured your application! " +
"It should not run with both the 'dev' and 'cloud' profiles at the same time.");
log.error("You have misconfigured your application! It should not" +
"run with both the 'dev' and 'cloud' profiles at the same time.");
}
}
}

View File

@ -19,6 +19,7 @@ import javax.persistence.metamodel.EntityType;
import java.util.Set;
import java.util.SortedSet;
@SuppressWarnings("unused")
@Configuration
@EnableCaching
@AutoConfigureAfter(value = { MetricsConfiguration.class, DatabaseConfiguration.class })

View File

@ -5,6 +5,8 @@ package com.mycompany.myapp.config;
*/
public final class Constants {
//Regex for acceptable logins
public static final String LOGIN_REGEX = "^[_'.@A-Za-z0-9-]*$";
// Spring profile for development and production, see http://jhipster.github.io/profiles/
public static final String SPRING_PROFILE_DEVELOPMENT = "dev";
public static final String SPRING_PROFILE_PRODUCTION = "prod";

View File

@ -32,6 +32,8 @@ public class JHipsterProperties {
private final CorsConfiguration cors = new CorsConfiguration();
private final Ribbon ribbon = new Ribbon();
public Async getAsync() {
return async;
}
@ -64,6 +66,10 @@ public class JHipsterProperties {
return cors;
}
public Ribbon getRibbon() {
return ribbon;
}
public static class Async {
private int corePoolSize = 2;
@ -466,6 +472,20 @@ public class JHipsterProperties {
public void setQueueSize(int queueSize) { this.queueSize = queueSize; }
}
}
public static class Ribbon {
private String[] displayOnActiveProfiles;
public String[] getDisplayOnActiveProfiles() {
return displayOnActiveProfiles;
}
public void setDisplayOnActiveProfiles(String[] displayOnActiveProfiles) {
this.displayOnActiveProfiles = displayOnActiveProfiles;
}
}
}

View File

@ -15,6 +15,7 @@ import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
@Configuration
public class LocaleConfiguration extends WebMvcConfigurerAdapter implements EnvironmentAware {
@SuppressWarnings("unused")
private RelaxedPropertyResolver propertyResolver;
@Override

View File

@ -1,5 +1,6 @@
package com.mycompany.myapp.config;
import com.codahale.metrics.JmxReporter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Slf4jReporter;
@ -133,4 +134,5 @@ public class MetricsConfiguration extends MetricsConfigurerAdapter {
}
}
}
}

View File

@ -113,23 +113,10 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
.antMatchers("/api/authenticate").permitAll()
.antMatchers("/api/account/reset_password/init").permitAll()
.antMatchers("/api/account/reset_password/finish").permitAll()
.antMatchers("/api/logs/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/api/audits/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/api/profile-info").permitAll()
.antMatchers("/api/**").authenticated()
.antMatchers("/metrics/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/health/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/trace/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/dump/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/shutdown/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/beans/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/configprops/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/info/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/autoconfig/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/env/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/mappings/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/liquibase/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/v2/api-docs/**").permitAll()
.antMatchers("/configuration/security").permitAll()
.antMatchers("/configuration/ui").permitAll()
.antMatchers("/swagger-ui/index.html").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/protected/**").authenticated() ;

View File

@ -9,6 +9,7 @@ import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
@Configuration
public class ThymeleafConfiguration {
@SuppressWarnings("unused")
private final Logger log = LoggerFactory.getLogger(ThymeleafConfiguration.class);
@Bean

View File

@ -20,6 +20,7 @@ import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import java.io.File;
import java.nio.file.Paths;
import java.util.*;
import javax.inject.Inject;
import javax.servlet.*;
@ -68,17 +69,36 @@ public class WebConfigurer implements ServletContextInitializer, EmbeddedServlet
container.setMimeMappings(mappings);
// When running in an IDE or with ./mvnw spring-boot:run, set location of the static web assets.
setLocationForStaticAssets(container);
}
private void setLocationForStaticAssets(ConfigurableEmbeddedServletContainer container) {
File root;
String prefixPath = resolvePathPrefix();
if (env.acceptsProfiles(Constants.SPRING_PROFILE_PRODUCTION)) {
root = new File("target/www/");
root = new File(prefixPath + "target/www/");
} else {
root = new File("src/main/webapp/");
root = new File(prefixPath + "src/main/webapp/");
}
if (root.exists() && root.isDirectory()) {
container.setDocumentRoot(root);
}
}
/**
* Resolve path prefix to static resources.
*/
private String resolvePathPrefix() {
String fullExecutablePath = this.getClass().getResource("").getPath();
String rootPath = Paths.get(".").toUri().normalize().getPath();
String extractedPath = fullExecutablePath.replace(rootPath, "");
int extractionEndIndex = extractedPath.indexOf("target/");
if(extractionEndIndex <= 0) {
return "";
}
return extractedPath.substring(0, extractionEndIndex);
}
/**
* Initializes the caching HTTP Headers Filter.
*/
@ -115,7 +135,7 @@ public class WebConfigurer implements ServletContextInitializer, EmbeddedServlet
ServletRegistration.Dynamic metricsAdminServlet =
servletContext.addServlet("metricsServlet", new MetricsServlet());
metricsAdminServlet.addMapping("/metrics/metrics/*");
metricsAdminServlet.addMapping("/management/jhipster/metrics/*");
metricsAdminServlet.setAsyncSupported(true);
metricsAdminServlet.setLoadOnStartup(2);
}
@ -133,7 +153,7 @@ public class WebConfigurer implements ServletContextInitializer, EmbeddedServlet
}
/**
* Initializes H2 console
* Initializes H2 console.
*/
private void initH2Console(ServletContext servletContext) {
log.debug("Initialize H2 console");

View File

@ -14,7 +14,6 @@ import java.time.ZonedDateTime;
import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
/**
* Base abstract class for entities which will hold definitions for created, last modified by and created,

View File

@ -1,5 +1,7 @@
package com.mycompany.myapp.domain;
import com.mycompany.myapp.config.Constants;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
@ -11,6 +13,7 @@ import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.time.ZonedDateTime;
@ -29,7 +32,7 @@ public class User extends AbstractAuditingEntity implements Serializable {
private Long id;
@NotNull
@Pattern(regexp = "^[a-z0-9]*$|(anonymousUser)")
@Pattern(regexp = Constants.LOGIN_REGEX)
@Size(min = 1, max = 50)
@Column(length = 50, unique = true, nullable = false)
private String login;
@ -48,10 +51,9 @@ public class User extends AbstractAuditingEntity implements Serializable {
@Column(name = "last_name", length = 50)
private String lastName;
@NotNull
@Email
@Size(max = 100)
@Column(length = 100, unique = true, nullable = false)
@Column(length = 100, unique = true)
private String email;
@NotNull
@ -100,8 +102,9 @@ public class User extends AbstractAuditingEntity implements Serializable {
return login;
}
//Lowercase the login before saving it in database
public void setLogin(String login) {
this.login = login;
this.login = login.toLowerCase(Locale.ENGLISH);
}
public String getPassword() {

View File

@ -57,7 +57,8 @@ public class JSR310LocalDateDeserializer extends JsonDeserializer<LocalDate> {
return null;
}
return LocalDate.parse(string, ISO_DATE_OPTIONAL_TIME);
default:
throw context.wrongTokenException(parser, JsonToken.START_ARRAY, "Expected array or string.");
}
throw context.wrongTokenException(parser, JsonToken.START_ARRAY, "Expected array or string.");
}
}

View File

@ -9,6 +9,7 @@ import java.util.List;
/**
* Spring Data JPA repository for the BankAccount entity.
*/
@SuppressWarnings("unused")
public interface BankAccountRepository extends JpaRepository<BankAccount,Long> {
@Query("select bankAccount from BankAccount bankAccount where bankAccount.user.login = ?#{principal.username}")

View File

@ -24,7 +24,7 @@ public class CustomAuditEventRepository implements AuditEventRepository {
private static final String AUTHORIZATION_FAILURE = "AUTHORIZATION_FAILURE";
private static final String ANONYMOUS_USER = "anonymousUser";
private static final String ANONYMOUS_USER = "anonymoususer";
@Inject
private PersistenceAuditEventRepository persistenceAuditEventRepository;

View File

@ -9,6 +9,7 @@ import java.util.List;
/**
* Spring Data JPA repository for the Label entity.
*/
@SuppressWarnings("unused")
public interface LabelRepository extends JpaRepository<Label,Long> {
}

View File

@ -10,6 +10,7 @@ import java.util.List;
/**
* Spring Data JPA repository for the Operation entity.
*/
@SuppressWarnings("unused")
public interface OperationRepository extends JpaRepository<Operation,Long> {
@Query("select distinct operation from Operation operation left join fetch operation.labels")

View File

@ -4,7 +4,6 @@ import com.mycompany.myapp.domain.User;
import java.time.ZonedDateTime;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
import java.util.Optional;

View File

@ -1,13 +1,11 @@
package com.mycompany.myapp.security;
import com.mycompany.myapp.domain.PersistentToken;
import com.mycompany.myapp.domain.User;
import com.mycompany.myapp.repository.PersistentTokenRepository;
import com.mycompany.myapp.repository.UserRepository;
import com.mycompany.myapp.config.JHipsterProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.dao.DataAccessException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.UserDetails;

View File

@ -1,6 +1,4 @@
package com.mycompany.myapp.security;
import com.mycompany.myapp.domain.Authority;
import com.mycompany.myapp.domain.User;
import com.mycompany.myapp.repository.UserRepository;
import org.slf4j.Logger;
@ -31,7 +29,7 @@ public class UserDetailsService implements org.springframework.security.core.use
@Transactional
public UserDetails loadUserByUsername(final String login) {
log.debug("Authenticating {}", login);
String lowercaseLogin = login.toLowerCase();
String lowercaseLogin = login.toLowerCase(Locale.ENGLISH);
Optional<User> userFromDatabase = userRepository.findOneByLogin(lowercaseLogin);
return userFromDatabase.map(user -> {
if (!user.getActivated()) {

View File

@ -7,6 +7,8 @@ import org.springframework.security.core.AuthenticationException;
*/
public class UserNotActivatedException extends AuthenticationException {
private static final long serialVersionUID = 1L;
public UserNotActivatedException(String message) {
super(message);
}

View File

@ -10,7 +10,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.inject.Inject;
import java.util.List;
import java.util.Optional;
/**

View File

@ -1,7 +1,6 @@
package com.mycompany.myapp.service;
import com.mycompany.myapp.domain.Authority;
import com.mycompany.myapp.domain.PersistentToken;
import com.mycompany.myapp.domain.User;
import com.mycompany.myapp.repository.AuthorityRepository;
import com.mycompany.myapp.repository.PersistentTokenRepository;
@ -9,8 +8,6 @@ import com.mycompany.myapp.repository.UserRepository;
import com.mycompany.myapp.security.SecurityUtils;
import com.mycompany.myapp.service.util.RandomUtil;
import com.mycompany.myapp.web.rest.dto.ManagedUserDTO;
import java.time.ZonedDateTime;
import java.time.LocalDate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
@ -18,6 +15,8 @@ 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;
import java.util.*;

View File

@ -17,7 +17,7 @@ public class CachingHttpHeadersFilter implements Filter {
private long CACHE_TIME_TO_LIVE = TimeUnit.DAYS.toMillis(1461L);
private JHipsterProperties jHipsterProperties;;
private JHipsterProperties jHipsterProperties;
public CachingHttpHeadersFilter(JHipsterProperties jHipsterProperties) {
this.jHipsterProperties = jHipsterProperties;

View File

@ -1,7 +1,7 @@
package com.mycompany.myapp.web.rest;
import com.codahale.metrics.annotation.Timed;
import com.mycompany.myapp.domain.Authority;
import com.mycompany.myapp.domain.PersistentToken;
import com.mycompany.myapp.domain.User;
import com.mycompany.myapp.repository.PersistentTokenRepository;
@ -67,7 +67,7 @@ public class AccountResource {
HttpHeaders textPlainHeaders = new HttpHeaders();
textPlainHeaders.setContentType(MediaType.TEXT_PLAIN);
return userRepository.findOneByLogin(managedUserDTO.getLogin())
return userRepository.findOneByLogin(managedUserDTO.getLogin().toLowerCase())
.map(user -> new ResponseEntity<>("login already in use", textPlainHeaders, HttpStatus.BAD_REQUEST))
.orElseGet(() -> userRepository.findOneByEmail(managedUserDTO.getEmail())
.map(user -> new ResponseEntity<>("e-mail address already in use", textPlainHeaders, HttpStatus.BAD_REQUEST))

View File

@ -22,7 +22,7 @@ import java.util.List;
* REST controller for getting the audit events.
*/
@RestController
@RequestMapping(value = "/api/audits", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/management/jhipster/audits", produces = MediaType.APPLICATION_JSON_VALUE)
public class AuditResource {
private AuditEventService auditEventService;

View File

@ -17,7 +17,7 @@ import java.util.stream.Collectors;
* Controller for view and managing Log Level at runtime.
*/
@RestController
@RequestMapping("/api")
@RequestMapping("/management/jhipster")
public class LogsResource {
@RequestMapping(value = "/logs",

View File

@ -0,0 +1,58 @@
package com.mycompany.myapp.web.rest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.inject.Inject;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mycompany.myapp.config.JHipsterProperties;
@RestController
@RequestMapping("/api")
public class ProfileInfoResource {
@Inject
Environment env;
@Inject
private JHipsterProperties jHipsterProperties;
@RequestMapping("/profile-info")
public ProfileInfoResponse getActiveProfiles() {
return new ProfileInfoResponse(env.getActiveProfiles(), getRibbonEnv());
}
private String getRibbonEnv() {
String[] activeProfiles = env.getActiveProfiles();
String[] displayOnActiveProfiles = jHipsterProperties.getRibbon().getDisplayOnActiveProfiles();
if (displayOnActiveProfiles == null) {
return null;
}
List<String> ribbonProfiles = new ArrayList<>(Arrays.asList(displayOnActiveProfiles));
List<String> springBootProfiles = Arrays.asList(activeProfiles);
ribbonProfiles.retainAll(springBootProfiles);
if (ribbonProfiles.size() > 0) {
return ribbonProfiles.get(0);
}
return null;
}
class ProfileInfoResponse {
public String[] activeProfiles;
public String ribbonEnv;
ProfileInfoResponse(String[] activeProfiles,String ribbonEnv) {
this.activeProfiles=activeProfiles;
this.ribbonEnv=ribbonEnv;
}
}
}

View File

@ -1,5 +1,6 @@
package com.mycompany.myapp.web.rest;
import com.mycompany.myapp.config.Constants;
import com.codahale.metrics.annotation.Timed;
import com.mycompany.myapp.domain.Authority;
import com.mycompany.myapp.domain.User;
@ -9,7 +10,6 @@ import com.mycompany.myapp.security.AuthoritiesConstants;
import com.mycompany.myapp.service.MailService;
import com.mycompany.myapp.service.UserService;
import com.mycompany.myapp.web.rest.dto.ManagedUserDTO;
import com.mycompany.myapp.web.rest.dto.UserDTO;
import com.mycompany.myapp.web.rest.util.HeaderUtil;
import com.mycompany.myapp.web.rest.util.PaginationUtil;
import org.slf4j.Logger;
@ -94,7 +94,9 @@ public class UserResource {
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<?> createUser(@RequestBody ManagedUserDTO managedUserDTO, HttpServletRequest request) throws URISyntaxException {
log.debug("REST request to save User : {}", managedUserDTO);
if (userRepository.findOneByLogin(managedUserDTO.getLogin()).isPresent()) {
//Lowercase the user login before comparing with database
if (userRepository.findOneByLogin(managedUserDTO.getLogin().toLowerCase()).isPresent()) {
return ResponseEntity.badRequest()
.headers(HeaderUtil.createFailureAlert("userManagement", "userexists", "Login already in use"))
.body(null);
@ -137,7 +139,7 @@ public class UserResource {
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserDTO.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert("userManagement", "emailexists", "E-mail already in use")).body(null);
}
existingUser = userRepository.findOneByLogin(managedUserDTO.getLogin());
existingUser = userRepository.findOneByLogin(managedUserDTO.getLogin().toLowerCase());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserDTO.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert("userManagement", "userexists", "Login already in use")).body(null);
}
@ -192,7 +194,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:[_'.@a-z0-9-]+}",
@RequestMapping(value = "/users/{login:" + Constants.LOGIN_REGEX + "}",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
@ -209,7 +211,7 @@ public class UserResource {
* @param login the login of the user to delete
* @return the ResponseEntity with status 200 (OK)
*/
@RequestMapping(value = "/users/{login:[_'.@a-z0-9-]+}",
@RequestMapping(value = "/users/{login:" + Constants.LOGIN_REGEX + "}",
method = RequestMethod.DELETE,
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed

View File

@ -3,6 +3,7 @@ package com.mycompany.myapp.web.rest.dto;
public class KeyAndPasswordDTO {
private String key;
private String newPassword;
public KeyAndPasswordDTO() {

View File

@ -1,5 +1,7 @@
package com.mycompany.myapp.web.rest.dto;
import com.mycompany.myapp.config.Constants;
import com.mycompany.myapp.domain.Authority;
import com.mycompany.myapp.domain.User;
@ -13,7 +15,7 @@ import java.util.stream.Collectors;
*/
public class UserDTO {
@Pattern(regexp = "^[a-z0-9]*$")
@Pattern(regexp = Constants.LOGIN_REGEX)
@NotNull
@Size(min = 1, max = 50)
private String login;
@ -48,7 +50,7 @@ public class UserDTO {
public UserDTO(String login, String firstName, String lastName,
String email, boolean activated, String langKey, Set<String> authorities) {
this.login = login;
this.login = login;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;

View File

@ -1,5 +1,7 @@
package com.mycompany.myapp.web.rest.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
/**
@ -8,6 +10,8 @@ import org.springframework.http.HttpHeaders;
*/
public class HeaderUtil {
private static final Logger log = LoggerFactory.getLogger(HeaderUtil.class);
public static HttpHeaders createAlert(String message, String param) {
HttpHeaders headers = new HttpHeaders();
headers.add("X-sampleApplicationApp-alert", message);
@ -28,6 +32,7 @@ public class HeaderUtil {
}
public static HttpHeaders createFailureAlert(String entityName, String errorKey, String defaultMessage) {
log.error("Entity creation failed, {}", defaultMessage);
HttpHeaders headers = new HttpHeaders();
headers.add("X-sampleApplicationApp-error", "error." + errorKey);
headers.add("X-sampleApplicationApp-params", entityName);

View File

@ -56,6 +56,10 @@ jhipster:
timeToLiveSeconds: 3600
ehcache:
maxBytesLocalHeap: 16M
security:
rememberMe:
# security key (this key should be unique for your application, and kept secret)
key: 5c37379956bd1242f5636c8cb322c2966ad81277
mail: # specific JHipster mail property, for standard properties see MailProperties
from: sampleApplication@localhost
metrics: # DropWizard Metrics configuration, used by MetricsConfiguration
@ -69,7 +73,7 @@ jhipster:
host: localhost
port: 2003
prefix: sampleApplication
logs: # report metrics in the logs
logs: # Reports Dropwizard metrics in the logs
enabled: false
reportFrequency: 60 # in seconds
logging:

View File

@ -53,6 +53,7 @@ server:
compression:
enabled: true
mime-types: text/html,text/xml,text/plain,text/css, application/javascript, application/json
min-response-size: 1024
# ===================================================================
# JHipster specific properties
@ -66,6 +67,10 @@ jhipster:
timeToLiveSeconds: 3600
ehcache:
maxBytesLocalHeap: 256M
security:
rememberMe:
# security key (this key should be unique for your application, and kept secret)
key: 5c37379956bd1242f5636c8cb322c2966ad81277
mail: # specific JHipster mail property, for standard properties see MailProperties
from: sampleApplication@localhost
metrics: # DropWizard Metrics configuration, used by MetricsConfiguration
@ -79,7 +84,7 @@ jhipster:
host: localhost
port: 2003
prefix: sampleApplication
logs: # report metrics in the logs