src/main/java/org/edgegallery/appstore/domain/model/releases/AbstractFileChecker.java
public static String checkByPath(String filePath) {
        filePath = Normalizer.normalize(filePath, Normalizer.Form.NFKC);

        if (StringUtils.isEmpty(filePath)) {
            throw new IllegalRequestException(filePath + " :filepath is empty",
                ResponseConst.RET_FILE_PATH_INVALID);
        }

        // file name should not contains blank.
        if (filePath.split(BLANK_REG).length > 1) {
            throw new IllegalRequestException(filePath + " :filepath contain blank",
                ResponseConst.RET_FILE_PATH_INVALID);
        }

        String name = filePath.toLowerCase();
        if (!extensions.contains(name.substring(name.lastIndexOf(".")))) {
            throw new IllegalRequestException(filePath + " :filepath doesn't have file extension",
                ResponseConst.RET_FILE_PATH_INVALID);
        }

        String[] dirs = filePath.split(":");
        for (String dir : dirs) {
            Matcher matcher = Pattern.compile(AbstractFileChecker.REG).matcher(dir);
            if (!matcher.matches()) {
                throw new IllegalRequestException(filePath + " :filepath isn't regular",
                    ResponseConst.RET_FILE_PATH_INVALID);
            }
        }
        return filePath.replace(":", File.separator);
    }
/**
     * check if file path is valid.
     *
     * @param filePath file path.
     *
     */
check if file path is valid.
@param filePath file path.
check if file path is valid . @param filePath file path .
public static String checkByPath(String filePath) {
        filePath = Normalizer.normalize(filePath, Normalizer.Form.NFKC);
        if (StringUtils.isEmpty(filePath)) {
            throw new IllegalRequestException(filePath + " :filepath is empty",
                ResponseConst.RET_FILE_PATH_INVALID);
        }
        if (filePath.split(BLANK_REG).length > 1) {
            throw new IllegalRequestException(filePath + " :filepath contain blank",
                ResponseConst.RET_FILE_PATH_INVALID);
        }
        String name = filePath.toLowerCase();
        if (!extensions.contains(name.substring(name.lastIndexOf(".")))) {
            throw new IllegalRequestException(filePath + " :filepath doesn't have file extension",
                ResponseConst.RET_FILE_PATH_INVALID);
        }
        String[] dirs = filePath.split(":");
        for (String dir : dirs) {
            Matcher matcher = Pattern.compile(AbstractFileChecker.REG).matcher(dir);
            if (!matcher.matches()) {
                throw new IllegalRequestException(filePath + " :filepath isn't regular",
                    ResponseConst.RET_FILE_PATH_INVALID);
            }
        }
        return filePath.replace(":", File.separator);
    }
public static String checkByPath ( String filePath ) { filePath = Normalizer . normalize ( filePath , Normalizer . Form . NFKC ) ; if ( StringUtils . isEmpty ( filePath ) ) { throw new IllegalRequestException ( filePath + " :filepath is empty" , ResponseConst . RET_FILE_PATH_INVALID ) ; } if ( filePath . split ( BLANK_REG ) . length > 1 ) { throw new IllegalRequestException ( filePath + " :filepath contain blank" , ResponseConst . RET_FILE_PATH_INVALID ) ; } String name = filePath . toLowerCase ( ) ; if ( ! extensions . contains ( name . substring ( name . lastIndexOf ( "." ) ) ) ) { throw new IllegalRequestException ( filePath + " :filepath doesn't have file extension" , ResponseConst . RET_FILE_PATH_INVALID ) ; } String [ ] dirs = filePath . split ( ":" ) ; for ( String dir : dirs ) { Matcher matcher = Pattern . compile ( AbstractFileChecker . REG ) . matcher ( dir ) ; if ( ! matcher . matches ( ) ) { throw new IllegalRequestException ( filePath + " :filepath isn't regular" , ResponseConst . RET_FILE_PATH_INVALID ) ; } } return filePath . replace ( ":" , File . separator ) ; }
check if file path is valid.
check if file path is valid .
// file name should not contains blank.