All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.mosip.pms.device.validator.PurposeValidator Maven / Gradle / Ivy

The newest version!
package io.mosip.pms.device.validator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import org.springframework.web.client.RestClientException;

import io.mosip.kernel.core.util.EmptyCheckUtils;
import io.mosip.pms.common.exception.RequestException;
import io.mosip.pms.device.constant.RegisteredDeviceErrorCode;
import lombok.Data;

@Data
public class PurposeValidator implements ConstraintValidator{
	@Override
	public boolean isValid(String statusCode, ConstraintValidatorContext context) {
		if (EmptyCheckUtils.isNullEmpty(statusCode)) {
			return false;
		} else {
			try {

				for (String string : RegisteredDeviceConstant.PURPOSEARR) {
					if (statusCode.equalsIgnoreCase(string)) {
						return true;
					}
				}
			} catch (RestClientException e) {
				throw new RequestException(RegisteredDeviceErrorCode.PURPOSE_VALIDATION_EXCEPTION.getErrorCode(),
						RegisteredDeviceErrorCode.PURPOSE_VALIDATION_EXCEPTION.getErrorMessage() + " "
								+ e.getMessage());
			}
			return false;
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy