Skip to content

Commit

Permalink
MOSIP-30246-fix-sonar-code-smells-of-resident-service (#1143)
Browse files Browse the repository at this point in the history
* fixed additional comma issue

Signed-off-by: Ritik Jain <[email protected]>

* fixed error code

Signed-off-by: Ritik Jain <[email protected]>

* updated event enums

Signed-off-by: Ritik Jain <[email protected]>

* updated event enums

Signed-off-by: Ritik Jain <[email protected]>

* updated event enums

Signed-off-by: Ritik Jain <[email protected]>

* updated event enums

Signed-off-by: Ritik Jain <[email protected]>

* removed un necessary file

Signed-off-by: Ritik Jain <[email protected]>

* added async call for audits

Signed-off-by: Ritik Jain <[email protected]>

* updated method names

Signed-off-by: Ritik Jain <[email protected]>

* updated variable names

Signed-off-by: Ritik Jain <[email protected]>

* updated variable names

Signed-off-by: Ritik Jain <[email protected]>

* added default value

Signed-off-by: Ritik Jain <[email protected]>

* added separate value

Signed-off-by: Ritik Jain <[email protected]>

* updated property key

Signed-off-by: Ritik Jain <[email protected]>

* deleted one enum

Signed-off-by: Ritik Jain <[email protected]>

* removed refid and type from event enum

Signed-off-by: Ritik Jain <[email protected]>

* updated event type in event enum

Signed-off-by: Ritik Jain <[email protected]>

* removed generic type

Signed-off-by: Ritik Jain <[email protected]>

* removed generic type

Signed-off-by: Ritik Jain <[email protected]>

* updated constant

Signed-off-by: Ritik Jain <[email protected]>

---------

Signed-off-by: Ritik Jain <[email protected]>
Co-authored-by: Ritik Jain <[email protected]>
  • Loading branch information
RitikJain4108 and Ritik Jain authored Nov 14, 2023
1 parent 83c476c commit 99fd331
Show file tree
Hide file tree
Showing 6 changed files with 548 additions and 732 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ private RegistrationConstants() {
public static final String SINGLE = "single";
public static final String MULTIPLE = "multiple";
public static final String OTP_VALIDATION_SUCCESS = "success";
public static final String SUCCESS = "Success";
public static final String FAILURE = "Fail";
public static final String INFO = "INFO";
public static final String SPLITTER = "#TYPE#";
public static final String RESTART = "Restart";
public static final String SUPERVISOR = "REGISTRATION_SUPERVISOR";
Expand Down Expand Up @@ -1521,8 +1518,6 @@ public static List<String> fieldsToExclude() {
public static final String MESSAGE_CODE = "message";
public static final String TPM_PUBLIC_KEY_SYNC_SERVICE_NAME = "tpm_public_key";
public static final String SERIAL_NUMBER = "serialnumber";

public static final String SYSTEM="SYSTEM";

public static final String RESPONSE_SIGNATURE = "response-signature";
public static final String ON_BOARD_FACE = "FACE";
Expand Down Expand Up @@ -1679,11 +1674,12 @@ public static List<String> fieldsToExclude() {
public static final String DATETIME_PATTERN = "resident.datetime.pattern";
public static final String SYNCSTATUSCOMMENT = "UIN Reactivation and Deactivation By External Resources";
public static final String EXTENSION_OF_FILE = ".zip";


// Event enums
public static final String RESIDENT_APPLICATION_NAME="Resident Service";

public static final String RESIDENT_APPLICATION_ID="RES_SER";


public static final String SUCCESS = "Success";
public static final String FAILURE = "Failure";
public static final String INFO = "INFO";

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import io.mosip.resident.dto.AuditRequestDTO;
import io.mosip.resident.dto.AuthenticatedAuditRequestDto;
import io.mosip.resident.dto.UnauthenticatedAuditRequestDto;
import io.mosip.resident.exception.ApisResourceAccessException;
import io.mosip.resident.exception.ResidentServiceCheckedException;
import io.mosip.resident.util.AuditUtil;
import io.mosip.resident.util.Utility;
import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -53,9 +51,6 @@ public class ProxyAuditController {
*
* @param requestDto the authenticated audit request dto
* @return the response entity
* @throws ResidentServiceCheckedException the resident service checked exception
* @throws ApisResourceAccessException
* @throws NoSuchAlgorithmException
*/
@ResponseFilter
@Timed(value=API_RESPONSE_TIME_ID,description=API_RESPONSE_TIME_DESCRIPTION, percentiles = {0.5, 0.9, 0.95, 0.99} )
Expand All @@ -66,7 +61,7 @@ public class ProxyAuditController {
@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<?> authAuditLog(@RequestBody AuthenticatedAuditRequestDto requestDto, HttpServletRequest req) {
public ResponseEntity<Object> authAuditLog(@RequestBody AuthenticatedAuditRequestDto requestDto, HttpServletRequest req) {
AuditRequestDTO auditRequestDto=new AuditRequestDTO();
auditRequestDto.setEventId(requestDto.getAuditEventId());
auditRequestDto.setEventName(requestDto.getAuditEventName());
Expand Down Expand Up @@ -94,8 +89,6 @@ public ResponseEntity<?> authAuditLog(@RequestBody AuthenticatedAuditRequestDto
*
* @param requestDto the unauthenticated audit request dto
* @return the response entity
* @throws ResidentServiceCheckedException
* @throws ApisResourceAccessException
* @throws NoSuchAlgorithmException
*/
@ResponseFilter
Expand All @@ -107,7 +100,7 @@ public ResponseEntity<?> authAuditLog(@RequestBody AuthenticatedAuditRequestDto
@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<?> auditLog(@RequestBody UnauthenticatedAuditRequestDto requestDto, HttpServletRequest req)
public ResponseEntity<Object> auditLog(@RequestBody UnauthenticatedAuditRequestDto requestDto, HttpServletRequest req)
throws NoSuchAlgorithmException {
AuditRequestDTO auditRequestDto=new AuditRequestDTO();
auditRequestDto.setEventId(requestDto.getAuditEventId());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
package io.mosip.resident.service.impl;

import static io.mosip.resident.constant.ResidentConstants.VID_POLICIES;
import static io.mosip.resident.constant.ResidentConstants.VID_POLICY;

import java.io.IOException;
import java.net.URL;
import java.security.NoSuchAlgorithmException;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.stream.Collectors;

import javax.annotation.PostConstruct;

import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import io.mosip.idrepository.core.dto.VidPolicy;
import io.mosip.kernel.core.exception.ServiceError;
import io.mosip.kernel.core.logger.spi.Logger;
Expand All @@ -19,7 +45,6 @@
import io.mosip.resident.constant.RequestType;
import io.mosip.resident.constant.ResidentConstants;
import io.mosip.resident.constant.ResidentErrorCode;
import io.mosip.resident.constant.TemplateEnum;
import io.mosip.resident.constant.TemplateType;
import io.mosip.resident.constant.TemplateVariablesConstants;
import io.mosip.resident.dto.BaseVidRequestDto;
Expand Down Expand Up @@ -57,32 +82,9 @@
import io.mosip.resident.util.ResidentServiceRestClient;
import io.mosip.resident.util.Utilities;
import io.mosip.resident.util.Utility;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import reactor.util.function.Tuple2;
import reactor.util.function.Tuples;

import javax.annotation.PostConstruct;
import java.io.IOException;
import java.net.URL;
import java.security.NoSuchAlgorithmException;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.stream.Collectors;

import static io.mosip.resident.constant.ResidentConstants.VID_POLICIES;
import static io.mosip.resident.constant.ResidentConstants.VID_POLICY;

@Component
public class ResidentVidServiceImpl implements ResidentVidService {

Expand Down Expand Up @@ -223,7 +225,7 @@ public Tuple2<ResponseWrapper<VidResponseDto>, String> generateVidV2(BaseVidRequ
logger.debug(EventEnum.VID_GENERATED.getDescription(), requestDto.getTransactionID());
// send notification
Map<String, Object> additionalAttributes = new HashMap<>();
additionalAttributes.put(TemplateEnum.VID.name(), vidResponse.getVID());
additionalAttributes.put(IdType.VID.name(), vidResponse.getVID());
notificationRequestDto.setAdditionalAttributes(additionalAttributes);

NotificationResponseDTO notificationResponseDTO;
Expand Down Expand Up @@ -523,7 +525,7 @@ public Tuple2<ResponseWrapper<VidRevokeResponseDTO>, String> revokeVidV2(BaseVid
logger.debug(EventEnum.DEACTIVATED_VID.getDescription(), requestDto.getTransactionID());
// send notification
Map<String, Object> additionalAttributes = new HashMap<>();
additionalAttributes.put(TemplateEnum.VID.name(), vid);
additionalAttributes.put(IdType.VID.name(), vid);
notificationRequestDto.setAdditionalAttributes(additionalAttributes);

NotificationResponseDTO notificationResponseDTO;
Expand Down
Loading

0 comments on commit 99fd331

Please sign in to comment.