OWL ITS + 탐지시스템(인터넷 진흥원)
src/main/java/kr/wisestone/owl/service/impl/CompanyFieldServiceImpl.java
@@ -83,8 +83,11 @@
    public CompanyField addCompany(CompanyFieldForm companyFieldForm) {
        //  업체명 중복 체크
        this.verifyTitle(companyFieldForm.getName(), null);
        //  url 유효성 체크
        this.verifyUrl(companyFieldForm.getUrl(), null);
        if (companyFieldForm.getUrl() != null) {
            //  url 유효성 체크
            this.verifyUrl(companyFieldForm.getUrl(), null);
        }
        if (companyFieldForm.getTelList() != null && companyFieldForm.getTelList().size() > 0) {
            String tels = companyFieldForm.getTelList().toString();
@@ -109,12 +112,11 @@
    //  url 유효성 체크
    private void verifyUrl(String url, Long id) {
        if (StringUtils.isEmpty(url)) {
        /*if (StringUtils.isEmpty(url)) {
            throw new OwlRuntimeException(
                    this.messageAccessor.getMessage(MsgConstants.COMPANY_NOT_URL));
        }
        }*/
        CompanyField companyField;
        if(id == null){
            companyField = this.companyFieldRepository.findByUrl(url);
        } else {
@@ -222,8 +224,11 @@
    public void modifyCompany(CompanyFieldForm companyFieldForm) {
        //  업체명 유효성 체크
        this.verifyTitle(companyFieldForm.getName(), companyFieldForm.getId());
        //  url 유효성 체크
        this.verifyUrl(companyFieldForm.getUrl(), companyFieldForm.getId());
        if (companyFieldForm.getUrl() != null) {
            //  url 유효성 체크
            this.verifyUrl(companyFieldForm.getUrl(), companyFieldForm.getId());
        }
        if (companyFieldForm.getTelList() != null && companyFieldForm.getTelList().size() > 0) {
            String tels = companyFieldForm.getTelList().toString();
@@ -242,7 +247,7 @@
        if (companyFieldForm.getChildSectorId() != null) {
            CompanyFieldCategory companyFieldCategory = this.companyFieldCategoryService.find(companyFieldForm.getChildSectorId());
            if (!companyFieldCategory.getParentId().equals(companyFieldForm.getParentSectorId())) {
            if (companyFieldCategory != null && !companyFieldCategory.getParentId().equals(companyFieldForm.getParentSectorId())) {
                throw new OwlRuntimeException(
                        this.messageAccessor.getMessage(MsgConstants.PARENT_SECTOR_NOT_EQUAL));
            }
@@ -438,7 +443,17 @@
     * @return boolean
     */
    private Boolean cellNullCheck (Cell cell) {
        return cell != null && cell.getStringCellValue() != null && cell.getCellType() != Cell.CELL_TYPE_BLANK;
        if (cell != null && cell.getStringCellValue() != null) {
            cell.setCellValue(cell.getStringCellValue().trim());//셀 값 공백 제거
        }
        return cell != null && cell.getStringCellValue() != null && !cell.getStringCellValue().equals("") && cell.getCellType() != Cell.CELL_TYPE_BLANK;
    }
    private void telTypeCheck (Cell cell, int rowIndex) {
        if (cell.getCellType() != cell.CELL_TYPE_STRING) {
            throw new OwlRuntimeException(
                    this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_TEL_NOT_STRING_TYPE, rowIndex));
        }
    }
    //  엑셀 필드에 있는 정보를 업체 form 으로 옮긴다.
@@ -459,7 +474,9 @@
                case 1:
                    //  url
                    this.setCompanyFormUrl(cell, companyFieldForm, rowIndex);
                    if (cellNullCheck(cell)) {
                        this.setCompanyFormUrl(cell, companyFieldForm, rowIndex);
                    }
                    break;
                case 2:
@@ -478,6 +495,8 @@
                case 4:
                    // 연락처
                    this.telTypeCheck(cell, rowIndex); // 텍스트 형식 체크
                    if (cellNullCheck(cell)) {
                        this.setCompanyFormTel(cell, companyFieldForm, rowIndex);
                    }
@@ -678,17 +697,15 @@
    }
    private void setCompanyFormUrl(Cell cell, CompanyFieldForm companyFieldForm, int rowIndex) {
        if (cell == null) {
            throw new OwlRuntimeException(
                    this.messageAccessor.getMessage(MsgConstants.EXCEL_IMPORT_URL_IS_NULL, rowIndex));
        }
        String url = CommonUtil.convertExcelStringToCell(cell);
        if (url.contains(" ")) {
            url = url.replace(" ", "");
        }
        this.verifyUrl(url, null); //url 유효성 검사
        if (cell != null) {
            String url = CommonUtil.convertExcelStringToCell(cell);
            if (url.contains(" ")) {
                url = url.replace(" ", "");
            }
            this.verifyUrl(url, null); //url 유효성 검사
        companyFieldForm.setUrl(url);
            companyFieldForm.setUrl(url);
        }
    }
    //  업체명 유효성 체크