| | |
| | | |
| | | if (companyFieldForm.getIpStart() != null && companyFieldForm.getIpEnd() != null) { |
| | | // 아이피 유효성 체크 |
| | | this.verifyIp(companyFieldForm.getIpStart(), companyFieldForm.getIpEnd()); |
| | | this.verifyIp(companyFieldForm.getIpStart(), companyFieldForm.getIpEnd(), null); |
| | | } |
| | | |
| | | if (companyFieldForm.getUrl() != null) { |
| | |
| | | * IP 유효성 체크 |
| | | * @param ip String |
| | | */ |
| | | private void verifyIp(String ip, String ip2) { |
| | | if (ip2 == null) { |
| | | if (!StringUtils.isEmpty(ip)) { |
| | | if (!Pattern.matches("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\" + |
| | | ".(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", ip)) { |
| | | throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.IP_NOT_INVALID)); |
| | | } |
| | | private void verifyIp(String ip, String ip2, Long id) { |
| | | if (!StringUtils.isEmpty(ip)) { |
| | | if (!Pattern.matches("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\" + |
| | | ".(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", ip)) { |
| | | throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.IP_NOT_INVALID)); |
| | | } |
| | | } else { |
| | | if (!StringUtils.isEmpty(ip)) { |
| | | long ipStart = ConvertUtil.ipToLong(ip); |
| | | long ipEnd = ConvertUtil.ipToLong(ip2); |
| | | if (ipEnd < ipStart) { |
| | | throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.IP_START_NOT_LARGER_THAN_END)); |
| | | } |
| | | } |
| | | if (!StringUtils.isEmpty(ip2)) { |
| | | if (!Pattern.matches("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\" + |
| | | ".(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$", ip2)) { |
| | | throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.IP_NOT_INVALID)); |
| | | } |
| | | } |
| | | |
| | | if (!StringUtils.isEmpty(ip) && !StringUtils.isEmpty(ip2)) { |
| | | long ipStart = ConvertUtil.ipToLong(ip); |
| | | long ipEnd = ConvertUtil.ipToLong(ip2); |
| | | if (ipEnd < ipStart) { |
| | | throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.IP_START_NOT_LARGER_THAN_END)); |
| | | } |
| | | |
| | | List<CompanyField> companyFields = Lists.newArrayList(); |
| | | CompanyFieldCondition condition = new CompanyFieldCondition(); |
| | | condition.setIpStart(String.valueOf(ipStart)); |
| | | condition.setIpEnd(String.valueOf(ipEnd)); |
| | | if (id != null) { |
| | | condition.setId(id); |
| | | companyFields = this.companyFieldMapper.findByIpsAndIdNot(condition); |
| | | } else { |
| | | companyFields = this.companyFieldMapper.findByIps(condition); |
| | | } |
| | | |
| | | // IP대역대 중복 체크 |
| | | if (companyFields != null && companyFields.size() > 0) { |
| | | throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.COMPANY_EXIST_IP)); |
| | | } |
| | | } |
| | | } |
| | |
| | | public void modifyCompany(CompanyFieldForm companyFieldForm) { |
| | | // 업체명 유효성 체크 |
| | | this.verifyTitle(companyFieldForm.getName(), companyFieldForm.getId()); |
| | | |
| | | if (companyFieldForm.getIpStart() != null && companyFieldForm.getIpEnd() != null) { |
| | | // 아이피 유효성 체크 |
| | | this.verifyIp(companyFieldForm.getIpStart(), companyFieldForm.getIpEnd(), companyFieldForm.getId()); |
| | | } |
| | | |
| | | if (companyFieldForm.getUrl() != null) { |
| | | // url 유효성 체크 |
| | |
| | | // 업체로 등록하기 위해 CompanyFieldForm 에 데이터를 셋팅한다. |
| | | CompanyFieldForm newCompanyFieldForm = this.setCompanyFieldFormToExcelField(row, (rowIndex + 1), ispFieldMaps, hostingFieldMaps, companyTypeMaps, parentSectorMaps, childSectorMaps, regionMaps, statusMaps, headers); |
| | | // ip 유효성 체크 |
| | | this.verifyIp(newCompanyFieldForm.getIpStart(), newCompanyFieldForm.getIpEnd()); |
| | | this.verifyIp(newCompanyFieldForm.getIpStart(), newCompanyFieldForm.getIpEnd(), null); |
| | | |
| | | companyFieldForms.add(newCompanyFieldForm); |
| | | } |
| | |
| | | if (ipEnd.contains(" ")) { |
| | | ipEnd = ipEnd.replace(" ", ""); |
| | | } |
| | | this.verifyIp(ipEnd, null); //ip 유효성 검사 |
| | | this.verifyIp(ipEnd, null, null); //ip 유효성 검사 |
| | | |
| | | companyFieldForm.setIpEnd(ipEnd); |
| | | } |
| | |
| | | if (ipStart.contains(" ")) { |
| | | ipStart = ipStart.replace(" ", ""); |
| | | } |
| | | this.verifyIp(ipStart, null); //ip 유효성 검사 |
| | | this.verifyIp(ipStart, null, null); //ip 유효성 검사 |
| | | |
| | | companyFieldForm.setIpStart(ipStart); |
| | | } |