Done Ticket GEPAFINBE-71
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.entities.S3ConfigEntity;
|
||||
import net.gepafin.tendermanagement.model.request.S3ConfigReq;
|
||||
import net.gepafin.tendermanagement.model.response.S3ConfigBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Validated
|
||||
public interface S3ConfigApi {
|
||||
|
||||
@Operation(summary = "Api to create S3Path structure.", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@PostMapping(value = "", produces = { "application/json" })
|
||||
ResponseEntity<Response<S3ConfigBean>> addS3Path(@Valid @RequestBody S3ConfigReq s3pathReq);
|
||||
|
||||
@Operation(summary = "Api to get S3Path structure. by type", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "", produces = { "application/json" })
|
||||
ResponseEntity<Response<Optional<S3ConfigEntity>>> getS3PathByType(@Valid @Param(value = "type") String type);
|
||||
|
||||
@Operation(summary = "Api to delete S3Path structure. by id", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@DeleteMapping(value = "", produces = { "application/json" })
|
||||
ResponseEntity<Response<S3ConfigEntity>> deleteS3PathConfigById(@Valid @Param(value = "id") Long id);
|
||||
|
||||
@Operation(summary = "Api to update S3Path structure. by id", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@PutMapping(value = "", produces = { "application/json" })
|
||||
ResponseEntity<Response<S3ConfigBean>> updateS3PathConfigById(@Valid @RequestBody S3ConfigReq s3PathConfigurationReq, @Param(value = "id") Long id);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
|
||||
@Validated
|
||||
public interface S3MigrationApi {
|
||||
|
||||
@Operation(summary = "Api to migrate S3 doc to db and update s3 files as per specified folder.", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@PutMapping(value = "/{key}", produces = { "application/json" })
|
||||
String reUploadAndMigrateDocuments(@Parameter(description = "The secret key", required = true) @PathVariable("key") String key);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@Validated
|
||||
public interface UserSignedAndDelegationApi {
|
||||
@Operation(summary = "Api to migrate S3 doc to db and user-delegated folder", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "/{key}", produces = { "application/json" })
|
||||
String migrateUserDelegatedDocuments(@Parameter(description = "The secret key", required = true) @PathVariable("key") String key);
|
||||
|
||||
@Operation(summary = "Api to migrate S3 doc to user-signed.", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@PostMapping(value = "/{key}", produces = { "application/json" })
|
||||
String migrateUserSignedDocuments(@Parameter(description = "The secret key", required = true) @PathVariable("key") String key);
|
||||
}
|
||||
@@ -31,7 +31,7 @@ DocumentApiController implements DocumentApi {
|
||||
public ResponseEntity<Response<List<DocumentResponseBean>>> uploadFile(HttpServletRequest httpServletRequest, Long sourceId, DocumentSourceTypeEnum sourceType,
|
||||
List<MultipartFile> files, DocumentTypeEnum fileType) {
|
||||
try {
|
||||
List<DocumentResponseBean> responseBeans = documentService.uploadFile(files, sourceId,sourceType, fileType);
|
||||
List<DocumentResponseBean> responseBeans = documentService.uploadFile(files, sourceId, sourceType, fileType);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<List<DocumentResponseBean>>(responseBeans, Status.SUCCESS, Translator.toLocale(GepafinConstant.FILES_UPLOADED_MSG)));
|
||||
} catch (CustomValidationException ex) {
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.S3ConfigEntity;
|
||||
import net.gepafin.tendermanagement.model.request.S3ConfigReq;
|
||||
import net.gepafin.tendermanagement.model.response.S3ConfigBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.S3ConfigService;
|
||||
import net.gepafin.tendermanagement.web.rest.api.S3ConfigApi;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/s3-path-config}")
|
||||
public class S3ConfigController implements S3ConfigApi {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(S3ConfigController.class);
|
||||
|
||||
@Autowired
|
||||
S3ConfigService s3PathService;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<S3ConfigBean>> addS3Path(S3ConfigReq s3pathReq) {
|
||||
|
||||
log.info("Request Body : {}, {}, {}", s3pathReq.getPath(), s3pathReq.getType(), s3pathReq.getBucketName());
|
||||
S3ConfigBean s3Path = s3PathService.addS3Path(s3pathReq);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(new Response<S3ConfigBean>(s3Path, Status.SUCCESS, Translator.toLocale(GepafinConstant.ADDED_S3_PATH_STRUCTURE)));
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<Response<Optional<S3ConfigEntity>>> getS3PathByType(String type) {
|
||||
|
||||
log.info("Request to get S3Path by type {}", type);
|
||||
Optional<S3ConfigEntity> s3Path = s3PathService.getS3PathByType(type);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<Optional<S3ConfigEntity>>(s3Path, Status.SUCCESS, Translator.toLocale(GepafinConstant.S3_PATH_STRUCTURE_BY_TYPE)));
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<Response<S3ConfigEntity>> deleteS3PathConfigById(Long id) {
|
||||
log.info("Request to delete S3Path by Id {}", id);
|
||||
S3ConfigEntity deletedS3PathConfig = s3PathService.deleteS3PathById(id);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<S3ConfigEntity>(deletedS3PathConfig, Status.SUCCESS, Translator.toLocale(GepafinConstant.S3_PATH_DELETE_MSG)));
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<Response<S3ConfigBean>> updateS3PathConfigById(S3ConfigReq s3PathConfigurationReq, Long id) {
|
||||
S3ConfigBean updatedS3PathConfiguration = s3PathService.updateS3PathConfiguration(s3PathConfigurationReq, id);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<S3ConfigBean>(updatedS3PathConfiguration, Status.SUCCESS, Translator.toLocale(GepafinConstant.S3_PATH_CONFIG_UPDATE_MSG)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
|
||||
import net.gepafin.tendermanagement.service.impl.S3ReUploadMigrationService;
|
||||
import net.gepafin.tendermanagement.web.rest.api.S3MigrationApi;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/s3-migration}")
|
||||
public class S3MigrationApiController implements S3MigrationApi {
|
||||
|
||||
@Autowired
|
||||
S3ReUploadMigrationService s3MigrationService;
|
||||
@Override
|
||||
public String reUploadAndMigrateDocuments(String providedKey) {
|
||||
return s3MigrationService.reUploadAndMigrateDocuments(providedKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
|
||||
import net.gepafin.tendermanagement.service.impl.UserSignedAndDelegationServiceImpl;
|
||||
import net.gepafin.tendermanagement.web.rest.api.UserSignedAndDelegationApi;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/s3-user-signed-and-delegation-migration}")
|
||||
public class S3UserSignedAndDelegationMigrationController implements UserSignedAndDelegationApi {
|
||||
|
||||
@Autowired
|
||||
UserSignedAndDelegationServiceImpl userSignedAndDelegationService;
|
||||
|
||||
@Override
|
||||
public String migrateUserDelegatedDocuments(String providedKey) {
|
||||
return userSignedAndDelegationService.migrateUserDelegatedDocuments(providedKey);
|
||||
}
|
||||
@Override
|
||||
public String migrateUserSignedDocuments(String providedKey) {
|
||||
return userSignedAndDelegationService.migrateUserSignedDocuments(providedKey);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user