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

View file

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

View file

@ -4,7 +4,6 @@ import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException; import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter; import org.springframework.web.filter.OncePerRequestFilter;
@ -13,8 +12,11 @@ import java.io.IOException;
@Component @Component
public class JwtTokenFilter extends OncePerRequestFilter { public class JwtTokenFilter extends OncePerRequestFilter {
@Autowired private final JwtToken token;
private JwtToken token;
public JwtTokenFilter(JwtToken token) {
this.token = token;
}
@Override @Override
protected void doFilterInternal( 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> <suppressions>
<suppress files="build[\\/]" checks="."/> <suppress files="[\\/]de[\\/]hmmh[\\/]pmt[\\/]oas" checks="."/>
<suppress files="[\\/]de[\\/]hmmh[\\/]pmt[\\/]dtos" checks="."/>
</suppressions> </suppressions>

View file

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