[SonarQube][FindBugs] duplicating this literal, SafeLogger

This commit is contained in:
김현주
2025-07-21 14:40:40 +09:00
parent 1748bd62fb
commit 0be90dc915
30 changed files with 227 additions and 157 deletions

View File

@@ -30,6 +30,7 @@ public class AdminURIInterceptor implements HandlerInterceptor {
private final URICurrentMatchingPortIn uriCurrentMatchingPortIn;
private final URIAncestryPortIn uriAncestryPortIn;
private final URITopTierPortIn topTierPortIn;
@Value("${spring.profiles.active}")
private String activeProfiles;
@@ -39,6 +40,11 @@ public class AdminURIInterceptor implements HandlerInterceptor {
@Value("${app.aws.s3.bucketFolder:null}")
private String bucketFolder;
/**
* AttributeName: currentURI
*/
private static final String ATTR_NAME_URI = "currentURI";
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler)
@@ -57,7 +63,7 @@ public class AdminURIInterceptor implements HandlerInterceptor {
throw new NoMatchingURIException(String.format("매핑되는 않은 URI - %s", requestURI));
}
request.setAttribute("currentURI", currentURI);
request.setAttribute(ATTR_NAME_URI, currentURI);
return true;
}
@@ -83,8 +89,8 @@ public class AdminURIInterceptor implements HandlerInterceptor {
URITopTier topTierOutput = topTierPortIn.connectRoleId(AppType.ADMIN,roleId);
modelAndView.addObject("topNode", recursiveMapping(topTierOutput));
if (modelAndView.getModelMap().getAttribute("currentURI") == null) {
modelAndView.addObject("currentURI", request.getAttribute("currentURI"));
if (modelAndView.getModelMap().getAttribute(ATTR_NAME_URI) == null) {
modelAndView.addObject(ATTR_NAME_URI, request.getAttribute(ATTR_NAME_URI));
}
modelAndView.addObject("menuHierarchy", uriAncestryPortIn.connect(AppType.ADMIN, request.getRequestURI()));

View File

@@ -1,8 +1,10 @@
package app.module.admin.usecase.admin.saveAdmin.adapters.web.validator;
import app.module.admin.usecase.admin.saveAdmin.adapters.web.model.AdminCreateBindingVO;
import app.module.core.config.application.util.MessageUtil;
import app.module.core.config.constants.CommonConstants;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
@@ -12,6 +14,9 @@ import java.util.Optional;
@Component
public class AdminCreateValidator implements Validator {
@Autowired
private MessageUtil messageUtil;
@Override
public boolean supports(Class<?> clazz) {
return AdminCreateBindingVO.class.equals(clazz);
@@ -23,30 +28,30 @@ public class AdminCreateValidator implements Validator {
// [1] 필수값 누락 체크
if(StringUtils.isBlank(vo.getRoleId())) {
errors.rejectValue("roleId", "error.roleId", "필수입력항목을 확인해주세요.");
errors.rejectValue("roleId", "error.roleId", messageUtil.getMessage("valid.common.required.ask"));
return;
}
if(StringUtils.isBlank(vo.getId())) {
errors.rejectValue("id", "error.id", "필수입력항목을 확인해주세요.");
errors.rejectValue("id", "error.id", messageUtil.getMessage("valid.common.required.ask"));
return;
}
if(StringUtils.isBlank(vo.getPassword())) {
errors.rejectValue("password", "error.password", "필수입력항목을 확인해주세요.");
errors.rejectValue("password", "error.password", messageUtil.getMessage("valid.common.required.ask"));
return;
}
// 권한 조사원으로 선택했을 경우
if("ROLE_RESEARCHER".equals(vo.getRoleId())) {
if(StringUtils.isBlank(vo.getName())) {
errors.rejectValue("name", "error.name", "필수입력항목을 확인해주세요.");
errors.rejectValue("name", "error.name", messageUtil.getMessage("valid.common.required.ask"));
return;
}
if(StringUtils.isBlank(vo.getPhone1())) {
errors.rejectValue("phone1", "error.phone1", "필수입력항목을 확인해주세요.");
errors.rejectValue("phone1", "error.phone1", messageUtil.getMessage("valid.common.required.ask"));
return;
}
if(StringUtils.isBlank(vo.getPhone2())) {
errors.rejectValue("phone2", "error.phone2", "필수입력항목을 확인해주세요.");
errors.rejectValue("phone2", "error.phone2", messageUtil.getMessage("valid.common.required.ask"));
return;
}
if (!vo.getPhone1().matches("^\\d{4}$")) {
@@ -60,7 +65,7 @@ public class AdminCreateValidator implements Validator {
}
if(vo.getAccountDisabled() == null) {
errors.rejectValue("accountDisabled", "error.accountDisabled", "필수입력항목을 확인해주세요.");
errors.rejectValue("accountDisabled", "error.accountDisabled", messageUtil.getMessage("valid.common.required.ask"));
return;
}
@@ -69,7 +74,7 @@ public class AdminCreateValidator implements Validator {
.filter(id -> !id.equals("ROLE_ADMIN"))
.ifPresent(nonAdmins -> {
if (vo.getRegionMainCode() == null || vo.getRegionMainCode().isBlank()) {
errors.rejectValue("regionMainCode", "valid.common.required","필수입력항목을 확인해주세요.");
errors.rejectValue("regionMainCode", "valid.common.required.ask");
}
});

View File

@@ -1,7 +1,9 @@
package app.module.admin.usecase.admin.saveAdmin.adapters.web.validator;
import app.module.admin.usecase.admin.saveAdmin.adapters.web.model.AdminUpdateBindingVO;
import app.module.core.config.application.util.MessageUtil;
import app.module.core.config.constants.CommonConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
@@ -11,6 +13,9 @@ import java.util.Optional;
@Component
public class AdminUpdateValidator implements Validator {
@Autowired
private MessageUtil messageUtil;
@Override
public boolean supports(Class<?> clazz) {
return AdminUpdateBindingVO.class.equals(clazz);
@@ -22,22 +27,22 @@ public class AdminUpdateValidator implements Validator {
// [1] 필수값 누락 체크
if(vo.getRoleId() == null || vo.getRoleId().isEmpty()) {
errors.rejectValue("roleId", "error.roleId", "필수입력항목을 확인해주세요.");
errors.rejectValue("roleId", "error.roleId", messageUtil.getMessage("valid.common.required.ask"));
return;
}
// 권한 조사원으로 선택했을 경우
if(vo.getRoleId() != null && "ROLE_RESEARCHER".equals(vo.getRoleId())) {
if(vo.getName() == null || vo.getName().isEmpty()) {
errors.rejectValue("name", "error.name", "필수입력항목을 확인해주세요.");
errors.rejectValue("name", "error.name", messageUtil.getMessage("valid.common.required.ask"));
return;
}
if(vo.getPhone1() == null || vo.getPhone1().isBlank()) {
errors.rejectValue("phone1", "error.phone1", "필수입력항목을 확인해주세요.");
errors.rejectValue("phone1", "error.phone1", messageUtil.getMessage("valid.common.required.ask"));
return;
}
if(vo.getPhone2() == null || vo.getPhone2().isBlank()) {
errors.rejectValue("phone2", "error.phone2", "필수입력항목을 확인해주세요.");
errors.rejectValue("phone2", "error.phone2", messageUtil.getMessage("valid.common.required.ask"));
return;
}
if (!vo.getPhone1().matches("^\\d{4}$")) {
@@ -52,7 +57,7 @@ public class AdminUpdateValidator implements Validator {
// 사용여부
if(vo.getAccountDisabled() == null) {
errors.rejectValue("accountDisabled", "error.accountDisabled", "필수입력항목을 확인해주세요.");
errors.rejectValue("accountDisabled", "error.accountDisabled", messageUtil.getMessage("valid.common.required.ask"));
return;
}
@@ -61,7 +66,7 @@ public class AdminUpdateValidator implements Validator {
.filter(id -> !id.equals("ROLE_ADMIN"))
.ifPresent(nonAdmins -> {
if (vo.getRegionMainCode() == null || vo.getRegionMainCode().isBlank()) {
errors.rejectValue("regionMainCode", "valid.common.required","필수입력항목을 확인해주세요.");
errors.rejectValue("regionMainCode", "valid.common.required",messageUtil.getMessage("valid.common.required.ask"));
}
});

View File

@@ -238,11 +238,19 @@ class ExcelUploadCreateHouseholdDao implements ExcelUploadCreateHouseholdPortOut
}
private String getUsageType(Cell cell){
if (cell == null) return "MOBILE";
String returnValue = "MOBILE";
if (cell == null) {
return returnValue;
}
String usageType = cell.getStringCellValue().trim();
if("모바일".equals(usageType) ) return "MOBILE";
if("지류".equals(usageType) ) return "PAPER";
return "MOBILE";
if ("모바일".equals(usageType)) {
returnValue = "MOBILE";
}
if ("지류".equals(usageType)) {
returnValue = "PAPER";
}
return returnValue;
}
private boolean isValidHousehold(ExcelCreateHouseholdVO household, CheckHouseholdNum checkHouseholdNum, ExcelUploadContactVO contactVO) {

View File

@@ -23,28 +23,28 @@ public class SaveDailyExpenseValidator implements Validator {
if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) {
errors.rejectValue(
"quantity", "valid.common.required",
"quantity", CommonConstants.VALID_CODE_NOTBLANK,
"수량을 입력해 주세요.");
}
if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) {
errors.rejectValue(
"unitCode", "valid.common.required",
"unitCode", CommonConstants.VALID_CODE_NOTBLANK,
"단위를 선택해 주세요.");
}
if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) {
errors.rejectValue(
"unitSelf", "valid.common.required",
"unitSelf", CommonConstants.VALID_CODE_NOTBLANK,
"단위를 입력해 주세요.");
}
if (vo.getPrice() == null && vo.getEstimatedValue() == null) {
errors.rejectValue(
"price", "valid.common.required",
"price", CommonConstants.VALID_CODE_NOTBLANK,
"현금 또는 현물평가액을 입력해 주세요.");
errors.rejectValue(
"estimatedValue", "valid.common.required",
"estimatedValue", CommonConstants.VALID_CODE_NOTBLANK,
"현금 또는 현물평가액을 입력해 주세요.");
}
}

View File

@@ -22,31 +22,31 @@ public class SaveDailyFarmingValidator implements Validator {
if ("code.record.farming.self".equals(vo.getProductCode()) && StringUtils.isBlank(vo.getProductSelf())) {
errors.rejectValue(
"productSelf", "valid.common.required",
"productSelf", CommonConstants.VALID_CODE_NOTBLANK,
"생산물을 입력해 주세요.");
}
if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) {
errors.rejectValue(
"quantity", "valid.common.required",
"quantity", CommonConstants.VALID_CODE_NOTBLANK,
"수량을 입력해 주세요.");
}
if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) {
errors.rejectValue(
"unitCode", "valid.common.required",
"unitCode", CommonConstants.VALID_CODE_NOTBLANK,
"단위를 선택해 주세요.");
}
if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) {
errors.rejectValue(
"unitSelf", "valid.common.required",
"unitSelf", CommonConstants.VALID_CODE_NOTBLANK,
"단위를 입력해 주세요.");
}
if (vo.getEstimatedValue() == null) {
errors.rejectValue(
"estimatedValue", "valid.common.required",
"estimatedValue", CommonConstants.VALID_CODE_NOTBLANK,
"현물평가액을 입력해 주세요.");
}
}

View File

@@ -22,25 +22,25 @@ public class SaveDailyForestryValidator implements Validator {
if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) {
errors.rejectValue(
"quantity", "valid.common.required",
"quantity", CommonConstants.VALID_CODE_NOTBLANK,
"수량을 입력해 주세요.");
}
if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) {
errors.rejectValue(
"unitCode", "valid.common.required",
"unitCode", CommonConstants.VALID_CODE_NOTBLANK,
"단위를 선택해 주세요.");
}
if (CommonConstants.UNIT_CODE_SELF.equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) {
errors.rejectValue(
"unitSelf", "valid.common.required",
"unitSelf", CommonConstants.VALID_CODE_NOTBLANK,
"단위를 입력해 주세요.");
}
if (vo.getEstimatedValue() == null) {
errors.rejectValue(
"estimatedValue", "valid.common.required",
"estimatedValue", CommonConstants.VALID_CODE_NOTBLANK,
"현물평가액을 입력해 주세요.");
}
}

View File

@@ -1,6 +1,7 @@
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.adapters.web.validator;
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyIncome.adapters.web.model.SaveDailyIncomeReqVO;
import app.module.core.config.constants.CommonConstants;
import lombok.RequiredArgsConstructor;
import org.apache.tika.utils.StringUtils;
import org.springframework.stereotype.Component;
@@ -22,28 +23,28 @@ public class SaveDailyIncomeValidator implements Validator {
if (vo.getQuantity() == null && !StringUtils.isBlank(vo.getUnitCode())) {
errors.rejectValue(
"quantity", "valid.common.required",
"quantity", CommonConstants.VALID_CODE_NOTBLANK,
"수량을 입력해 주세요.");
}
if (vo.getQuantity() != null && StringUtils.isBlank(vo.getUnitCode())) {
errors.rejectValue(
"unitCode", "valid.common.required",
"unitCode", CommonConstants.VALID_CODE_NOTBLANK,
"단위를 선택해 주세요.");
}
if ("code.record.unit.self".equals(vo.getUnitCode()) && StringUtils.isBlank(vo.getUnitSelf())) {
errors.rejectValue(
"unitSelf", "valid.common.required",
"unitSelf", CommonConstants.VALID_CODE_NOTBLANK,
"단위를 입력해 주세요.");
}
if (vo.getPrice() == null && vo.getEstimatedValue() == null) {
errors.rejectValue(
"price", "valid.common.required",
"price", CommonConstants.VALID_CODE_NOTBLANK,
"현금 또는 현물평가액을 입력해 주세요.");
errors.rejectValue(
"estimatedValue", "valid.common.required",
"estimatedValue", CommonConstants.VALID_CODE_NOTBLANK,
"현금 또는 현물평가액을 입력해 주세요.");
}
}

View File

@@ -1,6 +1,7 @@
package app.module.admin.usecase.household.tab.dailyRecord.saveDailyPower.adapters.web.validator;
import app.module.admin.usecase.household.tab.dailyRecord.saveDailyPower.adapters.web.model.SaveDailyPowerReqVO;
import app.module.core.config.constants.CommonConstants;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
@@ -20,10 +21,10 @@ public class SaveDailyPowerValidator implements Validator {
if (vo.getOwnedHours() == null && vo.getLeasedHours() == null) {
errors.rejectValue(
"ownedHours", "valid.common.required",
"ownedHours", CommonConstants.VALID_CODE_NOTBLANK,
"자가 사용시간 또는 임차 사용시간을 입력해 주세요.");
errors.rejectValue(
"leasedHours", "valid.common.required",
"leasedHours", CommonConstants.VALID_CODE_NOTBLANK,
"자가 사용시간 또는 임차 사용시간을 입력해 주세요.");
}
}

View File

@@ -22,37 +22,37 @@ public class SaveDailyWorkValidator implements Validator {
if (vo.getWorkLandArea() == null && !StringUtils.isBlank(vo.getAreaUnitCode())) {
errors.rejectValue(
"workLandArea", "valid.common.required",
"workLandArea", CommonConstants.VALID_CODE_NOTBLANK,
"작업 면적을 입력해 주세요.");
}
if (vo.getWorkLandArea() != null && StringUtils.isBlank(vo.getAreaUnitCode())) {
errors.rejectValue(
"areaUnitCode", "valid.common.required",
"areaUnitCode", CommonConstants.VALID_CODE_NOTBLANK,
"단위를 선택해 주세요.");
}
if (CommonConstants.AREA_CODE_OTHER.equals(vo.getAreaUnitCode()) && StringUtils.isBlank(vo.getAreaUnitSelf())) {
errors.rejectValue(
"areaUnitSelf", "valid.common.required",
"areaUnitSelf", CommonConstants.VALID_CODE_NOTBLANK,
"단위를 입력해 주세요.");
}
if (vo.getHarvestQuantity() == null && !StringUtils.isBlank(vo.getHarvestUnitCode())) {
errors.rejectValue(
"harvestQuantity", "valid.common.required",
"harvestQuantity", CommonConstants.VALID_CODE_NOTBLANK,
"수확량을 입력해 주세요.");
}
if (vo.getHarvestQuantity() != null && StringUtils.isBlank(vo.getHarvestUnitCode())) {
errors.rejectValue(
"harvestUnitCode", "valid.common.required",
"harvestUnitCode", CommonConstants.VALID_CODE_NOTBLANK,
"단위를 선택해 주세요.");
}
if (CommonConstants.UNIT_CODE_SELF.equals(vo.getHarvestUnitCode()) && StringUtils.isBlank(vo.getHarvestUnitSelf())) {
errors.rejectValue(
"harvestUnitSelf", "valid.common.required",
"harvestUnitSelf", CommonConstants.VALID_CODE_NOTBLANK,
"단위를 입력해 주세요.");
}
@@ -61,16 +61,16 @@ public class SaveDailyWorkValidator implements Validator {
&& vo.getHiredMHours() == null && vo.getHiredFHours() == null
&& vo.getSharedMHours() == null && vo.getSharedFHours() == null
&& vo.getVolunteerMHours() == null && vo.getVolunteerFHours() == null) {
errors.rejectValue("ownerTime", "valid.common.required", "최소 1개의 노동투입시간을 입력해 주세요.");
errors.rejectValue("spouseTime", "valid.common.required");
errors.rejectValue("familyMHours", "valid.common.required");
errors.rejectValue("familyFHours", "valid.common.required");
errors.rejectValue("hiredMHours", "valid.common.required");
errors.rejectValue("hiredFHours", "valid.common.required");
errors.rejectValue("sharedMHours", "valid.common.required");
errors.rejectValue("sharedFHours", "valid.common.required");
errors.rejectValue("volunteerMHours", "valid.common.required");
errors.rejectValue("volunteerFHours", "valid.common.required");
errors.rejectValue("ownerTime", CommonConstants.VALID_CODE_NOTBLANK, "최소 1개의 노동투입시간을 입력해 주세요.");
errors.rejectValue("spouseTime", CommonConstants.VALID_CODE_NOTBLANK);
errors.rejectValue("familyMHours", CommonConstants.VALID_CODE_NOTBLANK);
errors.rejectValue("familyFHours", CommonConstants.VALID_CODE_NOTBLANK);
errors.rejectValue("hiredMHours", CommonConstants.VALID_CODE_NOTBLANK);
errors.rejectValue("hiredFHours", CommonConstants.VALID_CODE_NOTBLANK);
errors.rejectValue("sharedMHours", CommonConstants.VALID_CODE_NOTBLANK);
errors.rejectValue("sharedFHours", CommonConstants.VALID_CODE_NOTBLANK);
errors.rejectValue("volunteerMHours", CommonConstants.VALID_CODE_NOTBLANK);
errors.rejectValue("volunteerFHours", CommonConstants.VALID_CODE_NOTBLANK);
}
}
}

View File

@@ -1,4 +1,5 @@
valid.common.required=\uD544\uC218\uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.
valid.common.required.ask=\uD544\uC218\uC785\uB825\uD56D\uBAA9\uC744 \uD655\uC778\uD574\uC8FC\uC138\uC694.
valid.common.required.size={0} \uAC1C \uD56D\uBAA9\uC774 \uB2F4\uACA8\uC788\uC5B4\uC57C \uD569\uB2C8\uB2E4.
valid.common.required.size.min={0} \uAC1C \uC774\uC0C1 \uD56D\uBAA9\uC774 \uD544\uC694\uD569\uB2C8\uB2E4.
valid.common.required.remove.item=\uC0AD\uC81C\uD560 \uC544\uC774\uD15C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.