Commit 425beb1c authored by Kristel Meikas's avatar Kristel Meikas
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Kristel Meikas

See merge request teis/common-api-gateway!199
parents 705744ec c3294cc5
package ee.sm.ti.teis.commongateway.violationact;
import ee.sm.ti.teis.commongateway.CommonApiGatewayTestBase;
import ee.sm.ti.teis.commongateway.proceedings.violationact.ViolationActController;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import static java.util.UUID.randomUUID;
import static org.junit.jupiter.api.Assertions.assertThrows;
class ViolationActControllerTest extends CommonApiGatewayTestBase {
@Autowired
ViolationActController controller;
@Test
void getViolations_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.getViolationActs(randomUUID(), randomUUID(), new RequestMetaDTO()));
}
@Test
void getViolation_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.getViolationAct(randomUUID(), new RequestMetaDTO()));
}
}
package ee.sm.ti.teis.commongateway.admin;
import ee.sm.ti.teis.commongateway.file.FileReferenceDto;
import ee.sm.ti.teis.commongateway.messages.message.MessageProcessingService;
import ee.sm.ti.teis.commongateway.messages.message.dto.MessageFileReferenceDto;
import ee.sm.ti.teis.commongateway.messages.message.request.CreateMessageFileReferencesRequest;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.gatewaycommon.rabbit.RequestProcessingService;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
......@@ -20,8 +20,7 @@ import java.util.UUID;
@RequiredArgsConstructor
public class AdminForTestingController extends TeisBaseController {
private final AdminForTestingProcessingService service;
private final MessageProcessingService messageProcessingService;
private final RequestProcessingService service;
@ApiOperation(value = "${teis.api.admin.reset-message-email}")
@GetMapping("reset-message-email/{messageId}")
......@@ -29,7 +28,7 @@ public class AdminForTestingController extends TeisBaseController {
ResetMessageEmailRequest request = new ResetMessageEmailRequest();
request.setPayload(messageId, requestMetaDTO);
return service.resetMessageEmail(request);
return (UUID) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.message.post-message-file-references}", response = FileReferenceDto.class)
......@@ -40,7 +39,7 @@ public class AdminForTestingController extends TeisBaseController {
dtoList.forEach(reference -> reference.setObjectId(id));
request.setPayload(dtoList, requestMetaDTO);
return messageProcessingService.createFileReferences(request);
return (List<FileReferenceDto>) service.sendAndReceive(request);
}
}
package ee.sm.ti.teis.commongateway.admin;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import java.util.UUID;
@Service
@Deprecated(since = "1.19.0", forRemoval = true)
public class AdminForTestingProcessingService {
private final RabbitTemplate gwRabbitTemplate;
public AdminForTestingProcessingService(RabbitTemplate gwRabbitTemplate) {
this.gwRabbitTemplate = gwRabbitTemplate;
}
UUID resetMessageEmail(ResetMessageEmailRequest request) {
ResetMessageEmailResponse response = (ResetMessageEmailResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
}
package ee.sm.ti.teis.commongateway.admin;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.gatewaycommon.rabbit.RequestProcessingService;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
......@@ -16,7 +17,7 @@ import java.time.LocalDateTime;
@RequiredArgsConstructor
public class DeadlineController extends TeisBaseController {
private final DeadlineProcessingService deadlineProcessingService;
private final RequestProcessingService service;
@ApiOperation(value = "${teis.api.messages.deadline.get}", response = LocalDateTime.class)
@GetMapping(value = "deadline", produces = MediaType.APPLICATION_JSON_VALUE)
......@@ -24,7 +25,7 @@ public class DeadlineController extends TeisBaseController {
CalculateDeadlineGwRequest request = new CalculateDeadlineGwRequest();
request.setPayload(getDeadlineDto, requestMetaDTO);
return deadlineProcessingService.getDeadline(request);
return (LocalDateTime) service.sendAndReceive(request);
}
}
package ee.sm.ti.teis.commongateway.admin;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@Service
@Deprecated(since = "1.19.0", forRemoval = true)
@RequiredArgsConstructor
public class DeadlineProcessingService {
private final RabbitTemplate gwRabbitTemplate;
LocalDateTime getDeadline(CalculateDeadlineGwRequest requestDTO) {
CalculateDeadlineGwResponse resultDTO = (CalculateDeadlineGwResponse) gwRabbitTemplate
.convertSendAndReceive(requestDTO.routingKey(), requestDTO);
if (resultDTO != null) {
return resultDTO.processResponse();
}
throw new NoResponseFromRabbitException(requestDTO.getRequestMetaDTO().getRequestId());
}
}
package ee.sm.ti.teis.commongateway.admin;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.gatewaycommon.rabbit.RequestProcessingService;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
......@@ -15,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
@RequiredArgsConstructor
public class FeatureFlagController extends TeisBaseController {
private final FeatureFlagProcessingService service;
private final RequestProcessingService service;
@ApiOperation(value = "${teis.api.admin.get-feature-flags}", response = FeatureFlagDto.class)
@GetMapping("{id}")
......@@ -23,7 +24,6 @@ public class FeatureFlagController extends TeisBaseController {
FeatureFlagRequest request = new FeatureFlagRequest();
request.setPayload(id, requestMetaDTO);
return service.getFeatureFlag(request);
return (FeatureFlagDto) service.sendAndReceive(request);
}
}
package ee.sm.ti.teis.commongateway.admin;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
@Service
@Deprecated(since = "1.19.0", forRemoval = true)
@RequiredArgsConstructor
public class FeatureFlagProcessingService {
private final RabbitTemplate gwRabbitTemplate;
public FeatureFlagDto getFeatureFlag(FeatureFlagRequest request) {
FeatureFlagResponse response =
(FeatureFlagResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
}
......@@ -4,7 +4,6 @@ import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -19,10 +18,11 @@ public class PathController extends TeisBaseController {
private final PathProcessingService service;
@ApiOperation(value = "${teis.api.path.get}")
@GetMapping(value = "path", produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping("path")
public Map<String,String> getPath(PathDto path, RequestMetaDTO requestMetaDTO) {
GetPathRequest request = new GetPathRequest();
request.setPayload(path, requestMetaDTO);
return Map.of("path", service.getPath(request));
}
......
......@@ -5,7 +5,6 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
@Service
@Deprecated(since = "1.19.0", forRemoval = true)
public class PathProcessingService {
private final RabbitTemplate gwRabbitTemplate;
......@@ -16,9 +15,11 @@ public class PathProcessingService {
String getPath(GetPathRequest requestDTO) {
GetPathResponse resultDTO = (GetPathResponse) gwRabbitTemplate.convertSendAndReceive(requestDTO.routingKey(), requestDTO);
if (resultDTO != null) {
return resultDTO.processResponse();
}
throw new NoResponseFromRabbitException(requestDTO.getRequestMetaDTO().getRequestId());
}
......
......@@ -2,6 +2,7 @@ package ee.sm.ti.teis.commongateway.classifier;
import ee.sm.ti.teis.commongateway.classifier.search.ClassifierItemSearchFilterDto;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.gatewaycommon.rabbit.RequestProcessingService;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.types.enums.classifier.LinkedItems;
import ee.sm.ti.teis.types.enums.classifier.RelationType;
......@@ -17,7 +18,7 @@ import java.util.List;
@RequiredArgsConstructor
public class ClassifierController extends TeisBaseController {
private final ClassifierProcessingService classifierProcessingService;
private final RequestProcessingService service;
@ApiOperation(value = "${teis.api.messages.get-classifier-items}", response = String.class)
@GetMapping(value = "classifier-items", produces = MediaType.APPLICATION_JSON_VALUE)
......@@ -25,7 +26,7 @@ public class ClassifierController extends TeisBaseController {
ClassifierItemsRequest request = new ClassifierItemsRequest();
request.setPayload(new ClassifierItemsRequest.Parameters(searchFilterDto), requestMetaDTO);
return classifierProcessingService.getClassifiers(request);
return (List<ClassifierItemDto>) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.get-classifier}", response = String.class)
......@@ -37,7 +38,8 @@ public class ClassifierController extends TeisBaseController {
RequestMetaDTO requestMetaDTO) {
ClassifierItemRequest request = new ClassifierItemRequest();
request.setPayload(new ClassifierItemRequest.Parameters(id, linkedItems, relations), requestMetaDTO);
return classifierProcessingService.getClassifier(request);
return (ClassifierItemDto) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.get-classifier-default-value}")
......@@ -47,7 +49,7 @@ public class ClassifierController extends TeisBaseController {
ClassifierDefinitionRequest request = new ClassifierDefinitionRequest();
request.setPayload(new ClassifierDefinitionRequest.Parameters(definitionId), requestMetaDTO);
return classifierProcessingService.getDefaultValue(request);
return (ClassifierItemDto) service.sendAndReceive(request);
}
}
package ee.sm.ti.teis.commongateway.classifier;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Deprecated(since = "1.19.0", forRemoval = true)
@RequiredArgsConstructor
public class ClassifierProcessingService {
private final RabbitTemplate gwRabbitTemplate;
List<ClassifierItemDto> getClassifiers(ClassifierItemsRequest requestDTO) {
ClassifierItemsResponse resultDTO = (ClassifierItemsResponse) gwRabbitTemplate
.convertSendAndReceive(requestDTO.routingKey(), requestDTO);
if (resultDTO != null) {
return resultDTO.processResponse();
}
throw new NoResponseFromRabbitException(requestDTO.getRequestMetaDTO().getRequestId());
}
ClassifierItemDto getClassifier(ClassifierItemRequest requestDTO) {
ClassifierItemResponse resultDTO = (ClassifierItemResponse) gwRabbitTemplate
.convertSendAndReceive(requestDTO.routingKey(), requestDTO);
if (resultDTO != null) {
return resultDTO.processResponse();
}
throw new NoResponseFromRabbitException(requestDTO.getRequestMetaDTO().getRequestId());
}
ClassifierItemDto getDefaultValue(ClassifierDefinitionRequest requestDTO) {
ClassifierDefinitionFieldResponse resultDTO = (ClassifierDefinitionFieldResponse) gwRabbitTemplate
.convertSendAndReceive(requestDTO.routingKey(), requestDTO);
if (resultDTO != null) {
return resultDTO.processResponse();
}
throw new NoResponseFromRabbitException(requestDTO.getRequestMetaDTO().getRequestId());
}
}
package ee.sm.ti.teis.commongateway.dumonitor;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
@Service
@Deprecated(since = "1.19.0", forRemoval = true)
@RequiredArgsConstructor
public class DUMonitorProcessingService {
private final RabbitTemplate gwRabbitTemplate;
String send(SendPersonalDataUsageRequest request) {
SendPersonalDataUsageResponse response = (SendPersonalDataUsageResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
}
package ee.sm.ti.teis.commongateway.dumonitor;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.gatewaycommon.rabbit.RequestProcessingService;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
......@@ -10,21 +11,21 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/dumonitor")
@RequestMapping("dumonitor")
@Profile({"dev", "test", "local", "integtest"})
@RequiredArgsConstructor
public class DUMonitorTestController extends TeisBaseController {
private final DUMonitorProcessingService processingService;
private final RequestProcessingService service;
@ApiOperation(value = "${teis.api.messages.post-usage-data}", response = String.class)
@PostMapping
public String send(@RequestBody PersonalDataUsageDto usageData, RequestMetaDTO requestMetaDTO) {
SendPersonalDataUsageRequest request = new SendPersonalDataUsageRequest();
request.setPayload(new SendPersonalDataUsageRequest.Parameters(usageData), requestMetaDTO);
return processingService.send(request);
return (String) service.sendAndReceive(request);
}
}
......@@ -2,8 +2,6 @@ package ee.sm.ti.teis.commongateway.file;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
......@@ -22,11 +20,6 @@ public class FileController extends TeisBaseController {
private final FileProcessingService fileProcessingService;
@ApiOperation(value = "${teis.api.messages.proceeding.post-file}")
@ApiImplicitParams(value = {
@ApiImplicitParam(dataType = "__file", name = "file", required = true, paramType = "form"),
@ApiImplicitParam(dataType = "string", name = "contextType", paramType = "form"),
@ApiImplicitParam(dataType = "string", name = "data", paramType = "form")
})
@PostMapping
public FileReferenceDto upload(@PathVariable("fileReferencePath") FileObjectType fileReferencePath,
@PathVariable UUID id, HttpServletRequest request,
......@@ -62,8 +55,8 @@ public class FileController extends TeisBaseController {
@ApiOperation(value = "${teis.api.messages.proceeding.delete-file}")
@DeleteMapping("{fileId}")
public void delete(@PathVariable("fileReferencePath") FileObjectType fileReferencePath, @PathVariable String id,
@PathVariable String fileId, RequestMetaDTO requestMetaDTO) {
public void delete(@PathVariable("fileReferencePath") FileObjectType fileReferencePath, @PathVariable UUID id,
@PathVariable UUID fileId, RequestMetaDTO requestMetaDTO) {
fileProcessingService.delete(id, fileId, fileReferencePath.name(), requestMetaDTO);
}
......
......@@ -97,7 +97,7 @@ public class FileProcessingService {
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public void delete(String id, String fileId, String objectType, RequestMetaDTO requestMetaDTO) {
public void delete(UUID id, UUID fileId, String objectType, RequestMetaDTO requestMetaDTO) {
DeleteFileRequest request = new DeleteFileRequest(objectType);
request.setPayload(new DeleteFileRequest.Parameters(id, fileId, false), requestMetaDTO);
......@@ -113,7 +113,7 @@ public class FileProcessingService {
}
public void delete(String id, String fileId, boolean hard, String objectType, RequestMetaDTO requestMetaDTO) {
public void delete(UUID id, UUID fileId, boolean hard, String objectType, RequestMetaDTO requestMetaDTO) {
DeleteFileRequest request = new DeleteFileRequest(objectType);
request.setPayload(new DeleteFileRequest.Parameters(id, fileId, hard), requestMetaDTO);
......
......@@ -8,6 +8,7 @@ import org.springframework.context.annotation.Profile;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.UUID;
@Profile({"dev", "test", "local", "integtest"})
@RestController
......@@ -18,8 +19,8 @@ public class FileTestController extends TeisBaseController {
@ApiOperation(value = "${teis.api.messages.proceeding.delete-file}")
@DeleteMapping("{fileId}/{hard}")
public void delete(@PathVariable("fileReferencePath") FileObjectType fileReferencePath, @PathVariable String id,
@PathVariable String fileId, @PathVariable("hard") boolean hard, RequestMetaDTO requestMetaDTO) {
public void delete(@PathVariable("fileReferencePath") FileObjectType fileReferencePath, @PathVariable UUID id,
@PathVariable UUID fileId, @PathVariable("hard") boolean hard, RequestMetaDTO requestMetaDTO) {
fileProcessingService.delete(id, fileId, hard, fileReferencePath.name(), requestMetaDTO);
}
......
package ee.sm.ti.teis.commongateway.location;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.gatewaycommon.rabbit.RequestProcessingService;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -16,7 +17,7 @@ import java.util.UUID;
@RequiredArgsConstructor
public class LocationController extends TeisBaseController {
private final LocationProcessingService service;
private final RequestProcessingService service;
@ApiOperation(value = "${teis.api.messages.get-location}", response = LocationDto.class)
@ApiImplicitParams(
......@@ -26,7 +27,7 @@ public class LocationController extends TeisBaseController {
LocationRequest request = new LocationRequest();
request.setPayload(id, requestMetaDTO);
return service.getLocation(request);
return (LocationDto) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.get-location}", response = LocationDto.class)
......@@ -37,7 +38,7 @@ public class LocationController extends TeisBaseController {
LocationsRequest request = new LocationsRequest();
request.setPayload(employerId, requestMetaDTO);
return service.getLocations(request);
return (List<LocationDto>) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.post-location}", response = LocationDto.class)
......@@ -46,7 +47,7 @@ public class LocationController extends TeisBaseController {
CreateLocationRequest request = new CreateLocationRequest();
request.setPayload(new CreateLocationRequest.Parameters(location), requestMetaDTO);
return service.create(request);
return (LocationDto) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.put-location}", response = LocationDto.class)
......@@ -58,7 +59,7 @@ public class LocationController extends TeisBaseController {
location.setId(id);
request.setPayload(new UpdateLocationRequest.Parameters(location), requestMetaDTO);
return service.update(request);
return (LocationDto) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.delete-location}")
......@@ -69,7 +70,7 @@ public class LocationController extends TeisBaseController {
DeleteLocationRequest request = new DeleteLocationRequest();
request.setPayload(id, requestMetaDTO);
service.delete(request);
service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.post-locations}")
......@@ -80,7 +81,7 @@ public class LocationController extends TeisBaseController {
CreateLocationsRequest request = new CreateLocationsRequest();
request.setPayload(employerId, requestMetaDTO);
service.createLocations(request);
service.sendAndReceive(request);
}
}
package ee.sm.ti.teis.commongateway.location;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Deprecated(since = "1.19.0", forRemoval = true)
@Slf4j
@RequiredArgsConstructor
public class LocationProcessingService {
private final RabbitTemplate gwRabbitTemplate;
LocationDto getLocation(LocationRequest requestDTO) {
LocationResponse response = (LocationResponse) gwRabbitTemplate.convertSendAndReceive(requestDTO.routingKey(), requestDTO);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(requestDTO.getRequestMetaDTO().getRequestId());
}
List<LocationDto> getLocations(LocationsRequest requestDTO) {
LocationsResponse response = (LocationsResponse) gwRabbitTemplate.convertSendAndReceive(requestDTO.routingKey(), requestDTO);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(requestDTO.getRequestMetaDTO().getRequestId());
}