Skip to content

Commit

Permalink
re-format the project using eclipse code formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
EMEA\VEA3SF committed Jan 22, 2024
1 parent 3e7e275 commit 644a62c
Show file tree
Hide file tree
Showing 79 changed files with 2,011 additions and 1,529 deletions.
354 changes: 354 additions & 0 deletions codestyle/eclipse-java-style.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.springpageable.exception.BadRequestException;
import com.springpageable.exception.ConflictException;
import com.springpageable.exception.ResourceNotFoundException;
import jakarta.validation.ConstraintViolationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
Expand All @@ -17,7 +18,6 @@
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.multipart.support.MissingServletRequestPartException;

import jakarta.validation.ConstraintViolationException;
import java.time.LocalDateTime;

import static org.springframework.http.HttpStatus.CONFLICT;
Expand All @@ -32,14 +32,16 @@ public ErrorDetailsDTO handleResourceNotFoundException(final ConflictException e
return this.createErrorDetails(e, request);
}

@ExceptionHandler({MissingServletRequestParameterException.class, MethodArgumentTypeMismatchException.class, ConstraintViolationException.class, MissingServletRequestPartException.class, MissingRequestHeaderException.class, HttpMessageNotReadableException.class, BadRequestException.class})
@ExceptionHandler({ MissingServletRequestParameterException.class, MethodArgumentTypeMismatchException.class,
ConstraintViolationException.class, MissingServletRequestPartException.class,
MissingRequestHeaderException.class, HttpMessageNotReadableException.class, BadRequestException.class })
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ErrorDetailsDTO handleBadRequestExceptions(final Exception e, final WebRequest request) {
log.error("{}, endpoint: {}", e.getMessage(), request.getDescription(false));
return this.createErrorDetails(e, request);
}

@ExceptionHandler({ResourceNotFoundException.class})
@ExceptionHandler({ ResourceNotFoundException.class })
@ResponseStatus(HttpStatus.NOT_FOUND)
public ErrorDetailsDTO handleEntityNotFoundException(final ResourceNotFoundException e, final WebRequest request) {
return this.createErrorDetails((Exception) e, request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@

@Configuration
@ConditionalOnProperty(value = "springdoc.api-docs.enabled", havingValue = "true")
@ConfigurationPropertiesScan("com.device.configuration")
@ConfigurationPropertiesScan("com.springpageable.configuration")
@AllArgsConstructor
public class ApplicationConfig {

@Bean
public FutureDeviceMapper futureDeviceMapper() {
return new FutureDeviceMapperImpl();
}
@Bean
public UserMapper userMapper() {
return new UserMapperImpl();
}
@Bean
public FutureDeviceMapper futureDeviceMapper() {
return new FutureDeviceMapperImpl();
}

@Bean
public CountryStorage countryStorage() throws IOException {
return new CountryStorage();
}
@Bean
public UserMapper userMapper() {
return new UserMapperImpl();
}

@Bean
public CountryStorage countryStorage() throws IOException {
return new CountryStorage();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
@Component
public class HistoryLinkProvidingGitInfoContributor extends GitInfoContributor {

@Value("${git.url}")
public String gitHubUrl;
@Value("${git.url}")
public String gitHubUrl;

public static final String KEY_FOR_LINK = "history";
public static final String KEY_FOR_LINK = "history";

@Autowired
public HistoryLinkProvidingGitInfoContributor(GitProperties properties) {
super(properties);
}
@Autowired
public HistoryLinkProvidingGitInfoContributor(GitProperties properties) {
super(properties);
}

@Override
public void postProcessContent(Map<String, Object> content) {
super.postProcessContent(content);
@Override
public void postProcessContent(Map<String, Object> content) {
super.postProcessContent(content);

final String commitId = getProperties().getShortCommitId();
if (commitId != null) {
content.put(KEY_FOR_LINK, gitHubUrl + commitId);
final String commitId = getProperties().getShortCommitId();
if (commitId != null) {
content.put(KEY_FOR_LINK, gitHubUrl + commitId);
}
}
}
}
17 changes: 9 additions & 8 deletions src/main/java/com/springpageable/configuration/WebPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

public final class WebPath {

public static final String API_VERSION_1 = "/v1";
public static final String PATH_FUTURE_DEVICES = "/futures";
public static final String PATH_DATE = "/dates";
public static final String PATH_REMOVE_FUTURE_DEVICE = "/device/futures/{id}";
public static final String PATH_COUNTRIES = "/countries";
public static final String PATH_COUNTRIES_REGION_TYPE = "/regions/{regionId}/countries";
public static final String PATH_USERS = "/users";
public static final String API_VERSION_1 = "/v1";
public static final String PATH_FUTURE_DEVICES = "/futures";
public static final String PATH_DATE = "/dates";
public static final String PATH_REMOVE_FUTURE_DEVICE = "/device/futures/{id}";
public static final String PATH_COUNTRIES = "/countries";
public static final String PATH_COUNTRIES_REGION_TYPE = "/regions/{regionId}/countries";
public static final String PATH_USERS = "/users";

private WebPath() {}
private WebPath() {
}
}
Original file line number Diff line number Diff line change
@@ -1,62 +1,63 @@
package com.springpageable.controller;

import static com.springpageable.configuration.WebPath.API_VERSION_1;
import static com.springpageable.configuration.WebPath.PATH_USERS;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.springpageable.dto.GetUserResponseDTO;
import com.springpageable.enums.LdapGroup;
import com.springpageable.service.CriteriaBuilderExampleService;
import com.springpageable.swagger.SwaggerErrorResponses;
import com.springpageable.swagger.SwaggerPageable;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.springpageable.configuration.WebPath.API_VERSION_1;
import static com.springpageable.configuration.WebPath.PATH_USERS;

@RestController
@RequestMapping(API_VERSION_1)
@Validated
@Tag(name = "Criteria Builder Example", description = "Pageing result from criteria builder")
@Tag(name = "Criteria Builder Example", description = "Paging result from criteria builder")
public class CriteriaBuilderExampleController {

private final CriteriaBuilderExampleService criteriaBuilderExampleService;

public CriteriaBuilderExampleController(CriteriaBuilderExampleService criteriaBuilderExampleService) {
this.criteriaBuilderExampleService = criteriaBuilderExampleService;
}
@Autowired
private final CriteriaBuilderExampleService criteriaBuilderExampleService;

@GetMapping(PATH_USERS)
@SwaggerPageable
@SwaggerErrorResponses
@Operation(
summary = "Retrieves users by username. Can be used for retrieving or excluding " +
"users with concrete usernames, but not in the same time")
@Parameter(name = "exclude-usernames", description = "User names which to be excluded from the result set",
array = @ArraySchema(schema = @Schema(example = "testUser")))
@Parameter(name = "usernames", array = @ArraySchema(schema = @Schema(example = "testUser")),
description = "Search by list of usernames")
@Operation(summary = "Retrieves users by username. Can be used for retrieving or excluding " +
"users with concrete usernames, but not in the same time")
@Parameter(name = "exclude-usernames", description = "User names which to be excluded from the result set", array = @ArraySchema(schema = @Schema(example = "testUser")))
@Parameter(name = "usernames", array = @ArraySchema(schema = @Schema(example = "testUser")), description = "Search by list of usernames")
@Parameter(name = "searchParameter", example = "testUser", description = "Search by username, first name or last name")
@ApiResponse(responseCode = "200",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = GetUserResponseDTO.class))))
@ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = GetUserResponseDTO.class))))
public Page<GetUserResponseDTO> getUsers(
@RequestHeader(name = "exclude-usernames", required = false, defaultValue = "") List<String> excludeUsernames,
@RequestHeader(required = false, defaultValue = "") List<String> usernames,
@RequestHeader(name = "ldap-groups", required = false, defaultValue = "") List<LdapGroup> ldapGroups,
@RequestParam(required = false, defaultValue = "") String searchParameter,
@PageableDefault(direction = Sort.Direction.ASC, sort = {"firstName", "lastName", "username"})
Pageable p) {
@PageableDefault(direction = Sort.Direction.ASC, sort = { "firstName", "lastName",
"username" }) Pageable p) {
return criteriaBuilderExampleService.getUsers(usernames, excludeUsernames, ldapGroups, searchParameter, p);
}
}
46 changes: 25 additions & 21 deletions src/main/java/com/springpageable/controller/DateController.java
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
package com.springpageable.controller;

import static com.springpageable.configuration.WebPath.API_VERSION_1;
import static com.springpageable.configuration.WebPath.PATH_DATE;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.springpageable.dto.DateRequestDTO;
import com.springpageable.service.DateService;
import com.springpageable.swagger.SwaggerErrorResponses;

import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import static com.springpageable.configuration.WebPath.API_VERSION_1;
import static com.springpageable.configuration.WebPath.PATH_DATE;

@RestController
@RequestMapping(API_VERSION_1)
@Validated
@Tag(name = "Date validator", description = "Show custom date validator in spring")
public class DateController {

private final DateService dateService;
private final DateService dateService;

@Autowired
public DateController(DateService dateService) {
this.dateService = dateService;
}
@Autowired
public DateController(DateService dateService) {
this.dateService = dateService;
}

@PostMapping(PATH_DATE)
@SwaggerErrorResponses
@ResponseStatus(HttpStatus.CREATED)
@ApiResponse(responseCode = "201")
public void dateValidator(@Valid @RequestBody DateRequestDTO dateRequestDto) {
this.dateService.demo(dateRequestDto);
}
@PostMapping(PATH_DATE)
@SwaggerErrorResponses
@ResponseStatus(HttpStatus.CREATED)
@ApiResponse(responseCode = "201")
public void dateValidator(@Valid @RequestBody DateRequestDTO dateRequestDto) {
this.dateService.demo(dateRequestDto);
}
}
Loading

0 comments on commit 644a62c

Please sign in to comment.