Skip to content

Commit

Permalink
Merge branch 'mosip:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmsonkusare authored Apr 5, 2024
2 parents d7cf59f + c1e0080 commit f4bdd26
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 71 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.mosip.admin.controller;

import javax.servlet.http.HttpServletRequest;

import io.mosip.admin.packetstatusupdater.util.AuditUtil;
import io.mosip.admin.packetstatusupdater.util.EventEnum;
import io.mosip.admin.service.AdminProxyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
Expand All @@ -15,8 +15,8 @@
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import io.mosip.admin.packetstatusupdater.util.AuditUtil;
import io.mosip.admin.packetstatusupdater.util.EventEnum;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/keymanager/")
Expand All @@ -32,16 +32,70 @@ public class KeyManagerProxyController {
@Value("${mosip.admin.keymanager.service.url}")
private String url;

@RequestMapping(path = "/**", produces = MediaType.APPLICATION_JSON_VALUE, method = { RequestMethod.GET,
RequestMethod.POST, RequestMethod.DELETE,RequestMethod.PATCH,RequestMethod.PUT })
@Operation(summary = "KeyManager proxy", description = "KeyManager proxy", tags = "KeyManager-controller")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "401", description = "Unauthorized" ,content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", description = "Forbidden" ,content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", description = "Not Found" ,content = @Content(schema = @Schema(hidden = true)))})
public ResponseEntity<?> keyManagerProxyController(@RequestBody(required = false) String body,
HttpServletRequest request) {
auditUtil.setAuditRequestDto(EventEnum.KEYMANAGER_PROXY_API_CALLED,null);
return ResponseEntity.status(HttpStatus.OK).body(service.getResponse(body, request,url));
@RequestMapping(path = "/**", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
@Operation(summary = "KeyManager proxy", description = "KeyManager proxy", tags = "KeyManager-controller")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true)))
})
public ResponseEntity<?> getKeyManagerProxyController(@RequestBody(required = false) String body, HttpServletRequest request) {
auditUtil.setAuditRequestDto(EventEnum.KEYMANAGER_PROXY_API_CALLED, null);
return ResponseEntity.status(HttpStatus.OK).body(service.getResponse(null, request, url));
}

@RequestMapping(path = "/**", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@Operation(summary = "KeyManager proxy", description = "KeyManager proxy", tags = "KeyManager-controller")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true)))
})
public ResponseEntity<?> postKeyManagerProxyController(@RequestBody(required = false) String body, HttpServletRequest request) {
auditUtil.setAuditRequestDto(EventEnum.MASTERDATA_PROXY_API_CALLED, null);
return ResponseEntity.status(HttpStatus.OK).body(service.getResponse(body, request, url));
}

@RequestMapping(path = "/**", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.DELETE)
@Operation(summary = "KeyManager proxy", description = "KeyManager proxy", tags = "KeyManager-controller")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true)))
})
public ResponseEntity<?> deleteKeyManagerProxyController(@RequestBody(required = false) String body, HttpServletRequest request) {
auditUtil.setAuditRequestDto(EventEnum.MASTERDATA_PROXY_API_CALLED, null);
return ResponseEntity.status(HttpStatus.OK).body(service.getResponse(null, request, url));
}

@RequestMapping(path = "/**", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.PUT)
@Operation(summary = "KeyManager proxy", description = "KeyManager proxy", tags = "KeyManager-controller")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true)))
})
public ResponseEntity<?> putKeyManagerProxyController(@RequestBody(required = false) String body, HttpServletRequest request) {
auditUtil.setAuditRequestDto(EventEnum.MASTERDATA_PROXY_API_CALLED, null);
return ResponseEntity.status(HttpStatus.OK).body(service.getResponse(body, request, url));
}

@RequestMapping(path = "/**", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.PATCH)
@Operation(summary = "KeyManager proxy", description = "KeyManager proxy for PATCH requests", tags = "KeyManager-controller")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true)))
})
public ResponseEntity<?> patchKeyManagerProxyController(@RequestBody(required = false) String body, HttpServletRequest request) {
auditUtil.setAuditRequestDto(EventEnum.MASTERDATA_PROXY_API_CALLED, null);
return ResponseEntity.status(HttpStatus.OK).body(service.getResponse(body, request, url));
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

Expand All @@ -35,17 +32,71 @@ public class MasterdataProxyController {
@Value("${mosip.admin.masterdata.service.url}")
private String url;

@RequestMapping(path = "/**", produces = MediaType.APPLICATION_JSON_VALUE, method = { RequestMethod.GET,
RequestMethod.POST, RequestMethod.DELETE,RequestMethod.PATCH,RequestMethod.PUT })
@Operation(summary = "Master data proxy", description = "Master data proxy", tags = "proxy-masterdata-controller")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "401", description = "Unauthorized" ,content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", description = "Forbidden" ,content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", description = "Not Found" ,content = @Content(schema = @Schema(hidden = true)))})
public ResponseEntity<?> masterDataProxyController(@RequestBody(required = false) String body,
HttpServletRequest request) {
auditUtil.setAuditRequestDto(EventEnum.MASTERDATA_PROXY_API_CALLED,null);
return ResponseEntity.status(HttpStatus.OK).body(service.getResponse(body, request,url));
@RequestMapping(path = "/**", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
@Operation(summary = "Master data proxy", description = "Master data proxy", tags = "proxy-masterdata-controller")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true)))
})
public ResponseEntity<?> getMasterDataProxyController(@RequestBody(required = false) String body, HttpServletRequest request) {
auditUtil.setAuditRequestDto(EventEnum.MASTERDATA_PROXY_API_CALLED, null);
return ResponseEntity.status(HttpStatus.OK).body(service.getResponse(null, request, url));
}

@RequestMapping(path = "/**", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@Operation(summary = "Master data proxy", description = "Master data proxy", tags = "proxy-masterdata-controller")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true)))
})
public ResponseEntity<?> postMasterDataProxyController(@RequestBody(required = false) String body, HttpServletRequest request) {
auditUtil.setAuditRequestDto(EventEnum.MASTERDATA_PROXY_API_CALLED, null);
return ResponseEntity.status(HttpStatus.OK).body(service.getResponse(body, request, url));
}

@RequestMapping(path = "/**", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.DELETE)
@Operation(summary = "Master data proxy", description = "Master data proxy", tags = "proxy-masterdata-controller")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true)))
})
public ResponseEntity<?> deleteMasterDataProxyController(@RequestBody(required = false) String body, HttpServletRequest request) {
auditUtil.setAuditRequestDto(EventEnum.MASTERDATA_PROXY_API_CALLED, null);
return ResponseEntity.status(HttpStatus.OK).body(service.getResponse(null, request, url));
}

@RequestMapping(path = "/**", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.PUT)
@Operation(summary = "Master data proxy", description = "Master data proxy", tags = "proxy-masterdata-controller")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true)))
})
public ResponseEntity<?> putMasterDataProxyController(@RequestBody(required = false) String body, HttpServletRequest request) {
auditUtil.setAuditRequestDto(EventEnum.MASTERDATA_PROXY_API_CALLED, null);
return ResponseEntity.status(HttpStatus.OK).body(service.getResponse(body, request, url));
}


@RequestMapping(path = "/**", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.PATCH)
@Operation(summary = "Master data proxy", description = "Master data proxy for PATCH requests", tags = "proxy-masterdata-controller")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true)))
})
public ResponseEntity<?> patchMasterDataProxyController(@RequestBody(required = false) String body, HttpServletRequest request) {
auditUtil.setAuditRequestDto(EventEnum.MASTERDATA_PROXY_API_CALLED, null);
return ResponseEntity.status(HttpStatus.OK).body(service.getResponse(body, request, url));
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public enum SchemaErrorCode {
SUB_TYPE_REQUIRED_EXCEPTION("KER-SCH-017", "SubType is required for field %s"),
BIO_ATTRIBUTES_REQUIRED_EXCEPTION("KER-SCH-018", "BioAttributes are required for field %s"),
BIO_ATTRIBUTES_DUPLICATED_EXCEPTION("KER-SCH-019", "Same BioAttributes used in field with same SubType : %s"),

PUBLISHED_SCHEMA_EXCEPTION("KER-SCH-022", "Published identity schema can't be deleted"),

DYNAMIC_FIELD_VALUE_JSON_INVALID("KER-DYN-001", "Dynamic field is invalid, must contain code and value keys");

private final String errorCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public ResponseWrapper<FilterResponseCodeDto> holidayFilterValues(
public ResponseWrapper<List<MissingDataDto>> getMissingHolidayDetails(
@PathVariable("langcode") String langCode, @RequestParam(required = false) String fieldName) {
ResponseWrapper<List<MissingDataDto>> responseWrapper = new ResponseWrapper<>();
responseWrapper.setResponse(genericService.getMissingData(Holiday.class, langCode, "holidayDate", fieldName));
responseWrapper.setResponse(genericService.getMissingData(Holiday.class, langCode, "holidayId", fieldName));
return responseWrapper;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,16 @@ public IdSchemaResponseDto updateSchema(String id, IdentitySchemaDto dto) {
@Transactional
public String deleteSchema(String id) {
try {
int updatedRows = identitySchemaRepository.deleteIdentitySchema(id, MetaDataUtils.getCurrentDateTime(),
MetaDataUtils.getContextUser());

if (updatedRows < 1) {
IdentitySchema entity = identitySchemaRepository.findIdentitySchemaById(id);
if (entity == null) {
throw new RequestException(SchemaErrorCode.SCHEMA_NOT_FOUND_EXCEPTION.getErrorCode(),
SchemaErrorCode.SCHEMA_NOT_FOUND_EXCEPTION.getErrorMessage());
} else if (STATUS_PUBLISHED.equalsIgnoreCase(entity.getStatus())) {
throw new RequestException(SchemaErrorCode.PUBLISHED_SCHEMA_EXCEPTION.getErrorCode(),
SchemaErrorCode.PUBLISHED_SCHEMA_EXCEPTION.getErrorMessage());
}

identitySchemaRepository.deleteIdentitySchema(id, MetaDataUtils.getCurrentDateTime(),
MetaDataUtils.getContextUser());
} catch (DataAccessException | DataAccessLayerException e) {
LOGGER.error("Error while deleting identity schema : " , ExceptionUtils.neutralizeParam(id), e);
throw new MasterDataServiceException(SchemaErrorCode.SCHEMA_UPDATE_EXCEPTION.getErrorCode(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package io.mosip.kernel.masterdata.test.controller;

import static org.mockito.Mockito.doNothing;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import io.mosip.kernel.core.http.RequestWrapper;
import io.mosip.kernel.core.websub.model.EventModel;
import io.mosip.kernel.core.websub.spi.PublisherClient;
import io.mosip.kernel.masterdata.dto.ExceptionalHolidayPutPostDto;
import io.mosip.kernel.masterdata.dto.RegCenterLanguageSpecificPutDto;
import io.mosip.kernel.masterdata.dto.RegCenterNonLanguageSpecificPutDto;
import io.mosip.kernel.masterdata.dto.RegCenterPostReqDto;
import io.mosip.kernel.masterdata.dto.request.*;
import io.mosip.kernel.masterdata.test.TestBootApplication;
import io.mosip.kernel.masterdata.test.utils.MasterDataTest;
import io.mosip.kernel.masterdata.utils.AuditUtil;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
Expand All @@ -26,25 +31,14 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.mosip.kernel.core.http.RequestWrapper;
import io.mosip.kernel.core.websub.model.EventModel;
import io.mosip.kernel.core.websub.spi.PublisherClient;
import io.mosip.kernel.masterdata.dto.ExceptionalHolidayPutPostDto;
import io.mosip.kernel.masterdata.dto.RegCenterLanguageSpecificPutDto;
import io.mosip.kernel.masterdata.dto.RegCenterNonLanguageSpecificPutDto;
import io.mosip.kernel.masterdata.dto.RegCenterPostReqDto;
import io.mosip.kernel.masterdata.dto.request.FilterDto;
import io.mosip.kernel.masterdata.dto.request.FilterValueDto;
import io.mosip.kernel.masterdata.dto.request.Pagination;
import io.mosip.kernel.masterdata.dto.request.SearchDto;
import io.mosip.kernel.masterdata.dto.request.SearchFilter;
import io.mosip.kernel.masterdata.dto.request.SearchSort;
import io.mosip.kernel.masterdata.test.TestBootApplication;
import io.mosip.kernel.masterdata.test.utils.MasterDataTest;
import io.mosip.kernel.masterdata.utils.AuditUtil;
import static org.mockito.Mockito.doNothing;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestBootApplication.class)
Expand Down Expand Up @@ -373,6 +367,7 @@ public void t016validateTimestampFailTest() throws Exception {

}

@Ignore
@Test
@WithUserDetails("global-admin")
public void t017deleteRegistrationCenterTest() throws Exception {
Expand Down Expand Up @@ -515,6 +510,7 @@ public void t023decommissionRegCenterFailTest() throws Exception {

}

@Ignore
@Test
@WithUserDetails("global-admin")
public void t023decommissionRegCenterFailTest1() throws Exception {
Expand Down
Loading

0 comments on commit f4bdd26

Please sign in to comment.