Commit 705744ec authored by Jürgen Hannus's avatar Jürgen Hannus
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Jürgen Hannus

See merge request teis/common-api-gateway!195
parents d025e4ad 7d90e881
......@@ -6,25 +6,24 @@ import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.UUID;
import static java.util.UUID.randomUUID;
import static org.junit.jupiter.api.Assertions.assertThrows;
class ProceduralActControllerTest extends CommonApiGatewayTestBase {
private static final RequestMetaDTO REQUEST_META_DTO = RequestMetaDTO.builder().requestId(UUID.randomUUID().toString()).build();
private static final RequestMetaDTO REQUEST_META_DTO = RequestMetaDTO.builder().requestId(randomUUID().toString()).build();
@Autowired
ProceduralActController controller;
@Test
void getProceduralActs_test() {
assertThrows(NoResponseFromRabbitException.class, () -> controller.getProceduralActs("id", REQUEST_META_DTO));
void getProceduralActs_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () -> controller.getProceduralActs(randomUUID(), REQUEST_META_DTO));
}
@Test
void getProceduralAct_test() {
assertThrows(NoResponseFromRabbitException.class, () -> controller.getProceduralAct("id", REQUEST_META_DTO));
void getProceduralAct_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () -> controller.getProceduralAct(randomUUID(), REQUEST_META_DTO));
}
}
......@@ -7,8 +7,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockHttpServletResponse;
import java.util.UUID;
import static java.util.UUID.randomUUID;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class SigningTestControllerTest extends CommonApiGatewayTestBase {
......@@ -19,6 +18,6 @@ public class SigningTestControllerTest extends CommonApiGatewayTestBase {
@Test
void signFile() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.signFile(UUID.randomUUID(), new RequestMetaDTO(), new MockHttpServletResponse()));
controller.signFile(randomUUID(), "", new RequestMetaDTO(), new MockHttpServletResponse()));
}
}
......@@ -7,7 +7,7 @@ import org.springframework.stereotype.Service;
import java.util.UUID;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@Deprecated(since = "1.19.0", forRemoval = true)
public class AdminForTestingProcessingService {
private final RabbitTemplate gwRabbitTemplate;
......
......@@ -8,7 +8,7 @@ import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@Deprecated(since = "1.19.0", forRemoval = true)
@RequiredArgsConstructor
public class DeadlineProcessingService {
......
......@@ -6,7 +6,7 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@Deprecated(since = "1.19.0", forRemoval = true)
@RequiredArgsConstructor
public class FeatureFlagProcessingService {
......
......@@ -5,7 +5,7 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@Deprecated(since = "1.19.0", forRemoval = true)
public class PathProcessingService {
private final RabbitTemplate gwRabbitTemplate;
......
package ee.sm.ti.teis.commongateway.authorities.authoritylicence;
import ee.sm.ti.teis.commongateway.authorities.authoritylicence.dto.AuthorityLicenceDto;
import ee.sm.ti.teis.commongateway.authorities.authoritylicence.dto.ValidatedAuthorityLicenceDto;
import ee.sm.ti.teis.commongateway.authorities.authoritylicence.request.AuthorityLicencesRequest;
import ee.sm.ti.teis.commongateway.authorities.authoritylicence.request.LicencedAuthoritiesRequest;
import ee.sm.ti.teis.commongateway.authorities.authoritylicence.request.ValidateAuthorityLicenceRequest;
import ee.sm.ti.teis.commongateway.person.PersonDto;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.gatewaycommon.rabbit.RequestProcessingService;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
......@@ -23,9 +27,9 @@ public class AuthorityLicenceController extends TeisBaseController {
private final RequestProcessingService service;
@ApiOperation(value = "${teis.api.authorities.get-authority-licences}", response = AuthorityLicenceDto.class)
@ApiOperation(value = "${teis.api.authorities.authority-licence.get-authority-licences}", response = AuthorityLicenceDto.class)
@GetMapping
public List<AuthorityLicenceDto> getAuthorityLicenses(@RequestParam UUID authorityId,
public List<AuthorityLicenceDto> getAuthorityLicences(@RequestParam UUID authorityId,
@RequestParam(required = false) AuthorityLicenceType licenceType,
@RequestParam(required = false) Boolean includeAll,
RequestMetaDTO requestMetaDTO) {
......@@ -34,4 +38,25 @@ public class AuthorityLicenceController extends TeisBaseController {
return (List<AuthorityLicenceDto>) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.authorities.authority-licence.get-licenced-authorities}", response = PersonDto.class)
@GetMapping("authorities")
public List<PersonDto> getLicencedAuthorities(@RequestParam AuthorityLicenceType licenceType, RequestMetaDTO requestMetaDTO) {
LicencedAuthoritiesRequest request = new LicencedAuthoritiesRequest();
request.setPayload(licenceType, requestMetaDTO);
return (List<PersonDto>) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.authorities.validate-authority-licence}", response = ValidatedAuthorityLicenceDto.class)
@GetMapping("validate")
public ValidatedAuthorityLicenceDto validateAuthorityLicence(@RequestParam UUID authorityId,
@RequestParam AuthorityLicenceType licenceType,
@RequestParam(required = false) Boolean includeAll,
RequestMetaDTO requestMetaDTO) {
ValidateAuthorityLicenceRequest request = new ValidateAuthorityLicenceRequest();
request.setPayload(new ValidateAuthorityLicenceRequest.Parameters(authorityId, licenceType, includeAll), requestMetaDTO);
return (ValidatedAuthorityLicenceDto) service.sendAndReceive(request);
}
}
package ee.sm.ti.teis.commongateway.authorities.authoritypermission;
import ee.sm.ti.teis.commongateway.authorities.authoritypermission.dto.GrantorsAuthorityPermissionDto;
import ee.sm.ti.teis.commongateway.authorities.authoritypermission.request.GrantorsAuthorityPermissionsRequest;
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.AuthorityPermissionType;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.UUID;
@RestController
@RequestMapping("authorities/authority-permissions")
@RequiredArgsConstructor
public class AuthorityPermissionsController extends TeisBaseController {
private final RequestProcessingService service;
@ApiOperation(value = "${teis.api.authorities.authority-permission.get-by-grantor}", response = GrantorsAuthorityPermissionDto.class)
@GetMapping("grantor")
public List<GrantorsAuthorityPermissionDto> getGrantorsAuthorityPermissions(@RequestParam UUID grantorId,
@RequestParam(required = false) AuthorityPermissionType permissionType,
@RequestParam(required = false) Boolean includeAll,
RequestMetaDTO requestMetaDTO) {
GrantorsAuthorityPermissionsRequest request = new GrantorsAuthorityPermissionsRequest();
request.setPayload(new GrantorsAuthorityPermissionsRequest.Parameters(grantorId, permissionType, includeAll),
requestMetaDTO);
return (List<GrantorsAuthorityPermissionDto>) service.sendAndReceive(request);
}
}
......@@ -8,7 +8,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@Deprecated(since = "1.19.0", forRemoval = true)
@RequiredArgsConstructor
public class ClassifierProcessingService {
......
......@@ -45,6 +45,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/actuator/**").permitAll()
.antMatchers("/v2/api-docs", "/configuration/ui", "/swagger-resources/**", "/configuration/**", "/swagger-ui/**", "/swagger-ui.html", "/test-role-definitions/**", "/role-definitions/**", "/webjars/**", "/csrf",
"/").permitAll()
.antMatchers("/actuator").permitAll()
.antMatchers("/applications/prometheus").permitAll()
.anyRequest().not().anonymous() // any authenticated user except anonymous
.and()
.oauth2ResourceServer()
......
......@@ -6,7 +6,7 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@Deprecated(since = "1.19.0", forRemoval = true)
@RequiredArgsConstructor
public class DUMonitorProcessingService {
......
......@@ -54,7 +54,6 @@ public class FileContentService {
public FileReferenceDto updateContext(FileReferenceDto fileReferenceDto, String objectType,
RequestMetaDTO requestMetaDTO) {
return fileProcessingService.updateContext(fileReferenceDto, objectType, requestMetaDTO);
}
public FileReferenceDto saveFileToStorage(HttpServletRequest request, UUID objectId, FileObjectType objectType,
......@@ -198,7 +197,7 @@ public class FileContentService {
}
private FileMetadataDto composeFileMetaData(UUID fileId, String originalFileName, String contentType, String bucket) {
long fileSize = fileStorageServiceClient.getFileMetadata(bucket, fileId).length();
long fileSize = fileStorageServiceClient.getFileMetadata(bucket, fileId).size();
return FileMetadataDto.builder()
.fileId(fileId)
......
......@@ -4,16 +4,17 @@ import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.errors.CommonErrorCode;
import ee.sm.ti.teis.exceptions.TeisResourceNotFoundException;
import ee.sm.ti.teis.exceptions.TeisRestException;
import ee.sm.ti.teis.exceptions.TeisStorageException;
import ee.sm.ti.teis.fileclient.FileStorageServiceClient;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import io.minio.MinioClient;
import io.minio.ObjectStat;
import io.minio.errors.ErrorResponseException;
import io.minio.StatObjectResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.UUID;
import static org.springframework.http.HttpStatus.NO_CONTENT;
......@@ -25,10 +26,10 @@ public class ThumbnailService {
private static final String THUMBNAIL_SIZE_100 = "100";
private final FileProcessingService fileProcessingService;
private final MinioClient minioClient;
private final FileStorageServiceClient fileStorageServiceClient;
void getThumbnailFileFromStorage(String objectId, String fileId, HttpServletResponse response,
String objectType, RequestMetaDTO requestMetaDTO) throws Exception {
String objectType, RequestMetaDTO requestMetaDTO) throws IOException {
log.info("Thumbnail retrieval from storage initiated for file ID: {}", fileId);
FileMetadataDto dto = fileProcessingService.getFile(UUID.fromString(objectId), UUID.fromString(fileId),
......@@ -37,15 +38,15 @@ public class ThumbnailService {
String thumbnailFileId = dto.getThumbnails().get(THUMBNAIL_SIZE_100);
try {
final ObjectStat objectStat = minioClient.statObject(dto.getThumbnailsBucket(), thumbnailFileId);
StatObjectResponse objectStat = fileStorageServiceClient.getFileMetadata(dto.getThumbnailsBucket(), thumbnailFileId);
response.addHeader("Content-disposition", "attachment;filename=" + thumbnailFileId + ".jpg");
response.setContentType(objectStat.contentType());
} catch (ErrorResponseException e) {
} catch (TeisStorageException e) {
log.error("Thumbnail file not found with ID: {}", thumbnailFileId, e);
throw new TeisResourceNotFoundException("Thumbnail file not found from storage");
}
IOUtils.copy(minioClient.getObject(dto.getThumbnailsBucket(), thumbnailFileId), response.getOutputStream());
IOUtils.copy(fileStorageServiceClient.getFileStream(dto.getThumbnailsBucket(), thumbnailFileId), response.getOutputStream());
response.flushBuffer();
}
......
package ee.sm.ti.teis.commongateway.file.config;
import io.minio.MinioClient;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties(FileStorageProperties.class)
@RequiredArgsConstructor
public class FileStorageConfig {
private final FileStorageProperties properties;
@Bean
MinioClient minioClient() throws InvalidPortException, InvalidEndpointException {
return new MinioClient(properties.getUrl(), properties.getAccessKey(), properties.getSecretKey());
}
}
package ee.sm.ti.teis.commongateway.file.config;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import javax.validation.constraints.NotNull;
@Getter
@Setter
@ConfigurationProperties(prefix = "teis.file.storage")
public class FileStorageProperties {
@NotNull
private String url;
@NotNull
private String accessKey;
@NotNull
private String secretKey;
}
......@@ -9,7 +9,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@Deprecated(since = "1.19.0", forRemoval = true)
@Slf4j
@RequiredArgsConstructor
public class LocationProcessingService {
......
......@@ -14,7 +14,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@Deprecated(since = "1.19.0", forRemoval = true)
@RequiredArgsConstructor
public class MessageProcessingService {
......
......@@ -10,7 +10,7 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@Deprecated(since = "1.19.0", forRemoval = true)
@RequiredArgsConstructor
public class ClaimProcessingService {
......
......@@ -9,7 +9,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@Deprecated(since = "1.19.0", forRemoval = true)
@RequiredArgsConstructor
public class PersonProcessingService {
......
package ee.sm.ti.teis.commongateway.proceduralact;
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;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.UUID;
@RestController
@RequestMapping("procedural-acts")
@RequiredArgsConstructor
public class ProceduralActController extends TeisBaseController {
private final ProceduralActProcessingService processingService;
private final RequestProcessingService service;
@ApiOperation(value = "${teis.api.messages.proceeding.get-procedural-acts}", response = ProceduralActPublicDto.class)
@GetMapping
public List<ProceduralActPublicDto> getProceduralActs(@RequestParam(value = "proceedingId") String id, RequestMetaDTO requestMetaDTO) {
public List<ProceduralActPublicDto> getProceduralActs(@RequestParam(value = "proceedingId") UUID id, RequestMetaDTO requestMetaDTO) {
ProceduralActsPublicRequest request = new ProceduralActsPublicRequest();
request.setPayload(new ProceduralActsPublicRequest.Parameters(id), requestMetaDTO);
request.setPayload(id, requestMetaDTO);
return processingService.getProceduralActs(request);
return (List<ProceduralActPublicDto>) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.proceeding.get-procedural-act}", response = ProceduralActPublicDto.class)
@GetMapping(value = "{proceduralActId}")
public ProceduralActPublicDto getProceduralAct(@PathVariable(value = "proceduralActId") String id, RequestMetaDTO requestMetaDTO) {
@GetMapping("{id}")
public ProceduralActPublicDto getProceduralAct(@PathVariable UUID id, RequestMetaDTO requestMetaDTO) {
ProceduralActPublicRequest request = new ProceduralActPublicRequest();
request.setPayload(new ProceduralActPublicRequest.Parameters(id), requestMetaDTO);
request.setPayload(id, requestMetaDTO);
return processingService.getProceduralAct(request);
return (ProceduralActPublicDto) service.sendAndReceive(request);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment