Skip to content

Commit

Permalink
Merge pull request #29 from HariCazorla/audit
Browse files Browse the repository at this point in the history
Update dependencies to latest version
  • Loading branch information
HariCazorla authored Jul 20, 2022
2 parents 4e71b91 + 9c35315 commit 8da4e24
Show file tree
Hide file tree
Showing 11 changed files with 223 additions and 174 deletions.
20 changes: 10 additions & 10 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ version: '3.9'

services:

etracker:
build:
context: .
dockerfile: Dockerfile
depends_on:
- postgres
ports:
- 8080:8080
networks:
- expense-tracker-service-net
# etracker:
# build:
# context: .
# dockerfile: Dockerfile
# depends_on:
# - postgres
# ports:
# - 8080:8080
# networks:
# - expense-tracker-service-net

postgres:
image: postgres
Expand Down
44 changes: 40 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.2</version>
<version>2.7.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.shreeharibi</groupId>
Expand All @@ -24,6 +24,17 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.22</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -43,12 +54,23 @@
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
<version>2.9.2</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -62,9 +84,13 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.7.2</version>
<version>5.9.0-RC1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>

<build>
Expand All @@ -73,6 +99,16 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<excludes>
<exclude>org.apache.commons:commons-collections4</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.cyclonedx</groupId>
<artifactId>cyclonedx-maven-plugin</artifactId>
Expand Down
116 changes: 116 additions & 0 deletions pom.xml.versionsBackup
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.shreeharibi</groupId>
<artifactId>expense-tracker</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>expense-tracker</name>
<description>A project to manage your expenses</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.4.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.7.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<excludes>
<exclude>org.apache.commons:commons-collections4</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.cyclonedx</groupId>
<artifactId>cyclonedx-maven-plugin</artifactId>
<version>2.7.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>makeAggregateBom</goal>
</goals>
</execution>
</executions>
<configuration>
<projectType>library</projectType>
<schemaVersion>1.4</schemaVersion>
<includeBomSerialNumber>true</includeBomSerialNumber>
<includeCompileScope>true</includeCompileScope>
<includeProvidedScope>true</includeProvidedScope>
<includeRuntimeScope>true</includeRuntimeScope>
<includeSystemScope>true</includeSystemScope>
<includeTestScope>false</includeTestScope>
<includeLicenseText>true</includeLicenseText>
<outputReactorProjects>true</outputReactorProjects>
<outputFormat>all</outputFormat>
<outputName>bom</outputName>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.shreeharibi.expensetracker.config;

import com.google.common.base.Predicate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.RequestHandler;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
Expand All @@ -12,21 +11,22 @@
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


@Configuration
@EnableSwagger2
public class SpringFoxConfiguration {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis((Predicate<RequestHandler>) RequestHandlerSelectors.basePackage("com.shreeharibi.expensetracker"))
.paths((Predicate<String>) PathSelectors.any())
.apis(RequestHandlerSelectors.basePackage("com.shreeharibi.expensetracker"))
.paths(PathSelectors.any())
.build();
}

private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("Expense-tracker API")
.description("Expense-tracker API reference")
.version("1.0").build();
.version("2.0").build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import com.shreeharibi.expensetracker.exceptions.CategoryNotFoundException;
import com.shreeharibi.expensetracker.model.Category;
import com.shreeharibi.expensetracker.service.CategoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand All @@ -18,14 +17,11 @@

@RestController
@RequestMapping("api/v1/category")
@RequiredArgsConstructor
@Slf4j
public class CategoryController {
private final CategoryService categoryService;
Logger logger = LoggerFactory.getLogger(CategoryController.class);

@Autowired
public CategoryController(CategoryService categoryService) {
this.categoryService = categoryService;
}
private final CategoryService categoryService;

@GetMapping()
public List<Category> getCategoryByIdorName(
Expand All @@ -34,19 +30,19 @@ public List<Category> getCategoryByIdorName(
List<Category> result = new ArrayList<Category>();
try {
if ((id == null) && (name == null)) {
logger.info("Getting list of all categories...");
log.info("Getting list of all categories...");
result = categoryService.getCategories();
}
else if (name == null) {
logger.info("Getting category by id "+ id +"...");
log.info("Getting category by id "+ id +"...");
result.add(categoryService.getCategoryById(id));
}
else {
logger.info("Getting category by name "+ name +"...");
log.info("Getting category by name "+ name +"...");
result.add(categoryService.getCategoryByName(name));
}
} catch (CategoryNotFoundException e) {
logger.error("Failed to fetch category information...");
log.error("Failed to fetch category information...");
throw new ResponseStatusException(
HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage(), e);
}
Expand All @@ -56,10 +52,10 @@ else if (name == null) {
@PostMapping
public void addNewCategory(@RequestBody Category category) {
try {
logger.info("Adding new category "+ category +"...");
log.info("Adding new category "+ category +"...");
categoryService.addNewCategory(category);
} catch (CategoryExistsException e) {
logger.error("Failed to add new category...");
log.error("Failed to add new category...");
throw new ResponseStatusException(
HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage(), e);
}
Expand All @@ -71,15 +67,15 @@ public void deleteCategoryByName(@RequestBody Map<String, List<String>> category
boolean status = false;
for (String category : categories) {
try {
logger.info("Deleting category "+ category +"...");
log.info("Deleting category "+ category +"...");
categoryService.deleteCategoryByName(category);
} catch (CategoryNotFoundException e) {
status = true;
continue;
}
}
if (status) {
logger.error("Failed to delete some category...");
log.error("Failed to delete some category...");
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
Expand All @@ -89,10 +85,10 @@ public void deleteCategoryById(
@PathVariable("categoryId") Long categoryId
) {
try {
logger.info("Deleting category id "+ categoryId +"...");
log.info("Deleting category id "+ categoryId +"...");
categoryService.deleteCategoryById(categoryId);
} catch (CategoryNotFoundException e) {
logger.error("Failed to delete category...");
log.error("Failed to delete category...");
throw new ResponseStatusException(
HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage(), e);
}
Expand All @@ -104,10 +100,10 @@ public ResponseEntity<Category> updateCategory(
@RequestBody Category category
) {
try {
logger.info("update category name "+ oldCategoryName +"...");
log.info("update category name "+ oldCategoryName +"...");
return categoryService.updateCategory(oldCategoryName, category);
} catch (CategoryNotFoundException e) {
logger.error("Failed to update category...");
log.error("Failed to update category...");
throw new ResponseStatusException(
HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage(), e);
}
Expand Down
Loading

0 comments on commit 8da4e24

Please sign in to comment.