Compare commits

..

2 commits

Author SHA1 Message Date
32193fb080
In progress
Some checks failed
Quality Check / Validate OAS (push) Failing after 33s
Quality Check / Linting (push) Failing after 1m1s
Quality Check / Testing (push) Successful in 1m3s
Quality Check / Static Analysis (push) Failing after 1m6s
2024-09-30 06:11:53 +02:00
9b808a521c
PMT-19: In progress
Some checks failed
Quality Check / Validate OAS (push) Failing after 49s
Quality Check / Linting (push) Failing after 1m17s
Quality Check / Static Analysis (push) Failing after 1m23s
Quality Check / Testing (push) Successful in 4m22s
2024-09-27 16:40:33 +02:00
6 changed files with 26 additions and 60 deletions

View file

@ -201,9 +201,7 @@ paths:
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/EmployeeResponseDTO'
$ref: '#/components/schemas/EmployeeResponseDTO'
post:
tags:
- employee-controller
@ -469,5 +467,6 @@ components:
securitySchemes:
bearerAuth:
type: http
name: bearerAuth
scheme: bearer
bearerFormat: JWT

View file

@ -1,8 +1,9 @@
package de.hmmh.pmt;
import com.fasterxml.jackson.databind.ObjectMapper;
import de.hmmh.pmt.employee.ApiClientFactory;
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
import de.hmmh.pmt.auth.JwtToken;
import de.hmmh.pmt.employee.ApiClient;
import de.hmmh.pmt.employee.api.EmployeeControllerApi;
import de.hmmh.pmt.oas.DefaultApi;
import de.hmmh.pmt.dtos.HelloOut;
import jakarta.servlet.http.HttpServletRequest;
@ -16,8 +17,13 @@ import java.util.Optional;
@Controller
@RequestMapping("${openapi.projectManagement.base-path:/api/v1}")
public class ApiController implements DefaultApi {
@Autowired
private ApiClientFactory apiClientFactory;
private ApiClient apiClient;
@Autowired
private JwtToken apiToken;
@Autowired
private EmployeeControllerApi employeeApi;
@Override
public Optional<ObjectMapper> getObjectMapper() {
@ -31,14 +37,15 @@ public class ApiController implements DefaultApi {
@Override
public ResponseEntity<HelloOut> getHello() {
apiClient.setAccessToken(apiToken.getToken());
apiClient.setBasePath("https://employee.szut.dev");
//TODO: Get Authentication working
employeeApi.setApiClient(apiClient);
String data = employeeApi.findAll1().toString();
StringBuilder employees = new StringBuilder();
for (EmployeeResponseDTO employeeResponseDTO : apiClientFactory.getEmployeeApi().findAll1()) {
employees.append(employeeResponseDTO.toString());
}
HelloOut hello = new HelloOut();
hello.setMsg(employees.toString());
hello.setMsg(data);
return ResponseEntity.ok(hello);
}
}

View file

@ -4,7 +4,6 @@ import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
@ -13,8 +12,11 @@ import java.io.IOException;
@Component
public class JwtTokenFilter extends OncePerRequestFilter {
@Autowired
private JwtToken token;
private final JwtToken token;
public JwtTokenFilter(JwtToken token) {
this.token = token;
}
@Override
protected void doFilterInternal(

View file

@ -1,37 +0,0 @@
package de.hmmh.pmt.employee;
import de.hmmh.pmt.auth.JwtToken;
import de.hmmh.pmt.employee.api.EmployeeControllerApi;
import de.hmmh.pmt.employee.api.QualificationControllerApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class ApiClientFactory {
@Autowired
private ApiClient apiClient;
@Autowired
private JwtToken apiToken;
@Autowired
private EmployeeControllerApi employee;
@Autowired
private QualificationControllerApi qualification;
public EmployeeControllerApi getEmployeeApi() {
prepareApiClient();
employee.setApiClient(apiClient);
return employee;
}
public QualificationControllerApi getQualificationApi() {
prepareApiClient();
qualification.setApiClient(apiClient);
return qualification;
}
private void prepareApiClient() {
apiClient.setAccessToken(apiToken.getToken());
apiClient.setBasePath("https://employee.szut.dev");
}
}

View file

@ -5,5 +5,6 @@
>
<suppressions>
<suppress files="build[\\/]" checks="."/>
<suppress files="[\\/]de[\\/]hmmh[\\/]pmt[\\/]oas" checks="."/>
<suppress files="[\\/]de[\\/]hmmh[\\/]pmt[\\/]dtos" checks="."/>
</suppressions>

View file

@ -1,11 +1,5 @@
<FindBugsFilter xmlns="https://raw.githubusercontent.com/spotbugs/spotbugs/4.8.6/spotbugs/etc/findbugsfilter.xsd">
<Match>
<!-- We Want This Exposure of Resources the Way it is for our usage -->
<Class name="de.hmmh.pmt.employee.ApiClientFactory"/>
<Bug code="M,V,EI"/>
</Match>
<Match>
<!--Ignore Auto Generated Code -->
<Source name="~.*build/.*"/>
<Class name="de.hmmh.pmt.OpenAPISpringBoot$ExitException"/>
</Match>
</FindBugsFilter>