├── .bowerrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.json ├── .gitattributes ├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── .travis.yml ├── .yo-rc.json ├── README.md ├── bower.json ├── gulp ├── build.js ├── config.js ├── handleErrors.js ├── serve.js └── utils.js ├── gulpfile.js ├── mvnw ├── mvnw.cmd ├── package.json ├── pom.xml └── src ├── main ├── docker │ ├── Dockerfile │ ├── app.yml │ ├── cassandra-cluster.yml │ ├── cassandra-migration.yml │ ├── cassandra.yml │ ├── cassandra │ │ ├── Cassandra-Migration.Dockerfile │ │ └── scripts │ │ │ ├── autoMigrate.sh │ │ │ └── execute-cql.sh │ ├── central-server-config │ │ └── application.yml │ ├── jhipster-registry.yml │ ├── postgresql.yml │ └── sonar.yml ├── java │ └── com │ │ └── mycompany │ │ └── myapp │ │ ├── ApplicationWebXml.java │ │ ├── RibbonCacheApp.java │ │ ├── aop │ │ └── logging │ │ │ └── LoggingAspect.java │ │ ├── async │ │ ├── ExceptionHandlingAsyncTaskExecutor.java │ │ └── package-info.java │ │ ├── config │ │ ├── AsyncConfiguration.java │ │ ├── CacheConfiguration.java │ │ ├── CloudDatabaseConfiguration.java │ │ ├── Constants.java │ │ ├── DatabaseConfiguration.java │ │ ├── DefaultProfileUtil.java │ │ ├── GatewayConfiguration.java │ │ ├── JHipsterProperties.java │ │ ├── JacksonConfiguration.java │ │ ├── LocaleConfiguration.java │ │ ├── LoggingAspectConfiguration.java │ │ ├── LoggingConfiguration.java │ │ ├── MetricsConfiguration.java │ │ ├── SecurityConfiguration.java │ │ ├── ThymeleafConfiguration.java │ │ ├── WebConfigurer.java │ │ ├── apidoc │ │ │ ├── GatewaySwaggerResourcesProvider.java │ │ │ ├── SwaggerConfiguration.java │ │ │ └── package-info.java │ │ ├── audit │ │ │ ├── AuditEventConverter.java │ │ │ └── package-info.java │ │ ├── cassandra │ │ │ ├── CassandraConfiguration.java │ │ │ ├── CustomZonedDateTimeCodec.java │ │ │ └── package-info.java │ │ ├── liquibase │ │ │ ├── AsyncSpringLiquibase.java │ │ │ └── package-info.java │ │ ├── locale │ │ │ ├── AngularCookieLocaleResolver.java │ │ │ └── package-info.java │ │ ├── metrics │ │ │ └── SpectatorLogMetricWriter.java │ │ └── package-info.java │ │ ├── domain │ │ ├── AbstractAuditingEntity.java │ │ ├── Authority.java │ │ ├── PersistentAuditEvent.java │ │ ├── User.java │ │ ├── package-info.java │ │ └── util │ │ │ ├── FixedH2Dialect.java │ │ │ ├── FixedPostgreSQL82Dialect.java │ │ │ ├── JSR310DateConverters.java │ │ │ ├── JSR310DateTimeSerializer.java │ │ │ ├── JSR310LocalDateDeserializer.java │ │ │ └── JSR310PersistenceConverters.java │ │ ├── gateway │ │ ├── TokenRelayFilter.java │ │ ├── accesscontrol │ │ │ └── AccessControlFilter.java │ │ ├── caching │ │ │ ├── CachingBaseFilter.java │ │ │ ├── CachingPostFilter.java │ │ │ └── CachingPreFilter.java │ │ ├── ratelimiting │ │ │ ├── RateLimitingFilter.java │ │ │ └── RateLimitingRepository.java │ │ └── responserewriting │ │ │ └── SwaggerBasePathRewritingFilter.java │ │ ├── repository │ │ ├── AuthorityRepository.java │ │ ├── CustomAuditEventRepository.java │ │ ├── PersistenceAuditEventRepository.java │ │ ├── UserRepository.java │ │ └── package-info.java │ │ ├── security │ │ ├── AuthoritiesConstants.java │ │ ├── Http401UnauthorizedEntryPoint.java │ │ ├── SecurityUtils.java │ │ ├── SpringSecurityAuditorAware.java │ │ ├── UserDetailsService.java │ │ ├── UserNotActivatedException.java │ │ ├── jwt │ │ │ ├── JWTConfigurer.java │ │ │ ├── JWTFilter.java │ │ │ └── TokenProvider.java │ │ └── package-info.java │ │ ├── service │ │ ├── AuditEventService.java │ │ ├── MailService.java │ │ ├── UserService.java │ │ ├── package-info.java │ │ └── util │ │ │ └── RandomUtil.java │ │ └── web │ │ ├── filter │ │ ├── CachingHttpHeadersFilter.java │ │ └── package-info.java │ │ └── rest │ │ ├── AccountResource.java │ │ ├── AuditResource.java │ │ ├── GatewayResource.java │ │ ├── JWTToken.java │ │ ├── LogsResource.java │ │ ├── ProfileInfoResource.java │ │ ├── UserJWTController.java │ │ ├── UserResource.java │ │ ├── dto │ │ ├── KeyAndPasswordDTO.java │ │ ├── LoggerDTO.java │ │ ├── LoginDTO.java │ │ ├── ManagedUserDTO.java │ │ ├── RouteDTO.java │ │ ├── UserDTO.java │ │ └── package-info.java │ │ ├── errors │ │ ├── CustomParameterizedException.java │ │ ├── ErrorConstants.java │ │ ├── ErrorDTO.java │ │ ├── ExceptionTranslator.java │ │ ├── FieldErrorDTO.java │ │ └── ParameterizedErrorDTO.java │ │ ├── mapper │ │ └── UserMapper.java │ │ ├── package-info.java │ │ └── util │ │ ├── HeaderUtil.java │ │ └── PaginationUtil.java ├── resources │ ├── .h2.server.properties │ ├── banner.txt │ ├── config │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ ├── bootstrap-dev.yml │ │ ├── bootstrap-prod.yml │ │ ├── cql │ │ │ ├── changelog │ │ │ │ └── README.md │ │ │ ├── create-keyspace-prod.cql │ │ │ ├── create-keyspace.cql │ │ │ └── drop-keyspace.cql │ │ └── liquibase │ │ │ ├── authorities.csv │ │ │ ├── changelog │ │ │ └── 00000000000000_initial_schema.xml │ │ │ ├── master.xml │ │ │ ├── users.csv │ │ │ └── users_authorities.csv │ ├── ehcache.xml │ ├── i18n │ │ └── messages.properties │ ├── logback-spring.xml │ ├── mails │ │ ├── activationEmail.html │ │ ├── creationEmail.html │ │ └── passwordResetEmail.html │ └── templates │ │ └── error.html └── webapp │ ├── 404.html │ ├── app │ ├── account │ │ ├── account.state.js │ │ ├── activate │ │ │ ├── activate.controller.js │ │ │ ├── activate.html │ │ │ └── activate.state.js │ │ ├── password │ │ │ ├── password-strength-bar.directive.js │ │ │ ├── password.controller.js │ │ │ ├── password.html │ │ │ └── password.state.js │ │ ├── register │ │ │ ├── register.controller.js │ │ │ ├── register.html │ │ │ └── register.state.js │ │ ├── reset │ │ │ ├── finish │ │ │ │ ├── reset.finish.controller.js │ │ │ │ ├── reset.finish.html │ │ │ │ └── reset.finish.state.js │ │ │ └── request │ │ │ │ ├── reset.request.controller.js │ │ │ │ ├── reset.request.html │ │ │ │ └── reset.request.state.js │ │ └── settings │ │ │ ├── settings.controller.js │ │ │ ├── settings.html │ │ │ └── settings.state.js │ ├── admin │ │ ├── admin.state.js │ │ ├── audits │ │ │ ├── audits.controller.js │ │ │ ├── audits.html │ │ │ ├── audits.service.js │ │ │ └── audits.state.js │ │ ├── configuration │ │ │ ├── configuration.controller.js │ │ │ ├── configuration.html │ │ │ ├── configuration.service.js │ │ │ └── configuration.state.js │ │ ├── docs │ │ │ ├── docs.html │ │ │ └── docs.state.js │ │ ├── gateway │ │ │ ├── gateway.controller.js │ │ │ ├── gateway.html │ │ │ ├── gateway.routes.service.js │ │ │ └── gateway.state.js │ │ ├── health │ │ │ ├── health.controller.js │ │ │ ├── health.html │ │ │ ├── health.modal.controller.js │ │ │ ├── health.modal.html │ │ │ ├── health.service.js │ │ │ └── health.state.js │ │ ├── logs │ │ │ ├── logs.controller.js │ │ │ ├── logs.html │ │ │ ├── logs.service.js │ │ │ └── logs.state.js │ │ ├── metrics │ │ │ ├── metrics.controller.js │ │ │ ├── metrics.html │ │ │ ├── metrics.modal.controller.js │ │ │ ├── metrics.modal.html │ │ │ ├── metrics.service.js │ │ │ └── metrics.state.js │ │ └── user-management │ │ │ ├── user-management-delete-dialog.controller.js │ │ │ ├── user-management-delete-dialog.html │ │ │ ├── user-management-detail.controller.js │ │ │ ├── user-management-detail.html │ │ │ ├── user-management-dialog.controller.js │ │ │ ├── user-management-dialog.html │ │ │ ├── user-management.controller.js │ │ │ ├── user-management.html │ │ │ └── user-management.state.js │ ├── app.constants.js │ ├── app.module.js │ ├── app.state.js │ ├── blocks │ │ ├── config │ │ │ ├── alert.config.js │ │ │ ├── compile.config.js │ │ │ ├── http.config.js │ │ │ ├── localstorage.config.js │ │ │ ├── uib-pager.config.js │ │ │ └── uib-pagination.config.js │ │ ├── handlers │ │ │ └── state.handler.js │ │ └── interceptor │ │ │ ├── auth-expired.interceptor.js │ │ │ ├── auth.interceptor.js │ │ │ ├── errorhandler.interceptor.js │ │ │ └── notification.interceptor.js │ ├── components │ │ ├── alert │ │ │ ├── alert-error.directive.js │ │ │ ├── alert.directive.js │ │ │ └── alert.service.js │ │ ├── form │ │ │ ├── maxbytes.directive.js │ │ │ ├── minbytes.directive.js │ │ │ ├── pagination.constants.js │ │ │ └── show-validation.directive.js │ │ ├── login │ │ │ ├── login.controller.js │ │ │ ├── login.html │ │ │ └── login.service.js │ │ └── util │ │ │ ├── base64.service.js │ │ │ ├── capitalize.filter.js │ │ │ ├── data-util.service.js │ │ │ ├── date-util.service.js │ │ │ ├── jhi-item-count.directive.js │ │ │ ├── pagination-util.service.js │ │ │ ├── parse-links.service.js │ │ │ ├── sort-by.directive.js │ │ │ ├── sort.directive.js │ │ │ ├── truncate-characters.filter.js │ │ │ └── truncate-words.filter.js │ ├── entities │ │ └── entity.state.js │ ├── home │ │ ├── home.controller.js │ │ ├── home.html │ │ └── home.state.js │ ├── layouts │ │ ├── error │ │ │ ├── accessdenied.html │ │ │ ├── error.html │ │ │ └── error.state.js │ │ └── navbar │ │ │ ├── active-link.directive.js │ │ │ ├── navbar.controller.js │ │ │ └── navbar.html │ └── services │ │ ├── auth │ │ ├── account.service.js │ │ ├── activate.service.js │ │ ├── auth.jwt.service.js │ │ ├── auth.service.js │ │ ├── has-any-authority.directive.js │ │ ├── has-authority.directive.js │ │ ├── password-reset-finish.service.js │ │ ├── password-reset-init.service.js │ │ ├── password.service.js │ │ ├── principal.service.js │ │ └── register.service.js │ │ ├── profiles │ │ ├── page-ribbon.directive.js │ │ └── profile.service.js │ │ └── user │ │ └── user.service.js │ ├── content │ ├── css │ │ ├── documentation.css │ │ └── main.css │ └── images │ │ ├── hipster.png │ │ ├── hipster2x.png │ │ └── logo-jhipster.png │ ├── favicon.ico │ ├── index.html │ ├── robots.txt │ └── swagger-ui │ ├── images │ └── throbber.gif │ └── index.html └── test ├── java └── com │ └── mycompany │ └── myapp │ ├── gateway │ ├── caching │ │ ├── CachingPostFilterTest.java │ │ └── CachingPreFilterTest.java │ └── responserewriting │ │ └── SwaggerBasePathRewritingFilterTest.java │ ├── security │ └── SecurityUtilsUnitTest.java │ ├── service │ └── UserServiceIntTest.java │ └── web │ └── rest │ ├── AccountResourceIntTest.java │ ├── AuditResourceIntTest.java │ ├── TestUtil.java │ └── UserResourceIntTest.java ├── javascript ├── karma.conf.js └── spec │ ├── app │ ├── account │ │ ├── activate │ │ │ └── activate.controller.spec.js │ │ ├── password │ │ │ ├── password-strength-bar.directive.spec.js │ │ │ └── password.controller.spec.js │ │ ├── register │ │ │ └── register.controller.spec.js │ │ ├── reset │ │ │ ├── finish │ │ │ │ └── reset.finish.controller.spec.js │ │ │ └── request │ │ │ │ └── reset.request.controller.spec.js │ │ └── settings │ │ │ └── settings.controller.spec.js │ ├── admin │ │ └── health │ │ │ └── health.controller.spec.js │ ├── components │ │ └── login │ │ │ └── login.controller.spec.js │ └── services │ │ └── auth │ │ └── auth.services.spec.js │ └── helpers │ ├── httpBackend.js │ └── module.js └── resources ├── config └── application.yml └── logback-test.xml /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "src/main/webapp/bower_components" 3 | } 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | 9 | # Change these settings to your own preference 10 | indent_style = space 11 | indent_size = 4 12 | 13 | # We recommend you to keep these unchanged 14 | end_of_line = lf 15 | charset = utf-8 16 | trim_trailing_whitespace = true 17 | insert_final_newline = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | 22 | [{package,bower}.json] 23 | indent_style = space 24 | indent_size = 2 25 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # more info here - http://eslint.org/docs/user-guide/configuring.html#ignoring-files-and-directories 2 | 3 | # node_modules ignored by default 4 | 5 | # ignore bower_components 6 | src/main/webapp/bower_components 7 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | // See: http://eslint.org/ 2 | // See: https://www.npmjs.com/package/eslint-plugin-angular 3 | { 4 | "extends": [ 5 | "eslint:recommended", 6 | "angular" 7 | ], 8 | "env": { 9 | "node": true, 10 | "browser": true 11 | }, 12 | // severity for a rule should be one of the following: 0 = off, 1 = warning, 2 = error 13 | "rules": { 14 | // coding style 15 | "wrap-iife": [2, "inside"], 16 | "eqeqeq": 2, 17 | "no-use-before-define": [2, "nofunc"], 18 | "no-unused-vars": [2, {"vars": "local", "args": "none"}], 19 | "no-multi-str": 2, 20 | "no-irregular-whitespace": 2, 21 | "semi": [2, "always"], 22 | "indent": 2, 23 | 24 | // os/git options 25 | // we want to run on all OSes 26 | "linebreak-style": 0, 27 | "eol-last": 2 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # All text files should have the "lf" (Unix) line endings 2 | * text eol=lf 3 | 4 | # Explicitly declare text files you want to always be normalized and converted 5 | # to native line endings on checkout. 6 | *.java text 7 | *.js text 8 | *.css text 9 | *.html text 10 | 11 | # Denote all files that are truly binary and should not be modified. 12 | *.png binary 13 | *.jpg binary 14 | *.jar binary 15 | *.pdf binary 16 | *.eot binary 17 | *.ttf binary 18 | *.gzip binary 19 | *.gz binary 20 | *.ai binary 21 | *.eps binary 22 | *.swf binary 23 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gmarziou/gateway-ribbon-cache/bfa5a0ce172595af4d9b258f0d7abf2315da0ae2/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "4.4.3" 4 | sudo: false 5 | before_install: npm install -g gulp 6 | install: npm install 7 | before_script: gulp build 8 | notifications: 9 | webhooks: 10 | on_success: change # options: [always|never|change] default: always 11 | on_failure: always # options: [always|never|change] default: always 12 | on_start: false # default: false 13 | -------------------------------------------------------------------------------- /.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-jhipster": { 3 | "jhipsterVersion": "3.4.2", 4 | "baseName": "ribbon_cache", 5 | "packageName": "com.mycompany.myapp", 6 | "packageFolder": "com/mycompany/myapp", 7 | "serverPort": "8080", 8 | "authenticationType": "jwt", 9 | "hibernateCache": "no", 10 | "clusteredHttpSession": "no", 11 | "websocket": "no", 12 | "databaseType": "sql", 13 | "devDatabaseType": "h2Memory", 14 | "prodDatabaseType": "postgresql", 15 | "searchEngine": "no", 16 | "buildTool": "maven", 17 | "jwtSecretKey": "35d5a5cdf950380203c44bf65306dec1f2cc8660", 18 | "useSass": false, 19 | "applicationType": "gateway", 20 | "testFrameworks": [], 21 | "jhiPrefix": "jhi", 22 | "enableTranslation": false 23 | } 24 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gateway caching 2 | 3 | Caching implemented with 2 Zuul filters: 4 | 5 | - [CachingPreFilter](src/main/java/com/mycompany/myapp/gateway/caching/CachingPreFilter.java): reads cache and fill response if URI found in cache 6 | - [CachingPostFilter](src/main/java/com/mycompany/myapp/gateway/caching/CachingPostFilter.java): stores response into cache using URI as key 7 | 8 | Cache name uses service id. 9 | 10 | We should take into account whether the response is gzipped. 11 | 12 | ## Define an API to manage caches 13 | 14 | Maybe on top of gateway routes. 15 | 16 | - GET /api/gateway/routes/[serviceId}/cache returns cache information (# elements, hits, configuration, ...) if any 17 | - POST /api/gateway/routes/{serviceId}/cache/clear clears cache 18 | 19 | ## Add tests and look at closing connections 20 | 21 | https://github.com/spring-cloud/spring-cloud-netflix/pull/1196 22 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.0", 3 | "name": "ribbon-cache", 4 | "appPath": "src/main/webapp/", 5 | "testPath": "src/test/javascript/spec", 6 | "dependencies": { 7 | "angular": "1.5.5", 8 | "angular-aria": "1.5.5", 9 | "angular-bootstrap": "1.3.3", 10 | "angular-cache-buster": "0.4.3", 11 | "angular-cookies": "1.5.5", 12 | "ngstorage": "0.3.10", 13 | "angular-loading-bar": "0.9.0", 14 | "angular-resource": "1.5.5", 15 | "angular-sanitize": "1.5.5", 16 | "angular-ui-router": "0.3.0", 17 | "bootstrap": "3.3.6", 18 | "bootstrap-ui-datetime-picker": "2.4.0", 19 | "jquery": "2.2.4", 20 | "json3": "3.3.2", 21 | "messageformat": "0.3.1", 22 | "modernizr": "3.3.1", 23 | "ng-file-upload": "12.0.4", 24 | "ngInfiniteScroll": "1.2.2", 25 | "swagger-ui": "2.1.4" 26 | }, 27 | "devDependencies": { 28 | "angular-mocks": "1.5.5" 29 | }, 30 | "overrides": { 31 | "angular" : { 32 | "dependencies": { 33 | "jquery": "2.2.4" 34 | } 35 | }, 36 | "angular-cache-buster" : { 37 | "dependencies": { 38 | "angular": "1.5.5" 39 | } 40 | }, 41 | "bootstrap": { 42 | "main": [ 43 | "dist/css/bootstrap.css" 44 | ] 45 | } 46 | }, 47 | "resolutions": { 48 | "angular": "1.5.5", 49 | "angular-cookies": "1.5.5", 50 | "angular-bootstrap": "1.3.3", 51 | "jquery": "2.2.4" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /gulp/build.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'), 2 | gulp = require('gulp'), 3 | lazypipe = require('lazypipe'), 4 | footer = require('gulp-footer'), 5 | sourcemaps = require('gulp-sourcemaps'), 6 | rev = require('gulp-rev'), 7 | htmlmin = require('gulp-htmlmin'), 8 | ngAnnotate = require('gulp-ng-annotate'), 9 | prefix = require('gulp-autoprefixer'), 10 | cssnano = require('gulp-cssnano'), 11 | uglify = require('gulp-uglify'), 12 | useref = require("gulp-useref"), 13 | revReplace = require("gulp-rev-replace") 14 | plumber = require('gulp-plumber'), 15 | gulpIf = require('gulp-if'), 16 | handleErrors = require('./handleErrors'); 17 | 18 | var config = require('./config'); 19 | 20 | var initTask = lazypipe() 21 | .pipe(sourcemaps.init) 22 | .pipe(footer, ';'); 23 | var jsTask = lazypipe() 24 | .pipe(ngAnnotate) 25 | .pipe(uglify); 26 | var cssTask = lazypipe() 27 | .pipe(prefix) 28 | .pipe(cssnano); 29 | 30 | module.exports = function() { 31 | var templates = fs.readFileSync(config.tmp + '/templates.js'); 32 | var manifest = gulp.src(config.revManifest); 33 | 34 | return gulp.src([config.app + '**/*.html', 35 | '!' + config.app + 'app/**/*.html', 36 | '!' + config.app + 'swagger-ui/**/*', 37 | '!' + config.bower + '**/*.html']) 38 | .pipe(plumber({errorHandler: handleErrors})) 39 | //init sourcemaps and prepend semicolon 40 | .pipe(useref({}, initTask)) 41 | //append html templates 42 | .pipe(gulpIf('**/app.js', footer(templates))) 43 | .pipe(gulpIf('*.js', jsTask())) 44 | .pipe(gulpIf('*.css', cssTask())) 45 | .pipe(gulpIf('*.html', htmlmin({collapseWhitespace: true}))) 46 | .pipe(gulpIf('**/*.!(html)', rev())) 47 | .pipe(revReplace({manifest: manifest})) 48 | .pipe(sourcemaps.write('.')) 49 | .pipe(gulp.dest(config.dist)); 50 | } 51 | -------------------------------------------------------------------------------- /gulp/config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | app: 'src/main/webapp/', 3 | dist: 'target/www/', 4 | test: 'src/test/javascript/', 5 | bower: 'src/main/webapp/bower_components/', 6 | tmp: 'target/tmp', 7 | revManifest: 'target/tmp/rev-manifest.json', 8 | port: 9000, 9 | apiPort: 8080, 10 | liveReloadPort: 35729, 11 | uri: 'http://localhost:', 12 | constantTemplate: 13 | '(function () {\n' + 14 | ' \'use strict\';\n' + 15 | ' // DO NOT EDIT THIS FILE, EDIT THE GULP TASK NGCONSTANT SETTINGS INSTEAD WHICH GENERATES THIS FILE\n' + 16 | ' angular\n' + 17 | ' .module(\'<%- moduleName %>\')\n' + 18 | '<% constants.forEach(function(constant) { %> .constant(\'<%- constant.name %>\', <%= constant.value %>)\n<% }) %>;\n' + 19 | '})();\n' 20 | }; 21 | -------------------------------------------------------------------------------- /gulp/handleErrors.js: -------------------------------------------------------------------------------- 1 | var notify = require("gulp-notify"); 2 | var argv = require('yargs').argv; 3 | 4 | module.exports = function() { 5 | 6 | var args = Array.prototype.slice.call(arguments); 7 | var notification = argv.notification === undefined ? true : argv.notification; 8 | // Send error to notification center with gulp-notify 9 | if(notification) { 10 | notify.onError({ 11 | title: "JHipster Gulp Build", 12 | subtitle: "Failure!", 13 | message: "Error: <%= error.message %>", 14 | sound: "Beep" 15 | }).apply(this, args); 16 | } 17 | // Keep gulp from hanging on this task 18 | this.emit('end'); 19 | 20 | }; 21 | -------------------------------------------------------------------------------- /gulp/serve.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'), 2 | util = require('./utils'), 3 | url = require('url'), 4 | browserSync = require('browser-sync'), 5 | proxy = require('proxy-middleware'); 6 | 7 | var config = require('./config'); 8 | 9 | module.exports = function () { 10 | var baseUri = config.uri + config.apiPort; 11 | // Routes to proxy to the backend. Routes ending with a / will setup 12 | // a redirect so that if accessed without a trailing slash, will 13 | // redirect. This is required for some endpoints for proxy-middleware 14 | // to correctly handle them. 15 | var proxyRoutes = [ 16 | '/' 17 | ]; 18 | 19 | var requireTrailingSlash = proxyRoutes.filter(function (r) { 20 | return util.endsWith(r, '/'); 21 | }).map(function (r) { 22 | // Strip trailing slash so we can use the route to match requests 23 | // with non trailing slash 24 | return r.substr(0, r.length - 1); 25 | }); 26 | 27 | var proxies = [ 28 | // Ensure trailing slash in routes that require it 29 | function (req, res, next) { 30 | requireTrailingSlash.forEach(function (route){ 31 | if (url.parse(req.url).path === route) { 32 | res.statusCode = 301; 33 | res.setHeader('Location', route + '/'); 34 | res.end(); 35 | } 36 | }); 37 | 38 | next(); 39 | } 40 | ] 41 | .concat( 42 | // Build a list of proxies for routes: [route1_proxy, route2_proxy, ...] 43 | proxyRoutes.map(function (r) { 44 | var options = url.parse(baseUri + r); 45 | options.route = r; 46 | options.preserveHost = true; 47 | return proxy(options); 48 | })); 49 | 50 | browserSync({ 51 | open: true, 52 | port: config.port, 53 | server: { 54 | baseDir: config.app, 55 | middleware: proxies 56 | } 57 | }); 58 | 59 | gulp.start('watch'); 60 | } 61 | -------------------------------------------------------------------------------- /gulp/utils.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var fs = require('fs'); 4 | 5 | module.exports = { 6 | endsWith : endsWith, 7 | parseVersion : parseVersion, 8 | isLintFixed : isLintFixed 9 | } 10 | 11 | function endsWith(str, suffix) { 12 | return str.indexOf('/', str.length - suffix.length) !== -1; 13 | }; 14 | 15 | var parseString = require('xml2js').parseString; 16 | // return the version number from `pom.xml` file 17 | function parseVersion() { 18 | var version; 19 | var pomXml = fs.readFileSync('pom.xml', 'utf8'); 20 | parseString(pomXml, function (err, result) { 21 | if (result.project.version && result.project.version[0]) { 22 | version = result.project.version[0]; 23 | } else if (result.project.parent && result.project.parent[0] && result.project.parent[0].version && result.project.parent[0].version[0]) { 24 | version = result.project.parent[0].version[0]; 25 | } else { 26 | throw new Error('pom.xml is malformed. No version is defined'); 27 | } 28 | }); 29 | return version; 30 | } 31 | 32 | 33 | function isLintFixed(file) { 34 | // Has ESLint fixed the file contents? 35 | return file.eslint !== null && file.eslint.fixed; 36 | } 37 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ribbon-cache", 3 | "version": "0.0.0", 4 | "description": "Description for ribbon_cache", 5 | "private": true, 6 | "cacheDirectories": [ 7 | "node_modules", 8 | "src/main/webapp/bower_components" 9 | ], 10 | "devDependencies": { 11 | "bower": "1.7.9", 12 | "browser-sync": "2.12.10", 13 | "del": "2.2.0", 14 | "eslint-config-angular": "0.5.0", 15 | "eslint-plugin-angular": "1.0.1", 16 | "event-stream": "3.3.2", 17 | "generator-jhipster": "3.4.2", 18 | "gulp": "3.9.1", 19 | "gulp-angular-filesort": "1.1.1", 20 | "gulp-angular-templatecache": "1.9.0", 21 | "gulp-autoprefixer": "3.1.0", 22 | "gulp-changed": "1.3.0", 23 | "gulp-cssnano": "2.1.2", 24 | "gulp-eslint": "2.0.0", 25 | "gulp-flatten": "0.2.0", 26 | "gulp-footer": "1.0.5", 27 | "gulp-htmlmin": "2.0.0", 28 | "gulp-if": "2.0.1", 29 | "gulp-imagemin": "3.0.1", 30 | "gulp-inject": "4.1.0", 31 | "gulp-natural-sort": "0.1.1", 32 | "gulp-ng-annotate": "2.0.0", 33 | "gulp-rename": "1.2.2", 34 | "gulp-ng-constant": "1.1.0", 35 | "gulp-notify": "2.2.0", 36 | "gulp-plumber": "1.1.0", 37 | "gulp-rev": "7.0.0", 38 | "gulp-rev-replace": "0.4.3", 39 | "gulp-sourcemaps": "1.6.0", 40 | "gulp-uglify": "1.5.3", 41 | "gulp-useref": "3.1.0", 42 | "jasmine-core": "2.4.1", 43 | "karma": "0.13.22", 44 | "karma-chrome-launcher": "1.0.1", 45 | "karma-coverage": "1.0.0", 46 | "karma-jasmine": "1.0.2", 47 | "karma-junit-reporter": "1.0.0", 48 | "karma-phantomjs-launcher": "1.0.0", 49 | "karma-script-launcher": "1.0.0", 50 | "lazypipe": "1.0.1", 51 | "lodash": "4.13.1", 52 | "main-bower-files": "2.13.1", 53 | "map-stream": "0.0.6", 54 | "phantomjs-prebuilt": "2.1.7", 55 | "proxy-middleware": "0.15.0", 56 | "run-sequence": "1.2.1", 57 | "xml2js": "0.4.16", 58 | "yargs": "4.7.1" 59 | }, 60 | "engines": { 61 | "node": "^4.3" 62 | }, 63 | "scripts": { 64 | "test": "gulp test" 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:openjdk-8-jre-alpine 2 | 3 | ENV JHIPSTER_SLEEP 0 4 | 5 | # add directly the war 6 | ADD *.war /app.war 7 | 8 | RUN sh -c 'touch /app.war' 9 | VOLUME /tmp 10 | EXPOSE 8080 11 | CMD echo "The application will start in ${JHIPSTER_SLEEP}s..." && \ 12 | sleep ${JHIPSTER_SLEEP} && \ 13 | java -Djava.security.egd=file:/dev/./urandom -jar /app.war 14 | -------------------------------------------------------------------------------- /src/main/docker/app.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | ribbon_cache-app: 4 | image: ribbon_cache 5 | external_links: 6 | - ribbon_cache-postgresql:postgresql 7 | # Uncomment to have Cassandra working with the gateway 8 | # - ribbon_cache-cassandra:cassandra 9 | - jhipster-registry:registry 10 | environment: 11 | - SPRING_PROFILES_ACTIVE=prod 12 | - SPRING_CLOUD_CONFIG_URI=http://admin:admin@registry:8761/config 13 | - SPRING_DATASOURCE_URL=jdbc:postgresql://postgresql:5432/ribbon_cache 14 | - SPRING_DATA_CASSANDRA_CONTACTPOINTS=cassandra 15 | - JHIPSTER_SLEEP=30 # gives time for the cassandra cluster to start and execute the migration scripts 16 | ports: 17 | - 8080:8080 18 | ribbon_cache-postgresql: 19 | extends: 20 | file: postgresql.yml 21 | service: ribbon_cache-postgresql 22 | # Uncomment to have Cassandra working with the gateway 23 | # extends: 24 | # file: cassandra-cluster.yml 25 | # service: ribbon_cache-cassandra 26 | jhipster-registry: 27 | extends: 28 | file: jhipster-registry.yml 29 | service: jhipster-registry 30 | -------------------------------------------------------------------------------- /src/main/docker/cassandra-cluster.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | ribbon_cache-cassandra: 4 | container_name: ribbon_cache-cassandra 5 | image: cassandra:2.2.5 6 | # volumes: 7 | # - ~/volumes/jhipster/ribbon_cache/cassandra/:/var/lib/cassandra/data 8 | ports: 9 | - 7000:7000 10 | - 7001:7001 11 | - 7199:7199 12 | - 9042:9042 13 | - 9160:9160 14 | ribbon_cache-cassandra-node: 15 | image: cassandra:2.2.5 16 | links: 17 | - ribbon_cache-cassandra:seed 18 | environment: 19 | - CASSANDRA_SEEDS=seed 20 | ribbon_cache-cassandra-migration: 21 | extends: 22 | file: cassandra-migration.yml 23 | service: ribbon_cache-cassandra-migration 24 | links: 25 | - ribbon_cache-cassandra 26 | environment: 27 | - CREATE_KEYSPACE_SCRIPT=create-keyspace-prod.cql 28 | -------------------------------------------------------------------------------- /src/main/docker/cassandra-migration.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | ribbon_cache-cassandra-migration: 4 | container_name: ribbon_cache-cassandra-migration 5 | environment: 6 | - CASSANDRA_CONTACT_POINT=ribbon_cache-cassandra 7 | - USER=docker-cassandra-migration 8 | # - DEBUG_LOG=1 # uncomment to show debug logs durinq the migration process 9 | build: 10 | context: . 11 | dockerfile: cassandra/Cassandra-Migration.Dockerfile 12 | volumes: 13 | - ../resources/config/cql:/cql:ro 14 | -------------------------------------------------------------------------------- /src/main/docker/cassandra.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | ribbon_cache-cassandra: 4 | container_name: ribbon_cache-cassandra 5 | image: cassandra:2.2.5 6 | # volumes: 7 | # - ~/volumes/jhipster/ribbon_cache/cassandra/:/var/lib/cassandra/data 8 | ports: 9 | - 7000:7000 10 | - 7001:7001 11 | - 7199:7199 12 | - 9042:9042 13 | - 9160:9160 14 | ribbon_cache-cassandra-migration: 15 | extends: 16 | file: cassandra-migration.yml 17 | service: ribbon_cache-cassandra-migration 18 | links: 19 | - ribbon_cache-cassandra 20 | environment: 21 | - CREATE_KEYSPACE_SCRIPT=create-keyspace.cql 22 | -------------------------------------------------------------------------------- /src/main/docker/cassandra/Cassandra-Migration.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM cassandra:2.2.5 2 | 3 | # script to orchestrate the automatic keyspace creation and apply all migration scripts 4 | ADD cassandra/scripts/autoMigrate.sh /usr/local/bin/autoMigrate 5 | RUN chmod 755 /usr/local/bin/autoMigrate 6 | 7 | # script to run any cql script from src/main/resources/config/cql 8 | ADD cassandra/scripts/execute-cql.sh /usr/local/bin/execute-cql 9 | RUN chmod 755 /usr/local/bin/execute-cql 10 | 11 | ENTRYPOINT ["autoMigrate"] 12 | -------------------------------------------------------------------------------- /src/main/docker/cassandra/scripts/autoMigrate.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Orchestrate the automatic execution of all the cql migration scripts when starting the cluster 4 | 5 | # Protect from iterating on empty directories 6 | shopt -s nullglob 7 | 8 | function log { 9 | echo "[$(date)]: $*" 10 | } 11 | 12 | function logDebug { 13 | ((DEBUG_LOG)) && echo "[DEBUG][$(date)]: $*" 14 | } 15 | 16 | function waitForClusterConnection() { 17 | log "waiting for cassandra connection..." 18 | retryCount=0 19 | maxRetry=20 20 | cqlsh -e "Describe KEYSPACES;" $CASSANDRA_CONTACT_POINT &>/dev/null 21 | while [ $? -ne 0 ] && [ "$retryCount" -ne "$maxRetry" ]; do 22 | logDebug 'cassandra not reachable yet. sleep and retry. retryCount =' $retryCount 23 | sleep 5 24 | ((retryCount+=1)) 25 | cqlsh -e "Describe KEYSPACES;" $CASSANDRA_CONTACT_POINT &>/dev/null 26 | done 27 | 28 | if [ $? -ne 0 ]; then 29 | log "not connected after " $retryCount " retry. Abort the migration." 30 | exit 1 31 | fi 32 | 33 | log "connected to cassandra cluster" 34 | } 35 | 36 | waitForClusterConnection 37 | 38 | log "execute cassandra setup and all migration scripts" 39 | 40 | CQL_FILES_PATH="/cql/changelog/" 41 | EXECUTE_CQL_SCRIPT="./usr/local/bin/execute-cql" 42 | if [ "$#" -eq 1 ]; then 43 | log "overriding for local usage" 44 | CQL_FILES_PATH=$1 45 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 46 | EXECUTE_CQL_SCRIPT=$SCRIPT_DIR'/execute-cql.sh' 47 | else 48 | log "use $CREATE_KEYSPACE_SCRIPT script to create keyspace if necessary" 49 | cqlsh -f /cql/$CREATE_KEYSPACE_SCRIPT $CASSANDRA_CONTACT_POINT 50 | fi 51 | 52 | function executeScripts() { 53 | local filePattern=$1 54 | # loop over migration scripts 55 | for cqlFile in $filePattern; do 56 | . $EXECUTE_CQL_SCRIPT $cqlFile 57 | done 58 | } 59 | 60 | log "execute all non already executed scripts from $CQL_FILES_PATH" 61 | executeScripts "$CQL_FILES_PATH*.cql" 62 | 63 | log "migration done" 64 | -------------------------------------------------------------------------------- /src/main/docker/central-server-config/application.yml: -------------------------------------------------------------------------------- 1 | #common configuration shared between all applications 2 | configserver: 3 | name: Docker JHipster Registry 4 | status: Connected to the JHipster Registry running in Docker 5 | 6 | jhipster: 7 | security: 8 | authentication: 9 | jwt: 10 | secret: my-secret-token-to-change-in-production 11 | -------------------------------------------------------------------------------- /src/main/docker/jhipster-registry.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | jhipster-registry: 4 | container_name: jhipster-registry 5 | image: jhipster/jhipster-registry:v2.2.0 6 | volumes: 7 | - ./central-server-config:/central-config 8 | # By default the JHipster Registry runs with the "prod" and "native" 9 | # Spring profiles. 10 | # "native" profile means the filesystem is used to store data, see 11 | # http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html 12 | environment: 13 | - SPRING_PROFILES_ACTIVE=dev,native 14 | - SECURITY_USER_PASSWORD=admin 15 | # - GIT_URI=https://github.com/jhipster/jhipster-registry/ 16 | # - GIT_SEARCH_PATH=central-config 17 | ports: 18 | - 8761:8761 19 | -------------------------------------------------------------------------------- /src/main/docker/postgresql.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | ribbon_cache-postgresql: 4 | container_name: ribbon_cache-postgresql 5 | image: postgres:9.5.2 6 | # volumes: 7 | # - ~/volumes/jhipster/ribbon_cache/postgresql/:/var/lib/postgresql/ 8 | environment: 9 | - POSTGRES_USER=ribbon_cache 10 | - POSTGRES_PASSWORD= 11 | ports: 12 | - 5432:5432 13 | -------------------------------------------------------------------------------- /src/main/docker/sonar.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | ribbon_cache-sonar: 4 | container_name: ribbon_cache-sonar 5 | image: sonarqube:5.5-alpine 6 | ports: 7 | - 9000:9000 8 | - 9092:9092 9 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/ApplicationWebXml.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp; 2 | 3 | import com.mycompany.myapp.config.DefaultProfileUtil; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | import org.springframework.boot.context.web.SpringBootServletInitializer; 6 | 7 | /** 8 | * This is a helper Java class that provides an alternative to creating a web.xml. 9 | * This will be invoked only when the application is deployed to a servlet container like Tomcat, Jboss etc. 10 | */ 11 | public class ApplicationWebXml extends SpringBootServletInitializer { 12 | 13 | @Override 14 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 15 | /** 16 | * set a default to use when no profile is configured. 17 | */ 18 | DefaultProfileUtil.addDefaultProfile(application.application()); 19 | return application.sources(RibbonCacheApp.class); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/async/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Async helpers. 3 | */ 4 | package com.mycompany.myapp.async; 5 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/config/AsyncConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.config; 2 | 3 | import com.mycompany.myapp.async.ExceptionHandlingAsyncTaskExecutor; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; 8 | import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | import org.springframework.scheduling.annotation.*; 12 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 13 | 14 | import java.util.concurrent.Executor; 15 | 16 | import javax.inject.Inject; 17 | 18 | @Configuration 19 | @EnableAsync 20 | @EnableScheduling 21 | public class AsyncConfiguration implements AsyncConfigurer { 22 | 23 | private final Logger log = LoggerFactory.getLogger(AsyncConfiguration.class); 24 | 25 | @Inject 26 | private JHipsterProperties jHipsterProperties; 27 | 28 | @Override 29 | @Bean(name = "taskExecutor") 30 | public Executor getAsyncExecutor() { 31 | log.debug("Creating Async Task Executor"); 32 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); 33 | executor.setCorePoolSize(jHipsterProperties.getAsync().getCorePoolSize()); 34 | executor.setMaxPoolSize(jHipsterProperties.getAsync().getMaxPoolSize()); 35 | executor.setQueueCapacity(jHipsterProperties.getAsync().getQueueCapacity()); 36 | executor.setThreadNamePrefix("ribbon-cache-Executor-"); 37 | return new ExceptionHandlingAsyncTaskExecutor(executor); 38 | } 39 | 40 | @Override 41 | public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { 42 | return new SimpleAsyncUncaughtExceptionHandler(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/config/CacheConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.config; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.boot.autoconfigure.AutoConfigureAfter; 6 | import org.springframework.cache.CacheManager; 7 | import org.springframework.cache.annotation.EnableCaching; 8 | import org.springframework.context.annotation.*; 9 | import org.springframework.cache.support.NoOpCacheManager; 10 | 11 | import javax.annotation.PreDestroy; 12 | import javax.inject.Inject; 13 | 14 | @SuppressWarnings("unused") 15 | @Configuration 16 | @EnableCaching 17 | @AutoConfigureAfter(value = { MetricsConfiguration.class, DatabaseConfiguration.class }) 18 | public class CacheConfiguration { 19 | 20 | private final Logger log = LoggerFactory.getLogger(CacheConfiguration.class); 21 | 22 | private CacheManager cacheManager; 23 | 24 | @PreDestroy 25 | public void destroy() { 26 | log.info("Closing Cache Manager"); 27 | } 28 | 29 | //@Bean 30 | public CacheManager cacheManager() { 31 | log.debug("No cache"); 32 | cacheManager = new NoOpCacheManager(); 33 | return cacheManager; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/config/CloudDatabaseConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.config; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.cloud.config.java.AbstractCloudConfig; 6 | import org.springframework.context.annotation.*; 7 | 8 | import javax.sql.DataSource; 9 | 10 | @Configuration 11 | @Profile(Constants.SPRING_PROFILE_CLOUD) 12 | public class CloudDatabaseConfiguration extends AbstractCloudConfig { 13 | 14 | private final Logger log = LoggerFactory.getLogger(CloudDatabaseConfiguration.class); 15 | 16 | @Bean 17 | public DataSource dataSource() { 18 | log.info("Configuring JDBC datasource from a cloud provider"); 19 | return connectionFactory().dataSource(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/config/Constants.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.config; 2 | 3 | /** 4 | * Application constants. 5 | */ 6 | public final class Constants { 7 | 8 | //Regex for acceptable logins 9 | public static final String LOGIN_REGEX = "^[_'.@A-Za-z0-9-]*$"; 10 | // Spring profile for development and production, see http://jhipster.github.io/profiles/ 11 | public static final String SPRING_PROFILE_DEVELOPMENT = "dev"; 12 | public static final String SPRING_PROFILE_PRODUCTION = "prod"; 13 | // Spring profile used when deploying with Spring Cloud (used when deploying to CloudFoundry) 14 | public static final String SPRING_PROFILE_CLOUD = "cloud"; 15 | // Spring profile used when deploying to Heroku 16 | public static final String SPRING_PROFILE_HEROKU = "heroku"; 17 | // Spring profile used to disable swagger 18 | public static final String SPRING_PROFILE_NO_SWAGGER = "no-swagger"; 19 | // Spring profile used to disable running liquibase 20 | public static final String SPRING_PROFILE_NO_LIQUIBASE = "no-liquibase"; 21 | 22 | public static final String SYSTEM_ACCOUNT = "system"; 23 | 24 | private Constants() { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/config/JacksonConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.config; 2 | 3 | import com.mycompany.myapp.domain.util.*; 4 | import com.fasterxml.jackson.databind.SerializationFeature; 5 | import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; 6 | import java.time.*; 7 | import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | @Configuration 12 | public class JacksonConfiguration { 13 | 14 | @Bean 15 | Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() { 16 | JavaTimeModule module = new JavaTimeModule(); 17 | module.addSerializer(OffsetDateTime.class, JSR310DateTimeSerializer.INSTANCE); 18 | module.addSerializer(ZonedDateTime.class, JSR310DateTimeSerializer.INSTANCE); 19 | module.addSerializer(LocalDateTime.class, JSR310DateTimeSerializer.INSTANCE); 20 | module.addSerializer(Instant.class, JSR310DateTimeSerializer.INSTANCE); 21 | module.addDeserializer(LocalDate.class, JSR310LocalDateDeserializer.INSTANCE); 22 | return new Jackson2ObjectMapperBuilder() 23 | .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) 24 | .findModulesViaServiceLoader(true) 25 | .modulesToInstall(module); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/config/LocaleConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.config; 2 | 3 | import com.mycompany.myapp.config.locale.AngularCookieLocaleResolver; 4 | 5 | import org.springframework.boot.bind.RelaxedPropertyResolver; 6 | import org.springframework.context.EnvironmentAware; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.core.env.Environment; 10 | import org.springframework.web.servlet.LocaleResolver; 11 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 12 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 13 | import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; 14 | 15 | @Configuration 16 | public class LocaleConfiguration extends WebMvcConfigurerAdapter implements EnvironmentAware { 17 | 18 | @SuppressWarnings("unused") 19 | private RelaxedPropertyResolver propertyResolver; 20 | 21 | @Override 22 | public void setEnvironment(Environment environment) { 23 | this.propertyResolver = new RelaxedPropertyResolver(environment, "spring.messages."); 24 | } 25 | 26 | @Bean(name = "localeResolver") 27 | public LocaleResolver localeResolver() { 28 | AngularCookieLocaleResolver cookieLocaleResolver = new AngularCookieLocaleResolver(); 29 | cookieLocaleResolver.setCookieName("NG_TRANSLATE_LANG_KEY"); 30 | return cookieLocaleResolver; 31 | } 32 | 33 | @Override 34 | public void addInterceptors(InterceptorRegistry registry) { 35 | LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor(); 36 | localeChangeInterceptor.setParamName("language"); 37 | registry.addInterceptor(localeChangeInterceptor); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/config/LoggingAspectConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.config; 2 | 3 | import com.mycompany.myapp.aop.logging.LoggingAspect; 4 | import org.springframework.context.annotation.*; 5 | 6 | @Configuration 7 | @EnableAspectJAutoProxy 8 | public class LoggingAspectConfiguration { 9 | 10 | @Bean 11 | @Profile(Constants.SPRING_PROFILE_DEVELOPMENT) 12 | public LoggingAspect loggingAspect() { 13 | return new LoggingAspect(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/config/ThymeleafConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.config; 2 | 3 | import org.apache.commons.lang.CharEncoding; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.context.annotation.*; 7 | import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; 8 | 9 | @Configuration 10 | public class ThymeleafConfiguration { 11 | 12 | @SuppressWarnings("unused") 13 | private final Logger log = LoggerFactory.getLogger(ThymeleafConfiguration.class); 14 | 15 | @Bean 16 | @Description("Thymeleaf template resolver serving HTML 5 emails") 17 | public ClassLoaderTemplateResolver emailTemplateResolver() { 18 | ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver(); 19 | emailTemplateResolver.setPrefix("mails/"); 20 | emailTemplateResolver.setSuffix(".html"); 21 | emailTemplateResolver.setTemplateMode("HTML5"); 22 | emailTemplateResolver.setCharacterEncoding(CharEncoding.UTF_8); 23 | emailTemplateResolver.setOrder(1); 24 | return emailTemplateResolver; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/config/apidoc/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Swagger api specific code. 3 | */ 4 | package com.mycompany.myapp.config.apidoc; -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/config/audit/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Audit specific code. 3 | */ 4 | package com.mycompany.myapp.config.audit; 5 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/config/cassandra/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Cassandra specific configuration. 3 | */ 4 | package com.mycompany.myapp.config.cassandra; 5 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/config/liquibase/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Liquibase specific code. 3 | */ 4 | package com.mycompany.myapp.config.liquibase; 5 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/config/locale/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Locale specific code. 3 | */ 4 | package com.mycompany.myapp.config.locale; 5 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/config/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Spring Framework configuration files. 3 | */ 4 | package com.mycompany.myapp.config; 5 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/domain/Authority.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.domain; 2 | 3 | 4 | import javax.persistence.Entity; 5 | import javax.persistence.Id; 6 | import javax.persistence.Table; 7 | import javax.persistence.Column; 8 | import javax.validation.constraints.NotNull; 9 | import javax.validation.constraints.Size; 10 | import java.io.Serializable; 11 | 12 | /** 13 | * An authority (a security role) used by Spring Security. 14 | */ 15 | @Entity 16 | @Table(name = "jhi_authority") 17 | public class Authority implements Serializable { 18 | 19 | private static final long serialVersionUID = 1L; 20 | 21 | @NotNull 22 | @Size(min = 0, max = 50) 23 | @Id 24 | @Column(length = 50) 25 | private String name; 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | 35 | @Override 36 | public boolean equals(Object o) { 37 | if (this == o) { 38 | return true; 39 | } 40 | if (o == null || getClass() != o.getClass()) { 41 | return false; 42 | } 43 | 44 | Authority authority = (Authority) o; 45 | 46 | if (name != null ? !name.equals(authority.name) : authority.name != null) { 47 | return false; 48 | } 49 | 50 | return true; 51 | } 52 | 53 | @Override 54 | public int hashCode() { 55 | return name != null ? name.hashCode() : 0; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | return "Authority{" + 61 | "name='" + name + '\'' + 62 | "}"; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/domain/PersistentAuditEvent.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.domain; 2 | 3 | import java.time.LocalDateTime; 4 | import javax.persistence.*; 5 | import javax.validation.constraints.NotNull; 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | /** 10 | * Persist AuditEvent managed by the Spring Boot actuator 11 | * @see org.springframework.boot.actuate.audit.AuditEvent 12 | */ 13 | @Entity 14 | @Table(name = "jhi_persistent_audit_event") 15 | public class PersistentAuditEvent { 16 | 17 | @Id 18 | @GeneratedValue(strategy = GenerationType.AUTO) 19 | @Column(name = "event_id") 20 | private Long id; 21 | 22 | @NotNull 23 | @Column(nullable = false) 24 | private String principal; 25 | 26 | @Column(name = "event_date") 27 | private LocalDateTime auditEventDate; 28 | @Column(name = "event_type") 29 | private String auditEventType; 30 | 31 | @ElementCollection 32 | @MapKeyColumn(name = "name") 33 | @Column(name = "value") 34 | @CollectionTable(name = "jhi_persistent_audit_evt_data", joinColumns=@JoinColumn(name="event_id")) 35 | private Map data = new HashMap<>(); 36 | 37 | public Long getId() { 38 | return id; 39 | } 40 | 41 | public void setId(Long id) { 42 | this.id = id; 43 | } 44 | 45 | public String getPrincipal() { 46 | return principal; 47 | } 48 | 49 | public void setPrincipal(String principal) { 50 | this.principal = principal; 51 | } 52 | 53 | public LocalDateTime getAuditEventDate() { 54 | return auditEventDate; 55 | } 56 | 57 | public void setAuditEventDate(LocalDateTime auditEventDate) { 58 | this.auditEventDate = auditEventDate; 59 | } 60 | 61 | public String getAuditEventType() { 62 | return auditEventType; 63 | } 64 | 65 | public void setAuditEventType(String auditEventType) { 66 | this.auditEventType = auditEventType; 67 | } 68 | 69 | public Map getData() { 70 | return data; 71 | } 72 | 73 | public void setData(Map data) { 74 | this.data = data; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/domain/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * JPA domain objects. 3 | */ 4 | package com.mycompany.myapp.domain; 5 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/domain/util/FixedH2Dialect.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.domain.util; 2 | 3 | import java.sql.Types; 4 | 5 | import org.hibernate.dialect.H2Dialect; 6 | 7 | public class FixedH2Dialect extends H2Dialect { 8 | 9 | public FixedH2Dialect() { 10 | super(); 11 | registerColumnType(Types.FLOAT, "real"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/domain/util/FixedPostgreSQL82Dialect.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.domain.util; 2 | 3 | import org.hibernate.dialect.PostgreSQL82Dialect; 4 | import org.hibernate.type.descriptor.sql.BinaryTypeDescriptor; 5 | import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; 6 | 7 | import java.sql.Types; 8 | 9 | public class FixedPostgreSQL82Dialect extends PostgreSQL82Dialect { 10 | 11 | public FixedPostgreSQL82Dialect() { 12 | super(); 13 | registerColumnType(Types.BLOB, "bytea"); 14 | } 15 | 16 | @Override 17 | public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) { 18 | if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) { 19 | return BinaryTypeDescriptor.INSTANCE; 20 | } 21 | return super.remapSqlTypeDescriptor(sqlTypeDescriptor); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/domain/util/JSR310DateTimeSerializer.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.domain.util; 2 | 3 | import java.io.IOException; 4 | import java.time.ZoneId; 5 | import java.time.format.DateTimeFormatter; 6 | import java.time.temporal.TemporalAccessor; 7 | 8 | import com.fasterxml.jackson.core.JsonGenerator; 9 | import com.fasterxml.jackson.databind.JsonSerializer; 10 | import com.fasterxml.jackson.databind.SerializerProvider; 11 | 12 | public final class JSR310DateTimeSerializer extends JsonSerializer { 13 | 14 | private static final DateTimeFormatter ISOFormatter = 15 | DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").withZone(ZoneId.of("Z")); 16 | 17 | public static final JSR310DateTimeSerializer INSTANCE = new JSR310DateTimeSerializer(); 18 | 19 | private JSR310DateTimeSerializer() {} 20 | 21 | @Override 22 | public void serialize(TemporalAccessor value, JsonGenerator generator, SerializerProvider serializerProvider) throws IOException { 23 | generator.writeString(ISOFormatter.format(value)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/domain/util/JSR310PersistenceConverters.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.domain.util; 2 | 3 | import com.mycompany.myapp.domain.util.JSR310DateConverters.*; 4 | 5 | import java.time.*; 6 | import java.util.Date; 7 | 8 | import javax.persistence.AttributeConverter; 9 | import javax.persistence.Converter; 10 | 11 | public final class JSR310PersistenceConverters { 12 | 13 | private JSR310PersistenceConverters() {} 14 | 15 | @Converter(autoApply = true) 16 | public static class LocalDateConverter implements AttributeConverter { 17 | 18 | @Override 19 | public java.sql.Date convertToDatabaseColumn(LocalDate date) { 20 | return date == null ? null : java.sql.Date.valueOf(date); 21 | } 22 | 23 | @Override 24 | public LocalDate convertToEntityAttribute(java.sql.Date date) { 25 | return date == null ? null : date.toLocalDate(); 26 | } 27 | } 28 | 29 | @Converter(autoApply = true) 30 | public static class ZonedDateTimeConverter implements AttributeConverter { 31 | 32 | @Override 33 | public Date convertToDatabaseColumn(ZonedDateTime zonedDateTime) { 34 | return ZonedDateTimeToDateConverter.INSTANCE.convert(zonedDateTime); 35 | } 36 | 37 | @Override 38 | public ZonedDateTime convertToEntityAttribute(Date date) { 39 | return DateToZonedDateTimeConverter.INSTANCE.convert(date); 40 | } 41 | } 42 | 43 | @Converter(autoApply = true) 44 | public static class LocalDateTimeConverter implements AttributeConverter { 45 | 46 | @Override 47 | public Date convertToDatabaseColumn(LocalDateTime localDateTime) { 48 | return LocalDateTimeToDateConverter.INSTANCE.convert(localDateTime); 49 | } 50 | 51 | @Override 52 | public LocalDateTime convertToEntityAttribute(Date date) { 53 | return DateToLocalDateTimeConverter.INSTANCE.convert(date); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/gateway/TokenRelayFilter.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.gateway; 2 | 3 | import com.netflix.zuul.ZuulFilter; 4 | import com.netflix.zuul.context.RequestContext; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.Set; 8 | 9 | @Component 10 | public class TokenRelayFilter extends ZuulFilter { 11 | @Override 12 | public Object run() { 13 | RequestContext ctx = RequestContext.getCurrentContext(); 14 | 15 | Set headers = (Set) ctx.get("ignoredHeaders"); 16 | // We need our JWT tokens relayed to resource servers 17 | headers.remove("authorization"); 18 | 19 | return null; 20 | } 21 | 22 | @Override 23 | public boolean shouldFilter() { 24 | return true; 25 | } 26 | 27 | @Override 28 | public String filterType() { 29 | return "pre"; 30 | } 31 | 32 | @Override 33 | public int filterOrder() { 34 | return 10000; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/gateway/caching/CachingPostFilter.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.gateway.caching; 2 | 3 | import com.mycompany.myapp.config.JHipsterProperties; 4 | import com.netflix.zuul.context.RequestContext; 5 | import org.springframework.cache.Cache; 6 | import org.springframework.cache.CacheManager; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | /** 12 | * Store response in cache. 13 | * There is a cache per service. 14 | */ 15 | public class CachingPostFilter extends CachingBaseFilter { 16 | 17 | public CachingPostFilter(CacheManager cacheManager, JHipsterProperties jHipsterProperties) { 18 | super(cacheManager, jHipsterProperties); 19 | } 20 | 21 | @Override 22 | public String filterType() { 23 | return "post"; 24 | } 25 | 26 | @Override 27 | public int filterOrder() { 28 | return 900; 29 | } 30 | 31 | @Override 32 | public boolean shouldFilter() { 33 | RequestContext ctx = RequestContext.getCurrentContext(); 34 | return super.shouldFilter() && !ctx.getBoolean(CACHE_HIT); 35 | } 36 | 37 | @Override 38 | public Object run() { 39 | RequestContext ctx = RequestContext.getCurrentContext(); 40 | HttpServletRequest req = ctx.getRequest(); 41 | HttpServletResponse res = ctx.getResponse(); 42 | 43 | if (isSuccess(res)) { 44 | // Store only successful responses 45 | Cache cache = cache(ctx); 46 | if (cache != null) { 47 | // TODO cache should probably not store HttpServletResponse 48 | String key = cacheKey(req); 49 | cache.put(key, res); 50 | log.debug("Cached successful response for '{}' into '{}' cache", key, cache.getName()); 51 | } 52 | } 53 | return null; 54 | } 55 | 56 | private boolean isSuccess(HttpServletResponse res) { 57 | return (res != null) && (res.getStatus() < 300); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/gateway/caching/CachingPreFilter.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.gateway.caching; 2 | 3 | import com.mycompany.myapp.config.JHipsterProperties; 4 | import com.netflix.zuul.context.RequestContext; 5 | import org.springframework.cache.Cache; 6 | import org.springframework.cache.CacheManager; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | import static com.netflix.zuul.constants.ZuulHeaders.ACCEPT_ENCODING; 12 | 13 | /** 14 | * Use response in cache. 15 | */ 16 | public class CachingPreFilter extends CachingBaseFilter { 17 | 18 | public CachingPreFilter(CacheManager cacheManager, JHipsterProperties jHipsterProperties) { 19 | super(cacheManager, jHipsterProperties); 20 | } 21 | 22 | @Override 23 | public String filterType() { 24 | return "pre"; 25 | } 26 | 27 | @Override 28 | public int filterOrder() { 29 | return 15; 30 | } 31 | 32 | @Override 33 | public Object run() { 34 | RequestContext ctx = RequestContext.getCurrentContext(); 35 | HttpServletRequest req = ctx.getRequest(); 36 | 37 | Cache cache = cache(ctx); 38 | if (cache != null) { 39 | String key = cacheKey(req); 40 | Cache.ValueWrapper valueWrapper = cache.get(key); 41 | if (valueWrapper != null) { 42 | // TODO cache should probably not store HttpServletResponse 43 | HttpServletResponse res = (HttpServletResponse) valueWrapper.get(); 44 | if (res != null) { 45 | log.debug("Filling response for '{}' from '{}' cache", key, cache.getName()); 46 | ctx.setResponse(res); 47 | ctx.set(CACHE_HIT, true); 48 | return res; 49 | } 50 | } 51 | } 52 | ctx.set(CACHE_HIT, false); 53 | return null; 54 | } 55 | 56 | private boolean isGzipRequested(RequestContext ctx) { 57 | String requestEncoding = ctx.getRequest().getHeader(ACCEPT_ENCODING); 58 | return requestEncoding != null && requestEncoding.equals("gzip"); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/gateway/ratelimiting/RateLimitingRepository.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.gateway.ratelimiting; 2 | 3 | import java.util.Date; 4 | import javax.annotation.PostConstruct; 5 | import javax.inject.Inject; 6 | 7 | import com.datastax.driver.core.*; 8 | 9 | /** 10 | * Repository storing data used by the gateway's rate limiting filter. 11 | */ 12 | public class RateLimitingRepository { 13 | 14 | @Inject 15 | private Session session; 16 | 17 | private PreparedStatement rateLimitingIncrement; 18 | 19 | private PreparedStatement rateLimitingCount; 20 | 21 | @PostConstruct 22 | public void init() { 23 | rateLimitingIncrement = session.prepare( 24 | "UPDATE gateway_ratelimiting\n" + 25 | " SET value = value + 1\n" + 26 | " WHERE id = :id AND time_unit = :time_unit AND time = :time"); 27 | 28 | rateLimitingCount = session.prepare( 29 | "SELECT value\n" + 30 | " FROM gateway_ratelimiting\n" + 31 | " WHERE id = :id AND time_unit = :time_unit AND time = :time" 32 | ); 33 | } 34 | 35 | public void incrementCounter(String id, String timeUnit, Date time) { 36 | BoundStatement stmt = rateLimitingIncrement.bind(); 37 | stmt.setString("id", id); 38 | stmt.setString("time_unit", timeUnit); 39 | stmt.setTimestamp("time", time); 40 | session.executeAsync(stmt); 41 | } 42 | 43 | public long getCounter(String id, String timeUnit, Date time) { 44 | BoundStatement stmt = rateLimitingCount.bind(); 45 | stmt.setString("id", id); 46 | stmt.setString("time_unit", timeUnit); 47 | stmt.setTimestamp("time", time); 48 | ResultSet rs = session.execute(stmt); 49 | if (rs.isExhausted()) { 50 | return 0; 51 | } 52 | return rs.one().getLong(0); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/repository/AuthorityRepository.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.repository; 2 | 3 | import com.mycompany.myapp.domain.Authority; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | /** 8 | * Spring Data JPA repository for the Authority entity. 9 | */ 10 | public interface AuthorityRepository extends JpaRepository { 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/repository/PersistenceAuditEventRepository.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.repository; 2 | 3 | import com.mycompany.myapp.domain.PersistentAuditEvent; 4 | 5 | import java.time.LocalDateTime; 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | import org.springframework.data.domain.Page; 8 | import org.springframework.data.domain.Pageable; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Spring Data JPA repository for the PersistentAuditEvent entity. 14 | */ 15 | public interface PersistenceAuditEventRepository extends JpaRepository { 16 | 17 | List findByPrincipal(String principal); 18 | 19 | List findByPrincipalAndAuditEventDateAfter(String principal, LocalDateTime after); 20 | 21 | Page findAllByAuditEventDateBetween(LocalDateTime fromDate, LocalDateTime toDate, Pageable pageable); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.repository; 2 | 3 | import com.mycompany.myapp.domain.User; 4 | 5 | import java.time.ZonedDateTime; 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | 8 | import java.util.List; 9 | import java.util.Optional; 10 | 11 | /** 12 | * Spring Data JPA repository for the User entity. 13 | */ 14 | public interface UserRepository extends JpaRepository { 15 | 16 | Optional findOneByActivationKey(String activationKey); 17 | 18 | List findAllByActivatedIsFalseAndCreatedDateBefore(ZonedDateTime dateTime); 19 | 20 | Optional findOneByResetKey(String resetKey); 21 | 22 | Optional findOneByEmail(String email); 23 | 24 | Optional findOneByLogin(String login); 25 | 26 | Optional findOneById(Long userId); 27 | 28 | @Override 29 | void delete(User t); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/repository/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Spring Data JPA repositories. 3 | */ 4 | package com.mycompany.myapp.repository; 5 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/security/AuthoritiesConstants.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.security; 2 | 3 | /** 4 | * Constants for Spring Security authorities. 5 | */ 6 | public final class AuthoritiesConstants { 7 | 8 | public static final String ADMIN = "ROLE_ADMIN"; 9 | 10 | public static final String USER = "ROLE_USER"; 11 | 12 | public static final String ANONYMOUS = "ROLE_ANONYMOUS"; 13 | 14 | private AuthoritiesConstants() { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/security/Http401UnauthorizedEntryPoint.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.security; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.security.core.AuthenticationException; 6 | import org.springframework.security.web.AuthenticationEntryPoint; 7 | import org.springframework.stereotype.Component; 8 | 9 | import javax.servlet.ServletException; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import java.io.IOException; 13 | 14 | /** 15 | * Returns a 401 error code (Unauthorized) to the client. 16 | */ 17 | @Component 18 | public class Http401UnauthorizedEntryPoint implements AuthenticationEntryPoint { 19 | 20 | private final Logger log = LoggerFactory.getLogger(Http401UnauthorizedEntryPoint.class); 21 | 22 | /** 23 | * Always returns a 401 error code to the client. 24 | */ 25 | @Override 26 | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException arg2) 27 | throws IOException, 28 | ServletException { 29 | 30 | log.debug("Pre-authenticated entry point called. Rejecting access"); 31 | response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Access Denied"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/security/SpringSecurityAuditorAware.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.security; 2 | 3 | import com.mycompany.myapp.config.Constants; 4 | 5 | import org.springframework.data.domain.AuditorAware; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Implementation of AuditorAware based on Spring Security. 10 | */ 11 | @Component 12 | public class SpringSecurityAuditorAware implements AuditorAware { 13 | 14 | @Override 15 | public String getCurrentAuditor() { 16 | String userName = SecurityUtils.getCurrentUserLogin(); 17 | return (userName != null ? userName : Constants.SYSTEM_ACCOUNT); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/security/UserDetailsService.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.security; 2 | import com.mycompany.myapp.domain.User; 3 | import com.mycompany.myapp.repository.UserRepository; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.security.core.GrantedAuthority; 7 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 8 | import org.springframework.security.core.userdetails.UserDetails; 9 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 10 | import org.springframework.stereotype.Component; 11 | import org.springframework.transaction.annotation.Transactional; 12 | 13 | import javax.inject.Inject; 14 | import java.util.*; 15 | import java.util.stream.Collectors; 16 | 17 | /** 18 | * Authenticate a user from the database. 19 | */ 20 | @Component("userDetailsService") 21 | public class UserDetailsService implements org.springframework.security.core.userdetails.UserDetailsService { 22 | 23 | private final Logger log = LoggerFactory.getLogger(UserDetailsService.class); 24 | 25 | @Inject 26 | private UserRepository userRepository; 27 | 28 | @Override 29 | @Transactional 30 | public UserDetails loadUserByUsername(final String login) { 31 | log.debug("Authenticating {}", login); 32 | String lowercaseLogin = login.toLowerCase(Locale.ENGLISH); 33 | Optional userFromDatabase = userRepository.findOneByLogin(lowercaseLogin); 34 | return userFromDatabase.map(user -> { 35 | if (!user.getActivated()) { 36 | throw new UserNotActivatedException("User " + lowercaseLogin + " was not activated"); 37 | } 38 | List grantedAuthorities = user.getAuthorities().stream() 39 | .map(authority -> new SimpleGrantedAuthority(authority.getName())) 40 | .collect(Collectors.toList()); 41 | return new org.springframework.security.core.userdetails.User(lowercaseLogin, 42 | user.getPassword(), 43 | grantedAuthorities); 44 | }).orElseThrow(() -> new UsernameNotFoundException("User " + lowercaseLogin + " was not found in the " + 45 | "database")); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/security/UserNotActivatedException.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.security; 2 | 3 | import org.springframework.security.core.AuthenticationException; 4 | 5 | /** 6 | * This exception is throw in case of a not activated user trying to authenticate. 7 | */ 8 | public class UserNotActivatedException extends AuthenticationException { 9 | 10 | private static final long serialVersionUID = 1L; 11 | 12 | public UserNotActivatedException(String message) { 13 | super(message); 14 | } 15 | 16 | public UserNotActivatedException(String message, Throwable t) { 17 | super(message, t); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/security/jwt/JWTConfigurer.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.security.jwt; 2 | 3 | import org.springframework.security.config.annotation.SecurityConfigurerAdapter; 4 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 5 | import org.springframework.security.web.DefaultSecurityFilterChain; 6 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 7 | 8 | public class JWTConfigurer extends SecurityConfigurerAdapter { 9 | 10 | public final static String AUTHORIZATION_HEADER = "Authorization"; 11 | 12 | private TokenProvider tokenProvider; 13 | 14 | public JWTConfigurer(TokenProvider tokenProvider) { 15 | this.tokenProvider = tokenProvider; 16 | } 17 | 18 | @Override 19 | public void configure(HttpSecurity http) throws Exception { 20 | JWTFilter customFilter = new JWTFilter(tokenProvider); 21 | http.addFilterBefore(customFilter, UsernamePasswordAuthenticationFilter.class); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/security/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Spring Security configuration. 3 | */ 4 | package com.mycompany.myapp.security; 5 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/service/AuditEventService.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.service; 2 | 3 | import com.mycompany.myapp.config.audit.AuditEventConverter; 4 | import com.mycompany.myapp.repository.PersistenceAuditEventRepository; 5 | import java.time.LocalDateTime; 6 | import org.springframework.boot.actuate.audit.AuditEvent; 7 | import org.springframework.data.domain.Page; 8 | import org.springframework.data.domain.Pageable; 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.transaction.annotation.Transactional; 11 | 12 | import javax.inject.Inject; 13 | import java.util.Optional; 14 | 15 | /** 16 | * Service for managing audit events. 17 | *

18 | * This is the default implementation to support SpringBoot Actuator AuditEventRepository 19 | *

20 | */ 21 | @Service 22 | @Transactional 23 | public class AuditEventService { 24 | 25 | private PersistenceAuditEventRepository persistenceAuditEventRepository; 26 | 27 | private AuditEventConverter auditEventConverter; 28 | 29 | @Inject 30 | public AuditEventService( 31 | PersistenceAuditEventRepository persistenceAuditEventRepository, 32 | AuditEventConverter auditEventConverter) { 33 | 34 | this.persistenceAuditEventRepository = persistenceAuditEventRepository; 35 | this.auditEventConverter = auditEventConverter; 36 | } 37 | 38 | public Page findAll(Pageable pageable) { 39 | return persistenceAuditEventRepository.findAll(pageable) 40 | .map(persistentAuditEvents -> auditEventConverter.convertToAuditEvent(persistentAuditEvents)); 41 | } 42 | 43 | public Page findByDates(LocalDateTime fromDate, LocalDateTime toDate, Pageable pageable) { 44 | return persistenceAuditEventRepository.findAllByAuditEventDateBetween(fromDate, toDate, pageable) 45 | .map(persistentAuditEvents -> auditEventConverter.convertToAuditEvent(persistentAuditEvents)); 46 | } 47 | 48 | public Optional find(Long id) { 49 | return Optional.ofNullable(persistenceAuditEventRepository.findOne(id)).map 50 | (auditEventConverter::convertToAuditEvent); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/service/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Service layer beans. 3 | */ 4 | package com.mycompany.myapp.service; 5 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/service/util/RandomUtil.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.service.util; 2 | 3 | import org.apache.commons.lang.RandomStringUtils; 4 | 5 | /** 6 | * Utility class for generating random Strings. 7 | */ 8 | public final class RandomUtil { 9 | 10 | private static final int DEF_COUNT = 20; 11 | 12 | private RandomUtil() { 13 | } 14 | 15 | /** 16 | * Generates a password. 17 | * 18 | * @return the generated password 19 | */ 20 | public static String generatePassword() { 21 | return RandomStringUtils.randomAlphanumeric(DEF_COUNT); 22 | } 23 | 24 | /** 25 | * Generates an activation key. 26 | * 27 | * @return the generated activation key 28 | */ 29 | public static String generateActivationKey() { 30 | return RandomStringUtils.randomNumeric(DEF_COUNT); 31 | } 32 | 33 | /** 34 | * Generates a reset key. 35 | * 36 | * @return the generated reset key 37 | */ 38 | public static String generateResetKey() { 39 | return RandomStringUtils.randomNumeric(DEF_COUNT); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/filter/CachingHttpHeadersFilter.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.filter; 2 | 3 | import com.mycompany.myapp.config.JHipsterProperties; 4 | 5 | import javax.servlet.*; 6 | import javax.servlet.http.HttpServletResponse; 7 | import java.io.IOException; 8 | import java.util.concurrent.TimeUnit; 9 | 10 | /** 11 | * This filter is used in production, to put HTTP cache headers with a long (1 month) expiration time. 12 | */ 13 | public class CachingHttpHeadersFilter implements Filter { 14 | 15 | // We consider the last modified date is the start up time of the server 16 | private final static long LAST_MODIFIED = System.currentTimeMillis(); 17 | 18 | private long CACHE_TIME_TO_LIVE = TimeUnit.DAYS.toMillis(1461L); 19 | 20 | private JHipsterProperties jHipsterProperties; 21 | 22 | public CachingHttpHeadersFilter(JHipsterProperties jHipsterProperties) { 23 | this.jHipsterProperties = jHipsterProperties; 24 | } 25 | 26 | @Override 27 | public void init(FilterConfig filterConfig) throws ServletException { 28 | CACHE_TIME_TO_LIVE = TimeUnit.DAYS.toMillis(jHipsterProperties.getHttp().getCache().getTimeToLiveInDays()); 29 | } 30 | 31 | @Override 32 | public void destroy() { 33 | // Nothing to destroy 34 | } 35 | 36 | @Override 37 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 38 | throws IOException, ServletException { 39 | 40 | HttpServletResponse httpResponse = (HttpServletResponse) response; 41 | 42 | httpResponse.setHeader("Cache-Control", "max-age=" + CACHE_TIME_TO_LIVE + ", public"); 43 | httpResponse.setHeader("Pragma", "cache"); 44 | 45 | // Setting Expires header, for proxy caching 46 | httpResponse.setDateHeader("Expires", CACHE_TIME_TO_LIVE + System.currentTimeMillis()); 47 | 48 | // Setting the Last-Modified header, for browser caching 49 | httpResponse.setDateHeader("Last-Modified", LAST_MODIFIED); 50 | 51 | chain.doFilter(request, response); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/filter/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Servlet filters. 3 | */ 4 | package com.mycompany.myapp.web.filter; 5 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/GatewayResource.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest; 2 | 3 | import com.mycompany.myapp.web.rest.dto.RouteDTO; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import javax.inject.Inject; 8 | 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.cloud.client.discovery.DiscoveryClient; 12 | import org.springframework.cloud.netflix.zuul.filters.Route; 13 | import org.springframework.cloud.netflix.zuul.filters.RouteLocator; 14 | import org.springframework.http.*; 15 | import org.springframework.web.bind.annotation.*; 16 | 17 | import com.codahale.metrics.annotation.Timed; 18 | 19 | /** 20 | * REST controller for managing Gateway configuration. 21 | */ 22 | @RestController 23 | @RequestMapping("/api/gateway") 24 | public class GatewayResource { 25 | 26 | private final Logger log = LoggerFactory.getLogger(GatewayResource.class); 27 | 28 | @Inject 29 | private RouteLocator routeLocator; 30 | 31 | @Inject 32 | private DiscoveryClient discoveryClient; 33 | 34 | /** 35 | * GET /routes : get the active routes. 36 | * 37 | * @return the ResponseEntity with status 200 (OK) and with body the list of routes 38 | */ 39 | @RequestMapping(value = "/routes", 40 | method = RequestMethod.GET, 41 | produces = MediaType.APPLICATION_JSON_VALUE) 42 | @Timed 43 | public ResponseEntity> activeRoutes() { 44 | List routes = routeLocator.getRoutes(); 45 | List routeDTOs = new ArrayList<>(); 46 | routes.forEach(route -> { 47 | RouteDTO routeDTO = new RouteDTO(); 48 | routeDTO.setPath(route.getFullPath()); 49 | routeDTO.setServiceId(route.getId()); 50 | routeDTO.setServiceInstances(discoveryClient.getInstances(route.getId())); 51 | routeDTOs.add(routeDTO); 52 | }); 53 | return new ResponseEntity<>(routeDTOs, HttpStatus.OK); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/JWTToken.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest; 2 | 3 | import com.fasterxml.jackson.annotation.JsonProperty; 4 | 5 | /** 6 | * Object to return as body in JWT Authentication. 7 | */ 8 | public class JWTToken { 9 | 10 | private String idToken; 11 | 12 | public JWTToken(String idToken) { 13 | this.idToken = idToken; 14 | } 15 | 16 | @JsonProperty("id_token") 17 | public String getIdToken() { 18 | return idToken; 19 | } 20 | 21 | public void setIdToken(String idToken) { 22 | this.idToken = idToken; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/LogsResource.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest; 2 | 3 | import com.mycompany.myapp.web.rest.dto.LoggerDTO; 4 | 5 | import ch.qos.logback.classic.Level; 6 | import ch.qos.logback.classic.LoggerContext; 7 | import com.codahale.metrics.annotation.Timed; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.http.HttpStatus; 10 | import org.springframework.http.MediaType; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import java.util.List; 14 | import java.util.stream.Collectors; 15 | 16 | /** 17 | * Controller for view and managing Log Level at runtime. 18 | */ 19 | @RestController 20 | @RequestMapping("/management/jhipster") 21 | public class LogsResource { 22 | 23 | @RequestMapping(value = "/logs", 24 | method = RequestMethod.GET, 25 | produces = MediaType.APPLICATION_JSON_VALUE) 26 | @Timed 27 | public List getList() { 28 | LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); 29 | return context.getLoggerList() 30 | .stream() 31 | .map(LoggerDTO::new) 32 | .collect(Collectors.toList()); 33 | } 34 | 35 | @RequestMapping(value = "/logs", 36 | method = RequestMethod.PUT) 37 | @ResponseStatus(HttpStatus.NO_CONTENT) 38 | @Timed 39 | public void changeLevel(@RequestBody LoggerDTO jsonLogger) { 40 | LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); 41 | context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel())); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/ProfileInfoResource.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest; 2 | 3 | import com.mycompany.myapp.config.JHipsterProperties; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Arrays; 7 | import java.util.List; 8 | import javax.inject.Inject; 9 | 10 | import org.springframework.core.env.Environment; 11 | import org.springframework.http.MediaType; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | @RestController 17 | @RequestMapping("/api") 18 | public class ProfileInfoResource { 19 | 20 | @Inject 21 | Environment env; 22 | 23 | @Inject 24 | private JHipsterProperties jHipsterProperties; 25 | 26 | @RequestMapping(value = "/profile-info", 27 | method = RequestMethod.GET, 28 | produces = MediaType.APPLICATION_JSON_VALUE) 29 | public ProfileInfoResponse getActiveProfiles() { 30 | return new ProfileInfoResponse(env.getActiveProfiles(), getRibbonEnv()); 31 | } 32 | 33 | private String getRibbonEnv() { 34 | String[] activeProfiles = env.getActiveProfiles(); 35 | String[] displayOnActiveProfiles = jHipsterProperties.getRibbon().getDisplayOnActiveProfiles(); 36 | 37 | if (displayOnActiveProfiles == null) { 38 | return null; 39 | } 40 | 41 | List ribbonProfiles = new ArrayList<>(Arrays.asList(displayOnActiveProfiles)); 42 | List springBootProfiles = Arrays.asList(activeProfiles); 43 | ribbonProfiles.retainAll(springBootProfiles); 44 | 45 | if (ribbonProfiles.size() > 0) { 46 | return ribbonProfiles.get(0); 47 | } 48 | return null; 49 | } 50 | 51 | class ProfileInfoResponse { 52 | 53 | public String[] activeProfiles; 54 | public String ribbonEnv; 55 | 56 | ProfileInfoResponse(String[] activeProfiles,String ribbonEnv) { 57 | this.activeProfiles=activeProfiles; 58 | this.ribbonEnv=ribbonEnv; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/dto/KeyAndPasswordDTO.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest.dto; 2 | 3 | public class KeyAndPasswordDTO { 4 | 5 | private String key; 6 | 7 | private String newPassword; 8 | 9 | public KeyAndPasswordDTO() { 10 | } 11 | 12 | public String getKey() { 13 | return key; 14 | } 15 | 16 | public void setKey(String key) { 17 | this.key = key; 18 | } 19 | 20 | public String getNewPassword() { 21 | return newPassword; 22 | } 23 | 24 | public void setNewPassword(String newPassword) { 25 | this.newPassword = newPassword; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/dto/LoggerDTO.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest.dto; 2 | 3 | import ch.qos.logback.classic.Logger; 4 | import com.fasterxml.jackson.annotation.JsonCreator; 5 | 6 | public class LoggerDTO { 7 | 8 | private String name; 9 | 10 | private String level; 11 | 12 | public LoggerDTO(Logger logger) { 13 | this.name = logger.getName(); 14 | this.level = logger.getEffectiveLevel().toString(); 15 | } 16 | 17 | @JsonCreator 18 | public LoggerDTO() { 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | 29 | public String getLevel() { 30 | return level; 31 | } 32 | 33 | public void setLevel(String level) { 34 | this.level = level; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return "LoggerDTO{" + 40 | "name='" + name + '\'' + 41 | ", level='" + level + '\'' + 42 | '}'; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/dto/LoginDTO.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest.dto; 2 | 3 | import com.mycompany.myapp.config.Constants; 4 | import javax.validation.constraints.NotNull; 5 | import javax.validation.constraints.Pattern; 6 | import javax.validation.constraints.Size; 7 | 8 | /** 9 | * A DTO representing a user's credentials 10 | */ 11 | public class LoginDTO { 12 | 13 | @Pattern(regexp = Constants.LOGIN_REGEX) 14 | @NotNull 15 | @Size(min = 1, max = 50) 16 | private String username; 17 | 18 | @NotNull 19 | @Size(min = ManagedUserDTO.PASSWORD_MIN_LENGTH, max = ManagedUserDTO.PASSWORD_MAX_LENGTH) 20 | private String password; 21 | 22 | private Boolean rememberMe; 23 | 24 | public String getUsername() { 25 | return username; 26 | } 27 | 28 | public void setUsername(String username) { 29 | this.username = username; 30 | } 31 | 32 | public String getPassword() { 33 | return password; 34 | } 35 | 36 | public void setPassword(String password) { 37 | this.password = password; 38 | } 39 | 40 | public Boolean isRememberMe() { 41 | return rememberMe; 42 | } 43 | 44 | public void setRememberMe(Boolean rememberMe) { 45 | this.rememberMe = rememberMe; 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return "LoginDTO{" + 51 | "password='" + password + '\'' + 52 | ", username='" + username + '\'' + 53 | ", rememberMe=" + rememberMe + 54 | '}'; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/dto/RouteDTO.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest.dto; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.cloud.client.ServiceInstance; 6 | 7 | /** 8 | * Stores a route managed by the Gateway. 9 | */ 10 | public class RouteDTO { 11 | 12 | private String path; 13 | 14 | private String serviceId; 15 | 16 | private List serviceInstances; 17 | 18 | public String getPath() { 19 | return path; 20 | } 21 | 22 | public void setPath(String path) { 23 | this.path = path; 24 | } 25 | 26 | public String getServiceId() { 27 | return serviceId; 28 | } 29 | 30 | public void setServiceId(String serviceId) { 31 | this.serviceId = serviceId; 32 | } 33 | 34 | public List getServiceInstances() { 35 | return serviceInstances; 36 | } 37 | 38 | public void setServiceInstances(List serviceInstances) { 39 | this.serviceInstances = serviceInstances; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/dto/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Data Transfer Objects used by Spring MVC REST controllers. 3 | */ 4 | package com.mycompany.myapp.web.rest.dto; 5 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/errors/CustomParameterizedException.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest.errors; 2 | 3 | /** 4 | * Custom, parameterized exception, which can be translated on the client side. 5 | * For example: 6 | * 7 | *
 8 |  * throw new CustomParameterizedException("myCustomError", "hello", "world");
 9 |  * 
10 | * 11 | * Can be translated with: 12 | * 13 | *
14 |  * "error.myCustomError" :  "The server says {{params[0]}} to {{params[1]}}"
15 |  * 
16 | */ 17 | public class CustomParameterizedException extends RuntimeException { 18 | 19 | private static final long serialVersionUID = 1L; 20 | 21 | private final String message; 22 | private final String[] params; 23 | 24 | public CustomParameterizedException(String message, String... params) { 25 | super(message); 26 | this.message = message; 27 | this.params = params; 28 | } 29 | 30 | public ParameterizedErrorDTO getErrorDTO() { 31 | return new ParameterizedErrorDTO(message, params); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/errors/ErrorConstants.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest.errors; 2 | 3 | public final class ErrorConstants { 4 | 5 | public static final String ERR_CONCURRENCY_FAILURE = "error.concurrencyFailure"; 6 | public static final String ERR_ACCESS_DENIED = "error.accessDenied"; 7 | public static final String ERR_VALIDATION = "error.validation"; 8 | public static final String ERR_METHOD_NOT_SUPPORTED = "error.methodNotSupported"; 9 | public static final String ERR_INTERNAL_SERVER_ERROR = "error.internalServerError"; 10 | 11 | private ErrorConstants() { 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/errors/ErrorDTO.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest.errors; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | /** 8 | * DTO for transfering error message with a list of field errors. 9 | */ 10 | public class ErrorDTO implements Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | private final String message; 15 | private final String description; 16 | 17 | private List fieldErrors; 18 | 19 | public ErrorDTO(String message) { 20 | this(message, null); 21 | } 22 | 23 | public ErrorDTO(String message, String description) { 24 | this.message = message; 25 | this.description = description; 26 | } 27 | 28 | public ErrorDTO(String message, String description, List fieldErrors) { 29 | this.message = message; 30 | this.description = description; 31 | this.fieldErrors = fieldErrors; 32 | } 33 | 34 | public void add(String objectName, String field, String message) { 35 | if (fieldErrors == null) { 36 | fieldErrors = new ArrayList<>(); 37 | } 38 | fieldErrors.add(new FieldErrorDTO(objectName, field, message)); 39 | } 40 | 41 | public String getMessage() { 42 | return message; 43 | } 44 | 45 | public String getDescription() { 46 | return description; 47 | } 48 | 49 | public List getFieldErrors() { 50 | return fieldErrors; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/errors/FieldErrorDTO.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest.errors; 2 | 3 | import java.io.Serializable; 4 | 5 | public class FieldErrorDTO implements Serializable { 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | private final String objectName; 10 | 11 | private final String field; 12 | 13 | private final String message; 14 | 15 | public FieldErrorDTO(String dto, String field, String message) { 16 | this.objectName = dto; 17 | this.field = field; 18 | this.message = message; 19 | } 20 | 21 | public String getObjectName() { 22 | return objectName; 23 | } 24 | 25 | public String getField() { 26 | return field; 27 | } 28 | 29 | public String getMessage() { 30 | return message; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/errors/ParameterizedErrorDTO.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest.errors; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * DTO for sending a parameterized error message. 7 | */ 8 | public class ParameterizedErrorDTO implements Serializable { 9 | 10 | private static final long serialVersionUID = 1L; 11 | private final String message; 12 | private final String[] params; 13 | 14 | public ParameterizedErrorDTO(String message, String... params) { 15 | this.message = message; 16 | this.params = params; 17 | } 18 | 19 | public String getMessage() { 20 | return message; 21 | } 22 | 23 | public String[] getParams() { 24 | return params; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest.mapper; 2 | 3 | import com.mycompany.myapp.domain.Authority; 4 | import com.mycompany.myapp.domain.User; 5 | import com.mycompany.myapp.web.rest.dto.UserDTO; 6 | import org.mapstruct.*; 7 | 8 | import java.util.List; 9 | import java.util.Set; 10 | import java.util.stream.Collectors; 11 | 12 | /** 13 | * Mapper for the entity User and its DTO UserDTO. 14 | */ 15 | @Mapper(componentModel = "spring", uses = {}) 16 | public interface UserMapper { 17 | 18 | UserDTO userToUserDTO(User user); 19 | 20 | List usersToUserDTOs(List users); 21 | 22 | @Mapping(target = "createdBy", ignore = true) 23 | @Mapping(target = "createdDate", ignore = true) 24 | @Mapping(target = "lastModifiedBy", ignore = true) 25 | @Mapping(target = "lastModifiedDate", ignore = true) 26 | @Mapping(target = "id", ignore = true) 27 | @Mapping(target = "activationKey", ignore = true) 28 | @Mapping(target = "resetKey", ignore = true) 29 | @Mapping(target = "resetDate", ignore = true) 30 | @Mapping(target = "password", ignore = true) 31 | User userDTOToUser(UserDTO userDTO); 32 | 33 | List userDTOsToUsers(List userDTOs); 34 | 35 | default User userFromId(Long id) { 36 | if (id == null) { 37 | return null; 38 | } 39 | User user = new User(); 40 | user.setId(id); 41 | return user; 42 | } 43 | 44 | default Set stringsFromAuthorities (Set authorities) { 45 | return authorities.stream().map(Authority::getName) 46 | .collect(Collectors.toSet()); 47 | } 48 | 49 | default Set authoritiesFromStrings(Set strings) { 50 | return strings.stream().map(string -> { 51 | Authority auth = new Authority(); 52 | auth.setName(string); 53 | return auth; 54 | }).collect(Collectors.toSet()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Spring MVC REST controllers. 3 | */ 4 | package com.mycompany.myapp.web.rest; 5 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/util/HeaderUtil.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest.util; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.http.HttpHeaders; 6 | 7 | /** 8 | * Utility class for HTTP headers creation. 9 | * 10 | */ 11 | public class HeaderUtil { 12 | 13 | private static final Logger log = LoggerFactory.getLogger(HeaderUtil.class); 14 | 15 | public static HttpHeaders createAlert(String message, String param) { 16 | HttpHeaders headers = new HttpHeaders(); 17 | headers.add("X-ribbonCacheApp-alert", message); 18 | headers.add("X-ribbonCacheApp-params", param); 19 | return headers; 20 | } 21 | 22 | public static HttpHeaders createEntityCreationAlert(String entityName, String param) { 23 | return createAlert("A new " + entityName + " is created with identifier " + param, param); 24 | } 25 | 26 | public static HttpHeaders createEntityUpdateAlert(String entityName, String param) { 27 | return createAlert("A " + entityName + " is updated with identifier " + param, param); 28 | } 29 | 30 | public static HttpHeaders createEntityDeletionAlert(String entityName, String param) { 31 | return createAlert("A " + entityName + " is deleted with identifier " + param, param); 32 | } 33 | 34 | public static HttpHeaders createFailureAlert(String entityName, String errorKey, String defaultMessage) { 35 | log.error("Entity creation failed, {}", defaultMessage); 36 | HttpHeaders headers = new HttpHeaders(); 37 | headers.add("X-ribbonCacheApp-error", defaultMessage); 38 | headers.add("X-ribbonCacheApp-params", entityName); 39 | return headers; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/mycompany/myapp/web/rest/util/PaginationUtil.java: -------------------------------------------------------------------------------- 1 | package com.mycompany.myapp.web.rest.util; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.http.HttpHeaders; 5 | import org.springframework.web.util.UriComponentsBuilder; 6 | 7 | import java.net.URI; 8 | import java.net.URISyntaxException; 9 | 10 | /** 11 | * Utility class for handling pagination. 12 | * 13 | *

14 | * Pagination uses the same principles as the Github API, 15 | * and follow RFC 5988 (Link header). 16 | */ 17 | public class PaginationUtil { 18 | 19 | public static HttpHeaders generatePaginationHttpHeaders(Page page, String baseUrl) 20 | throws URISyntaxException { 21 | 22 | HttpHeaders headers = new HttpHeaders(); 23 | headers.add("X-Total-Count", "" + page.getTotalElements()); 24 | String link = ""; 25 | if ((page.getNumber() + 1) < page.getTotalPages()) { 26 | link = "<" + generateUri(baseUrl, page.getNumber() + 1, page.getSize()) + ">; rel=\"next\","; 27 | } 28 | // prev link 29 | if ((page.getNumber()) > 0) { 30 | link += "<" + generateUri(baseUrl, page.getNumber() - 1, page.getSize()) + ">; rel=\"prev\","; 31 | } 32 | // last and first link 33 | int lastPage = 0; 34 | if (page.getTotalPages() > 0) { 35 | lastPage = page.getTotalPages() - 1; 36 | } 37 | link += "<" + generateUri(baseUrl, lastPage, page.getSize()) + ">; rel=\"last\","; 38 | link += "<" + generateUri(baseUrl, 0, page.getSize()) + ">; rel=\"first\""; 39 | headers.add(HttpHeaders.LINK, link); 40 | return headers; 41 | } 42 | 43 | private static String generateUri(String baseUrl, int page, int size) throws URISyntaxException { 44 | return UriComponentsBuilder.fromUriString(baseUrl).queryParam("page", page).queryParam("size", size).toUriString(); 45 | } 46 | 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/resources/.h2.server.properties: -------------------------------------------------------------------------------- 1 | #H2 Server Properties 2 | 0=JHipster H2 (Memory)|org.h2.Driver|jdbc\:h2\:mem\:ribbon_cache|ribbon_cache 3 | webAllowOthers=true 4 | webPort=8082 5 | webSSL=false 6 | -------------------------------------------------------------------------------- /src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | 2 | ${AnsiColor.GREEN} ██ ${AnsiColor.RED} ██ ██ ████████ ███████ ██████ ████████ ████████ ███████ 3 | ${AnsiColor.GREEN} ██ ${AnsiColor.RED} ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ 4 | ${AnsiColor.GREEN} ██ ${AnsiColor.RED} ████████ ██ ███████ █████ ██ ██████ ███████ 5 | ${AnsiColor.GREEN}██ ██ ${AnsiColor.RED} ██ ██ ██ ██ ██ ██ ██ ██ ██ 6 | ${AnsiColor.GREEN} ██████ ${AnsiColor.RED} ██ ██ ████████ ██ ██████ ██ ████████ ██ ██ 7 | 8 | ${AnsiColor.BRIGHT_BLUE}:: JHipster 🤓 :: Running Spring Boot ${spring-boot.version} :: 9 | :: http://jhipster.github.io ::${AnsiColor.DEFAULT} 10 | -------------------------------------------------------------------------------- /src/main/resources/config/bootstrap-dev.yml: -------------------------------------------------------------------------------- 1 | # =================================================================== 2 | # Spring Cloud Config bootstrap configuration for the "dev" profile 3 | # =================================================================== 4 | 5 | spring: 6 | cloud: 7 | config: 8 | fail-fast: true 9 | uri: http://admin:admin@localhost:8761/config 10 | # name of the config server's property source (file.yml) that we want to use 11 | name: ribbon_cache 12 | profile: dev # profile(s) of the property source 13 | label: master # toggle to switch to a different version of the configuration as stored in git 14 | # it can be set to any label, branch or commit of the config source git repository 15 | -------------------------------------------------------------------------------- /src/main/resources/config/bootstrap-prod.yml: -------------------------------------------------------------------------------- 1 | # =================================================================== 2 | # Spring Cloud Config bootstrap configuration for the "prod" profile 3 | # =================================================================== 4 | 5 | spring: 6 | cloud: 7 | config: 8 | fail-fast: true 9 | retry: 10 | initial-interval: 1000 11 | max-interval: 2000 12 | max-attempts: 100 13 | uri: http://admin:admin@localhost:8761/config 14 | # name of the config server's property source (file.yml) that we want to use 15 | name: ribbon_cache 16 | profile: prod # profile(s) of the property source 17 | label: master # toggle to switch to a different version of the configuration as stored in git 18 | # it can be set to any label, branch or commit of the config source git repository 19 | -------------------------------------------------------------------------------- /src/main/resources/config/cql/changelog/README.md: -------------------------------------------------------------------------------- 1 | The changelog folder for cassandra/cql files is similar to Liquibase (for SQL databases), but with a minimal tooling. 2 | 3 | - The script name should follow the pattern yyyyMMddHHmmss_{script-name}.cql 4 | - eg: 20150805124838_added_entity_BankAccount.cql 5 | - The scripts will be applied sequentially in alphabetical order 6 | - The scripts will be applied automatically only in two contexts: 7 | - Unit tests 8 | - Docker-compose for to start a [cassandra cluster for development](http://jhipster.github.io/docker-compose/#cassandra-in-development) 9 | 10 | Unlike Liquibase, the scripts are not currently automatically applied to the database when deployed with a production profile 11 | -------------------------------------------------------------------------------- /src/main/resources/config/cql/create-keyspace-prod.cql: -------------------------------------------------------------------------------- 1 | CREATE KEYSPACE IF NOT EXISTS ribbon_cache 2 | WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 } 3 | AND DURABLE_WRITES = true; 4 | 5 | CREATE TABLE IF NOT EXISTS ribbon_cache.schema_version ( 6 | script_name text, 7 | checksum text, 8 | executed_by text, 9 | executed_on timestamp, 10 | execution_time int, 11 | status text, 12 | PRIMARY KEY(script_name) 13 | ); 14 | -------------------------------------------------------------------------------- /src/main/resources/config/cql/create-keyspace.cql: -------------------------------------------------------------------------------- 1 | CREATE KEYSPACE IF NOT EXISTS ribbon_cache 2 | WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 } 3 | AND DURABLE_WRITES = true; 4 | 5 | CREATE TABLE IF NOT EXISTS ribbon_cache.schema_version ( 6 | script_name text, 7 | checksum text, 8 | executed_by text, 9 | executed_on timestamp, 10 | execution_time int, 11 | status text, 12 | PRIMARY KEY(script_name) 13 | ); 14 | -------------------------------------------------------------------------------- /src/main/resources/config/cql/drop-keyspace.cql: -------------------------------------------------------------------------------- 1 | DROP KEYSPACE IF EXISTS ribbon_cache; 2 | -------------------------------------------------------------------------------- /src/main/resources/config/liquibase/authorities.csv: -------------------------------------------------------------------------------- 1 | name 2 | ROLE_ADMIN 3 | ROLE_USER 4 | -------------------------------------------------------------------------------- /src/main/resources/config/liquibase/master.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main/resources/config/liquibase/users.csv: -------------------------------------------------------------------------------- 1 | id;login;password_hash;first_name;last_name;email;activated;lang_key;created_by 2 | 1;system;$2a$10$mE.qmcV0mFU5NcKh73TZx.z4ueI/.bDWbj0T1BYyqP481kGGarKLG;System;System;system@localhost;true;en;system 3 | 2;anonymoususer;$2a$10$j8S5d7Sr7.8VTOYNviDPOeWX8KcYILUVJBsYV83Y5NtECayypx9lO;Anonymous;User;anonymous@localhost;true;en;system 4 | 3;admin;$2a$10$gSAhZrxMllrbgj/kkK9UceBPpChGWJA7SYIb1Mqo.n5aNLq1/oRrC;Administrator;Administrator;admin@localhost;true;en;system 5 | 4;user;$2a$10$VEjxo0jq2YG9Rbk2HmX9S.k1uZBGYUHdUcid3g/vfiEl7lwWgOH/K;User;User;user@localhost;true;en;system 6 | -------------------------------------------------------------------------------- /src/main/resources/config/liquibase/users_authorities.csv: -------------------------------------------------------------------------------- 1 | user_id;authority_name 2 | 1;ROLE_ADMIN 3 | 1;ROLE_USER 4 | 3;ROLE_ADMIN 5 | 3;ROLE_USER 6 | 4;ROLE_USER 7 | -------------------------------------------------------------------------------- /src/main/resources/ehcache.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 19 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/main/resources/i18n/messages.properties: -------------------------------------------------------------------------------- 1 | # Error page 2 | error.title=Your request cannot be processed 3 | error.subtitle=Sorry, an error has occurred. 4 | error.status=Status: 5 | error.message=Message: 6 | 7 | # Activation e-mail 8 | email.activation.title=ribbon_cache account activation 9 | email.activation.greeting=Dear {0} 10 | email.activation.text1=Your ribbon_cache account has been created, please click on the URL below to activate it: 11 | email.activation.text2=Regards, 12 | email.signature=ribbon_cache Team. 13 | 14 | # Creation email 15 | email.creation.text1=Your ribbon_cache account has been created, please click on the URL below to access it: 16 | 17 | # Reset e-mail 18 | email.reset.title=ribbon_cache password reset 19 | email.reset.greeting=Dear {0} 20 | email.reset.text1=For your ribbon_cache account a password reset was requested, please click on the URL below to reset it: 21 | email.reset.text2=Regards, 22 | 23 | -------------------------------------------------------------------------------- /src/main/resources/mails/activationEmail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | JHipster activation 5 | 6 | 7 | 8 |

9 | Dear 10 |

11 |

12 | Your JHipster account has been created, please click on the URL below to activate it: 13 |

14 |

15 | Activation Link 17 |

18 |

19 | Regards, 20 |
21 | JHipster. 22 |

23 | 24 | 25 | -------------------------------------------------------------------------------- /src/main/resources/mails/creationEmail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | JHipster creation 5 | 6 | 7 | 8 |

9 | Dear 10 |

11 |

12 | Your JHipster account has been created, please click on the URL below to access it: 13 |

14 |

15 | login 17 |

18 |

19 | Regards, 20 |
21 | JHipster. 22 |

23 | 24 | 25 | -------------------------------------------------------------------------------- /src/main/resources/mails/passwordResetEmail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | JHipster password reset 5 | 6 | 7 | 8 |

9 | Dear 10 |

11 |

12 | For your JHipster account a password reset was requested, please click on the URL below to reset it: 13 |

14 |

15 | Reset Link 17 |

18 |

19 | Regards, 20 |
21 | JHipster. 22 |

23 | 24 | 25 | -------------------------------------------------------------------------------- /src/main/webapp/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Page Not Found 6 | 7 | 54 | 55 | 56 |

Page Not Found

57 |

Sorry, but the page you were trying to view does not exist.

58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/main/webapp/app/account/account.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('account', { 12 | abstract: true, 13 | parent: 'app' 14 | }); 15 | } 16 | })(); 17 | -------------------------------------------------------------------------------- /src/main/webapp/app/account/activate/activate.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('ActivationController', ActivationController); 7 | 8 | ActivationController.$inject = ['$stateParams', 'Auth', 'LoginService']; 9 | 10 | function ActivationController ($stateParams, Auth, LoginService) { 11 | var vm = this; 12 | 13 | Auth.activateAccount({key: $stateParams.key}).then(function () { 14 | vm.error = null; 15 | vm.success = 'OK'; 16 | }).catch(function () { 17 | vm.success = null; 18 | vm.error = 'ERROR'; 19 | }); 20 | 21 | vm.login = LoginService.open; 22 | } 23 | })(); 24 | -------------------------------------------------------------------------------- /src/main/webapp/app/account/activate/activate.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

Activation

5 | 6 |
7 | Your user has been activated. Please sign in. 8 |
9 | 10 |
11 | Your user could not be activated. Please use the registration form to sign up. 12 |
13 | 14 |
15 |
16 |
17 | -------------------------------------------------------------------------------- /src/main/webapp/app/account/activate/activate.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('activate', { 12 | parent: 'account', 13 | url: '/activate?key', 14 | data: { 15 | authorities: [], 16 | pageTitle: 'Activation' 17 | }, 18 | views: { 19 | 'content@': { 20 | templateUrl: 'app/account/activate/activate.html', 21 | controller: 'ActivationController', 22 | controllerAs: 'vm' 23 | } 24 | } 25 | }); 26 | } 27 | })(); 28 | -------------------------------------------------------------------------------- /src/main/webapp/app/account/password/password.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('PasswordController', PasswordController); 7 | 8 | PasswordController.$inject = ['Auth', 'Principal']; 9 | 10 | function PasswordController (Auth, Principal) { 11 | var vm = this; 12 | 13 | vm.changePassword = changePassword; 14 | vm.doNotMatch = null; 15 | vm.error = null; 16 | vm.success = null; 17 | 18 | Principal.identity().then(function(account) { 19 | vm.account = account; 20 | }); 21 | 22 | function changePassword () { 23 | if (vm.password !== vm.confirmPassword) { 24 | vm.error = null; 25 | vm.success = null; 26 | vm.doNotMatch = 'ERROR'; 27 | } else { 28 | vm.doNotMatch = null; 29 | Auth.changePassword(vm.password).then(function () { 30 | vm.error = null; 31 | vm.success = 'OK'; 32 | }).catch(function () { 33 | vm.success = null; 34 | vm.error = 'ERROR'; 35 | }); 36 | } 37 | } 38 | } 39 | })(); 40 | -------------------------------------------------------------------------------- /src/main/webapp/app/account/password/password.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('password', { 12 | parent: 'account', 13 | url: '/password', 14 | data: { 15 | authorities: ['ROLE_USER'], 16 | pageTitle: 'Password' 17 | }, 18 | views: { 19 | 'content@': { 20 | templateUrl: 'app/account/password/password.html', 21 | controller: 'PasswordController', 22 | controllerAs: 'vm' 23 | } 24 | } 25 | }); 26 | } 27 | })(); 28 | -------------------------------------------------------------------------------- /src/main/webapp/app/account/register/register.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('RegisterController', RegisterController); 7 | 8 | 9 | RegisterController.$inject = [ '$timeout', 'Auth', 'LoginService']; 10 | 11 | function RegisterController ($timeout, Auth, LoginService) { 12 | var vm = this; 13 | 14 | vm.doNotMatch = null; 15 | vm.error = null; 16 | vm.errorUserExists = null; 17 | vm.login = LoginService.open; 18 | vm.register = register; 19 | vm.registerAccount = {}; 20 | vm.success = null; 21 | 22 | $timeout(function (){angular.element('#login').focus();}); 23 | 24 | function register () { 25 | if (vm.registerAccount.password !== vm.confirmPassword) { 26 | vm.doNotMatch = 'ERROR'; 27 | } else { 28 | vm.registerAccount.langKey = 'en' ; 29 | vm.doNotMatch = null; 30 | vm.error = null; 31 | vm.errorUserExists = null; 32 | vm.errorEmailExists = null; 33 | 34 | Auth.createAccount(vm.registerAccount).then(function () { 35 | vm.success = 'OK'; 36 | }).catch(function (response) { 37 | vm.success = null; 38 | if (response.status === 400 && response.data === 'login already in use') { 39 | vm.errorUserExists = 'ERROR'; 40 | } else if (response.status === 400 && response.data === 'e-mail address already in use') { 41 | vm.errorEmailExists = 'ERROR'; 42 | } else { 43 | vm.error = 'ERROR'; 44 | } 45 | }); 46 | } 47 | } 48 | } 49 | })(); 50 | -------------------------------------------------------------------------------- /src/main/webapp/app/account/register/register.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('register', { 12 | parent: 'account', 13 | url: '/register', 14 | data: { 15 | authorities: [], 16 | pageTitle: 'Registration' 17 | }, 18 | views: { 19 | 'content@': { 20 | templateUrl: 'app/account/register/register.html', 21 | controller: 'RegisterController', 22 | controllerAs: 'vm' 23 | } 24 | } 25 | }); 26 | } 27 | })(); 28 | -------------------------------------------------------------------------------- /src/main/webapp/app/account/reset/finish/reset.finish.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('ResetFinishController', ResetFinishController); 7 | 8 | ResetFinishController.$inject = ['$stateParams', '$timeout', 'Auth', 'LoginService']; 9 | 10 | function ResetFinishController ($stateParams, $timeout, Auth, LoginService) { 11 | var vm = this; 12 | 13 | vm.keyMissing = angular.isUndefined($stateParams.key); 14 | vm.confirmPassword = null; 15 | vm.doNotMatch = null; 16 | vm.error = null; 17 | vm.finishReset = finishReset; 18 | vm.login = LoginService.open; 19 | vm.resetAccount = {}; 20 | vm.success = null; 21 | 22 | $timeout(function (){angular.element('#password').focus();}); 23 | 24 | function finishReset() { 25 | vm.doNotMatch = null; 26 | vm.error = null; 27 | if (vm.resetAccount.password !== vm.confirmPassword) { 28 | vm.doNotMatch = 'ERROR'; 29 | } else { 30 | Auth.resetPasswordFinish({key: $stateParams.key, newPassword: vm.resetAccount.password}).then(function () { 31 | vm.success = 'OK'; 32 | }).catch(function () { 33 | vm.success = null; 34 | vm.error = 'ERROR'; 35 | }); 36 | } 37 | } 38 | } 39 | })(); 40 | -------------------------------------------------------------------------------- /src/main/webapp/app/account/reset/finish/reset.finish.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('finishReset', { 12 | parent: 'account', 13 | url: '/reset/finish?key', 14 | data: { 15 | authorities: [] 16 | }, 17 | views: { 18 | 'content@': { 19 | templateUrl: 'app/account/reset/finish/reset.finish.html', 20 | controller: 'ResetFinishController', 21 | controllerAs: 'vm' 22 | } 23 | } 24 | }); 25 | } 26 | })(); 27 | -------------------------------------------------------------------------------- /src/main/webapp/app/account/reset/request/reset.request.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('RequestResetController', RequestResetController); 7 | 8 | RequestResetController.$inject = ['$timeout', 'Auth']; 9 | 10 | function RequestResetController ($timeout, Auth) { 11 | var vm = this; 12 | 13 | vm.error = null; 14 | vm.errorEmailNotExists = null; 15 | vm.requestReset = requestReset; 16 | vm.resetAccount = {}; 17 | vm.success = null; 18 | 19 | $timeout(function (){angular.element('#email').focus();}); 20 | 21 | function requestReset () { 22 | 23 | vm.error = null; 24 | vm.errorEmailNotExists = null; 25 | 26 | Auth.resetPasswordInit(vm.resetAccount.email).then(function () { 27 | vm.success = 'OK'; 28 | }).catch(function (response) { 29 | vm.success = null; 30 | if (response.status === 400 && response.data === 'e-mail address not registered') { 31 | vm.errorEmailNotExists = 'ERROR'; 32 | } else { 33 | vm.error = 'ERROR'; 34 | } 35 | }); 36 | } 37 | } 38 | })(); 39 | -------------------------------------------------------------------------------- /src/main/webapp/app/account/reset/request/reset.request.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('requestReset', { 12 | parent: 'account', 13 | url: '/reset/request', 14 | data: { 15 | authorities: [] 16 | }, 17 | views: { 18 | 'content@': { 19 | templateUrl: 'app/account/reset/request/reset.request.html', 20 | controller: 'RequestResetController', 21 | controllerAs: 'vm' 22 | } 23 | } 24 | }); 25 | } 26 | })(); 27 | -------------------------------------------------------------------------------- /src/main/webapp/app/account/settings/settings.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('SettingsController', SettingsController); 7 | 8 | SettingsController.$inject = ['Principal', 'Auth']; 9 | 10 | function SettingsController (Principal, Auth) { 11 | var vm = this; 12 | 13 | vm.error = null; 14 | vm.save = save; 15 | vm.settingsAccount = null; 16 | vm.success = null; 17 | 18 | /** 19 | * Store the "settings account" in a separate variable, and not in the shared "account" variable. 20 | */ 21 | var copyAccount = function (account) { 22 | return { 23 | activated: account.activated, 24 | email: account.email, 25 | firstName: account.firstName, 26 | langKey: account.langKey, 27 | lastName: account.lastName, 28 | login: account.login 29 | }; 30 | }; 31 | 32 | Principal.identity().then(function(account) { 33 | vm.settingsAccount = copyAccount(account); 34 | }); 35 | 36 | function save () { 37 | Auth.updateAccount(vm.settingsAccount).then(function() { 38 | vm.error = null; 39 | vm.success = 'OK'; 40 | Principal.identity(true).then(function(account) { 41 | vm.settingsAccount = copyAccount(account); 42 | }); 43 | }).catch(function() { 44 | vm.success = null; 45 | vm.error = 'ERROR'; 46 | }); 47 | } 48 | } 49 | })(); 50 | -------------------------------------------------------------------------------- /src/main/webapp/app/account/settings/settings.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('settings', { 12 | parent: 'account', 13 | url: '/settings', 14 | data: { 15 | authorities: ['ROLE_USER'], 16 | pageTitle: 'Settings' 17 | }, 18 | views: { 19 | 'content@': { 20 | templateUrl: 'app/account/settings/settings.html', 21 | controller: 'SettingsController', 22 | controllerAs: 'vm' 23 | } 24 | } 25 | }); 26 | } 27 | })(); 28 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/admin.state.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig ($stateProvider) { 11 | $stateProvider.state('admin', { 12 | abstract: true, 13 | parent: 'app' 14 | }); 15 | } 16 | })(); 17 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/audits/audits.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('AuditsController', AuditsController); 7 | 8 | AuditsController.$inject = ['$filter', 'AuditsService', 'ParseLinks']; 9 | 10 | function AuditsController ($filter, AuditsService, ParseLinks) { 11 | var vm = this; 12 | 13 | vm.audits = null; 14 | vm.fromDate = null; 15 | vm.links = null; 16 | vm.loadPage = loadPage; 17 | vm.onChangeDate = onChangeDate; 18 | vm.page = 1; 19 | vm.previousMonth = previousMonth; 20 | vm.toDate = null; 21 | vm.today = today; 22 | vm.totalItems = null; 23 | 24 | vm.today(); 25 | vm.previousMonth(); 26 | vm.onChangeDate(); 27 | 28 | function onChangeDate () { 29 | var dateFormat = 'yyyy-MM-dd'; 30 | var fromDate = $filter('date')(vm.fromDate, dateFormat); 31 | var toDate = $filter('date')(vm.toDate, dateFormat); 32 | 33 | AuditsService.query({page: vm.page -1, size: 20, fromDate: fromDate, toDate: toDate}, function(result, headers){ 34 | vm.audits = result; 35 | vm.links = ParseLinks.parse(headers('link')); 36 | vm.totalItems = headers('X-Total-Count'); 37 | }); 38 | } 39 | 40 | // Date picker configuration 41 | function today () { 42 | // Today + 1 day - needed if the current day must be included 43 | var today = new Date(); 44 | vm.toDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1); 45 | } 46 | 47 | function previousMonth () { 48 | var fromDate = new Date(); 49 | if (fromDate.getMonth() === 0) { 50 | fromDate = new Date(fromDate.getFullYear() - 1, 11, fromDate.getDate()); 51 | } else { 52 | fromDate = new Date(fromDate.getFullYear(), fromDate.getMonth() - 1, fromDate.getDate()); 53 | } 54 | 55 | vm.fromDate = fromDate; 56 | } 57 | 58 | function loadPage (page) { 59 | vm.page = page; 60 | vm.onChangeDate(); 61 | } 62 | } 63 | })(); 64 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/audits/audits.html: -------------------------------------------------------------------------------- 1 |
2 |

Audits

3 | 4 |
5 |
6 |

Filter by date

7 |

8 | from 9 | 10 | to 11 | 12 |

13 |
14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 35 | 36 |
DateUserStateExtra data
{{audit.timestamp| date:'medium'}}{{audit.principal}}{{audit.type}} 32 | {{audit.data.message}} 33 | Remote Address {{audit.data.remoteAddress}} 34 |
37 | 38 |
39 | 40 |
41 |
42 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/audits/audits.service.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('AuditsService', AuditsService); 7 | 8 | AuditsService.$inject = ['$resource']; 9 | 10 | function AuditsService ($resource) { 11 | var service = $resource('management/jhipster/audits/:id', {}, { 12 | 'get': { 13 | method: 'GET', 14 | isArray: true 15 | }, 16 | 'query': { 17 | method: 'GET', 18 | isArray: true, 19 | params: {fromDate: null, toDate: null} 20 | } 21 | }); 22 | 23 | return service; 24 | } 25 | })(); 26 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/audits/audits.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('audits', { 12 | parent: 'admin', 13 | url: '/audits', 14 | data: { 15 | authorities: ['ROLE_ADMIN'], 16 | pageTitle: 'Audits' 17 | }, 18 | views: { 19 | 'content@': { 20 | templateUrl: 'app/admin/audits/audits.html', 21 | controller: 'AuditsController', 22 | controllerAs: 'vm' 23 | } 24 | } 25 | }); 26 | } 27 | })(); 28 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/configuration/configuration.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('JhiConfigurationController', JhiConfigurationController); 7 | 8 | JhiConfigurationController.$inject = ['$filter','JhiConfigurationService']; 9 | 10 | function JhiConfigurationController (filter,JhiConfigurationService) { 11 | var vm = this; 12 | 13 | vm.allConfiguration = null; 14 | vm.configuration = null; 15 | 16 | JhiConfigurationService.get().then(function(configuration) { 17 | vm.configuration = configuration; 18 | }); 19 | JhiConfigurationService.getEnv().then(function (configuration) { 20 | vm.allConfiguration = configuration; 21 | }); 22 | } 23 | })(); 24 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/configuration/configuration.html: -------------------------------------------------------------------------------- 1 |
2 |

Configuration

3 | 4 | Filter (by prefix) 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 25 | 26 |
PrefixProperties
{{entry.prefix}} 18 |
19 |
{{key}}
20 |
21 | {{value}} 22 |
23 |
24 |
27 |
28 | 29 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 | 45 |
PropertyValue
{{item.key}} 41 | {{item.val}} 42 |
46 |
47 |
48 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/configuration/configuration.service.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('JhiConfigurationService', JhiConfigurationService); 7 | 8 | JhiConfigurationService.$inject = ['$filter', '$http']; 9 | 10 | function JhiConfigurationService ($filter, $http) { 11 | var service = { 12 | get: get, 13 | getEnv: getEnv 14 | }; 15 | 16 | return service; 17 | 18 | function get () { 19 | return $http.get('management/configprops').then(getConfigPropsComplete); 20 | 21 | function getConfigPropsComplete (response) { 22 | var properties = []; 23 | angular.forEach(response.data, function (data) { 24 | properties.push(data); 25 | }); 26 | var orderBy = $filter('orderBy'); 27 | return orderBy(properties, 'prefix'); 28 | } 29 | } 30 | 31 | function getEnv () { 32 | return $http.get('management/env').then(getEnvComplete); 33 | 34 | function getEnvComplete (response) { 35 | var properties = {}; 36 | angular.forEach(response.data, function (val,key) { 37 | var vals = []; 38 | angular.forEach(val, function (v,k) { 39 | vals.push({ key:k, val:v }); 40 | }); 41 | properties[key] = vals; 42 | }); 43 | return properties; 44 | } 45 | } 46 | } 47 | })(); 48 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/configuration/configuration.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('jhi-configuration', { 12 | parent: 'admin', 13 | url: '/configuration', 14 | data: { 15 | authorities: ['ROLE_ADMIN'], 16 | pageTitle: 'Configuration' 17 | }, 18 | views: { 19 | 'content@': { 20 | templateUrl: 'app/admin/configuration/configuration.html', 21 | controller: 'JhiConfigurationController', 22 | controllerAs: 'vm' 23 | } 24 | } 25 | }); 26 | } 27 | })(); 28 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/docs/docs.html: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/docs/docs.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig ($stateProvider) { 11 | $stateProvider.state('docs', { 12 | parent: 'admin', 13 | url: '/docs', 14 | data: { 15 | authorities: ['ROLE_ADMIN'], 16 | pageTitle: 'API' 17 | }, 18 | views: { 19 | 'content@': { 20 | templateUrl: 'app/admin/docs/docs.html' 21 | } 22 | } 23 | }); 24 | } 25 | })(); 26 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/gateway/gateway.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('GatewayController', GatewayController); 7 | 8 | GatewayController.$inject = ['$filter', '$interval', 'GatewayRoutes']; 9 | 10 | function GatewayController ($filter, $interval, GatewayRoutes) { 11 | var vm = this; 12 | 13 | vm.gatewayRoutes = null; 14 | vm.refresh = refresh; 15 | vm.updatingRoutes = null; 16 | 17 | vm.refresh(); 18 | 19 | function refresh () { 20 | vm.updatingRoutes = true; 21 | GatewayRoutes.query(function(result) { 22 | vm.gatewayRoutes = result; 23 | vm.updatingRoutes = false; 24 | }); 25 | } 26 | } 27 | 28 | })(); 29 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/gateway/gateway.html: -------------------------------------------------------------------------------- 1 |
2 |

Gateway

3 | 4 |

Current routes

5 |

6 | 9 | 12 |

13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 37 | 38 |
URLServiceAvailable servers
{{route.path}}{{route.serviceId}} 26 |
27 | Warning: no server available! 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 |
{{instance.host}}:{{instance.port}}
{{instance.instanceInfo.status}}
{{instance.instanceInfo.status}}
36 |
39 |
40 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/gateway/gateway.routes.service.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('GatewayRoutes', GatewayRoutes); 7 | 8 | GatewayRoutes.$inject = ['$resource']; 9 | 10 | function GatewayRoutes ($resource) { 11 | var service = $resource('api/gateway/routes/:id', {}, { 12 | 'query': { method: 'GET', isArray: true}, 13 | 'get': { 14 | method: 'GET', 15 | transformResponse: function (data) { 16 | data = angular.fromJson(data); 17 | return data; 18 | } 19 | }, 20 | 'update': { method:'PUT' } 21 | }); 22 | 23 | return service; 24 | } 25 | 26 | })(); 27 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/gateway/gateway.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('gateway', { 12 | parent: 'admin', 13 | url: '/gateway', 14 | data: { 15 | authorities: ['ROLE_ADMIN'], 16 | pageTitle: 'Gateway' 17 | }, 18 | views: { 19 | 'content@': { 20 | templateUrl: 'app/admin/gateway/gateway.html', 21 | controller: 'GatewayController', 22 | controllerAs: 'vm' 23 | } 24 | } 25 | }); 26 | } 27 | })(); 28 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/health/health.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('JhiHealthCheckController', JhiHealthCheckController); 7 | 8 | JhiHealthCheckController.$inject = ['JhiHealthService', '$uibModal']; 9 | 10 | function JhiHealthCheckController (JhiHealthService, $uibModal) { 11 | var vm = this; 12 | 13 | vm.updatingHealth = true; 14 | vm.getLabelClass = getLabelClass; 15 | vm.refresh = refresh; 16 | vm.showHealth = showHealth; 17 | vm.baseName = JhiHealthService.getBaseName; 18 | vm.subSystemName = JhiHealthService.getSubSystemName; 19 | 20 | vm.refresh(); 21 | 22 | function getLabelClass (statusState) { 23 | if (statusState === 'UP') { 24 | return 'label-success'; 25 | } else { 26 | return 'label-danger'; 27 | } 28 | } 29 | 30 | function refresh () { 31 | vm.updatingHealth = true; 32 | JhiHealthService.checkHealth().then(function (response) { 33 | vm.healthData = JhiHealthService.transformHealthData(response); 34 | vm.updatingHealth = false; 35 | }, function (response) { 36 | vm.healthData = JhiHealthService.transformHealthData(response.data); 37 | vm.updatingHealth = false; 38 | }); 39 | } 40 | 41 | function showHealth (health) { 42 | $uibModal.open({ 43 | templateUrl: 'app/admin/health/health.modal.html', 44 | controller: 'HealthModalController', 45 | controllerAs: 'vm', 46 | size: 'lg', 47 | resolve: { 48 | currentHealth: function() { 49 | return health; 50 | }, 51 | baseName: function() { 52 | return vm.baseName; 53 | }, 54 | subSystemName: function() { 55 | return vm.subSystemName; 56 | } 57 | 58 | } 59 | }); 60 | } 61 | 62 | } 63 | })(); 64 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/health/health.html: -------------------------------------------------------------------------------- 1 |
2 |

Health Checks

3 | 4 |

5 | 7 |

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 26 | 31 | 32 | 33 |
Service NameStatusDetails
{{ vm.baseName(health.name) }} {{vm.subSystemName(health.name)}} 22 | 23 | {{ health.status }} 24 | 25 | 27 | 28 | 29 | 30 |
34 |
35 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/health/health.modal.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular.module('ribbonCacheApp') 5 | .controller('HealthModalController', HealthModalController); 6 | 7 | HealthModalController.$inject = ['$uibModalInstance', 'currentHealth', 'baseName', 'subSystemName']; 8 | 9 | function HealthModalController ($uibModalInstance, currentHealth, baseName, subSystemName) { 10 | var vm = this; 11 | 12 | vm.cancel = cancel; 13 | vm.currentHealth = currentHealth; 14 | vm.baseName = baseName; 15 | vm.subSystemName = subSystemName; 16 | 17 | function cancel() { 18 | $uibModalInstance.dismiss('cancel'); 19 | } 20 | } 21 | })(); 22 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/health/health.modal.html: -------------------------------------------------------------------------------- 1 | 8 | 31 | 34 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/health/health.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('jhi-health', { 12 | parent: 'admin', 13 | url: '/health', 14 | data: { 15 | authorities: ['ROLE_ADMIN'], 16 | pageTitle: 'Health Checks' 17 | }, 18 | views: { 19 | 'content@': { 20 | templateUrl: 'app/admin/health/health.html', 21 | controller: 'JhiHealthCheckController', 22 | controllerAs: 'vm' 23 | } 24 | } 25 | }); 26 | } 27 | })(); 28 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/logs/logs.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('LogsController', LogsController); 7 | 8 | LogsController.$inject = ['LogsService']; 9 | 10 | function LogsController (LogsService) { 11 | var vm = this; 12 | 13 | vm.changeLevel = changeLevel; 14 | vm.loggers = LogsService.findAll(); 15 | 16 | function changeLevel (name, level) { 17 | LogsService.changeLevel({name: name, level: level}, function () { 18 | vm.loggers = LogsService.findAll(); 19 | }); 20 | } 21 | } 22 | })(); 23 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/logs/logs.html: -------------------------------------------------------------------------------- 1 |
2 |

Logs

3 | 4 |

There are {{ vm.loggers.length }} loggers.

5 | 6 | Filter 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 25 | 26 |
NameLevel
{{logger.name | characters:140}} 19 | 20 | 21 | 22 | 23 | 24 |
27 |
28 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/logs/logs.service.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('LogsService', LogsService); 7 | 8 | LogsService.$inject = ['$resource']; 9 | 10 | function LogsService ($resource) { 11 | var service = $resource('management/jhipster/logs', {}, { 12 | 'findAll': { method: 'GET', isArray: true}, 13 | 'changeLevel': { method: 'PUT'} 14 | }); 15 | 16 | return service; 17 | } 18 | })(); 19 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/logs/logs.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('logs', { 12 | parent: 'admin', 13 | url: '/logs', 14 | data: { 15 | authorities: ['ROLE_ADMIN'], 16 | pageTitle: 'Logs' 17 | }, 18 | views: { 19 | 'content@': { 20 | templateUrl: 'app/admin/logs/logs.html', 21 | controller: 'LogsController', 22 | controllerAs: 'vm' 23 | } 24 | } 25 | }); 26 | } 27 | })(); 28 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/metrics/metrics.modal.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('JhiMetricsMonitoringModalController', JhiMetricsMonitoringModalController); 7 | 8 | JhiMetricsMonitoringModalController.$inject = ['$uibModalInstance', 'threadDump']; 9 | 10 | function JhiMetricsMonitoringModalController ($uibModalInstance, threadDump) { 11 | var vm = this; 12 | 13 | vm.cancel = cancel; 14 | vm.getLabelClass = getLabelClass; 15 | vm.threadDump = threadDump; 16 | vm.threadDumpAll = 0; 17 | vm.threadDumpBlocked = 0; 18 | vm.threadDumpRunnable = 0; 19 | vm.threadDumpTimedWaiting = 0; 20 | vm.threadDumpWaiting = 0; 21 | 22 | angular.forEach(threadDump, function(value) { 23 | if (value.threadState === 'RUNNABLE') { 24 | vm.threadDumpRunnable += 1; 25 | } else if (value.threadState === 'WAITING') { 26 | vm.threadDumpWaiting += 1; 27 | } else if (value.threadState === 'TIMED_WAITING') { 28 | vm.threadDumpTimedWaiting += 1; 29 | } else if (value.threadState === 'BLOCKED') { 30 | vm.threadDumpBlocked += 1; 31 | } 32 | }); 33 | 34 | vm.threadDumpAll = vm.threadDumpRunnable + vm.threadDumpWaiting + 35 | vm.threadDumpTimedWaiting + vm.threadDumpBlocked; 36 | 37 | function cancel () { 38 | $uibModalInstance.dismiss('cancel'); 39 | } 40 | 41 | function getLabelClass (threadState) { 42 | if (threadState === 'RUNNABLE') { 43 | return 'label-success'; 44 | } else if (threadState === 'WAITING') { 45 | return 'label-info'; 46 | } else if (threadState === 'TIMED_WAITING') { 47 | return 'label-warning'; 48 | } else if (threadState === 'BLOCKED') { 49 | return 'label-danger'; 50 | } 51 | } 52 | } 53 | })(); 54 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/metrics/metrics.service.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('JhiMetricsService', JhiMetricsService); 7 | 8 | JhiMetricsService.$inject = ['$rootScope', '$http']; 9 | 10 | function JhiMetricsService ($rootScope, $http) { 11 | var service = { 12 | getMetrics: getMetrics, 13 | threadDump: threadDump 14 | }; 15 | 16 | return service; 17 | 18 | function getMetrics () { 19 | return $http.get('management/jhipster/metrics').then(function (response) { 20 | return response.data; 21 | }); 22 | } 23 | 24 | function threadDump () { 25 | return $http.get('management/dump').then(function (response) { 26 | return response.data; 27 | }); 28 | } 29 | } 30 | })(); 31 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/metrics/metrics.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('jhi-metrics', { 12 | parent: 'admin', 13 | url: '/metrics', 14 | data: { 15 | authorities: ['ROLE_ADMIN'], 16 | pageTitle: 'Application Metrics' 17 | }, 18 | views: { 19 | 'content@': { 20 | templateUrl: 'app/admin/metrics/metrics.html', 21 | controller: 'JhiMetricsMonitoringController', 22 | controllerAs: 'vm' 23 | } 24 | } 25 | }); 26 | } 27 | })(); 28 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/user-management/user-management-delete-dialog.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('UserManagementDeleteController', UserManagementDeleteController); 7 | 8 | UserManagementDeleteController.$inject = ['$uibModalInstance', 'entity', 'User']; 9 | 10 | function UserManagementDeleteController ($uibModalInstance, entity, User) { 11 | var vm = this; 12 | 13 | vm.user = entity; 14 | vm.clear = clear; 15 | vm.confirmDelete = confirmDelete; 16 | 17 | function clear () { 18 | $uibModalInstance.dismiss('cancel'); 19 | } 20 | 21 | function confirmDelete (login) { 22 | User.delete({login: login}, 23 | function () { 24 | $uibModalInstance.close(true); 25 | }); 26 | } 27 | } 28 | })(); 29 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/user-management/user-management-delete-dialog.html: -------------------------------------------------------------------------------- 1 |
2 | 7 | 11 | 19 |
20 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/user-management/user-management-detail.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('UserManagementDetailController', UserManagementDetailController); 7 | 8 | UserManagementDetailController.$inject = ['$stateParams', 'User']; 9 | 10 | function UserManagementDetailController ($stateParams, User) { 11 | var vm = this; 12 | 13 | vm.load = load; 14 | vm.user = {}; 15 | 16 | vm.load($stateParams.login); 17 | 18 | function load (login) { 19 | User.get({login: login}, function(result) { 20 | vm.user = result; 21 | }); 22 | } 23 | } 24 | })(); 25 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/user-management/user-management-detail.html: -------------------------------------------------------------------------------- 1 |
2 |

User "{{vm.user.login}}"

3 |
4 |
Login
5 |
{{vm.user.login}}
6 |
First Name
7 |
{{vm.user.firstName}}
8 |
Last Name
9 |
{{vm.user.lastName}}
10 |
Email
11 |
{{vm.user.email}}
12 |
Activated
13 |
{{vm.user.activated}}
14 |
Created By
15 |
{{vm.user.createdBy}}
16 |
Created Date
17 |
{{vm.user.createdDate | date:'dd/MM/yy HH:mm' }}
18 |
Last Modified By
19 |
{{vm.user.lastModifiedBy}}
20 |
Last Modified Date
21 |
{{vm.user.lastModifiedDate | date:'dd/MM/yy HH:mm'}}
22 |
Profiles
23 |
24 |
    25 |
  • {{authority}}
  • 26 |
27 |
28 |
29 | 34 |
35 | -------------------------------------------------------------------------------- /src/main/webapp/app/admin/user-management/user-management-dialog.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('UserManagementDialogController',UserManagementDialogController); 7 | 8 | UserManagementDialogController.$inject = ['$stateParams', '$uibModalInstance', 'entity', 'User']; 9 | 10 | function UserManagementDialogController ($stateParams, $uibModalInstance, entity, User) { 11 | var vm = this; 12 | 13 | vm.authorities = ['ROLE_USER', 'ROLE_ADMIN']; 14 | vm.clear = clear; 15 | vm.languages = null; 16 | vm.save = save; 17 | vm.user = entity; 18 | 19 | 20 | 21 | function clear () { 22 | $uibModalInstance.dismiss('cancel'); 23 | } 24 | 25 | function onSaveSuccess (result) { 26 | vm.isSaving = false; 27 | $uibModalInstance.close(result); 28 | } 29 | 30 | function onSaveError () { 31 | vm.isSaving = false; 32 | } 33 | 34 | function save () { 35 | vm.isSaving = true; 36 | if (vm.user.id !== null) { 37 | User.update(vm.user, onSaveSuccess, onSaveError); 38 | } else { 39 | vm.user.langKey = 'en'; 40 | User.save(vm.user, onSaveSuccess, onSaveError); 41 | } 42 | } 43 | } 44 | })(); 45 | -------------------------------------------------------------------------------- /src/main/webapp/app/app.constants.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | 'use strict'; 3 | // DO NOT EDIT THIS FILE, EDIT THE GULP TASK NGCONSTANT SETTINGS INSTEAD WHICH GENERATES THIS FILE 4 | angular 5 | .module('ribbonCacheApp') 6 | .constant('VERSION', "0.0.1-SNAPSHOT") 7 | .constant('DEBUG_INFO_ENABLED', true) 8 | ; 9 | })(); 10 | -------------------------------------------------------------------------------- /src/main/webapp/app/app.module.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp', [ 6 | 'ngStorage', 7 | 'ngResource', 8 | 'ngCookies', 9 | 'ngAria', 10 | 'ngCacheBuster', 11 | 'ngFileUpload', 12 | 'ui.bootstrap', 13 | 'ui.bootstrap.datetimepicker', 14 | 'ui.router', 15 | 'infinite-scroll', 16 | // jhipster-needle-angularjs-add-module JHipster will add new module here 17 | 'angular-loading-bar' 18 | ]) 19 | .run(run); 20 | 21 | run.$inject = ['stateHandler']; 22 | 23 | function run(stateHandler) { 24 | stateHandler.initialize(); 25 | } 26 | })(); 27 | -------------------------------------------------------------------------------- /src/main/webapp/app/app.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('app', { 12 | abstract: true, 13 | views: { 14 | 'navbar@': { 15 | templateUrl: 'app/layouts/navbar/navbar.html', 16 | controller: 'NavbarController', 17 | controllerAs: 'vm' 18 | } 19 | }, 20 | resolve: { 21 | authorize: ['Auth', 22 | function (Auth) { 23 | return Auth.authorize(); 24 | } 25 | ] 26 | } 27 | }); 28 | } 29 | })(); 30 | -------------------------------------------------------------------------------- /src/main/webapp/app/blocks/config/alert.config.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(alertServiceConfig); 7 | 8 | alertServiceConfig.$inject = ['AlertServiceProvider']; 9 | 10 | function alertServiceConfig(AlertServiceProvider) { 11 | // set below to true to make alerts look like toast 12 | AlertServiceProvider.showAsToast(false); 13 | } 14 | })(); 15 | -------------------------------------------------------------------------------- /src/main/webapp/app/blocks/config/compile.config.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(compileServiceConfig); 7 | 8 | compileServiceConfig.$inject = ['$compileProvider','DEBUG_INFO_ENABLED']; 9 | 10 | function compileServiceConfig($compileProvider,DEBUG_INFO_ENABLED) { 11 | // disable debug data on prod profile to improve performance 12 | $compileProvider.debugInfoEnabled(DEBUG_INFO_ENABLED); 13 | 14 | /* 15 | If you wish to debug an application with this information 16 | then you should open up a debug console in the browser 17 | then call this method directly in this console: 18 | 19 | angular.reloadWithDebugInfo(); 20 | */ 21 | } 22 | })(); 23 | -------------------------------------------------------------------------------- /src/main/webapp/app/blocks/config/http.config.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(httpConfig); 7 | 8 | httpConfig.$inject = ['$urlRouterProvider', '$httpProvider', 'httpRequestInterceptorCacheBusterProvider', '$urlMatcherFactoryProvider']; 9 | 10 | function httpConfig($urlRouterProvider, $httpProvider, httpRequestInterceptorCacheBusterProvider, $urlMatcherFactoryProvider) { 11 | 12 | //Cache everything except rest api requests 13 | httpRequestInterceptorCacheBusterProvider.setMatchlist([/.*api.*/, /.*protected.*/], true); 14 | 15 | $urlRouterProvider.otherwise('/'); 16 | 17 | $httpProvider.interceptors.push('errorHandlerInterceptor'); 18 | $httpProvider.interceptors.push('authExpiredInterceptor'); 19 | $httpProvider.interceptors.push('authInterceptor'); 20 | $httpProvider.interceptors.push('notificationInterceptor'); 21 | // jhipster-needle-angularjs-add-interceptor JHipster will add new application http interceptor here 22 | 23 | $urlMatcherFactoryProvider.type('boolean', { 24 | name : 'boolean', 25 | decode: function(val) { return val === true || val === 'true'; }, 26 | encode: function(val) { return val ? 1 : 0; }, 27 | equals: function(a, b) { return this.is(a) && a === b; }, 28 | is: function(val) { return [true,false,0,1].indexOf(val) >= 0; }, 29 | pattern: /bool|true|0|1/ 30 | }); 31 | } 32 | })(); 33 | -------------------------------------------------------------------------------- /src/main/webapp/app/blocks/config/localstorage.config.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(localStorageConfig); 7 | 8 | localStorageConfig.$inject = ['$localStorageProvider', '$sessionStorageProvider']; 9 | 10 | function localStorageConfig($localStorageProvider, $sessionStorageProvider) { 11 | $localStorageProvider.setKeyPrefix('jhi-'); 12 | $sessionStorageProvider.setKeyPrefix('jhi-'); 13 | } 14 | })(); 15 | -------------------------------------------------------------------------------- /src/main/webapp/app/blocks/config/uib-pager.config.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(pagerConfig); 7 | 8 | pagerConfig.$inject = ['uibPagerConfig', 'paginationConstants']; 9 | 10 | function pagerConfig(uibPagerConfig, paginationConstants) { 11 | uibPagerConfig.itemsPerPage = paginationConstants.itemsPerPage; 12 | uibPagerConfig.previousText = '«'; 13 | uibPagerConfig.nextText = '»'; 14 | } 15 | })(); 16 | -------------------------------------------------------------------------------- /src/main/webapp/app/blocks/config/uib-pagination.config.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(paginationConfig); 7 | 8 | paginationConfig.$inject = ['uibPaginationConfig', 'paginationConstants']; 9 | 10 | function paginationConfig(uibPaginationConfig, paginationConstants) { 11 | uibPaginationConfig.itemsPerPage = paginationConstants.itemsPerPage; 12 | uibPaginationConfig.maxSize = 5; 13 | uibPaginationConfig.boundaryLinks = true; 14 | uibPaginationConfig.firstText = '«'; 15 | uibPaginationConfig.previousText = '‹'; 16 | uibPaginationConfig.nextText = '›'; 17 | uibPaginationConfig.lastText = '»'; 18 | } 19 | })(); 20 | -------------------------------------------------------------------------------- /src/main/webapp/app/blocks/interceptor/auth-expired.interceptor.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('authExpiredInterceptor', authExpiredInterceptor); 7 | 8 | 9 | authExpiredInterceptor.$inject = ['$rootScope', '$q', '$injector', '$localStorage', '$sessionStorage']; 10 | 11 | function authExpiredInterceptor($rootScope, $q, $injector, $localStorage, $sessionStorage) { 12 | var service = { 13 | responseError: responseError 14 | }; 15 | 16 | return service; 17 | 18 | function responseError(response) { 19 | if (response.status === 401) { 20 | delete $localStorage.authenticationToken; 21 | delete $sessionStorage.authenticationToken; 22 | var Principal = $injector.get('Principal'); 23 | if (Principal.isAuthenticated()) { 24 | var Auth = $injector.get('Auth'); 25 | Auth.authorize(true); 26 | } 27 | } 28 | return $q.reject(response); 29 | } 30 | } 31 | })(); 32 | -------------------------------------------------------------------------------- /src/main/webapp/app/blocks/interceptor/auth.interceptor.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('authInterceptor', authInterceptor); 7 | 8 | authInterceptor.$inject = ['$rootScope', '$q', '$location', '$localStorage', '$sessionStorage']; 9 | 10 | function authInterceptor ($rootScope, $q, $location, $localStorage, $sessionStorage) { 11 | var service = { 12 | request: request 13 | }; 14 | 15 | return service; 16 | 17 | function request (config) { 18 | /*jshint camelcase: false */ 19 | config.headers = config.headers || {}; 20 | var token = $localStorage.authenticationToken || $sessionStorage.authenticationToken; 21 | 22 | if (token) { 23 | config.headers.Authorization = 'Bearer ' + token; 24 | } 25 | 26 | return config; 27 | } 28 | } 29 | })(); 30 | -------------------------------------------------------------------------------- /src/main/webapp/app/blocks/interceptor/errorhandler.interceptor.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('errorHandlerInterceptor', errorHandlerInterceptor); 7 | 8 | errorHandlerInterceptor.$inject = ['$q', '$rootScope']; 9 | 10 | function errorHandlerInterceptor ($q, $rootScope) { 11 | var service = { 12 | responseError: responseError 13 | }; 14 | 15 | return service; 16 | 17 | function responseError (response) { 18 | if (!(response.status === 401 && (response.data === '' || (response.data.path && response.data.path.indexOf('/api/account') === 0 )))) { 19 | $rootScope.$emit('ribbonCacheApp.httpError', response); 20 | } 21 | return $q.reject(response); 22 | } 23 | } 24 | })(); 25 | -------------------------------------------------------------------------------- /src/main/webapp/app/blocks/interceptor/notification.interceptor.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('notificationInterceptor', notificationInterceptor); 7 | 8 | notificationInterceptor.$inject = ['$q', 'AlertService']; 9 | 10 | function notificationInterceptor ($q, AlertService) { 11 | var service = { 12 | response: response 13 | }; 14 | 15 | return service; 16 | 17 | function response (response) { 18 | var alertKey = response.headers('X-ribbonCacheApp-alert'); 19 | if (angular.isString(alertKey)) { 20 | AlertService.success(alertKey, { param : response.headers('X-ribbonCacheApp-params')}); 21 | } 22 | return response; 23 | } 24 | } 25 | })(); 26 | -------------------------------------------------------------------------------- /src/main/webapp/app/components/alert/alert.directive.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var jhiAlert = { 5 | template: '
' + 6 | '
' + 7 | '
' + 8 | '
' + 9 | '
', 10 | controller: jhiAlertController 11 | }; 12 | 13 | angular 14 | .module('ribbonCacheApp') 15 | .component('jhiAlert', jhiAlert); 16 | 17 | jhiAlertController.$inject = ['$scope', 'AlertService']; 18 | 19 | function jhiAlertController($scope, AlertService) { 20 | var vm = this; 21 | 22 | vm.alerts = AlertService.get(); 23 | $scope.$on('$destroy', function () { 24 | vm.alerts = []; 25 | }); 26 | } 27 | })(); 28 | -------------------------------------------------------------------------------- /src/main/webapp/app/components/form/maxbytes.directive.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .directive('maxbytes', maxbytes); 7 | 8 | function maxbytes () { 9 | var directive = { 10 | restrict: 'A', 11 | require: '?ngModel', 12 | link: linkFunc 13 | }; 14 | 15 | return directive; 16 | 17 | function linkFunc (scope, element, attrs, ngModel) { 18 | if (!ngModel) { 19 | return; 20 | } 21 | 22 | ngModel.$validators.maxbytes = function (modelValue) { 23 | return ngModel.$isEmpty(modelValue) || numberOfBytes(modelValue) <= attrs.maxbytes; 24 | }; 25 | } 26 | 27 | function endsWith(suffix, str) { 28 | return str.indexOf(suffix, str.length - suffix.length) !== -1; 29 | } 30 | 31 | function paddingSize(base64String) { 32 | if (endsWith('==', base64String)) { 33 | return 2; 34 | } 35 | if (endsWith('=', base64String)) { 36 | return 1; 37 | } 38 | return 0; 39 | } 40 | 41 | function numberOfBytes(base64String) { 42 | return base64String.length / 4 * 3 - paddingSize(base64String); 43 | } 44 | } 45 | 46 | })(); 47 | -------------------------------------------------------------------------------- /src/main/webapp/app/components/form/minbytes.directive.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .directive('minbytes', minbytes); 7 | 8 | function minbytes () { 9 | var directive = { 10 | restrict: 'A', 11 | require: '?ngModel', 12 | link: linkFunc 13 | }; 14 | 15 | return directive; 16 | 17 | function linkFunc (scope, element, attrs, ngModel) { 18 | if (!ngModel) { 19 | return; 20 | } 21 | 22 | ngModel.$validators.minbytes = function (modelValue) { 23 | return ngModel.$isEmpty(modelValue) || numberOfBytes(modelValue) >= attrs.minbytes; 24 | }; 25 | } 26 | 27 | function endsWith(suffix, str) { 28 | return str.indexOf(suffix, str.length - suffix.length) !== -1; 29 | } 30 | 31 | function paddingSize(base64String) { 32 | if (endsWith('==', base64String)) { 33 | return 2; 34 | } 35 | if (endsWith('=', base64String)) { 36 | return 1; 37 | } 38 | return 0; 39 | } 40 | 41 | function numberOfBytes(base64String) { 42 | return base64String.length / 4 * 3 - paddingSize(base64String); 43 | } 44 | } 45 | })(); 46 | -------------------------------------------------------------------------------- /src/main/webapp/app/components/form/pagination.constants.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .constant('paginationConstants', { 7 | 'itemsPerPage': 20 8 | }); 9 | })(); 10 | -------------------------------------------------------------------------------- /src/main/webapp/app/components/form/show-validation.directive.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .directive('showValidation', showValidation); 7 | 8 | function showValidation () { 9 | var directive = { 10 | restrict: 'A', 11 | require: 'form', 12 | link: linkFunc 13 | }; 14 | 15 | return directive; 16 | 17 | function linkFunc (scope, element) { 18 | element.find('.form-group').each(function() { 19 | var $formGroup = angular.element(this); 20 | var $inputs = $formGroup.find('input[ng-model],textarea[ng-model],select[ng-model]'); 21 | 22 | if ($inputs.length > 0) { 23 | $inputs.each(function() { 24 | var $input = angular.element(this); 25 | scope.$watch(function() { 26 | return $input.hasClass('ng-invalid') && $input.hasClass('ng-dirty'); 27 | }, function(isInvalid) { 28 | $formGroup.toggleClass('has-error', isInvalid); 29 | }); 30 | }); 31 | } 32 | }); 33 | } 34 | } 35 | })(); 36 | -------------------------------------------------------------------------------- /src/main/webapp/app/components/login/login.html: -------------------------------------------------------------------------------- 1 | 6 | 45 | -------------------------------------------------------------------------------- /src/main/webapp/app/components/login/login.service.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('LoginService', LoginService); 7 | 8 | LoginService.$inject = ['$uibModal']; 9 | 10 | function LoginService ($uibModal) { 11 | var service = { 12 | open: open 13 | }; 14 | 15 | var modalInstance = null; 16 | var resetModal = function () { 17 | modalInstance = null; 18 | }; 19 | 20 | return service; 21 | 22 | function open () { 23 | if (modalInstance !== null) return; 24 | modalInstance = $uibModal.open({ 25 | animation: true, 26 | templateUrl: 'app/components/login/login.html', 27 | controller: 'LoginController', 28 | controllerAs: 'vm' 29 | }); 30 | modalInstance.result.then( 31 | resetModal, 32 | resetModal 33 | ); 34 | } 35 | } 36 | })(); 37 | -------------------------------------------------------------------------------- /src/main/webapp/app/components/util/capitalize.filter.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .filter('capitalize', capitalize); 7 | 8 | function capitalize() { 9 | return capitalizeFilter; 10 | 11 | function capitalizeFilter (input) { 12 | if (input !== null) { 13 | input = input.toLowerCase(); 14 | } 15 | return input.substring(0, 1).toUpperCase() + input.substring(1); 16 | } 17 | } 18 | })(); 19 | -------------------------------------------------------------------------------- /src/main/webapp/app/components/util/date-util.service.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('DateUtils', DateUtils); 7 | 8 | DateUtils.$inject = ['$filter']; 9 | 10 | function DateUtils ($filter) { 11 | 12 | var service = { 13 | convertDateTimeFromServer : convertDateTimeFromServer, 14 | convertLocalDateFromServer : convertLocalDateFromServer, 15 | convertLocalDateToServer : convertLocalDateToServer, 16 | dateformat : dateformat 17 | }; 18 | 19 | return service; 20 | 21 | function convertDateTimeFromServer (date) { 22 | if (date) { 23 | return new Date(date); 24 | } else { 25 | return null; 26 | } 27 | } 28 | 29 | function convertLocalDateFromServer (date) { 30 | if (date) { 31 | var dateString = date.split('-'); 32 | return new Date(dateString[0], dateString[1] - 1, dateString[2]); 33 | } 34 | return null; 35 | } 36 | 37 | function convertLocalDateToServer (date) { 38 | if (date) { 39 | return $filter('date')(date, 'yyyy-MM-dd'); 40 | } else { 41 | return null; 42 | } 43 | } 44 | 45 | function dateformat () { 46 | return 'yyyy-MM-dd'; 47 | } 48 | } 49 | 50 | })(); 51 | -------------------------------------------------------------------------------- /src/main/webapp/app/components/util/jhi-item-count.directive.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | var jhiItemCount = { 5 | template: '
' + 6 | 'Showing {{(($ctrl.page - 1) * $ctrl.itemsPerPage) == 0 ? 1 : (($ctrl.page - 1) * $ctrl.itemsPerPage + 1)}} - ' + 7 | '{{($ctrl.page * $ctrl.itemsPerPage) < $ctrl.queryCount ? ($ctrl.page * $ctrl.itemsPerPage) : $ctrl.queryCount}} ' + 8 | 'of {{$ctrl.queryCount}} items.' + 9 | '
', 10 | bindings: { 11 | page: '<', 12 | queryCount: ' 1){ 21 | return sort.split(',').slice(-1)[0] === 'asc'; 22 | } else { 23 | // default to true if no sort defined 24 | return true; 25 | } 26 | } 27 | 28 | // query params are strings, and need to be parsed 29 | function parsePage (page) { 30 | return parseInt(page); 31 | } 32 | 33 | // sort can be in the format `id,asc` or `id` 34 | function parsePredicate (sort) { 35 | var sortArray = sort.split(','); 36 | if (sortArray.length > 1){ 37 | sortArray.pop(); 38 | } 39 | return sortArray.join(','); 40 | } 41 | } 42 | })(); 43 | -------------------------------------------------------------------------------- /src/main/webapp/app/components/util/parse-links.service.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('ParseLinks', ParseLinks); 7 | 8 | function ParseLinks () { 9 | 10 | var service = { 11 | parse : parse 12 | }; 13 | 14 | return service; 15 | 16 | function parse(header) { 17 | if (header.length === 0) { 18 | throw new Error('input must not be of zero length'); 19 | } 20 | 21 | // Split parts by comma 22 | var parts = header.split(','); 23 | var links = {}; 24 | // Parse each part into a named link 25 | angular.forEach(parts, function(p) { 26 | var section = p.split(';'); 27 | if (section.length !== 2) { 28 | throw new Error('section could not be split on ";"'); 29 | } 30 | var url = section[0].replace(/<(.*)>/, '$1').trim(); 31 | var queryString = {}; 32 | url.replace( 33 | new RegExp('([^?=&]+)(=([^&]*))?', 'g'), 34 | function($0, $1, $2, $3) { queryString[$1] = $3; } 35 | ); 36 | var page = queryString.page; 37 | if (angular.isString(page)) { 38 | page = parseInt(page); 39 | } 40 | var name = section[1].replace(/rel="(.*)"/, '$1').trim(); 41 | links[name] = page; 42 | }); 43 | return links; 44 | } 45 | } 46 | })(); 47 | -------------------------------------------------------------------------------- /src/main/webapp/app/components/util/sort-by.directive.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .directive('jhSortBy', jhSortBy); 7 | 8 | function jhSortBy() { 9 | var directive = { 10 | restrict: 'A', 11 | scope: false, 12 | require: '^jhSort', 13 | link: linkFunc 14 | }; 15 | 16 | return directive; 17 | 18 | function linkFunc(scope, element, attrs, parentCtrl) { 19 | element.bind('click', function () { 20 | parentCtrl.sort(attrs.jhSortBy); 21 | }); 22 | } 23 | } 24 | })(); 25 | -------------------------------------------------------------------------------- /src/main/webapp/app/components/util/truncate-characters.filter.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .filter('characters', characters); 7 | 8 | function characters () { 9 | return charactersFilter; 10 | 11 | function charactersFilter(input, chars, breakOnWord) { 12 | if (isNaN(chars)) { 13 | return input; 14 | } 15 | if (chars <= 0) { 16 | return ''; 17 | } 18 | if (input && input.length > chars) { 19 | input = input.substring(0, chars); 20 | 21 | if (!breakOnWord) { 22 | var lastspace = input.lastIndexOf(' '); 23 | // Get last space 24 | if (lastspace !== -1) { 25 | input = input.substr(0, lastspace); 26 | } 27 | } else { 28 | while (input.charAt(input.length-1) === ' ') { 29 | input = input.substr(0, input.length - 1); 30 | } 31 | } 32 | return input + '...'; 33 | } 34 | return input; 35 | } 36 | } 37 | })(); 38 | -------------------------------------------------------------------------------- /src/main/webapp/app/components/util/truncate-words.filter.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .filter('words', words); 7 | 8 | function words() { 9 | return wordsFilter; 10 | 11 | function wordsFilter(input, words) { 12 | if (isNaN(words)) { 13 | return input; 14 | } 15 | if (words <= 0) { 16 | return ''; 17 | } 18 | if (input) { 19 | var inputWords = input.split(/\s+/); 20 | if (inputWords.length > words) { 21 | input = inputWords.slice(0, words).join(' ') + '...'; 22 | } 23 | } 24 | 25 | return input; 26 | } 27 | } 28 | })(); 29 | -------------------------------------------------------------------------------- /src/main/webapp/app/entities/entity.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('entity', { 12 | abstract: true, 13 | parent: 'app' 14 | }); 15 | } 16 | })(); 17 | -------------------------------------------------------------------------------- /src/main/webapp/app/home/home.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('HomeController', HomeController); 7 | 8 | HomeController.$inject = ['$scope', 'Principal', 'LoginService', '$state']; 9 | 10 | function HomeController ($scope, Principal, LoginService, $state) { 11 | var vm = this; 12 | 13 | vm.account = null; 14 | vm.isAuthenticated = null; 15 | vm.login = LoginService.open; 16 | vm.register = register; 17 | $scope.$on('authenticationSuccess', function() { 18 | getAccount(); 19 | }); 20 | 21 | getAccount(); 22 | 23 | function getAccount() { 24 | Principal.identity().then(function(account) { 25 | vm.account = account; 26 | vm.isAuthenticated = Principal.isAuthenticated; 27 | }); 28 | } 29 | function register () { 30 | $state.go('register'); 31 | } 32 | } 33 | })(); 34 | -------------------------------------------------------------------------------- /src/main/webapp/app/home/home.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 |
6 |
7 |

Welcome, Java Hipster!

8 |

This is your homepage

9 | 10 |
11 |
12 | You are logged in as user "{{vm.account.login}}". 13 |
14 | 15 |
16 | If you want to sign in, you can try the default accounts:
- Administrator (login="admin" and password="admin")
- User (login="user" and password="user"). 17 |
18 | 19 |
20 | You don't have an account yet? Register a new account 21 |
22 |
23 | 24 |

25 | If you have any question on JHipster: 26 |

27 | 28 | 35 | 36 |

37 | If you like JHipster, don't forget to give us a star on  Github! 38 |

39 |
40 |
41 |
42 | -------------------------------------------------------------------------------- /src/main/webapp/app/home/home.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider.state('home', { 12 | parent: 'app', 13 | url: '/', 14 | data: { 15 | authorities: [] 16 | }, 17 | views: { 18 | 'content@': { 19 | templateUrl: 'app/home/home.html', 20 | controller: 'HomeController', 21 | controllerAs: 'vm' 22 | } 23 | } 24 | }); 25 | } 26 | })(); 27 | -------------------------------------------------------------------------------- /src/main/webapp/app/layouts/error/accessdenied.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 |
6 |
7 |

Error Page!

8 | 9 |
You are not authorized to access the page. 10 |
11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /src/main/webapp/app/layouts/error/error.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 |
6 |
7 |

Error Page!

8 | 9 |
10 |
{{errorMessage}} 11 |
12 |
13 |
14 |
15 |
16 | -------------------------------------------------------------------------------- /src/main/webapp/app/layouts/error/error.state.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .config(stateConfig); 7 | 8 | stateConfig.$inject = ['$stateProvider']; 9 | 10 | function stateConfig($stateProvider) { 11 | $stateProvider 12 | .state('error', { 13 | parent: 'app', 14 | url: '/error', 15 | data: { 16 | authorities: [], 17 | pageTitle: 'Error page!' 18 | }, 19 | views: { 20 | 'content@': { 21 | templateUrl: 'app/layouts/error/error.html' 22 | } 23 | } 24 | }) 25 | .state('accessdenied', { 26 | parent: 'app', 27 | url: '/accessdenied', 28 | data: { 29 | authorities: [] 30 | }, 31 | views: { 32 | 'content@': { 33 | templateUrl: 'app/layouts/error/accessdenied.html' 34 | } 35 | } 36 | }); 37 | } 38 | })(); 39 | -------------------------------------------------------------------------------- /src/main/webapp/app/layouts/navbar/active-link.directive.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .directive('activeLink', activeLink); 7 | 8 | function activeLink() { 9 | var directive = { 10 | restrict: 'A', 11 | link: linkFunc 12 | }; 13 | 14 | return directive; 15 | 16 | function linkFunc(scope, element, attrs) { 17 | var clazz = attrs.activeLink; 18 | var path = attrs.href; 19 | path = path.substring(1); //hack because path does bot return including hashbang 20 | scope.location = location; 21 | scope.$watch('location.path()', function(newPath) { 22 | if (path === newPath) { 23 | element.addClass(clazz); 24 | } else { 25 | element.removeClass(clazz); 26 | } 27 | }); 28 | } 29 | } 30 | })(); 31 | -------------------------------------------------------------------------------- /src/main/webapp/app/layouts/navbar/navbar.controller.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .controller('NavbarController', NavbarController); 7 | 8 | NavbarController.$inject = ['$state', 'Auth', 'Principal', 'ProfileService', 'LoginService']; 9 | 10 | function NavbarController ($state, Auth, Principal, ProfileService, LoginService) { 11 | var vm = this; 12 | 13 | vm.isNavbarCollapsed = true; 14 | vm.isAuthenticated = Principal.isAuthenticated; 15 | 16 | ProfileService.getProfileInfo().then(function(response) { 17 | vm.inProduction = response.inProduction; 18 | vm.swaggerDisabled = response.swaggerDisabled; 19 | }); 20 | 21 | vm.login = login; 22 | vm.logout = logout; 23 | vm.toggleNavbar = toggleNavbar; 24 | vm.collapseNavbar = collapseNavbar; 25 | vm.$state = $state; 26 | 27 | function login() { 28 | collapseNavbar(); 29 | LoginService.open(); 30 | } 31 | 32 | function logout() { 33 | collapseNavbar(); 34 | Auth.logout(); 35 | $state.go('home'); 36 | } 37 | 38 | function toggleNavbar() { 39 | vm.isNavbarCollapsed = !vm.isNavbarCollapsed; 40 | } 41 | 42 | function collapseNavbar() { 43 | vm.isNavbarCollapsed = true; 44 | } 45 | } 46 | })(); 47 | -------------------------------------------------------------------------------- /src/main/webapp/app/services/auth/account.service.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('Account', Account); 7 | 8 | Account.$inject = ['$resource']; 9 | 10 | function Account ($resource) { 11 | var service = $resource('api/account', {}, { 12 | 'get': { method: 'GET', params: {}, isArray: false, 13 | interceptor: { 14 | response: function(response) { 15 | // expose response 16 | return response; 17 | } 18 | } 19 | } 20 | }); 21 | 22 | return service; 23 | } 24 | })(); 25 | -------------------------------------------------------------------------------- /src/main/webapp/app/services/auth/activate.service.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('Activate', Activate); 7 | 8 | Activate.$inject = ['$resource']; 9 | 10 | function Activate ($resource) { 11 | var service = $resource('api/activate', {}, { 12 | 'get': { method: 'GET', params: {}, isArray: false} 13 | }); 14 | 15 | return service; 16 | } 17 | })(); 18 | -------------------------------------------------------------------------------- /src/main/webapp/app/services/auth/has-any-authority.directive.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .directive('hasAnyAuthority', hasAnyAuthority); 7 | 8 | hasAnyAuthority.$inject = ['Principal']; 9 | 10 | function hasAnyAuthority(Principal) { 11 | var directive = { 12 | restrict: 'A', 13 | link: linkFunc 14 | }; 15 | 16 | return directive; 17 | 18 | function linkFunc(scope, element, attrs) { 19 | var authorities = attrs.hasAnyAuthority.replace(/\s+/g, '').split(','); 20 | 21 | var setVisible = function () { 22 | element.removeClass('hidden'); 23 | }, 24 | setHidden = function () { 25 | element.addClass('hidden'); 26 | }, 27 | defineVisibility = function (reset) { 28 | var result; 29 | if (reset) { 30 | setVisible(); 31 | } 32 | 33 | result = Principal.hasAnyAuthority(authorities); 34 | if (result) { 35 | setVisible(); 36 | } else { 37 | setHidden(); 38 | } 39 | }; 40 | 41 | if (authorities.length > 0) { 42 | defineVisibility(true); 43 | 44 | scope.$watch(function() { 45 | return Principal.isAuthenticated(); 46 | }, function() { 47 | defineVisibility(true); 48 | }); 49 | } 50 | } 51 | } 52 | })(); 53 | -------------------------------------------------------------------------------- /src/main/webapp/app/services/auth/has-authority.directive.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .directive('hasAuthority', hasAuthority); 7 | 8 | hasAuthority.$inject = ['Principal']; 9 | 10 | function hasAuthority(Principal) { 11 | var directive = { 12 | restrict: 'A', 13 | link: linkFunc 14 | }; 15 | 16 | return directive; 17 | 18 | function linkFunc(scope, element, attrs) { 19 | var authority = attrs.hasAuthority.replace(/\s+/g, ''); 20 | 21 | var setVisible = function () { 22 | element.removeClass('hidden'); 23 | }, 24 | setHidden = function () { 25 | element.addClass('hidden'); 26 | }, 27 | defineVisibility = function (reset) { 28 | 29 | if (reset) { 30 | setVisible(); 31 | } 32 | 33 | Principal.hasAuthority(authority) 34 | .then(function (result) { 35 | if (result) { 36 | setVisible(); 37 | } else { 38 | setHidden(); 39 | } 40 | }); 41 | }; 42 | 43 | if (authority.length > 0) { 44 | defineVisibility(true); 45 | 46 | scope.$watch(function() { 47 | return Principal.isAuthenticated(); 48 | }, function() { 49 | defineVisibility(true); 50 | }); 51 | } 52 | } 53 | } 54 | })(); 55 | -------------------------------------------------------------------------------- /src/main/webapp/app/services/auth/password-reset-finish.service.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('PasswordResetFinish', PasswordResetFinish); 7 | 8 | PasswordResetFinish.$inject = ['$resource']; 9 | 10 | function PasswordResetFinish($resource) { 11 | var service = $resource('api/account/reset_password/finish', {}, {}); 12 | 13 | return service; 14 | } 15 | })(); 16 | -------------------------------------------------------------------------------- /src/main/webapp/app/services/auth/password-reset-init.service.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('PasswordResetInit', PasswordResetInit); 7 | 8 | PasswordResetInit.$inject = ['$resource']; 9 | 10 | function PasswordResetInit($resource) { 11 | var service = $resource('api/account/reset_password/init', {}, {}); 12 | 13 | return service; 14 | } 15 | })(); 16 | -------------------------------------------------------------------------------- /src/main/webapp/app/services/auth/password.service.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('Password', Password); 7 | 8 | Password.$inject = ['$resource']; 9 | 10 | function Password($resource) { 11 | var service = $resource('api/account/change_password', {}, {}); 12 | 13 | return service; 14 | } 15 | })(); 16 | -------------------------------------------------------------------------------- /src/main/webapp/app/services/auth/register.service.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('Register', Register); 7 | 8 | Register.$inject = ['$resource']; 9 | 10 | function Register ($resource) { 11 | return $resource('api/register', {}, {}); 12 | } 13 | })(); 14 | -------------------------------------------------------------------------------- /src/main/webapp/app/services/profiles/page-ribbon.directive.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .directive('pageRibbon', pageRibbon); 7 | 8 | pageRibbon.$inject = ['ProfileService', '$rootScope']; 9 | 10 | function pageRibbon(ProfileService, $rootScope) { 11 | var directive = { 12 | replace : true, 13 | restrict : 'AE', 14 | template : '', 15 | link : linkFunc 16 | }; 17 | 18 | return directive; 19 | 20 | function linkFunc(scope, element, attrs) { 21 | ProfileService.getProfileInfo().then(function(response) { 22 | if (response.ribbonEnv) { 23 | scope.ribbonEnv = response.ribbonEnv; 24 | element.addClass(response.ribbonEnv); 25 | element.removeClass('hidden'); 26 | } 27 | }); 28 | } 29 | } 30 | })(); 31 | -------------------------------------------------------------------------------- /src/main/webapp/app/services/profiles/profile.service.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('ProfileService', ProfileService); 7 | 8 | ProfileService.$inject = ['$q', '$http']; 9 | 10 | function ProfileService($q, $http) { 11 | 12 | var dataPromise; 13 | 14 | var service = { 15 | getProfileInfo : getProfileInfo 16 | }; 17 | 18 | return service; 19 | 20 | function getProfileInfo() { 21 | if (angular.isUndefined(dataPromise)) { 22 | dataPromise = $http.get('api/profile-info').then(function(result) { 23 | if (result.data.activeProfiles) { 24 | var response = {}; 25 | response.activeProfiles = result.data.activeProfiles; 26 | response.ribbonEnv = result.data.ribbonEnv; 27 | response.inProduction = result.data.activeProfiles.indexOf("prod") !== -1; 28 | response.swaggerDisabled = result.data.activeProfiles.indexOf("no-swagger") !== -1; 29 | return response; 30 | } 31 | }); 32 | } 33 | return dataPromise; 34 | } 35 | } 36 | })(); 37 | -------------------------------------------------------------------------------- /src/main/webapp/app/services/user/user.service.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | 'use strict'; 3 | 4 | angular 5 | .module('ribbonCacheApp') 6 | .factory('User', User); 7 | 8 | User.$inject = ['$resource']; 9 | 10 | function User ($resource) { 11 | var service = $resource('api/users/:login', {}, { 12 | 'query': {method: 'GET', isArray: true}, 13 | 'get': { 14 | method: 'GET', 15 | transformResponse: function (data) { 16 | data = angular.fromJson(data); 17 | return data; 18 | } 19 | }, 20 | 'save': { method:'POST' }, 21 | 'update': { method:'PUT' }, 22 | 'delete':{ method:'DELETE'} 23 | }); 24 | 25 | return service; 26 | } 27 | })(); 28 | -------------------------------------------------------------------------------- /src/main/webapp/content/css/documentation.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Your CSS files will be generated in this directory by "gulp sass" 3 | */ 4 | -------------------------------------------------------------------------------- /src/main/webapp/content/images/hipster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gmarziou/gateway-ribbon-cache/bfa5a0ce172595af4d9b258f0d7abf2315da0ae2/src/main/webapp/content/images/hipster.png -------------------------------------------------------------------------------- /src/main/webapp/content/images/hipster2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gmarziou/gateway-ribbon-cache/bfa5a0ce172595af4d9b258f0d7abf2315da0ae2/src/main/webapp/content/images/hipster2x.png -------------------------------------------------------------------------------- /src/main/webapp/content/images/logo-jhipster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gmarziou/gateway-ribbon-cache/bfa5a0ce172595af4d9b258f0d7abf2315da0ae2/src/main/webapp/content/images/logo-jhipster.png -------------------------------------------------------------------------------- /src/main/webapp/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gmarziou/gateway-ribbon-cache/bfa5a0ce172595af4d9b258f0d7abf2315da0ae2/src/main/webapp/favicon.ico -------------------------------------------------------------------------------- /src/main/webapp/robots.txt: -------------------------------------------------------------------------------- 1 | # robotstxt.org/ 2 | 3 | User-agent: * 4 | Disallow: /api/account 5 | Disallow: /api/account/change_password 6 | Disallow: /api/account/sessions 7 | Disallow: /api/audits/ 8 | Disallow: /api/logs/ 9 | Disallow: /api/users/ 10 | Disallow: /management/ 11 | Disallow: /v2/api-docs/ 12 | -------------------------------------------------------------------------------- /src/main/webapp/swagger-ui/images/throbber.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gmarziou/gateway-ribbon-cache/bfa5a0ce172595af4d9b258f0d7abf2315da0ae2/src/main/webapp/swagger-ui/images/throbber.gif -------------------------------------------------------------------------------- /src/test/javascript/spec/app/components/login/login.controller.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | describe('Controller Tests', function () { 4 | 5 | beforeEach(module('ribbonCacheApp')); 6 | 7 | describe('LoginController', function () { 8 | var $scope, authService; 9 | 10 | beforeEach(inject(function ($rootScope, $controller, Auth) { 11 | $scope = $rootScope.$new(); 12 | authService = Auth; 13 | $controller('LoginController as vm', 14 | { 15 | $scope: $scope, 16 | Auth: authService, 17 | $uibModalInstance: null 18 | }); 19 | })); 20 | 21 | it('should set remember Me', function () { 22 | expect($scope.vm.rememberMe).toBeTruthy(); 23 | }); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/test/javascript/spec/app/services/auth/auth.services.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | describe('Service Tests', function () { 4 | beforeEach(mockApiAccountCall); 5 | beforeEach(mockScriptsCalls); 6 | 7 | describe('Auth', function () { 8 | var $httpBackend, localStorageService, sessionStorageService, authService, spiedAuthServerProvider; 9 | 10 | beforeEach(inject(function($injector, $localStorage, $sessionStorage, Auth, AuthServerProvider) { 11 | $httpBackend = $injector.get('$httpBackend'); 12 | localStorageService = $localStorage; 13 | sessionStorageService = $sessionStorage; 14 | authService = Auth; 15 | spiedAuthServerProvider = AuthServerProvider; 16 | })); 17 | //make sure no expectations were missed in your tests. 18 | //(e.g. expectGET or expectPOST) 19 | afterEach(function() { 20 | $httpBackend.verifyNoOutstandingExpectation(); 21 | $httpBackend.verifyNoOutstandingRequest(); 22 | }); 23 | it('should call backend on logout then call authServerProvider.logout', function(){ 24 | //GIVEN 25 | //Set spy 26 | spyOn(spiedAuthServerProvider, 'logout').and.callThrough(); 27 | 28 | //WHEN 29 | authService.logout(); 30 | //flush the backend to "execute" the request to do the expectedGET assertion. 31 | $httpBackend.flush(); 32 | 33 | //THEN 34 | expect(spiedAuthServerProvider.logout).toHaveBeenCalled(); 35 | expect(localStorageService.authenticationToken).toBe(undefined); 36 | expect(sessionStorageService.authenticationToken).toBe(undefined); 37 | }); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /src/test/javascript/spec/helpers/httpBackend.js: -------------------------------------------------------------------------------- 1 | function mockApiAccountCall() { 2 | inject(function($httpBackend) { 3 | $httpBackend.whenGET(/api\/account.*/).respond({}); 4 | }); 5 | } 6 | 7 | function mockI18nCalls() { 8 | inject(function($httpBackend) { 9 | $httpBackend.whenGET(/i18n\/.*\/.+\.json/).respond({}); 10 | }); 11 | } 12 | 13 | function mockScriptsCalls() { 14 | inject(function($httpBackend) { 15 | $httpBackend.whenGET(/app\/.*/).respond({}); 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /src/test/javascript/spec/helpers/module.js: -------------------------------------------------------------------------------- 1 | beforeEach(module('ribbonCacheApp')); 2 | /** 3 | * returns a function whose angular will be replaced 4 | * with whatever mock was supplied. 5 | */ 6 | function withMockedAngular(mockAngular, fn) { 7 | return function() { 8 | var _angular = window.angular; 9 | window.angular = mockAngular; 10 | var v = fn.apply(this, arguments); 11 | window.angular = _angular; 12 | return v; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | --------------------------------------------------------------------------------