Skip to content

Commit

Permalink
Merge pull request jhipster#2 from jhipster/master
Browse files Browse the repository at this point in the history
latest from jhipster
  • Loading branch information
jcr216 committed Nov 10, 2014
2 parents 7d3903d + e5ed21a commit 7f93ba2
Show file tree
Hide file tree
Showing 45 changed files with 374 additions and 66 deletions.
5 changes: 4 additions & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ JhipsterGenerator.prototype.app = function app() {
this.template('src/main/java/package/config/_Constants.java', javaDir + 'config/Constants.java');
this.template('src/main/java/package/config/_CloudDatabaseConfiguration.java', javaDir + 'config/CloudDatabaseConfiguration.java');
if (this.databaseType == 'nosql') {
this.template('src/main/java/package/config/_CloudMongoDbConfiguration.java', javaDir + 'config/CloudMongoDbConfiguration.java');
this.template('src/main/java/package/config/_CloudMongoDbConfiguration.java', javaDir + 'config/CloudMongoDbConfiguration.java');
}
this.template('src/main/java/package/config/_DatabaseConfiguration.java', javaDir + 'config/DatabaseConfiguration.java');
this.template('src/main/java/package/config/_LocaleConfiguration.java', javaDir + 'config/LocaleConfiguration.java');
Expand Down Expand Up @@ -527,6 +527,8 @@ JhipsterGenerator.prototype.app = function app() {
this.template('src/main/java/package/domain/_PersistentToken.java', javaDir + 'domain/PersistentToken.java');
this.template('src/main/java/package/domain/_User.java', javaDir + 'domain/User.java');
this.template('src/main/java/package/domain/util/_CustomLocalDateSerializer.java', javaDir + 'domain/util/CustomLocalDateSerializer.java');
this.template('src/main/java/package/domain/util/_CustomDateTimeSerializer.java', javaDir + 'domain/util/CustomDateTimeSerializer.java');
this.template('src/main/java/package/domain/util/_CustomDateTimeDeserializer.java', javaDir + 'domain/util/CustomDateTimeDeserializer.java');

this.template('src/main/java/package/repository/_package-info.java', javaDir + 'repository/package-info.java');
this.template('src/main/java/package/repository/_AuthorityRepository.java', javaDir + 'repository/AuthorityRepository.java');
Expand Down Expand Up @@ -656,6 +658,7 @@ JhipsterGenerator.prototype.app = function app() {
this.angularAppName = _s.camelize(_s.slugify(this.baseName)) + 'App';
this.copy(webappDir + '/views/activate.html', webappDir + 'views/activate.html');
this.copy(webappDir + '/views/audits.html', webappDir + 'views/audits.html');
this.copy(webappDir + '/views/configuration.html', webappDir + 'views/configuration.html');
this.copy(webappDir + '/views/docs.html', webappDir + 'views/docs.html');
this.copy(webappDir + '/views/error.html', webappDir + 'views/error.html');
this.copy(webappDir + '/views/health.html', webappDir + 'views/health.html');
Expand Down
14 changes: 14 additions & 0 deletions app/templates/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ module.exports = function (grunt) {
https: false,
changeOrigin: false
},
{
context: '/configprops',
host: 'localhost',
port: 8080,
https: false,
changeOrigin: false
},
{
context: '/beans',
host: 'localhost',
port: 8080,
https: false,
changeOrigin: false
},
{
context: '/api-docs',
host: 'localhost',
Expand Down
2 changes: 1 addition & 1 deletion app/templates/_build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ dependencies {
compile group: 'com.hazelcast', name: 'hazelcast-spring', version: hazelcast_version<% } %><% if (clusteredHttpSession == 'hazelcast' && hibernateCache != 'hazelcast') { %>
compile group: 'com.hazelcast', name: 'hazelcast', version: hazelcast_version<% } %><% if (clusteredHttpSession == 'hazelcast') { %>
compile group: 'com.hazelcast', name: 'hazelcast-wm', version: hazelcast_version<% } %>
compile(group: 'com.zaxxer', name: 'HikariCP', version: HikariCP_version) {
compile(group: 'com.zaxxer', name: 'HikariCP<% if (javaVersion == '7') { %>-java6<% } %>', version: HikariCP_version) {
exclude(module: 'tools')
}
compile group: 'commons-lang', name: 'commons-lang', version: commons_lang_version
Expand Down
2 changes: 1 addition & 1 deletion app/templates/_gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jackson_version=2.3.3
geronimo_javamail_1_4_mail_version=1.8.4<% if (clusteredHttpSession == 'hazelcast' || hibernateCache == 'hazelcast') { %>
hazelcast_version=3.2.5<% } %>
hibernate_entitymanager_version=4.3.6.Final
HikariCP_version=1.4.0<% if (databaseType == 'sql') { %>
HikariCP_version=2.2.4<% if (databaseType == 'sql') { %>
liquibase_slf4j_version=1.2.1
liquibase_core_version=3.1.1
liquibase_hibernate_version=3.3<% } %><% if (databaseType == 'nosql') { %>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/_pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</prerequisites>

<properties>
<HikariCP.version>1.4.0</HikariCP.version>
<HikariCP.version>2.2.4</HikariCP.version>
<assertj-core.version>1.6.1</assertj-core.version><% if (websocket == 'atmosphere') { %>
<atmosphere-spring.version>2.2.0</atmosphere-spring.version><% } %>
<awaitility.version>1.4.0</awaitility.version>
Expand Down Expand Up @@ -176,7 +176,7 @@
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<artifactId>HikariCP<% if (javaVersion == '7') { %>-java6<% } %></artifactId>
<version>${HikariCP.version}</version>
<exclusions>
<exclusion>
Expand Down
21 changes: 21 additions & 0 deletions app/templates/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,27 @@ gulp.task('server', ['watch'<% if(useCompass) { %>, 'compass'<% } %>], function(
options.route = '/app';
return proxy(options);
})(),
(function() {
var url = require('url');
var proxy = require('proxy-middleware');
var options = url.parse('http://localhost:8080/health');
options.route = '/api-docs';
return proxy(options);
})(),
(function() {
var url = require('url');
var proxy = require('proxy-middleware');
var options = url.parse('http://localhost:8080/configprops');
options.route = '/api-docs';
return proxy(options);
})(),
(function() {
var url = require('url');
var proxy = require('proxy-middleware');
var options = url.parse('http://localhost:8080/beans');
options.route = '/api-docs';
return proxy(options);
})(),
(function() {
var url = require('url');
var proxy = require('proxy-middleware');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package <%=packageName%>.config;

import com.mongodb.Mongo;<% if (authenticationType == 'token') { %>
import com.mycompany.myapp.config.oauth2.OAuth2AuthenticationReadConverter;<% } %>
import <%=packageName%>.config.oauth2.OAuth2AuthenticationReadConverter;<% } %>
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class MetricsConfiguration extends MetricsConfigurerAdapter implements En
private static final String ENV_METRICS_GRAPHITE = "metrics.graphite.";
private static final String PROP_JMX_ENABLED = "jmx.enabled";
private static final String PROP_GRAPHITE_ENABLED = "enabled";
private static final String PROP_GRAPHITE_PREFIX = "";

private static final String PROP_PORT = "port";
private static final String PROP_HOST = "host";
private static final String PROP_METRIC_REG_JVM_MEMORY = "jvm.memory";
Expand Down Expand Up @@ -102,10 +104,13 @@ private void init() {
log.info("Initializing Metrics Graphite reporting");
String graphiteHost = propertyResolver.getRequiredProperty(PROP_HOST);
Integer graphitePort = propertyResolver.getRequiredProperty(PROP_PORT, Integer.class);
String graphitePrefix = propertyResolver.getProperty(PROP_GRAPHITE_PREFIX, String.class, "");

Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort));
GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.prefixedWith(graphitePrefix)
.build(graphite);
graphiteReporter.start(1, TimeUnit.MINUTES);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public void configure(HttpSecurity http) throws Exception {
.antMatchers("/dump/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/shutdown/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/beans/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/configprops/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/info/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/autoconfig/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/env/**").hasAuthority(AuthoritiesConstants.ADMIN)
Expand All @@ -91,8 +92,8 @@ protected static class AuthorizationServerConfiguration extends AuthorizationSer
private static final String PROP_SECRET = "secret";
private static final String PROP_TOKEN_VALIDITY_SECONDS = "tokenValidityInSeconds";

private RelaxedPropertyResolver propertyResolver;
<% if (databaseType == 'sql') { %>
private RelaxedPropertyResolver propertyResolver;<% if (databaseType == 'sql') { %>

@Inject
private DataSource dataSource;<% } %><% if (databaseType == 'nosql') { %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
<% if (authenticationType == 'cookie') { %>
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {<% if (authenticationType == 'cookie') { %>

@Inject
private Environment env;

Expand Down Expand Up @@ -74,8 +74,8 @@ public void configure(WebSecurity web) throws Exception {
.antMatchers("/app/rest/activate")<% if (websocket == 'atmosphere') { %>
.antMatchers("/websocket/activity")<% } %><% } %><% if (devDatabaseType != 'h2Memory') { %>;<% } else { %>
.antMatchers("/console/**");<% } %>
}
<% if (authenticationType == 'cookie') { %>
}<% if (authenticationType == 'cookie') { %>

@Override
protected void configure(HttpSecurity http) throws Exception {
http
Expand Down Expand Up @@ -119,22 +119,22 @@ protected void configure(HttpSecurity http) throws Exception {
.antMatchers("/dump/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/shutdown/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/beans/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/configprops/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/info/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/autoconfig/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/env/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/trace/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/api-docs/**").hasAuthority(AuthoritiesConstants.ADMIN)
.antMatchers("/protected/**").authenticated();

}<% } %>

<% if (authenticationType == 'token') { %>
}<% } %><% if (authenticationType == 'token') { %>

@Override
@Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}<% } %>

@EnableGlobalMethodSecurity(prePostEnabled = true, jsr250Enabled = true)
private static class GlobalSecurityConfiguration extends GlobalMethodSecurityConfiguration {<% if (authenticationType == 'token') { %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected void doHealthCheck(Health.Builder builder) throws Exception {
builder.up();

} catch (MessagingException e) {
log.debug("Cannot connect to e-mail server.", e);
log.debug("Cannot connect to e-mail server. Error: {}", e.getMessage());
builder.down(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package <%=packageName%>.domain;

<% if (databaseType == 'sql') { %>import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
<% if (databaseType == 'sql') { %>
import org.hibernate.annotations.Type;<% } %>
import org.joda.time.LocalDateTime;<% if (databaseType == 'nosql') { %>
import org.springframework.data.annotation.Id;
Expand All @@ -18,13 +16,12 @@
*/

<% if (databaseType == 'sql') { %>@Entity
@Table(name = "T_PERSISTENT_AUDIT_EVENT")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)<% } %><% if (databaseType == 'nosql') { %>
@Table(name = "T_PERSISTENT_AUDIT_EVENT")<% } %><% if (databaseType == 'nosql') { %>
@Document(collection = "T_PERSISTENT_AUDIT_EVENT")<% } %>
public class PersistentAuditEvent {

@Id<% if (databaseType == 'sql') { %>
@GeneratedValue(strategy = GenerationType.TABLE)
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "event_id")
private Long id;<% } else { %>
@Field("event_id")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package <%=packageName%>.domain.util;

import java.io.IOException;

import org.joda.time.DateTime;
import org.joda.time.format.ISODateTimeFormat;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

/**
* Custom Jackson deserializer for displaying Joda DateTime objects.
*/
public class CustomDateTimeDeserializer extends JsonDeserializer<DateTime> {

@Override
public DateTime deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
JsonToken t = jp.getCurrentToken();
if (t == JsonToken.VALUE_STRING) {
String str = jp.getText().trim();
return ISODateTimeFormat.dateTimeParser().parseDateTime(str);
}
if (t == JsonToken.VALUE_NUMBER_INT) {
return new DateTime(jp.getLongValue());
}
throw ctxt.mappingException(handledType());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package <%=packageName%>.domain.util;

import java.io.IOException;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
* Custom Jackson serializer for displaying Joda DateTime objects.
*/
public class CustomDateTimeSerializer extends JsonSerializer<DateTime> {

private static DateTimeFormatter formatter = DateTimeFormat
.forPattern("yyyy-MM-dd'T'HH:mm:ss");

@Override
public void serialize(DateTime value, JsonGenerator generator,
SerializerProvider serializerProvider)
throws IOException {
generator.writeString(formatter.print(value));
}

}
5 changes: 0 additions & 5 deletions app/templates/src/main/resources/_ehcache.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,4 @@
<cache name="<%=packageName%>.domain.User.persistentTokens"
timeToLiveSeconds="3600">
</cache>

<cache name="<%=packageName%>.domain.PersistentAuditEvent"
timeToLiveSeconds="3600">
</cache>
</ehcache>

5 changes: 4 additions & 1 deletion app/templates/src/main/resources/_logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
</appender>
-->

<logger name="javax.activation" level="WARN"/>
<logger name="<%=packageName%>" level="DEBUG"/>

<logger name="javax.activation" level="WARN"/>
<logger name="javax.xml.bind" level="WARN"/>
<logger name="ch.qos.logback" level="WARN"/>
<logger name="com.codahale.metrics" level="WARN"/>
<logger name="com.ryantenney" level="WARN"/>
<logger name="com.sun.xml.internal.bind" level="WARN"/>
<logger name="com.zaxxer" level="WARN"/><% if (hibernateCache == 'ehcache') { %>
<logger name="net.sf.ehcache" level="WARN"/><% } %>
<logger name="org.apache" level="WARN"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ metrics:
enabled: false
host: localhost
port: 2003
prefix: <%= baseName %>

<% if (clusteredHttpSession == 'hazelcast' || hibernateCache == 'hazelcast' || hibernateCache == 'ehcache') { %>cache:
timeToLiveSeconds: 3600<% } if (clusteredHttpSession == 'hazelcast' || hibernateCache == 'hazelcast') { %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ metrics:
enabled: false
host: localhost
port: 2003
prefix: <%= baseName %>

<% if (clusteredHttpSession == 'hazelcast' || hibernateCache == 'hazelcast' || hibernateCache == 'ehcache') {%>cache:
timeToLiveSeconds: 3600<% } if (clusteredHttpSession == 'hazelcast' || hibernateCache == 'hazelcast') {%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
<property name="now" value="now()" dbms="mysql,h2"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>

<changeSet id="00000000000000" author="jhipster" dbms="postgresql">
<createSequence sequenceName="hibernate_sequence" startValue="1" incrementBy="1"/>
</changeSet>

<!--
JHipster core tables.
The initial schema has the '00000000000000' id, so that it is over-written if we re-generate it.
The initial schema has the '00000000000001' id, so that it is over-written if we re-generate it.
-->
<changeSet id="00000000000000" author="jhipster">
<changeSet id="00000000000001" author="jhipster">
<createTable tableName="T_USER">
<column name="login" type="varchar(50)">
<constraints primaryKey="true" nullable="false"/>
Expand Down Expand Up @@ -112,7 +116,7 @@
tableName="T_USER_AUTHORITY"/>

<createTable tableName="T_PERSISTENT_AUDIT_EVENT">
<column name="event_id" type="bigint">
<column name="event_id" type="bigint" autoIncrement="true">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="principal" type="varchar(255)">
Expand Down
2 changes: 2 additions & 0 deletions app/templates/src/main/webapp/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
&nbsp;<span translate="global.menu.account.metrics">Metrics</span></a></li>
<li><a href="#/health"><span class="glyphicon glyphicon-heart"></span>
&#xA0;<span translate="global.menu.account.health">Health</span></a></li>
<li><a href="#/configuration"><span class="glyphicon glyphicon-list-alt"></span>
&#xA0;<span translate="global.menu.account.configuration">Configuration</span></a></li>
<li><a href="#/audits"><span class="glyphicon glyphicon-bell"></span>
&nbsp;<span translate="global.menu.account.audits">Audits</span></a></li>
<li><a href="#/logs"><span class="glyphicon glyphicon-tasks"></span>
Expand Down
Loading

0 comments on commit 7f93ba2

Please sign in to comment.