Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New API for employees #6

Merged
merged 11 commits into from
Dec 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 95 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@
<springfox.version>2.6.1</springfox.version>
<validation-api.version>1.1.0.Final</validation-api.version>
<yarn.version>v0.24.6</yarn.version>
<kotlin.version>1.2.51</kotlin.version>
<!--
This version of jackson-module-kotlin pulls
kotlin-reflect 1.2.51 (which the version of kotlin we
specified just above.

Be careful if you upgrade to keep kotlin-reflect at
the same version as the rest of the kotlin libs
-->
<jackson.version>2.9.7</jackson.version>
</properties>


Expand Down Expand Up @@ -165,6 +175,10 @@
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-afterburner</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
Expand Down Expand Up @@ -386,23 +400,48 @@
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>spring-boot:run</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -593,7 +632,52 @@
</resources>
</configuration>
</plugin>
<!-- jhipster-needle-maven-add-plugin -->
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/main/java</source>
<source>target/generated-sources/annotations</source>
<source>target/generated-test-sources/test-annotations</source>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/test/java</source>
</sourceDirs>
</configuration>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
<pluginManagement>
<plugins>
Expand Down Expand Up @@ -868,20 +952,6 @@
-->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
Expand Down
49 changes: 22 additions & 27 deletions src/main/java/com/zenika/proxybeez/ProxybeezApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@

import com.zenika.proxybeez.config.ApplicationProperties;
import com.zenika.proxybeez.config.DefaultProfileUtil;

import io.github.jhipster.config.JHipsterConstants;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.*;
import org.springframework.boot.actuate.autoconfigure.MetricFilterAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.MetricRepositoryAutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;

import javax.annotation.PostConstruct;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
Expand All @@ -38,26 +33,6 @@ public ProxybeezApp(Environment env) {
this.env = env;
}

/**
* Initializes Proxybeez.
* <p>
* Spring profiles can be configured with a program arguments --spring.profiles.active=your-active-profile
* <p>
* You can find more information on how profiles work with JHipster on <a href="http://jhipster.github.io/profiles/">http://jhipster.github.io/profiles/</a>.
*/
@PostConstruct
public void initApplication() {
Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) {
log.error("You have misconfigured your application! It should not run " +
"with both the 'dev' and 'prod' profiles at the same time.");
}
if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_CLOUD)) {
log.error("You have misconfigured your application! It should not" +
"run with both the 'dev' and 'cloud' profiles at the same time.");
}
}

/**
* Main method, used to run the application.
*
Expand Down Expand Up @@ -85,4 +60,24 @@ public static void main(String[] args) throws UnknownHostException {
env.getProperty("server.port"),
env.getActiveProfiles());
}

/**
* Initializes Proxybeez.
* <p>
* Spring profiles can be configured with a program arguments --spring.profiles.active=your-active-profile
* <p>
* You can find more information on how profiles work with JHipster on <a href="http://jhipster.github.io/profiles/">http://jhipster.github.io/profiles/</a>.
*/
@PostConstruct
public void initApplication() {
Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) {
log.error("You have misconfigured your application! It should not run " +
"with both the 'dev' and 'prod' profiles at the same time.");
}
if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_CLOUD)) {
log.error("You have misconfigured your application! It should not" +
"run with both the 'dev' and 'cloud' profiles at the same time.");
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no change in this method, it was simply moved by automated formatting.

}
17 changes: 17 additions & 0 deletions src/main/java/com/zenika/proxybeez/ProxybeezAppKt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.zenika.proxybeez

import com.zenika.proxybeez.alibeez.v2.AlibeezProperties
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Configuration

/**
* Since Java sources are compiled before Kotlin sources,
* Java code cannot refer to Kotlin code. This means the
* AlibeezProperties configuration properties class cannot
* be referred to in ProxybeezApp. This is why ProxybeezAppKt
* exists. It's a Spring @Configuration class that can
* refer to Kotlin classes.
*/
@Configuration
@EnableConfigurationProperties(AlibeezProperties::class)
class ProxybeezAppKt
21 changes: 21 additions & 0 deletions src/main/java/com/zenika/proxybeez/alibeez/v2/AlibeezProperties.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.zenika.proxybeez.alibeez.v2

import org.springframework.boot.context.properties.ConfigurationProperties

@ConfigurationProperties(prefix = "application.alibeez", ignoreUnknownFields = true)
class AlibeezProperties {
val instances: Map<String, AlibeezInstanceProperties> = mutableMapOf()
}

class AlibeezInstanceProperties {
lateinit var baseUrl: String
lateinit var key: String
val fields: List<String> = mutableListOf()
val filters: List<String> = mutableListOf()
var defaults: AlibeezInstanceDefaults? = null
}

class AlibeezInstanceDefaults {
var location: String? = null
var division: String? = null
}
Loading