Package com.baasbox.dao.exception

Examples of com.baasbox.dao.exception.InvalidScriptException


    }

    public static String getAndvalidateCodeProperty(JsonNode script) throws InvalidScriptException{
        JsonNode code = script.get(ScriptsDao.CODE);
        if (code == null||!code.isTextual()){
            throw new InvalidScriptException("missing code property");
        }
        String c = code.asText();
        if (c==null){
            throw new InvalidScriptException("missing code property");
        }
        return c;
    }
View Full Code Here


    public static ScriptLanguage getAndValidateScriptLanguage(JsonNode script) throws InvalidScriptException{
        JsonNode langNode = script.get(ScriptsDao.LANG);
        if (langNode==null){
            return ScriptLanguage.JS;
        } else if(!langNode.isTextual()){
            throw new InvalidScriptException("Invalid language: should be a name");
        }else {
            return validateLang(langNode.asText());
        }
    }
View Full Code Here


    public static String getAndValidateNameProperty(JsonNode script) throws InvalidScriptException{
        JsonNode nameNode = script.get(ScriptsDao.NAME);
        if (nameNode==null||!nameNode.isTextual()){
            throw new InvalidScriptException("Missing name property");
        }
        String name = nameNode.asText();
        validateName(name);
        return name;
    }
View Full Code Here

    }

    public static ScriptLanguage validateLang(String name) throws InvalidScriptException {
        ScriptLanguage lang = ScriptLanguage.forName(name);
        if(lang==null)
            throw new InvalidScriptException("Invalid language: "+name);
        return lang;
    }
View Full Code Here

        return lang;
    }

    public static void validateName(String name) throws InvalidScriptException{
        if (name == null||name.trim().length()==0){
            throw new InvalidScriptException("Scripts must have non empty name");
        } else if (name.startsWith("baasbox")){
            throw new InvalidScriptException("Scripts name cannot begin with baasbox");
        } else {
            char c = name.charAt(0);
            if (!(c == '_')||Character.isAlphabetic(c)){
                throw new InvalidScriptException("Script name must begin with '_' or a letter");
            }
        }
    }
View Full Code Here

    }


    public static void checkValidName(String name) throws ScriptException{
        if (name== null||name.trim().length()==0){
            throw new InvalidScriptException("Script must have non empty name");
        }
        if (!VALID_NAME_PATTERN.matcher(name).matches()){
            throw new InvalidScriptException("Script names must be composed of letters numbers and underscores, and cannot start with numbers. Script must have at least one namespace part. Valid example: mynamespace.myscript");
        }
        if (isInternalName(name)){
            throw new InvalidScriptException("User scripts cannot belong to 'baasbox' namespace");
        }
    }
View Full Code Here

TOP

Related Classes of com.baasbox.dao.exception.InvalidScriptException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.