diff --git a/authenticationserivce/authenticationserivce.iml b/authenticationserivce/authenticationserivce.iml
new file mode 100644
index 0000000..e63a8e9
--- /dev/null
+++ b/authenticationserivce/authenticationserivce.iml
@@ -0,0 +1,132 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/authenticationserivce/pom.xml b/authenticationserivce/pom.xml
new file mode 100644
index 0000000..148b5bc
--- /dev/null
+++ b/authenticationserivce/pom.xml
@@ -0,0 +1,91 @@
+
+
+ 4.0.0
+
+ com
+ authenticationserivce
+ 0.0.1-SNAPSHOT
+ jar
+
+ authenticationSerivce
+ Demo project for Spring Boot
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.1.0.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ Greenwich.M3
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-oauth2
+
+
+ org.springframework.cloud
+ spring-cloud-starter-security
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ com.h2database
+ h2
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+
+
diff --git a/authenticationserivce/src/main/java/com/authenticationserivce/AuthenticationSerivceApplication.java b/authenticationserivce/src/main/java/com/authenticationserivce/AuthenticationSerivceApplication.java
new file mode 100644
index 0000000..b1dc9c9
--- /dev/null
+++ b/authenticationserivce/src/main/java/com/authenticationserivce/AuthenticationSerivceApplication.java
@@ -0,0 +1,31 @@
+package com.authenticationserivce;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.security.core.authority.AuthorityUtils;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
+import org.springframework.security.oauth2.provider.OAuth2Authentication;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@SpringBootApplication
+@EnableResourceServer
+@EnableAuthorizationServer
+@RestController
+public class AuthenticationSerivceApplication {
+ @RequestMapping(value = { "/user" }, produces = "application/json")
+ public Map user(OAuth2Authentication user) {
+ Map userInfo = new HashMap<>();
+ userInfo.put("user", user.getUserAuthentication().getPrincipal());
+ userInfo.put("authorities", AuthorityUtils.authorityListToSet(user.getUserAuthentication().getAuthorities()));
+ return userInfo;
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(AuthenticationSerivceApplication.class, args);
+ }
+}
diff --git a/authenticationserivce/src/main/java/com/authenticationserivce/security/CustomAuthorizationServerConfigurer.java b/authenticationserivce/src/main/java/com/authenticationserivce/security/CustomAuthorizationServerConfigurer.java
new file mode 100644
index 0000000..5a4b89c
--- /dev/null
+++ b/authenticationserivce/src/main/java/com/authenticationserivce/security/CustomAuthorizationServerConfigurer.java
@@ -0,0 +1,39 @@
+package com.authenticationserivce.security;
+
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
+import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
+import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
+import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
+import org.springframework.stereotype.Component;
+
+//@Component
+public class CustomAuthorizationServerConfigurer extends AuthorizationServerConfigurerAdapter {
+
+ AuthenticationManager authenticationManager;
+
+ public CustomAuthorizationServerConfigurer(
+ AuthenticationConfiguration authenticationConfiguration
+ ) throws Exception {
+ this.authenticationManager =
+ authenticationConfiguration.getAuthenticationManager();
+ }
+
+ @Override
+ public void configure(
+ ClientDetailsServiceConfigurer clients
+ ) throws Exception {
+ clients.inMemory()
+ .withClient("client")
+ .authorizedGrantTypes("password")
+ .secret("secret")
+ .scopes("all");
+ }
+
+ @Override
+ public void configure(
+ AuthorizationServerEndpointsConfigurer endpoints
+ ) throws Exception {
+ endpoints.authenticationManager(authenticationManager);
+ }
+}
diff --git a/authenticationserivce/src/main/java/com/authenticationserivce/security/OAuth2Config.java b/authenticationserivce/src/main/java/com/authenticationserivce/security/OAuth2Config.java
new file mode 100644
index 0000000..39f076e
--- /dev/null
+++ b/authenticationserivce/src/main/java/com/authenticationserivce/security/OAuth2Config.java
@@ -0,0 +1,44 @@
+package com.authenticationserivce.security;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
+import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
+import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
+import org.springframework.stereotype.Component;
+
+@Component
+public class OAuth2Config extends AuthorizationServerConfigurerAdapter {
+
+ @Autowired
+ private AuthenticationManager authenticationManager;
+
+ @Autowired
+ private UserDetailsService userDetailsService;
+
+ @Override
+ public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
+// clients.inMemory()
+// .withClient("eagleeye")
+// .secret("thisissecret")
+// .authorizedGrantTypes("refresh_token", "password", "authorization_code");
+ //.scopes("webclient", "mobileclient");
+
+ clients.inMemory()
+ .withClient("acme")
+ .secret("acmesecret")
+ .authorizedGrantTypes("authorization_code", "refresh_token",
+ "password").scopes("openid");
+
+ }
+
+
+ @Override
+ public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
+ //super.configure(endpoints);
+ endpoints.authenticationManager(authenticationManager).userDetailsService(userDetailsService);
+ //endpoints.authenticationManager(authenticationManager);
+ }
+}
diff --git a/authenticationserivce/src/main/java/com/authenticationserivce/security/WebSecurityConfigurer.java b/authenticationserivce/src/main/java/com/authenticationserivce/security/WebSecurityConfigurer.java
new file mode 100644
index 0000000..8352508
--- /dev/null
+++ b/authenticationserivce/src/main/java/com/authenticationserivce/security/WebSecurityConfigurer.java
@@ -0,0 +1,69 @@
+package com.authenticationserivce.security;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.crypto.password.NoOpPasswordEncoder;
+import org.springframework.security.crypto.password.PasswordEncoder;
+
+import javax.sql.DataSource;
+
+@Configuration
+public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
+
+
+ @Autowired
+ DataSource dataSource;
+
+ @Autowired
+ PasswordEncoder passwordEncoder;
+
+ @Override
+ @Bean
+ public AuthenticationManager authenticationManagerBean() throws Exception {
+ return super.authenticationManagerBean();
+ }
+
+ @Override
+ @Bean(name = "userDetailsService")
+ public UserDetailsService userDetailsServiceBean() throws Exception {
+ return super.userDetailsServiceBean();
+ }
+
+
+ @Override
+ public void configure(AuthenticationManagerBuilder auth) throws Exception {
+ /**
+ * @Author: Robbie
+ * @Description:
+ * @param auth
+ * @Return: void
+ * @Date: 下午1:46 18-11-26
+ */
+ //super.configure(auth);
+ //auth.jdbcAuthentication().dataSource(dataSource);
+ auth.inMemoryAuthentication()//.passwordEncoder(passwordEncoder)
+ .withUser("john.carnell").password( "password1").roles("USER")
+ .and()
+ .withUser("william.woodward").password("password2").roles("USER", "ADMIN");
+
+ //System.out.println(auth.getp());
+ }
+
+ //https://docs.spring.io/spring-security/site/docs/5.0.2.RELEASE/reference/htmlsingle/#troubleshooting
+ //Must explicitly provide the PasswordEncoder in Spring 5.X
+ @Bean
+ public static NoOpPasswordEncoder passwordEncoder() {
+ return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
+ }
+
+// @Bean
+// public PasswordEncoder passwordEncoder() {
+// return new BCryptPasswordEncoder();
+// }
+}
diff --git a/authenticationserivce/src/main/resources/application.yml b/authenticationserivce/src/main/resources/application.yml
new file mode 100644
index 0000000..a75badb
--- /dev/null
+++ b/authenticationserivce/src/main/resources/application.yml
@@ -0,0 +1,21 @@
+server:
+ port: 8091
+ context-path: /auth
+
+
+logging:
+ level:
+ org.springframework.security: TRACE
+
+#security:
+# oauth2:
+# client:
+# client-id: qiu
+# client-secret: 19811981
+# #access-token-uri: http://localhost:8091/oauth/token
+# authorization:
+# check-token-access: permitAll()
+#security:
+# user:
+# name: robbie
+# password: 19811981
diff --git a/authenticationserivce/src/main/resources/schema.sql b/authenticationserivce/src/main/resources/schema.sql
new file mode 100644
index 0000000..09819fd
--- /dev/null
+++ b/authenticationserivce/src/main/resources/schema.sql
@@ -0,0 +1,30 @@
+DROP TABLE IF EXISTS users;
+DROP TABLE IF EXISTS user_roles;
+DROP TABLE IF EXISTS user_orgs;
+
+CREATE TABLE users (
+ user_name VARCHAR(100) NOT NULL ,
+ password VARCHAR(100) NOT NULL ,
+ enabled boolean NOT NULL ,
+ PRIMARY KEY (user_name));
+
+CREATE TABLE user_roles (
+ user_role_id SERIAL,
+ user_name varchar(100) NOT NULL,
+ role varchar(100) NOT NULL,
+ PRIMARY KEY (user_role_id));
+
+CREATE TABLE user_orgs (
+ organization_id VARCHAR(100) NOT NULL,
+ user_name VARCHAR(100) NOT NULL,
+ PRIMARY KEY (user_name));
+
+INSERT INTO users(user_name,password,enabled) VALUES ('john.carnell','$2a$04$NX3QTkBJB00upxKeaKqFBeoIVc9JHvwVnj1lItxNphRj34wNx5wlu', true);
+INSERT INTO users(user_name,password,enabled) VALUES ('william.woodward','$2a$04$lM2hIsZVNYrQLi8mhvnTA.pheZtmzeivz6fyxCr9GZ6YSfP6YibCW', true);
+
+INSERT INTO user_roles (user_name, role) VALUES ('john.carnell', 'ROLE_USER');
+INSERT INTO user_roles (user_name, role) VALUES ('william.woodward', 'ROLE_ADMIN');
+INSERT INTO user_roles (user_name, role) VALUES ('william.woodward', 'ROLE_USER');
+
+INSERT INTO user_orgs (organization_id, user_name) VALUES ('d1859f1f-4bd7-4593-8654-ea6d9a6a626e', 'john.carnell');
+INSERT INTO user_orgs (organization_id, user_name) VALUES ('42d3d4f5-9f33-42f4-8aca-b7519d6af1bb', 'william.woodward');
diff --git a/authenticationserivce/src/test/java/com/authenticationserivce/AuthenticationSerivceApplicationTests.java b/authenticationserivce/src/test/java/com/authenticationserivce/AuthenticationSerivceApplicationTests.java
new file mode 100644
index 0000000..5091afe
--- /dev/null
+++ b/authenticationserivce/src/test/java/com/authenticationserivce/AuthenticationSerivceApplicationTests.java
@@ -0,0 +1,16 @@
+package com.authenticationserivce;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class AuthenticationSerivceApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/common/common.iml b/common/common.iml
new file mode 100644
index 0000000..1f8a836
--- /dev/null
+++ b/common/common.iml
@@ -0,0 +1,130 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/common/pom.xml b/common/pom.xml
new file mode 100644
index 0000000..f2047a4
--- /dev/null
+++ b/common/pom.xml
@@ -0,0 +1,27 @@
+
+
+
+ microservice
+ com
+ 0.0.1-SNAPSHOT
+
+ 4.0.0
+
+ common
+
+
+ org.springframework
+ spring-web
+ 5.1.4.RELEASE
+
+
+ org.apache.tomcat.embed
+ tomcat-embed-core
+ 9.0.12
+
+
+
+
+
\ No newline at end of file
diff --git a/common/src/main/java/utils/UserContext.java b/common/src/main/java/utils/UserContext.java
new file mode 100644
index 0000000..2193411
--- /dev/null
+++ b/common/src/main/java/utils/UserContext.java
@@ -0,0 +1,48 @@
+package utils;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserContext {
+ public static final String CORRELATION_ID = "tmx-correlation-id";
+ public static final String AUTH_TOKEN = "tmx-auth-token";
+ public static final String USER_ID = "tmx-user-id";
+ public static final String ORG_ID = "tmx-org-id";
+
+ private String correlationId;
+ private String authToken;
+ private String userId;
+ private String orgId;
+
+ public String getCorrelationId() {
+ return correlationId;
+ }
+
+ public void setCorrelationId(String correlationId) {
+ this.correlationId = correlationId;
+ }
+
+ public String getAuthToken() {
+ return authToken;
+ }
+
+ public void setAuthToken(String authToken) {
+ this.authToken = authToken;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getOrgId() {
+ return orgId;
+ }
+
+ public void setOrgId(String orgId) {
+ this.orgId = orgId;
+ }
+}
diff --git a/common/src/main/java/utils/UserContextFilter.java b/common/src/main/java/utils/UserContextFilter.java
new file mode 100644
index 0000000..84ac8df
--- /dev/null
+++ b/common/src/main/java/utils/UserContextFilter.java
@@ -0,0 +1,39 @@
+package utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
+//Saving tmx-correlation-id and other information from http header to UserContext
+@Component
+public class UserContextFilter implements Filter {
+
+ private static final Logger logger= LoggerFactory.getLogger(UserContextFilter.class);
+ @Override
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
+
+ HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
+
+ UserContextHolder.getContext().setCorrelationId(httpServletRequest.getHeader(UserContext.CORRELATION_ID));
+ UserContextHolder.getContext().setAuthToken(httpServletRequest.getHeader(UserContext.AUTH_TOKEN));
+ UserContextHolder.getContext().setUserId(httpServletRequest.getHeader(UserContext.USER_ID));
+ UserContextHolder.getContext().setOrgId(httpServletRequest.getHeader(UserContext.ORG_ID));
+
+ logger.debug("Special Routes Service Incoming Correlation id: {}", UserContextHolder.getContext().getCorrelationId());
+ filterChain.doFilter(httpServletRequest, servletResponse);
+ }
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+
+ }
+
+ @Override
+ public void destroy() {
+
+ }
+}
diff --git a/common/src/main/java/utils/UserContextHolder.java b/common/src/main/java/utils/UserContextHolder.java
new file mode 100644
index 0000000..17e0780
--- /dev/null
+++ b/common/src/main/java/utils/UserContextHolder.java
@@ -0,0 +1,21 @@
+package utils;
+
+public class UserContextHolder {
+
+ private static final ThreadLocal userContext = new ThreadLocal<>();
+
+ public static UserContext getContext() {
+ UserContext context = userContext.get();
+
+ if (context == null) {
+ context = new UserContext();
+ userContext.set(context);
+ }
+ return userContext.get();
+ }
+
+ public void setContext(UserContext context) {
+ userContext.set(context);
+ }
+
+}
diff --git a/common/src/main/java/utils/UserContextInterceptor.java b/common/src/main/java/utils/UserContextInterceptor.java
new file mode 100644
index 0000000..0823c9e
--- /dev/null
+++ b/common/src/main/java/utils/UserContextInterceptor.java
@@ -0,0 +1,25 @@
+package utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpRequest;
+import org.springframework.http.client.ClientHttpRequestExecution;
+import org.springframework.http.client.ClientHttpRequestInterceptor;
+import org.springframework.http.client.ClientHttpResponse;
+
+import java.io.IOException;
+
+public class UserContextInterceptor implements ClientHttpRequestInterceptor {
+ private final static Logger logger = LoggerFactory.getLogger(UserContextInterceptor.class);
+
+ @Override
+ public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
+
+ HttpHeaders headers = request.getHeaders();
+ logger.info("UserContextInterceptor: ", headers.toString());
+ headers.add(UserContext.CORRELATION_ID, UserContextHolder.getContext().getCorrelationId());
+ headers.add(UserContext.AUTH_TOKEN, UserContextHolder.getContext().getAuthToken());
+ return execution.execute(request, body);
+ }
+}
diff --git a/gateway/gateway.iml b/gateway/gateway.iml
new file mode 100644
index 0000000..b414827
--- /dev/null
+++ b/gateway/gateway.iml
@@ -0,0 +1,172 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/gateway/pom.xml b/gateway/pom.xml
new file mode 100644
index 0000000..1500ce3
--- /dev/null
+++ b/gateway/pom.xml
@@ -0,0 +1,116 @@
+
+
+ 4.0.0
+
+ com
+ gateway
+ 0.0.1-SNAPSHOT
+ jar
+
+ zuulGateway
+ Demo project for Spring Boot
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.1.0.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ Greenwich.M3
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-zuul
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-eureka-client
+
+
+ org.springframework.cloud
+ spring-cloud-config-client
+
+
+ com
+ common
+ 0.0.1-SNAPSHOT
+ compile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+
+
diff --git a/gateway/src/main/java/com/gateway/ZuulsrvApplication.java b/gateway/src/main/java/com/gateway/ZuulsrvApplication.java
new file mode 100644
index 0000000..7df707a
--- /dev/null
+++ b/gateway/src/main/java/com/gateway/ZuulsrvApplication.java
@@ -0,0 +1,39 @@
+package com.gateway;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
+import org.springframework.context.annotation.Bean;
+import org.springframework.web.client.RestTemplate;
+import utils.UserContextInterceptor;
+
+import java.util.Collections;
+import java.util.List;
+
+@SpringBootApplication
+@EnableZuulProxy
+public class ZuulsrvApplication {
+
+ @LoadBalanced
+ @Bean
+ public RestTemplate getRestTemplate() {
+
+ RestTemplate restTemplate = new RestTemplate();
+ List interceptors = restTemplate.getInterceptors();
+
+ if (interceptors == null){
+ restTemplate.setInterceptors(Collections.singletonList(new UserContextInterceptor()));
+ } else {
+ interceptors.add(new UserContextInterceptor());
+ restTemplate.setInterceptors(interceptors);
+ }
+
+ return restTemplate;
+ }
+
+ public static void main(String[] args) {
+
+ SpringApplication.run(ZuulsrvApplication.class, args);
+ }
+}
diff --git a/gateway/src/main/java/com/gateway/filters/FilterUtils.java b/gateway/src/main/java/com/gateway/filters/FilterUtils.java
new file mode 100644
index 0000000..4d61822
--- /dev/null
+++ b/gateway/src/main/java/com/gateway/filters/FilterUtils.java
@@ -0,0 +1,30 @@
+package com.gateway.filters;
+
+import com.netflix.zuul.context.RequestContext;
+import org.springframework.stereotype.Component;
+
+@Component
+public class FilterUtils {
+
+ public static final String CORRELATION_ID = "tmx-correlation-id";
+ public static final String AUTH_TOKEN = "tmx-auth-token";
+ public static final String USER_ID = "tmx-user-id";
+ public static final String ORG_ID = "tmx-org-id";
+ public static final String PRE_FILTER_TYPE = "pre";
+ public static final String POST_FILTER_TYPE = "post";
+ public static final String ROUTE_FILTER_TYPE = "route";
+
+ public String getCorrelationId() {
+ RequestContext requestContext = RequestContext.getCurrentContext();
+ if (requestContext.getRequest().getHeader(CORRELATION_ID) != null){
+ return requestContext.getRequest().getHeader(CORRELATION_ID);
+ } else {
+ return requestContext.getZuulRequestHeaders().get(CORRELATION_ID);
+ }
+ }
+
+ public void setCorrelationId(String correlationId) {
+ RequestContext requestContext = RequestContext.getCurrentContext();
+ requestContext.addZuulRequestHeader(CORRELATION_ID, correlationId);
+ }
+}
diff --git a/gateway/src/main/java/com/gateway/filters/ResponseFilter.java b/gateway/src/main/java/com/gateway/filters/ResponseFilter.java
new file mode 100644
index 0000000..dc9054a
--- /dev/null
+++ b/gateway/src/main/java/com/gateway/filters/ResponseFilter.java
@@ -0,0 +1,46 @@
+package com.gateway.filters;
+
+import com.gateway.filters.FilterUtils;
+import com.netflix.zuul.ZuulFilter;
+import com.netflix.zuul.context.RequestContext;
+import com.netflix.zuul.exception.ZuulException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ResponseFilter extends ZuulFilter {
+
+ private static final Logger logger = LoggerFactory.getLogger(ResponseFilter.class);
+
+ @Autowired
+ FilterUtils filterUtils;
+ @Override
+ public String filterType() {
+ return FilterUtils.POST_FILTER_TYPE;
+ }
+
+ @Override
+ public int filterOrder() {
+ return 1;
+ }
+
+ @Override
+ public boolean shouldFilter() {
+ return true;
+ }
+
+ @Override
+ public Object run() throws ZuulException {
+
+ RequestContext ctx = RequestContext.getCurrentContext();
+
+ logger.info("Adding the correlation id to the outbound headers. {}", filterUtils.getCorrelationId());
+ ctx.getResponse().addHeader(FilterUtils.CORRELATION_ID, filterUtils.getCorrelationId());
+
+ logger.info("Completing outgoing request for {}.", ctx.getRequest().getRequestURI());
+
+ return null;
+ }
+}
diff --git a/gateway/src/main/java/com/gateway/filters/SpecialRoutesFilter.java b/gateway/src/main/java/com/gateway/filters/SpecialRoutesFilter.java
new file mode 100644
index 0000000..045cb12
--- /dev/null
+++ b/gateway/src/main/java/com/gateway/filters/SpecialRoutesFilter.java
@@ -0,0 +1,36 @@
+package com.gateway.filters;
+
+import com.netflix.zuul.ZuulFilter;
+import com.netflix.zuul.exception.ZuulException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SpecialRoutesFilter extends ZuulFilter {
+
+ private static final int FILTER_ORDER = 1;
+ private static final boolean SHOULD_FILTER = true;
+
+ @Autowired
+ FilterUtils filterUtils;
+
+ @Override
+ public String filterType() {
+ return filterUtils.ROUTE_FILTER_TYPE;
+ }
+
+ @Override
+ public int filterOrder() {
+ return FILTER_ORDER;
+ }
+
+ @Override
+ public boolean shouldFilter() {
+ return SHOULD_FILTER;
+ }
+
+ @Override
+ public Object run() throws ZuulException {
+ return null;
+ }
+}
diff --git a/gateway/src/main/java/com/gateway/filters/TrackingFilter.java b/gateway/src/main/java/com/gateway/filters/TrackingFilter.java
new file mode 100644
index 0000000..f64404b
--- /dev/null
+++ b/gateway/src/main/java/com/gateway/filters/TrackingFilter.java
@@ -0,0 +1,61 @@
+package com.gateway.filters;
+
+import com.netflix.zuul.ZuulFilter;
+import com.netflix.zuul.context.RequestContext;
+import com.netflix.zuul.exception.ZuulException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class TrackingFilter extends ZuulFilter {
+
+ private static final int FILTER_ORDER = 1;
+
+ @Autowired
+ private FilterUtils filterUtil;
+
+ private static final Logger logger = LoggerFactory.getLogger(TrackingFilter.class);
+
+ @Override
+ public String filterType() {
+ return FilterUtils.PRE_FILTER_TYPE;
+ }
+
+ @Override
+ public int filterOrder() {
+ return FILTER_ORDER;
+ }
+
+ @Override
+ public boolean shouldFilter() {
+ return true;
+ }
+
+ private boolean isCorrelationIdPresent() {
+ if (filterUtil.getCorrelationId() != null){
+ return true;
+ }
+
+ return false;
+ }
+
+ private String generateCorrelationId(){
+ return java.util.UUID.randomUUID().toString();
+ }
+
+ @Override
+ public Object run() throws ZuulException {
+ if (isCorrelationIdPresent()) {
+ logger.info("tmx-correlation-id found in tracking filter: {}.", filterUtil.getCorrelationId());
+ } else {
+ filterUtil.setCorrelationId(generateCorrelationId());
+ logger.info("tmx-correlation-id generated in tracking filter: {}.", filterUtil.getCorrelationId());
+ }
+
+ RequestContext ctx = RequestContext.getCurrentContext();
+ logger.info("Processing incoming request for: {}.", ctx.getRequest().getRequestURI());
+ return null;
+ }
+}
diff --git a/gateway/src/main/java/com/gateway/models/AbTestingRoute.java b/gateway/src/main/java/com/gateway/models/AbTestingRoute.java
new file mode 100644
index 0000000..856ade8
--- /dev/null
+++ b/gateway/src/main/java/com/gateway/models/AbTestingRoute.java
@@ -0,0 +1,41 @@
+package com.gateway.models;
+
+public class AbTestingRoute {
+ private String serviceName;
+ private String active;
+ private String endpoint;
+ private Integer weight;
+
+ public String getActive() {
+ return active;
+ }
+
+ public void setActive(String active) {
+ this.active = active;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getEndpoint() {
+ return endpoint;
+ }
+
+ public void setEndpoint(String endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public Integer getWeight() {
+ return weight;
+ }
+
+ public void setWeight(Integer weight) {
+ this.weight = weight;
+ }
+
+}
diff --git a/gateway/src/main/resources/application.yml b/gateway/src/main/resources/application.yml
new file mode 100644
index 0000000..0297121
--- /dev/null
+++ b/gateway/src/main/resources/application.yml
@@ -0,0 +1,43 @@
+server:
+ port: 5559
+
+
+eureka:
+ instance:
+ prefer-ip-address: true
+
+ client:
+ fetch-registry: true
+ register-with-eureka: true
+ service-url:
+ defaultZone: http://140.143.45.252:8761/eureka/
+
+logging:
+ level:
+ org.springframework.cloud.config: DEBUG
+
+#eureka:
+# instance:
+# prefer-ip-address: true
+# client:
+# fetch-registry: true
+# register-with-eureka: true
+# service-url:
+# defaultZone: http://140.143.45.252:8761/eureka/
+
+ #eureka.client.fetch-registry=true
+#eureka.client.register-with-eureka=true
+#eureka.client.service-url.defaultZone = http://192.168.21.120:8761/eureka/
+
+#zuul.routes.organizationservice = /organization/**
+#management.endpoints.web.exposure.include=*
+management:
+ endpoints:
+ web:
+ exposure:
+ include: "*"
+
+#security:
+# oauth2:
+# resource:
+# user-info-uri: http://192.168.21.120:8091/user
diff --git a/gateway/src/main/resources/bootstrap.yaml b/gateway/src/main/resources/bootstrap.yaml
new file mode 100644
index 0000000..b1bc01b
--- /dev/null
+++ b/gateway/src/main/resources/bootstrap.yaml
@@ -0,0 +1,10 @@
+spring:
+ application:
+ name: zuulservice
+ profiles:
+ active:
+ default
+ cloud:
+ config:
+ enabled: true
+ uri: http://140.143.45.252:8888
\ No newline at end of file
diff --git a/gateway/src/test/java/com/zuulsrv/ZuulsrvApplicationTests.java b/gateway/src/test/java/com/zuulsrv/ZuulsrvApplicationTests.java
new file mode 100644
index 0000000..e0b4258
--- /dev/null
+++ b/gateway/src/test/java/com/zuulsrv/ZuulsrvApplicationTests.java
@@ -0,0 +1,16 @@
+package com.zuulsrv;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class ZuulsrvApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/licensingserivce/README.md b/licensingserivce/README.md
new file mode 100644
index 0000000..1a13293
--- /dev/null
+++ b/licensingserivce/README.md
@@ -0,0 +1,2 @@
+# licenseservice
+spring boot project
diff --git a/licensingserivce/licenseservice.iml b/licensingserivce/licenseservice.iml
new file mode 100644
index 0000000..0c0d057
--- /dev/null
+++ b/licensingserivce/licenseservice.iml
@@ -0,0 +1,232 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/licensingserivce/pom.xml b/licensingserivce/pom.xml
new file mode 100644
index 0000000..9f6eb7d
--- /dev/null
+++ b/licensingserivce/pom.xml
@@ -0,0 +1,204 @@
+
+
+ 4.0.0
+
+ com
+ licenseservice
+ 0.0.1-SNAPSHOT
+ jar
+
+ licenseService
+ Demo project for Spring Boot
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.1.0.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ Greenwich.M3
+ johncarnell/tmx-licensing-service
+ chapter3
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-rest
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 1.3.2
+
+
+
+
+
+
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-eureka-client
+
+
+
+ mysql
+ mysql-connector-java
+ runtime
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.cloud
+ spring-cloud-starter-feign
+ 1.4.6.RELEASE
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-sleuth
+
+
+ org.springframework.cloud
+ spring-cloud-sleuth-zipkin
+
+
+ org.springframework.cloud
+ spring-cloud-config-client
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-stream
+
+
+ org.springframework.cloud
+ spring-cloud-starter-stream-kafka
+
+
+
+
+ org.springframework.data
+ spring-data-redis
+ 2.1.2.RELEASE
+
+
+ redis.clients
+ jedis
+
+
+ org.apache.commons
+ commons-pool2
+
+
+ org.springframework.boot
+ spring-boot
+ 2.1.2.RELEASE
+
+
+
+ com
+ common
+ 0.0.1-SNAPSHOT
+ compile
+
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ maven-resources-plugin
+
+
+ copy-resources
+
+ validate
+
+ copy-resources
+
+
+ ${basedir}/target/dockerfile
+
+
+ src/main/docker
+ true
+
+
+
+
+
+
+
+ com.spotify
+ docker-maven-plugin
+ 0.4.10
+
+ ${docker.image.name}:${docker.image.tag}
+ ${basedir}/target/dockerfile
+
+
+ /
+ ${project.build.directory}
+ ${project.build.finalName}.jar
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+
+
diff --git a/licensingserivce/src/main/docker/Dockerfile b/licensingserivce/src/main/docker/Dockerfile
new file mode 100644
index 0000000..b2e28db
--- /dev/null
+++ b/licensingserivce/src/main/docker/Dockerfile
@@ -0,0 +1,7 @@
+FROM openjdk:8-jdk-alpine
+RUN apk update && apk upgrade && apk add netcat-openbsd
+RUN mkdir -p /usr/local/licensingservice
+ADD @project.build.finalName@.jar /usr/local/licensingservice/
+ADD run.sh run.sh
+RUN chmod +x run.sh
+CMD ./run.sh
\ No newline at end of file
diff --git a/licensingserivce/src/main/docker/run.sh b/licensingserivce/src/main/docker/run.sh
new file mode 100644
index 0000000..e129e08
--- /dev/null
+++ b/licensingserivce/src/main/docker/run.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+echo "********************************************************"
+echo "Waiting for the configuration server to start on port $CONFIGSERVER_PORT"
+echo "********************************************************"
+while ! `nc -z configserver $CONFIGSERVER_PORT `; do sleep 3; done
+echo ">>>>>>>>>>>> Configuration Server has started"
+
+echo "********************************************************"
+echo "Waiting for the database server to start on port $DATABASESERVER_PORT"
+echo "********************************************************"
+while ! `nc -z database $DATABASESERVER_PORT`; do sleep 3; done
+echo ">>>>>>>>>>>> Database Server has started"
+
+echo "********************************************************"
+echo "Starting License Server with Configuration Service : $CONFIGSERVER_URI";
+echo "********************************************************"
+java -Dspring.cloud.config.uri=$CONFIGSERVER_URI -Dspring.profiles.active=$PROFILE -jar /usr/local/licensingservice/@project.build.finalName@.jar
diff --git a/licensingserivce/src/main/java/com/licenseservice/Client/OrganizationDiscoveryClient.java b/licensingserivce/src/main/java/com/licenseservice/Client/OrganizationDiscoveryClient.java
new file mode 100644
index 0000000..bcda910
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/Client/OrganizationDiscoveryClient.java
@@ -0,0 +1,34 @@
+package com.licenseservice.Client;
+
+import com.licenseservice.model.Organization;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cloud.client.ServiceInstance;
+import org.springframework.cloud.client.discovery.DiscoveryClient;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.List;
+
+@Component
+public class OrganizationDiscoveryClient {
+ @Autowired
+ private DiscoveryClient discoveryClient = null;
+
+ public Organization getOrganization(Long organizationId) {
+ List serviceInstances = discoveryClient.getInstances("organizationservice");
+
+ if (serviceInstances.size() ==0) return null;
+
+ String serviceUrl = String.format("%s/v1/organizations/%d",
+ serviceInstances.get(0).getUri().toString(), organizationId);
+
+ RestTemplate restTemplate = new RestTemplate();
+
+ ResponseEntity restExchange = restTemplate.exchange(serviceUrl, HttpMethod.GET, null,
+ Organization.class, organizationId);
+
+ return restExchange.getBody();
+ }
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/Client/OrganizationFeignClient.java b/licensingserivce/src/main/java/com/licenseservice/Client/OrganizationFeignClient.java
new file mode 100644
index 0000000..e241309
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/Client/OrganizationFeignClient.java
@@ -0,0 +1,14 @@
+package com.licenseservice.Client;
+
+import com.licenseservice.model.Organization;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@FeignClient("organizationservice")
+public interface OrganizationFeignClient {
+
+ @RequestMapping(method = RequestMethod.GET, value = "/v1/organizations/{organizationId}", consumes = "application/json")
+ public Organization getOrganization(@PathVariable("organizationId") Long organizationId);
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/Client/OrganizationRestTemplateClient.java b/licensingserivce/src/main/java/com/licenseservice/Client/OrganizationRestTemplateClient.java
new file mode 100644
index 0000000..4c38fef
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/Client/OrganizationRestTemplateClient.java
@@ -0,0 +1,61 @@
+package com.licenseservice.Client;
+
+import com.licenseservice.model.Organization;
+import com.licenseservice.repository.OrganizationRedisRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+@Component
+public class OrganizationRestTemplateClient {
+
+ private final static Logger logger = LoggerFactory.getLogger(OrganizationRestTemplateClient.class);
+
+ @Autowired
+ private RestTemplate restTemplate = null;
+
+ @Autowired
+ OrganizationRedisRepository redisRepository;
+
+ private Organization checkRedisCache(Long orgId){
+ try {
+ return redisRepository.findOrganization(orgId);
+ } catch (Exception ex) {
+ logger.error("error occurs when retrieve redis cache");
+ return null;
+ }
+ }
+
+ private void cacheOrgObject(Organization organization){
+ try {
+ redisRepository.saveOrganization(organization);
+ } catch (Exception ex){
+ logger.error("error occurs when saving redis cache");
+ }
+ }
+
+
+ public Organization getOrganization(Long organizationId) {
+
+ Organization organization = checkRedisCache(organizationId);
+ if (organization != null){
+ logger.info("retrieve data from redis cache successfully");
+ return organization;
+ }
+
+ ResponseEntity responseEntity = restTemplate.exchange(
+ "http://organizationservice//v1/organizations/{organizationId}",
+ HttpMethod.GET, null, Organization.class, organizationId);
+
+ organization = responseEntity.getBody();
+ if (organization != null){
+ cacheOrgObject(responseEntity.getBody());
+ }
+
+ return organization;
+ }
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/Config/ClientConfig.java b/licensingserivce/src/main/java/com/licenseservice/Config/ClientConfig.java
new file mode 100644
index 0000000..3f5dc10
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/Config/ClientConfig.java
@@ -0,0 +1,36 @@
+package com.licenseservice.Config;
+
+import com.licenseservice.utils.UserContextInterceptor;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.Collections;
+import java.util.List;
+
+@Configuration
+public class ClientConfig {
+
+ @Bean
+ @LoadBalanced
+ public RestTemplate getRestTemplate(){
+
+ RestTemplate restTemplate = new RestTemplate();
+ List interceptors = restTemplate.getInterceptors();
+
+ if (interceptors == null){
+ restTemplate.setInterceptors(Collections.singletonList(new UserContextInterceptor()));
+ } else {
+ interceptors.add(new UserContextInterceptor());
+ restTemplate.setInterceptors(interceptors);
+ }
+
+ return restTemplate;
+ }
+
+// @Bean
+// CurrentTraceContext log4jTraceContext() {
+// return MDCCurrentTraceContext.create();
+// }
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/Config/MyBatisConfig.java b/licensingserivce/src/main/java/com/licenseservice/Config/MyBatisConfig.java
new file mode 100644
index 0000000..03c92bc
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/Config/MyBatisConfig.java
@@ -0,0 +1,9 @@
+package com.licenseservice.Config;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@MapperScan(basePackages = "com.licenseservice.Mapper")
+public class MyBatisConfig {
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/Config/ServiceConfig.java b/licensingserivce/src/main/java/com/licenseservice/Config/ServiceConfig.java
new file mode 100644
index 0000000..ca81ec3
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/Config/ServiceConfig.java
@@ -0,0 +1,43 @@
+package com.licenseservice.Config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ServiceConfig {
+
+ @Value("${example.property}")
+ private String exampleProperty;
+
+ public String getExampleProperty() {
+ return exampleProperty;
+ }
+
+ @Value("${redis.server}")
+ private String redisServer="";
+
+ @Value("${redis.port}")
+ private String redisPort="";
+
+ public void setExampleProperty(String exampleProperty) {
+ this.exampleProperty = exampleProperty;
+ }
+
+ public String getRedisServer() {
+ return redisServer;
+ }
+
+ public void setRedisServer(String redisServer) {
+ this.redisServer = redisServer;
+ }
+
+ public Integer getRedisPort() {
+ return new Integer(redisPort).intValue();
+ }
+
+ public void setRedisPort(String redisPort) {
+ this.redisPort = redisPort;
+ }
+
+
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/Controller/LicenseController.java b/licensingserivce/src/main/java/com/licenseservice/Controller/LicenseController.java
new file mode 100644
index 0000000..f0910fa
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/Controller/LicenseController.java
@@ -0,0 +1,30 @@
+package com.licenseservice.Controller;
+
+import com.licenseservice.model.License;
+import com.licenseservice.service.LicenseService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping(value="v1/organizations/{organizationId}/licenses")
+public class LicenseController {
+ private static final Logger logger = LoggerFactory.getLogger(LicenseController.class);
+
+ @Autowired
+ private LicenseService licenseService = null;
+
+ @GetMapping("/{licenseId}/{clientType}")
+ public License getLicense(@PathVariable("organizationId") Long organizationId,
+ @PathVariable("licenseId") Long licenseId,
+ @PathVariable("clientType") String clientType) {
+
+ logger.info("Entering the license-service-controller ");
+ return licenseService.getLicense(organizationId, licenseId, clientType);
+ }
+
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/LicenseserviceApplication.java b/licensingserivce/src/main/java/com/licenseservice/LicenseserviceApplication.java
new file mode 100644
index 0000000..b3916a0
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/LicenseserviceApplication.java
@@ -0,0 +1,16 @@
+package com.licenseservice;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+@SpringBootApplication
+@EnableDiscoveryClient
+@EnableFeignClients()
+public class LicenseserviceApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(LicenseserviceApplication.class, args);
+ }
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/Mapper/LicenseMapper.java b/licensingserivce/src/main/java/com/licenseservice/Mapper/LicenseMapper.java
new file mode 100644
index 0000000..4731715
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/Mapper/LicenseMapper.java
@@ -0,0 +1,9 @@
+package com.licenseservice.Mapper;
+
+import com.licenseservice.model.License;
+import org.apache.ibatis.annotations.Param;
+
+public interface LicenseMapper {
+ public License getLicense(@Param("organizationid") Long organizationId, @Param("licenseid") Long licenseId);
+ public void saveLicense(License license);
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/cache/RedisCache.java b/licensingserivce/src/main/java/com/licenseservice/cache/RedisCache.java
new file mode 100644
index 0000000..efb669c
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/cache/RedisCache.java
@@ -0,0 +1,31 @@
+package com.licenseservice.cache;
+
+import com.licenseservice.Config.ServiceConfig;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+
+@Component
+public class RedisCache {
+
+ @Autowired
+ ServiceConfig serviceConfig;
+
+ @Bean
+ public JedisConnectionFactory jedisConnectionFactory(){
+ JedisConnectionFactory factory = new JedisConnectionFactory();
+ factory.setHostName(serviceConfig.getRedisServer());
+ factory.setPort(serviceConfig.getRedisPort());
+ return factory;
+ }
+
+ @Bean
+ public RedisTemplate getRedisTemplate(){
+ RedisTemplate redisTemplate = new RedisTemplate();
+ redisTemplate.setConnectionFactory(jedisConnectionFactory());
+ return redisTemplate;
+ }
+
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/events/CustomChannels.java b/licensingserivce/src/main/java/com/licenseservice/events/CustomChannels.java
new file mode 100644
index 0000000..eee79ae
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/events/CustomChannels.java
@@ -0,0 +1,9 @@
+package com.licenseservice.events;
+
+import org.springframework.cloud.stream.annotation.Input;
+import org.springframework.messaging.SubscribableChannel;
+
+public interface CustomChannels {
+ @Input("inboundOrgChanges")
+ SubscribableChannel org();
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/events/OrgChangeModel.java b/licensingserivce/src/main/java/com/licenseservice/events/OrgChangeModel.java
new file mode 100644
index 0000000..59ccb32
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/events/OrgChangeModel.java
@@ -0,0 +1,51 @@
+package com.licenseservice.events;
+
+public class OrgChangeModel {
+ private String typeName;
+ private String action;
+ private Long orgId;
+ private String correlationId;
+
+ public OrgChangeModel(String typeName, String action, Long orgId, String correlationId) {
+ this.typeName = typeName;
+ this.action = action;
+ this.orgId = orgId;
+ this.correlationId = correlationId;
+ }
+
+ public OrgChangeModel(){
+
+ }
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public Long getOrgId() {
+ return orgId;
+ }
+
+ public void setOrgId(Long orgId) {
+ this.orgId = orgId;
+ }
+
+ public String getCorrelationId() {
+ return correlationId;
+ }
+
+ public void setCorrelationId(String correlationId) {
+ this.correlationId = correlationId;
+ }
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/events/OrganizationChangeHandler.java b/licensingserivce/src/main/java/com/licenseservice/events/OrganizationChangeHandler.java
new file mode 100644
index 0000000..3660806
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/events/OrganizationChangeHandler.java
@@ -0,0 +1,44 @@
+package com.licenseservice.events;
+
+import com.licenseservice.repository.OrganizationRedisRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cloud.stream.annotation.EnableBinding;
+import org.springframework.cloud.stream.annotation.StreamListener;
+
+@EnableBinding(CustomChannels.class)
+public class OrganizationChangeHandler {
+
+ private final static Logger logger = LoggerFactory.getLogger(OrganizationChangeHandler.class);
+
+ @Autowired
+ OrganizationRedisRepository redisRepository;
+
+ @StreamListener("inboundOrgChanges")
+ public void loggerSink(OrgChangeModel orgChange) {
+ logger.info("----Received a message of type " + orgChange.getTypeName());
+
+ switch (orgChange.getTypeName()){
+ case "get":
+ logger.debug("Received a GET event from the organization service for organization id {}", orgChange.getOrgId());
+ break;
+ case "save":
+ logger.debug("Received a SAVE event from the organization service for organization id {}", orgChange.getOrgId());
+ //redisRepository.saveOrganization(orgChange);
+ case "update":
+ logger.debug("Received a UPDATE event from the organization service for organization id {}", orgChange.getOrgId());
+ redisRepository.deleteOrganization(orgChange.getOrgId());
+ break;
+ case "delete":
+ logger.debug("Received a DELETE event from the organization service for organization id {}", orgChange.getOrgId());
+ redisRepository.deleteOrganization(orgChange.getOrgId());
+ break;
+ default:
+ logger.error("Received an UNKNOWN event from the organization service of type {}", orgChange.getTypeName());
+ break;
+
+ }
+ }
+
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/model/License.java b/licensingserivce/src/main/java/com/licenseservice/model/License.java
new file mode 100644
index 0000000..37e3bb7
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/model/License.java
@@ -0,0 +1,130 @@
+package com.licenseservice.model;
+
+import org.apache.ibatis.type.Alias;
+import org.springframework.data.annotation.Transient;
+
+@Alias("license")
+public class License {
+
+ private Long licenseId;
+
+
+ private Long organizationId;
+
+ @Transient
+ private String organizationName ="";
+
+ @Transient
+ private String contactName ="";
+
+ @Transient
+ private String contactPhone ="";
+
+ @Transient
+ private String contactEmail ="";
+
+
+ private String productName;
+
+
+ private String licenseType;
+
+
+ private Integer licenseMax;
+
+
+ private Integer licenseAllocated;
+
+
+ private String comment;
+
+ public Long getLicenseId() {
+ return licenseId;
+ }
+
+ public void setLicenseId(Long licenseId) {
+ this.licenseId = licenseId;
+ }
+
+ public Long getOrganizationId() {
+ return organizationId;
+ }
+
+ public void setOrganizationId(Long organizationId) {
+ this.organizationId = organizationId;
+ }
+
+ public String getOrganizationName() {
+ return organizationName;
+ }
+
+ public void setOrganizationName(String organizationName) {
+ this.organizationName = organizationName;
+ }
+
+ public String getContactName() {
+ return contactName;
+ }
+
+ public void setContactName(String contactName) {
+ this.contactName = contactName;
+ }
+
+ public String getContactPhone() {
+ return contactPhone;
+ }
+
+ public void setContactPhone(String contactPhone) {
+ this.contactPhone = contactPhone;
+ }
+
+ public String getContactEmail() {
+ return contactEmail;
+ }
+
+ public void setContactEmail(String contactEmail) {
+ this.contactEmail = contactEmail;
+ }
+
+ public String getProductName() {
+ return productName;
+ }
+
+ public void setProductName(String productName) {
+ this.productName = productName;
+ }
+
+ public String getLicenseType() {
+ return licenseType;
+ }
+
+ public void setLicenseType(String licenseType) {
+ this.licenseType = licenseType;
+ }
+
+ public Integer getLicenseMax() {
+ return licenseMax;
+ }
+
+ public void setLicenseMax(Integer licenseMax) {
+ this.licenseMax = licenseMax;
+ }
+
+ public Integer getLicenseAllocated() {
+ return licenseAllocated;
+ }
+
+ public void setLicenseAllocated(Integer licenseAllocated) {
+ this.licenseAllocated = licenseAllocated;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/model/Organization.java b/licensingserivce/src/main/java/com/licenseservice/model/Organization.java
new file mode 100644
index 0000000..3e21324
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/model/Organization.java
@@ -0,0 +1,54 @@
+package com.licenseservice.model;
+
+public class Organization {
+ private Long id;
+
+ private String name;
+
+ private String contactName;
+
+ private String contactEmail;
+
+ private String contactPhone;
+
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getContactName() {
+ return contactName;
+ }
+
+ public void setContactName(String contactName) {
+ this.contactName = contactName;
+ }
+
+ public String getContactEmail() {
+ return contactEmail;
+ }
+
+ public void setContactEmail(String contactEmail) {
+ this.contactEmail = contactEmail;
+ }
+
+ public String getContactPhone() {
+ return contactPhone;
+ }
+
+ public void setContactPhone(String contactPhone) {
+ this.contactPhone = contactPhone;
+ }
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/repository/OrganizationRedisRepository.java b/licensingserivce/src/main/java/com/licenseservice/repository/OrganizationRedisRepository.java
new file mode 100644
index 0000000..1d0fd82
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/repository/OrganizationRedisRepository.java
@@ -0,0 +1,10 @@
+package com.licenseservice.repository;
+
+import com.licenseservice.model.Organization;
+
+public interface OrganizationRedisRepository {
+ void saveOrganization(Organization org);
+ void updateOrganization(Organization org);
+ void deleteOrganization(Long organizationId);
+ Organization findOrganization(Long organizationId);
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/repository/OrganizationRedisRepositoryImpl.java b/licensingserivce/src/main/java/com/licenseservice/repository/OrganizationRedisRepositoryImpl.java
new file mode 100644
index 0000000..c99cead
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/repository/OrganizationRedisRepositoryImpl.java
@@ -0,0 +1,48 @@
+package com.licenseservice.repository;
+
+import com.licenseservice.model.Organization;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.HashOperations;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Repository;
+
+import javax.annotation.PostConstruct;
+
+@Repository
+public class OrganizationRedisRepositoryImpl implements OrganizationRedisRepository {
+
+ private final static String HASH_NAME = "organization";
+
+ private RedisTemplate redisTemplate;
+ private HashOperations hashOperations;
+
+ @Autowired
+ public OrganizationRedisRepositoryImpl(RedisTemplate redisTemplate) {
+ this.redisTemplate = redisTemplate;
+ }
+
+ @PostConstruct
+ public void init() {
+ hashOperations = redisTemplate.opsForHash();
+ }
+
+ @Override
+ public void saveOrganization(Organization org) {
+ hashOperations.put(HASH_NAME, org.getId(), org);
+ }
+
+ @Override
+ public void updateOrganization(Organization org) {
+ hashOperations.put(HASH_NAME, org.getId(), org);
+ }
+
+ @Override
+ public void deleteOrganization(Long organizationId) {
+ hashOperations.delete(organizationId);
+ }
+
+ @Override
+ public Organization findOrganization(Long organizationId) {
+ return (Organization) hashOperations.get(HASH_NAME, organizationId);
+ }
+}
diff --git a/licensingserivce/src/main/java/com/licenseservice/service/LicenseService.java b/licensingserivce/src/main/java/com/licenseservice/service/LicenseService.java
new file mode 100644
index 0000000..cbf65ed
--- /dev/null
+++ b/licensingserivce/src/main/java/com/licenseservice/service/LicenseService.java
@@ -0,0 +1,70 @@
+package com.licenseservice.service;
+
+import com.licenseservice.Client.OrganizationDiscoveryClient;
+import com.licenseservice.Client.OrganizationFeignClient;
+import com.licenseservice.Client.OrganizationRestTemplateClient;
+import com.licenseservice.Config.ServiceConfig;
+import com.licenseservice.Mapper.LicenseMapper;
+import com.licenseservice.model.License;
+import com.licenseservice.model.Organization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class LicenseService {
+
+ private Logger logger = LoggerFactory.getLogger(LicenseService.class);
+
+ @Autowired
+ private LicenseMapper licenseMapper = null;
+
+ @Autowired
+ private OrganizationDiscoveryClient discoveryClient = null;
+
+ @Autowired
+ private OrganizationRestTemplateClient restTemplateClient = null;
+
+ @Autowired
+ private OrganizationFeignClient feignClient = null;
+
+ @Autowired
+ private ServiceConfig serviceConfig = null;
+
+ private Organization retrieveOrgInfo(Long organizationId, String clientType){
+ Organization organization = null;
+
+ switch (clientType){
+ case "discovery":
+ logger.info("using discovery client");
+ System.out.println("---discovery client");
+ organization = discoveryClient.getOrganization(organizationId);
+ break;
+ case "rest":
+ System.out.println("---rest client");
+ organization = restTemplateClient.getOrganization(organizationId);
+ break;
+ case "feign":
+ System.out.println("---feign client");
+ organization = feignClient.getOrganization(organizationId);
+ }
+
+ return organization;
+
+ }
+
+ public License getLicense(Long organizationId, Long licenseId, String clientType) {
+ License license = licenseMapper.getLicense(organizationId, licenseId);
+
+ Organization org = retrieveOrgInfo(organizationId, clientType);
+
+ license.setOrganizationName(org.getName());
+ license.setContactName(org.getContactName());
+ license.setContactEmail(org.getContactEmail());
+ license.setContactPhone(org.getContactPhone());
+ license.setComment(serviceConfig.getExampleProperty());
+
+ return license;
+ }
+}
diff --git a/licensingserivce/src/main/main.iml b/licensingserivce/src/main/main.iml
new file mode 100644
index 0000000..ef94c73
--- /dev/null
+++ b/licensingserivce/src/main/main.iml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/licensingserivce/src/main/resources/META-INF/MANIFEST.MF b/licensingserivce/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..ede10cc
--- /dev/null
+++ b/licensingserivce/src/main/resources/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: com.licenseservice.LicenseserviceApplication
+
diff --git a/licensingserivce/src/main/resources/application.yml b/licensingserivce/src/main/resources/application.yml
new file mode 100644
index 0000000..752bfea
--- /dev/null
+++ b/licensingserivce/src/main/resources/application.yml
@@ -0,0 +1,58 @@
+server:
+ port: 8989
+
+#spring.datasource.url=jdbc:mysql://192.168.21.225:3306/mytest
+#spring.datasource.username=testuser
+#spring.datasource.password=19811981
+#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+
+#mybatis.mapper-locations=classpath:licenseMapper.xml
+#mybatis.config-location=classpath:mybatis-config.xml
+
+mybatis:
+ mapper-locations: classpath:licenseMapper.xml
+ config-location: classpath:mybatis-config.xml
+
+eureka:
+ instance:
+ prefer-ip-address: true
+
+ client:
+ fetch-registry: true
+ register-with-eureka: true
+ service-url:
+ defaultZone: http://140.143.45.252:8761/eureka/
+
+#eureka.instance.prefer-ip-address=true
+#eureka.client.fetch-registry=true
+#eureka.client.register-with-eureka=true
+#eureka.client.service-url.defaultZone = http://192.168.21.120:8761/eureka/
+
+#spring.zipkin.base-url=http://192.168.21.120:9411
+#spring.sleuth.sampler.probability=1.0
+
+spring:
+ zipkin:
+ base-url: http://127.0.0.1:9411
+
+ sleuth:
+ sampler:
+ probability: 1.0
+
+ cloud:
+ stream:
+ bindings:
+ inboundOrgChanges:
+ destination: orgChangeTopic
+ content-type: application/json
+ group: licesinggroup
+
+ kafka:
+ binder:
+ brokers: 192.168.21.225:9092
+ zk-nodes: 192.168.21.225:2181
+#logging.path=logs
+logging:
+ level:
+ org.springframework.cloud.config: DEBUG
+#logging.file=${logging.path}/licenseservice.log
\ No newline at end of file
diff --git a/licensingserivce/src/main/resources/bootstrap.yml b/licensingserivce/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..e7193cf
--- /dev/null
+++ b/licensingserivce/src/main/resources/bootstrap.yml
@@ -0,0 +1,9 @@
+spring:
+ application:
+ name: licensingservice
+
+ profiles:
+ active: work
+ cloud:
+ config:
+ uri: http://140.143.45.252:8888
\ No newline at end of file
diff --git a/licensingserivce/src/main/resources/licenseMapper.xml b/licensingserivce/src/main/resources/licenseMapper.xml
new file mode 100644
index 0000000..b8baf92
--- /dev/null
+++ b/licensingserivce/src/main/resources/licenseMapper.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+ insert into t_licenses (license_id, organization_id, license_type, product_name, license_max, license_allocated) values (
+ #{licenseId}, #{organizationId}, #{licenseType}, #{productName}, #{licenseMax}, #{licenseAllocated})
+
+
\ No newline at end of file
diff --git a/licensingserivce/src/main/resources/log4j2.xml b/licensingserivce/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..90ad7c9
--- /dev/null
+++ b/licensingserivce/src/main/resources/log4j2.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/licensingserivce/src/main/resources/mybatis-config.xml b/licensingserivce/src/main/resources/mybatis-config.xml
new file mode 100644
index 0000000..7b870e8
--- /dev/null
+++ b/licensingserivce/src/main/resources/mybatis-config.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/licensingserivce/src/main/resources/schema.sql b/licensingserivce/src/main/resources/schema.sql
new file mode 100644
index 0000000..4ff885b
--- /dev/null
+++ b/licensingserivce/src/main/resources/schema.sql
@@ -0,0 +1,10 @@
+DROP TABLE IF EXISTS `t_licenses`;
+CREATE TABLE `t_licenses` (
+ `license_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
+ `organization_id` bigint(20) not null,
+ `product_name` varchar(32) DEFAULT NULL,
+ `license_type` varchar(32) DEFAULT NULL COMMENT '类型',
+ `license_max` bigint(20) DEFAULT NULL COMMENT '密码',
+ `license_allocated` bigint(20) DEFAULT NULL,
+ PRIMARY KEY (`license_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8;
\ No newline at end of file
diff --git a/licensingserivce/src/test/java/com/licenseservice/LicenseserviceApplicationTests.java b/licensingserivce/src/test/java/com/licenseservice/LicenseserviceApplicationTests.java
new file mode 100644
index 0000000..9745da1
--- /dev/null
+++ b/licensingserivce/src/test/java/com/licenseservice/LicenseserviceApplicationTests.java
@@ -0,0 +1,16 @@
+package com.licenseservice;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class LicenseserviceApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/licensingserivce/src/test/test.iml b/licensingserivce/src/test/test.iml
new file mode 100644
index 0000000..a0e49a3
--- /dev/null
+++ b/licensingserivce/src/test/test.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/microservice.iml b/microservice.iml
new file mode 100644
index 0000000..9275fb1
--- /dev/null
+++ b/microservice.iml
@@ -0,0 +1,127 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mvnw b/mvnw
new file mode 100755
index 0000000..5551fde
--- /dev/null
+++ b/mvnw
@@ -0,0 +1,286 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven2 Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+# JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+# M2_HOME - location of maven2's installed home dir
+# MAVEN_OPTS - parameters passed to the Java VM when running Maven
+# e.g. to debug Maven itself, use
+# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+ if [ -f /etc/mavenrc ] ; then
+ . /etc/mavenrc
+ fi
+
+ if [ -f "$HOME/.mavenrc" ] ; then
+ . "$HOME/.mavenrc"
+ fi
+
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+ MINGW*) mingw=true;;
+ Darwin*) darwin=true
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ export JAVA_HOME="`/usr/libexec/java_home`"
+ else
+ export JAVA_HOME="/Library/Java/Home"
+ fi
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+ if [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=`java-config --jre-home`
+ fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+ ## resolve links - $0 may be a link to maven's home
+ PRG="$0"
+
+ # need this for relative symlinks
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname "$PRG"`/$link"
+ fi
+ done
+
+ saveddir=`pwd`
+
+ M2_HOME=`dirname "$PRG"`/..
+
+ # make it fully qualified
+ M2_HOME=`cd "$M2_HOME" && pwd`
+
+ cd "$saveddir"
+ # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --unix "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME="`(cd "$M2_HOME"; pwd)`"
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+ # TODO classpath?
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ javaExecutable="`which javac`"
+ if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=`which readlink`
+ if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+ if $darwin ; then
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+ else
+ javaExecutable="`readlink -f \"$javaExecutable\"`"
+ fi
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
+ fi
+ fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="`which java`"
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly." >&2
+ echo " We cannot execute $JAVACMD" >&2
+ exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+ echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+ if [ -z "$1" ]
+ then
+ echo "Path not specified to find_maven_basedir"
+ return 1
+ fi
+
+ basedir="$1"
+ wdir="$1"
+ while [ "$wdir" != '/' ] ; do
+ if [ -d "$wdir"/.mvn ] ; then
+ basedir=$wdir
+ break
+ fi
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+ if [ -d "${wdir}" ]; then
+ wdir=`cd "$wdir/.."; pwd`
+ fi
+ # end of workaround
+ done
+ echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+ if [ -f "$1" ]; then
+ echo "$(tr -s '\n' ' ' < "$1")"
+ fi
+}
+
+BASE_DIR=`find_maven_basedir "$(pwd)"`
+if [ -z "$BASE_DIR" ]; then
+ exit 1;
+fi
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found .mvn/wrapper/maven-wrapper.jar"
+ fi
+else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
+ fi
+ jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
+ while IFS="=" read key value; do
+ case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
+ esac
+ done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Downloading from: $jarUrl"
+ fi
+ wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+
+ if command -v wget > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found wget ... using wget"
+ fi
+ wget "$jarUrl" -O "$wrapperJarPath"
+ elif command -v curl > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found curl ... using curl"
+ fi
+ curl -o "$wrapperJarPath" "$jarUrl"
+ else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Falling back to using Java to download"
+ fi
+ javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ if [ -e "$javaClass" ]; then
+ if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Compiling MavenWrapperDownloader.java ..."
+ fi
+ # Compiling the Java class
+ ("$JAVA_HOME/bin/javac" "$javaClass")
+ fi
+ if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ # Running the downloader
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Running MavenWrapperDownloader.java ..."
+ fi
+ ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
+ fi
+ fi
+ fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+if [ "$MVNW_VERBOSE" = true ]; then
+ echo $MAVEN_PROJECTBASEDIR
+fi
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --path --windows "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+ MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+fi
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/mvnw.cmd b/mvnw.cmd
new file mode 100644
index 0000000..e5cfb0a
--- /dev/null
+++ b/mvnw.cmd
@@ -0,0 +1,161 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven2 Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
+FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
+ IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+ echo Found %WRAPPER_JAR%
+) else (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %DOWNLOAD_URL%
+ powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
+ echo Finished downloading %WRAPPER_JAR%
+)
+@REM End of extension
+
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%" == "on" pause
+
+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
+
+exit /B %ERROR_CODE%
diff --git a/organizationservice/.gitignore b/organizationservice/.gitignore
new file mode 100644
index 0000000..82eca33
--- /dev/null
+++ b/organizationservice/.gitignore
@@ -0,0 +1,25 @@
+/target/
+!.mvn/wrapper/maven-wrapper.jar
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/build/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
\ No newline at end of file
diff --git a/organizationservice/mvnw b/organizationservice/mvnw
new file mode 100755
index 0000000..5551fde
--- /dev/null
+++ b/organizationservice/mvnw
@@ -0,0 +1,286 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven2 Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+# JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+# M2_HOME - location of maven2's installed home dir
+# MAVEN_OPTS - parameters passed to the Java VM when running Maven
+# e.g. to debug Maven itself, use
+# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+ if [ -f /etc/mavenrc ] ; then
+ . /etc/mavenrc
+ fi
+
+ if [ -f "$HOME/.mavenrc" ] ; then
+ . "$HOME/.mavenrc"
+ fi
+
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+ MINGW*) mingw=true;;
+ Darwin*) darwin=true
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ export JAVA_HOME="`/usr/libexec/java_home`"
+ else
+ export JAVA_HOME="/Library/Java/Home"
+ fi
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+ if [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=`java-config --jre-home`
+ fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+ ## resolve links - $0 may be a link to maven's home
+ PRG="$0"
+
+ # need this for relative symlinks
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname "$PRG"`/$link"
+ fi
+ done
+
+ saveddir=`pwd`
+
+ M2_HOME=`dirname "$PRG"`/..
+
+ # make it fully qualified
+ M2_HOME=`cd "$M2_HOME" && pwd`
+
+ cd "$saveddir"
+ # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --unix "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME="`(cd "$M2_HOME"; pwd)`"
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+ # TODO classpath?
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ javaExecutable="`which javac`"
+ if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=`which readlink`
+ if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+ if $darwin ; then
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+ else
+ javaExecutable="`readlink -f \"$javaExecutable\"`"
+ fi
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
+ fi
+ fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="`which java`"
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly." >&2
+ echo " We cannot execute $JAVACMD" >&2
+ exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+ echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+ if [ -z "$1" ]
+ then
+ echo "Path not specified to find_maven_basedir"
+ return 1
+ fi
+
+ basedir="$1"
+ wdir="$1"
+ while [ "$wdir" != '/' ] ; do
+ if [ -d "$wdir"/.mvn ] ; then
+ basedir=$wdir
+ break
+ fi
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+ if [ -d "${wdir}" ]; then
+ wdir=`cd "$wdir/.."; pwd`
+ fi
+ # end of workaround
+ done
+ echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+ if [ -f "$1" ]; then
+ echo "$(tr -s '\n' ' ' < "$1")"
+ fi
+}
+
+BASE_DIR=`find_maven_basedir "$(pwd)"`
+if [ -z "$BASE_DIR" ]; then
+ exit 1;
+fi
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found .mvn/wrapper/maven-wrapper.jar"
+ fi
+else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
+ fi
+ jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
+ while IFS="=" read key value; do
+ case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
+ esac
+ done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Downloading from: $jarUrl"
+ fi
+ wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+
+ if command -v wget > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found wget ... using wget"
+ fi
+ wget "$jarUrl" -O "$wrapperJarPath"
+ elif command -v curl > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found curl ... using curl"
+ fi
+ curl -o "$wrapperJarPath" "$jarUrl"
+ else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Falling back to using Java to download"
+ fi
+ javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ if [ -e "$javaClass" ]; then
+ if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Compiling MavenWrapperDownloader.java ..."
+ fi
+ # Compiling the Java class
+ ("$JAVA_HOME/bin/javac" "$javaClass")
+ fi
+ if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ # Running the downloader
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Running MavenWrapperDownloader.java ..."
+ fi
+ ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
+ fi
+ fi
+ fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+if [ "$MVNW_VERBOSE" = true ]; then
+ echo $MAVEN_PROJECTBASEDIR
+fi
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --path --windows "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+ MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+fi
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/organizationservice/mvnw.cmd b/organizationservice/mvnw.cmd
new file mode 100644
index 0000000..e5cfb0a
--- /dev/null
+++ b/organizationservice/mvnw.cmd
@@ -0,0 +1,161 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Maven2 Start Up Batch script
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM M2_HOME - location of maven2's installed home dir
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
+FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
+ IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+ echo Found %WRAPPER_JAR%
+) else (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %DOWNLOAD_URL%
+ powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
+ echo Finished downloading %WRAPPER_JAR%
+)
+@REM End of extension
+
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%" == "on" pause
+
+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
+
+exit /B %ERROR_CODE%
diff --git a/organizationservice/pom.xml b/organizationservice/pom.xml
new file mode 100644
index 0000000..16d69d9
--- /dev/null
+++ b/organizationservice/pom.xml
@@ -0,0 +1,130 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.1.2.RELEASE
+
+
+ com
+ organizationservice
+ 0.0.1-SNAPSHOT
+ organizationService
+ Demo project for Spring Boot
+
+
+ 1.8
+ Greenwich.RC2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-eureka-client
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ mysql
+ mysql-connector-java
+
+ runtime
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 1.3.2
+
+
+
+
+
+
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-sleuth
+
+
+ org.springframework.cloud
+ spring-cloud-config-client
+
+
+ org.springframework.cloud
+ spring-cloud-starter-security
+
+
+ org.springframework.cloud
+ spring-cloud-starter-oauth2
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-stream
+
+
+ org.springframework.cloud
+ spring-cloud-starter-stream-kafka
+
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+
+
+
diff --git a/organizationservice/src/main/java/com/organizationservice/Mapper/OrganizationMapper.java b/organizationservice/src/main/java/com/organizationservice/Mapper/OrganizationMapper.java
new file mode 100644
index 0000000..aa9a09b
--- /dev/null
+++ b/organizationservice/src/main/java/com/organizationservice/Mapper/OrganizationMapper.java
@@ -0,0 +1,14 @@
+package com.organizationservice.Mapper;
+
+import com.organizationservice.model.Organization;
+
+public interface OrganizationMapper {
+
+ public Organization getOrg(Long organizationId);
+
+ public void saveOrg(Organization org);
+
+ public void updateOrg(Organization org);
+
+ public void deleteOrg(Long organizationId);
+}
diff --git a/organizationservice/src/main/java/com/organizationservice/OrganizationserviceApplication.java b/organizationservice/src/main/java/com/organizationservice/OrganizationserviceApplication.java
new file mode 100644
index 0000000..83b14e1
--- /dev/null
+++ b/organizationservice/src/main/java/com/organizationservice/OrganizationserviceApplication.java
@@ -0,0 +1,18 @@
+package com.organizationservice;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
+
+@SpringBootApplication
+@EnableEurekaClient
+@EnableResourceServer
+public class OrganizationserviceApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(OrganizationserviceApplication.class, args);
+ }
+
+}
+
diff --git a/organizationservice/src/main/java/com/organizationservice/ServiceConfig.java b/organizationservice/src/main/java/com/organizationservice/ServiceConfig.java
new file mode 100644
index 0000000..4174492
--- /dev/null
+++ b/organizationservice/src/main/java/com/organizationservice/ServiceConfig.java
@@ -0,0 +1,9 @@
+package com.organizationservice;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@MapperScan(basePackages = "com.organizationservice.Mapper")
+public class ServiceConfig {
+}
diff --git a/organizationservice/src/main/java/com/organizationservice/controller/OrganizationController.java b/organizationservice/src/main/java/com/organizationservice/controller/OrganizationController.java
new file mode 100644
index 0000000..ddc684c
--- /dev/null
+++ b/organizationservice/src/main/java/com/organizationservice/controller/OrganizationController.java
@@ -0,0 +1,42 @@
+package com.organizationservice.controller;
+
+import com.organizationservice.model.Organization;
+import com.organizationservice.service.OrganizationService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("/v1/organizations")
+public class OrganizationController {
+
+ Logger logger = LoggerFactory.getLogger(OrganizationController.class);
+
+ @Autowired
+ private OrganizationService service = null;
+
+ @GetMapping(value = "/{organizationId}")
+ public Organization get(@PathVariable("organizationId") Long organizationId, @RequestHeader HttpHeaders headers) {
+ logger.info("Get organization by id: " + organizationId);
+ //logger.info("tmx-correlation-id: ", headers.toString());
+ return service.getOrg(organizationId);
+ }
+
+ @PostMapping(value = "/{organizationId}")
+ public void post(@PathVariable("organizationId") String organizationId, @RequestBody Organization organization) {
+ service.saveOrg(organization);
+ }
+
+ @PutMapping(value = "/{organizationId}")
+ public void put(@PathVariable("organizationId") String organizationId, @RequestBody Organization organization) {
+ logger.info("Update organization by id: " + organizationId);
+ service.updateOrg(organization);
+ }
+
+ @DeleteMapping(value = "/{organizationId}")
+ public void deleteOrg(@PathVariable("organizationId") Long organizationId) {
+ service.deleteOrg(organizationId);
+ }
+}
diff --git a/organizationservice/src/main/java/com/organizationservice/events/OrgChangeModel.java b/organizationservice/src/main/java/com/organizationservice/events/OrgChangeModel.java
new file mode 100644
index 0000000..dc1090d
--- /dev/null
+++ b/organizationservice/src/main/java/com/organizationservice/events/OrgChangeModel.java
@@ -0,0 +1,48 @@
+package com.organizationservice.events;
+
+public class OrgChangeModel {
+
+ private String typeName;
+ private String action;
+ private Long orgId;
+ private String correlationId;
+
+ public OrgChangeModel(String typeName, String action, Long orgId, String correlationId) {
+ this.typeName = typeName;
+ this.action = action;
+ this.orgId = orgId;
+ this.correlationId = correlationId;
+ }
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public Long getOrgId() {
+ return orgId;
+ }
+
+ public void setOrgId(Long orgId) {
+ this.orgId = orgId;
+ }
+
+ public String getCorrelationId() {
+ return correlationId;
+ }
+
+ public void setCorrelationId(String correlationId) {
+ this.correlationId = correlationId;
+ }
+}
diff --git a/organizationservice/src/main/java/com/organizationservice/events/SimpleSourceBean.java b/organizationservice/src/main/java/com/organizationservice/events/SimpleSourceBean.java
new file mode 100644
index 0000000..338ddbd
--- /dev/null
+++ b/organizationservice/src/main/java/com/organizationservice/events/SimpleSourceBean.java
@@ -0,0 +1,31 @@
+package com.organizationservice.events;
+
+import com.organizationservice.utils.UserContextHolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cloud.stream.annotation.EnableBinding;
+import org.springframework.cloud.stream.messaging.Source;
+import org.springframework.messaging.support.MessageBuilder;
+import org.springframework.stereotype.Component;
+
+@Component
+@EnableBinding(Source.class)
+public class SimpleSourceBean {
+ private Source source;
+
+ private final static Logger logger = LoggerFactory.getLogger(SimpleSourceBean.class);
+
+ @Autowired
+ public SimpleSourceBean(Source source){
+ this.source = source;
+ }
+
+ public void publishOrg(String action, Long orgId) {
+ logger.info("Sending kafka message {} for org id {}", action, orgId);
+
+ OrgChangeModel changeModel = new OrgChangeModel(OrgChangeModel.class.getTypeName(), action, orgId, UserContextHolder.getContext().getCorrelationId());
+ source.output().send(MessageBuilder.withPayload(changeModel).build());
+
+ }
+}
diff --git a/organizationservice/src/main/java/com/organizationservice/model/Organization.java b/organizationservice/src/main/java/com/organizationservice/model/Organization.java
new file mode 100644
index 0000000..54ecc0c
--- /dev/null
+++ b/organizationservice/src/main/java/com/organizationservice/model/Organization.java
@@ -0,0 +1,57 @@
+package com.organizationservice.model;
+
+import org.apache.ibatis.type.Alias;
+
+@Alias(value = "organization")
+public class Organization {
+ private Long id;
+
+ private String name;
+
+ private String contactName;
+
+ private String contactEmail;
+
+ private String contactPhone;
+
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getContactName() {
+ return contactName;
+ }
+
+ public void setContactName(String contactName) {
+ this.contactName = contactName;
+ }
+
+ public String getContactEmail() {
+ return contactEmail;
+ }
+
+ public void setContactEmail(String contactEmail) {
+ this.contactEmail = contactEmail;
+ }
+
+ public String getContactPhone() {
+ return contactPhone;
+ }
+
+ public void setContactPhone(String contactPhone) {
+ this.contactPhone = contactPhone;
+ }
+}
diff --git a/organizationservice/src/main/java/com/organizationservice/security/ResourceServerConfiguration.java b/organizationservice/src/main/java/com/organizationservice/security/ResourceServerConfiguration.java
new file mode 100644
index 0000000..3174f95
--- /dev/null
+++ b/organizationservice/src/main/java/com/organizationservice/security/ResourceServerConfiguration.java
@@ -0,0 +1,17 @@
+package com.organizationservice.security;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpMethod;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
+
+@Configuration
+public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
+
+ @Override
+ public void configure(HttpSecurity http) throws Exception {
+ http.authorizeRequests().
+ antMatchers(HttpMethod.DELETE, "/v1/organizations/**").hasRole("ADMIN")
+ .anyRequest().authenticated();
+ }
+}
diff --git a/organizationservice/src/main/java/com/organizationservice/service/OrganizationService.java b/organizationservice/src/main/java/com/organizationservice/service/OrganizationService.java
new file mode 100644
index 0000000..6a01500
--- /dev/null
+++ b/organizationservice/src/main/java/com/organizationservice/service/OrganizationService.java
@@ -0,0 +1,39 @@
+package com.organizationservice.service;
+
+import com.organizationservice.Mapper.OrganizationMapper;
+import com.organizationservice.events.SimpleSourceBean;
+import com.organizationservice.model.Organization;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class OrganizationService {
+
+ @Autowired
+ private OrganizationMapper organizationMapper = null;
+
+ @Autowired
+ private SimpleSourceBean simpleSourceBean;
+
+ public Organization getOrg(Long organizationId){
+ simpleSourceBean.publishOrg("get", organizationId);
+ return organizationMapper.getOrg(organizationId);
+
+ }
+
+ public void saveOrg(Organization org){
+
+ simpleSourceBean.publishOrg("save", org.getId());
+ organizationMapper.saveOrg(org);
+ }
+
+ public void updateOrg(Organization org){
+ simpleSourceBean.publishOrg("update", org.getId());
+ organizationMapper.updateOrg(org);
+ }
+
+ public void deleteOrg(Long organizationId){
+ simpleSourceBean.publishOrg("delete", organizationId);
+ organizationMapper.deleteOrg(organizationId);
+ }
+}
diff --git a/organizationservice/src/main/resources/application.yml b/organizationservice/src/main/resources/application.yml
new file mode 100644
index 0000000..bb2e509
--- /dev/null
+++ b/organizationservice/src/main/resources/application.yml
@@ -0,0 +1,52 @@
+#mybatis.mapper-locations=classpath:organizationMapper.xml
+#mybatis.config-location=classpath:mybatis-config.xml
+#
+#spring.datasource.url=jdbc:mysql://192.168.21.225:3306/mytest
+#spring.datasource.username=testuser
+#spring.datasource.password=19811981
+#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
+#
+#
+#spring.application.name=organizationservice
+#spring.profiles.active=default
+#
+#eureka.instance.prefer-ip-address=true
+#eureka.client.fetch-registry=true
+#eureka.client.register-with-eureka=true
+#eureka.client.service-url.defaultZone = http://192.168.21.120:8761/eureka/
+
+#eureka:
+# instance:
+# prefer-ip-address: true
+#
+# client:
+# fetch-registry: true
+# register-with-eureka: true
+# service-url:
+# defaultZone: http://140.143.45.252:8761/eureka/
+
+logging.level.org.springframework.web: TRACE
+logging.level.org.springframework.http: TRACE
+logging.level.web: TRACE
+
+
+mybatis:
+ mapper-locations: classpath:organizationMapper.xml
+ config-location: classpath:mybatis-config.xml
+
+security:
+ oauth2:
+ resource:
+ user-info-uri: http://192.168.21.197:8091/user
+spring:
+ cloud:
+ stream:
+ bindings:
+ output:
+ destination: orgChangeTopic
+ content-type: application/json
+ kafka:
+ binder:
+ brokers: 192.168.21.225:9092
+ zk-nodes: 192.168.21.225:2181
+
diff --git a/organizationservice/src/main/resources/bootstrap.yml b/organizationservice/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..98af565
--- /dev/null
+++ b/organizationservice/src/main/resources/bootstrap.yml
@@ -0,0 +1,9 @@
+spring:
+ application:
+ name: organizationservice
+
+ profiles:
+ active: work
+ cloud:
+ config:
+ uri: http://140.143.45.252:8888
\ No newline at end of file
diff --git a/organizationservice/src/main/resources/mybatis-config.xml b/organizationservice/src/main/resources/mybatis-config.xml
new file mode 100644
index 0000000..a56877f
--- /dev/null
+++ b/organizationservice/src/main/resources/mybatis-config.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/organizationservice/src/main/resources/organizationMapper.xml b/organizationservice/src/main/resources/organizationMapper.xml
new file mode 100644
index 0000000..2d1ced9
--- /dev/null
+++ b/organizationservice/src/main/resources/organizationMapper.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+ insert into t_organizations (id, name, contact_name, contact_email, contact_phone) values (
+ #{id}, #{name}, #{contactName}, #{contactEmail}, #{contactPhone}
+ )
+
+
+
+ update t_organizations set name= #{name}, contact_name = #{contactName}, contact_email= #{contactEmail}, contact_phone = #{contactPhone}
+ where id = #{id}
+
+
+
+ delete from t_organizations where id = #{id}
+
+
\ No newline at end of file
diff --git a/organizationservice/src/test/java/com/organizationservice/OrganizationserviceApplicationTests.java b/organizationservice/src/test/java/com/organizationservice/OrganizationserviceApplicationTests.java
new file mode 100644
index 0000000..fe60b76
--- /dev/null
+++ b/organizationservice/src/test/java/com/organizationservice/OrganizationserviceApplicationTests.java
@@ -0,0 +1,17 @@
+package com.organizationservice;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class OrganizationserviceApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..e01cd8e
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,71 @@
+
+
+ 4.0.0
+ pom
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.1.2.RELEASE
+
+
+ com
+ microservice
+ 0.0.1-SNAPSHOT
+ microservice
+ Demo project for Spring Boot
+
+
+ 1.8
+ Greenwich.RC2
+
+
+
+ licensingserivce
+ organizationservice
+ common
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-eureka-client
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+
+
+