Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ mvnw.cmd
.tern-project
debug.log
mvnw
src/main/environment/common_local.properties
1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.8
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ This microservice is built on Java, Spring boot framework and MySQL DB.
* MySQL
* Springboot V2

Maven
$ ./mvn clean install

## Installation
To install the inventory module, follow these steps:

1. Clone the repository to your local machine.
2. Install the dependencies.
npm install
3. Run the development server.
npm start
2. Install the dependencies `mvn clean install`

### Creating a build configuration and running the application

1. You can copy `common_example.properties` to `common_local.properties` and edit the file accordingly. The file is under `src/main/environment` folder.
2. Run the spring server with local configuration `mvn spring-boot:run -DENV_VAR=local`

Open the application in your browser. The inventory module will be accessible at http://localhost:3000/inventory.

Expand Down
48 changes: 44 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<final-name>inventory-api-0.0.1</final-name>
<environment>${ENV_VAR}</environment>
<target-properties>target/classes/application.properties</target-properties>
<source-properties>src/main/environment/common_${environment}.properties</source-properties>
<source-properties>target/classes/common_${environment}.properties</source-properties>
<hostname-test>10.208.122.38</hostname-test>
<port-test>9990</port-test>
</properties>
Expand Down Expand Up @@ -220,6 +220,32 @@
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>filter-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
<configuration>
<delimiters>@</delimiters>
<useDefaultDelimiters>false</useDefaultDelimiters>
<resources>
<resource>
<directory>src/main/environment</directory>
<filtering>true</filtering>
<includes>
<include>common_${environment}.properties</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
Expand All @@ -228,10 +254,10 @@
<goals>
<goal>run</goal>
</goals>
<id>properties-updated</id>
<id>merge-properties</id>
<configuration>
<target>
<echo>concatinating properties file ${target-properties} and
<echo>concatenating properties file ${target-properties} and
${source-properties}</echo>
<concat destfile="${target-properties}" append="yes"
force="yes">
Expand All @@ -241,6 +267,20 @@
</target>
</configuration>
</execution>
<execution>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<id>clean-property-files</id>
<configuration>
<tasks>
<delete>
<file file="${source-properties}"/>
</delete>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
Expand Down Expand Up @@ -298,4 +338,4 @@
</plugin>
</plugins>
</reporting>
</project>
</project>
9 changes: 9 additions & 0 deletions src/main/environment/common_ci.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
spring.datasource.url=@env.DATABASE_URL@
spring.datasource.username=@env.DATABASE_USERNAME@
spring.datasource.password=@env.DATABASE_PASSWORD@
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
common-api-url=@env.COMMON_API_BASE_URL@
callcentre-server-ip=@env.CALLCENTRE_SERVER_IP@
### Redis IP
spring.redis.host=localhost

7 changes: 1 addition & 6 deletions src/main/environment/common_dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ spring.datasource.url=<Enter AMRIT DB URL here>
spring.datasource.username=<Enter your AMRIT DB username>
spring.datasource.password=<Enter your AMRIT DB password>
spring.datasource.driver-class-name=com.mysql.jdbc.Driver


spring.profiles.active=test

callcentre-server-ip=10.208.122.99


common-url=http://10.208.122.32:8080/commonapi-v1.0/
common-api-url=http://10.208.122.32:8080/commonapi-v1.0/
common-api-url=http://10.208.122.38:8080/commonapi-v1.0/

### Redis IP
spring.redis.host=localhost
Expand Down
12 changes: 12 additions & 0 deletions src/main/environment/common_example.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
spring.datasource.url=<Enter AMRIT DB URL here>
spring.datasource.username=<Enter your AMRIT DB username>
spring.datasource.password=<Enter your AMRIT DB password>
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

spring.profiles.active=test
callcentre-server-ip=10.208.122.99
common-api-url=http://10.208.122.38:8080/commonapi-v1.0/

### Redis IP
spring.redis.host=localhost

21 changes: 0 additions & 21 deletions src/main/environment/common_local.properties

This file was deleted.

8 changes: 1 addition & 7 deletions src/main/environment/common_test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@ spring.datasource.password=<Enter your AMRIT DB password>
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

#spring.jpa.show-sql=true

spring.profiles.active=test


common-url=http://10.208.122.38:8080/commonapi-v1.0/
callcentre-server-ip=10.208.122.99
common-api-url=http://10.208.122.38:8080/commonapi-v1.0/

corsIP = http://10.208.122.38:8080

### Redis IP
spring.redis.host=localhost

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.iemr.inventory.config;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class BlockingMethodInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String method = request.getMethod();
if (!("GET".equals(method) || "POST".equals(method))) {
response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
return false;
}
return true;
}

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
// TODO Auto-generated method stub

}

@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
throws Exception {
// TODO Auto-generated method stub

}
}
21 changes: 16 additions & 5 deletions src/main/java/com/iemr/inventory/config/InterceptorConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

//
//import com.iemr.common.config.BlockingMethodInterceptor;
import com.iemr.inventory.utils.http.HTTPRequestInterceptor;

@Configuration
Expand All @@ -35,9 +36,19 @@ public class InterceptorConfig extends WebMvcConfigurerAdapter
@Autowired
HTTPRequestInterceptor requestInterceptor;


// @Override
// public void addInterceptors(InterceptorRegistry registry)
// {
// registry.addInterceptor(requestInterceptor);
// }

@Override
public void addInterceptors(InterceptorRegistry registry)
{
registry.addInterceptor(requestInterceptor);
}
public void addInterceptors(InterceptorRegistry registry)
{
registry.addInterceptor(new BlockingMethodInterceptor())
.addPathPatterns("/**");
}


}