Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP-30099,MOSIP-30009,MOSIP-30026,MOSIP-19740:Bugfixes for admin-service #952

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Error code constants
*
*
* @author Bal Vikash Sharma
* @since 1.0.0
*/
Expand All @@ -11,8 +11,8 @@ public enum ApplicantTypeErrorCode {
NO_APPLICANT_FOUND_EXCEPTION("KER-MSD-147", "Applicant Type data does not exist"),
APPLICANT_TYPE_FETCH_EXCEPTION("KER-MSD-149",
"Error occurred while fetching Applicant Type-Document Category-Document Type Mapping details"),
APPLICANT_TYPE_NOT_FOUND_EXCEPTION("KER-MSD-150", "Document Category- Document Type mapping not found");

APPLICANT_TYPE_NOT_FOUND_EXCEPTION("KER-MSD-150", "Document Category- Document Type mapping not found"),
INVALID_ATTRIBUTE("KER-MSD-200", "Invalid value for attribute ");
private final String errorCode;
private final String errorMessage;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public enum BlocklistedWordsErrorCode {
BLOCKLISTED_WORDS_FETCH_EXCEPTION("KER-MSD-007", "Error occurred while fetching Blocklisted words"),
BLOCKLISTED_WORDS_INSERT_EXCEPTION("KER-MSD-070", "Error occurred while inserting Blocklisted words"),
BLOCKLISTED_WORDS_UPDATE_EXCEPTION("KER-MSD-105", "Error occurred while updating Blocklisted Word"),
BLOCKLISTED_WORDS_DELETE_EXCEPTION("KER-MSD-213", "Error occurred while deleting Blocklisted Word");
BLOCKLISTED_WORDS_DELETE_EXCEPTION("KER-MSD-213", "Error occurred while deleting Blocklisted Word"),
BLOCKLISTED_WORDS_INVALID_LANGUAGE_CODE("KER-MSD-202", "Invalid language code");

/**
* The error code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import java.time.LocalDateTime;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.fasterxml.jackson.annotation.JsonFormat;

import io.mosip.kernel.masterdata.validator.FilterType;
import io.mosip.kernel.masterdata.validator.FilterTypeEnum;
import io.mosip.kernel.masterdata.validator.StringFormatter;
import io.mosip.kernel.masterdata.validator.ValidLangCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
Expand Down Expand Up @@ -81,4 +83,12 @@ public class MachineExtnDto extends BaseDto {
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
private LocalDateTime validityDateTime;
}

@NotNull
@StringFormatter(min = 1, max = 36)
@ApiModelProperty(value = "zoneCode", required = true, dataType = "java.lang.String")
private String zoneCode;

@ApiModelProperty(value = "regCenterId", dataType = "java.lang.String")
private String regCenterId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,25 @@
import io.mosip.kernel.masterdata.exception.DataNotFoundException;
import io.mosip.kernel.masterdata.exception.RequestException;
import io.mosip.kernel.masterdata.service.ApplicantTypeService;
import org.springframework.beans.factory.annotation.Value;

@Service
public class ApplicantTypeServiceImpl implements ApplicantTypeService {

@Autowired
private ApplicantType applicantCodeService;
@Value("${mosip.kernel.masterdata.individualTypeCode}")
private String individualTypeCode;

@Value("${mosip.kernel.masterdata.genderCode}")
private String genderCode;

@Value("${mosip.kernel.masterdata.biometricAvailable}")
private String biometricAvailable;

/*
* (non-Javadoc)
*
*
* @see
* io.mosip.kernel.applicanttype.service.ApplicantTypeService#getApplicantType(
* io.mosip.kernel.applicanttype.dto.RequestDTO)
Expand All @@ -47,7 +56,27 @@ public ResponseDTO getApplicantType(RequestDTO dto) {
List<KeyValues<String, Object>> list = dto.getAttributes();
Map<String, Object> map = new HashMap<>();
for (KeyValues<String, Object> keyValues : list) {
map.put(keyValues.getAttribute(), keyValues.getValue());
String attribute = keyValues.getAttribute();
Object value = keyValues.getValue();

if ("residenceStatus".equals(attribute)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be handled here instead it should be checked in the mvel script. As of today if the provided values do not match any condition it returns "000"

if (value instanceof String && !individualTypeCode.contains((String) value)) {
throw new DataNotFoundException(ApplicantTypeErrorCode.INVALID_ATTRIBUTE.getErrorCode(),
ApplicantTypeErrorCode.INVALID_ATTRIBUTE.getErrorMessage()+attribute);
}
} else if ("gender".equals(attribute)) {
if (value instanceof String && !genderCode.contains((String) value)) {
throw new DataNotFoundException(ApplicantTypeErrorCode.INVALID_ATTRIBUTE.getErrorCode(),
ApplicantTypeErrorCode.INVALID_ATTRIBUTE.getErrorMessage()+attribute);
}
} else if ("biometricAvailable".equals(attribute)) {
if (value instanceof String && !biometricAvailable.contains((String) value)) {
throw new DataNotFoundException(ApplicantTypeErrorCode.INVALID_ATTRIBUTE.getErrorCode(),
ApplicantTypeErrorCode.INVALID_ATTRIBUTE.getErrorMessage()+attribute);
}
}

map.put(attribute, value);
}

ApplicantTypeCodeDTO appDto = new ApplicantTypeCodeDTO();
Expand All @@ -64,4 +93,4 @@ public ResponseDTO getApplicantType(RequestDTO dto) {
return response;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
import io.mosip.kernel.masterdata.validator.FilterColumnValidator;
import io.mosip.kernel.masterdata.validator.FilterTypeEnum;
import io.mosip.kernel.masterdata.validator.FilterTypeValidator;

import org.springframework.beans.factory.annotation.Value;
/**
* Service implementation class for {@link BlocklistedWordsService}.
*
Expand All @@ -70,7 +70,8 @@
*/
@Service
public class BlocklistedWordsServiceImpl implements BlocklistedWordsService {

@Value("${mosip.supported-languages}")
private String supportedLanguages;
/**
* Autowired reference for {@link BlocklistedWordsRepository}.
*/
Expand Down Expand Up @@ -119,6 +120,7 @@ public class BlocklistedWordsServiceImpl implements BlocklistedWordsService {
@Cacheable(value = "blocklisted-words", key = "'blocklistedword'.concat('-').concat(#langCode)", condition="#langCode != null")
@Override
public BlocklistedWordsResponseDto getAllBlocklistedWordsBylangCode(String langCode) {
validateLangCode(langCode);
List<BlocklistedWords> words = null;
try {
words = blocklistedWordsRepository.findAllByLangCode(langCode);
Expand All @@ -134,7 +136,13 @@ public BlocklistedWordsResponseDto getAllBlocklistedWordsBylangCode(String langC
throw new DataNotFoundException(BlocklistedWordsErrorCode.NO_BLOCKLISTED_WORDS_FOUND.getErrorCode(),
BlocklistedWordsErrorCode.NO_BLOCKLISTED_WORDS_FOUND.getErrorMessage());
}

private void validateLangCode(String langCode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we duplicating the code here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we are not duplicating the code

String[] supportedLanguagesArray = supportedLanguages.split(",");
if (!Arrays.asList(supportedLanguagesArray).contains(langCode)) {
throw new DataNotFoundException(BlocklistedWordsErrorCode.BLOCKLISTED_WORDS_INVALID_LANGUAGE_CODE.getErrorCode(),
BlocklistedWordsErrorCode.BLOCKLISTED_WORDS_INVALID_LANGUAGE_CODE.getErrorMessage());
}
}
/*
* (non-Javadoc)
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public IdAndLanguageCodeID createMachineSpecification(MachineSpecificationDto ma


try {
String uniqueId = generateId();
String uniqueId = machineSpecification.getId() != null ? machineSpecification.getId() : generateId();
machineSpecification.setId(uniqueId);
MachineSpecification entity = MetaDataUtils.setCreateMetaData(machineSpecification,
MachineSpecification.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ auth.server.admin.offline.token.validate=false
aplication.configuration.level.version=1.1.5
mosip.optional-languages=
mosip.mandatory-languages=eng
mosip.supported-languages=eng,ara,fra
auth.server.validate.url=https://dev.mosip.net/v1/authmanager/authorize/admin/validateToken
auth.server.admin.validate.url=https://dev.mosip.net/v1/authmanager/authorize/admin/validateToken

Expand Down Expand Up @@ -397,4 +398,9 @@ mosip.role.admin.masterdata.getdynamicfieldmissingidslangcode=GLOBAL_ADMIN,ZONAL

zone.user.details.url=https://dev.mosip.net/v1/authmanager/userdetails
mosip.kernel.masterdata.code.validate.regex=[^a-z0-9]
mosip.kernel.masterdata.name.validate.regex=[^A-Za-z]
mosip.kernel.masterdata.name.validate.regex=[^A-Za-z]

#Properties for applicant type
mosip.kernel.masterdata.individualTypeCode=FR,NFR
mosip.kernel.masterdata.genderCode=MLE,FLE
mosip.kernel.masterdata.biometricAvailable=true,false