Package com.baasbox.dao.exception

Examples of com.baasbox.dao.exception.ScriptException


        return result;
    }

    private static void validateBody(JsonNode body) throws ScriptException{
        if (body == null){
            throw new ScriptException("missing body");
        }
        JsonNode name = body.get(ScriptsDao.NAME);
        if (name == null || (!name.isTextual())|| name.asText().trim().length()==0) {
            throw new ScriptException("missing required 'name' property");
        }
        JsonNode code = body.get(ScriptsDao.CODE);
        if (code == null||(!code.isTextual())||code.asText().trim().length()==0) {
            throw new ScriptException("missing required 'code' property");
        }
    }
View Full Code Here


     */

    public static ODocument resetStore(String name,JsonNode data) throws ScriptException {
        ScriptsDao dao = ScriptsDao.getInstance();
        ODocument script = dao.getByName(name);
        if (script == null) throw new ScriptException("Script not found");
        ODocument emdedded = new ODocument().fromJSON(data.toString());
        script.field(ScriptsDao.LOCAL_STORAGE,emdedded);
        dao.save(script);
        return emdedded;
    }
View Full Code Here

    }

    public static ODocument getStore(String name) throws ScriptException {
        ScriptsDao dao = ScriptsDao.getInstance();
        ODocument script = dao.getByName(name);
        if (script == null) throw new ScriptException("Script not found");
        return script.<ODocument>field(ScriptsDao.LOCAL_STORAGE);
    }
View Full Code Here

    private static ODocument updateStorageLocked(String name,boolean before,JsonCallback updaterFn) throws ScriptException {
        final ScriptsDao dao = ScriptsDao.getInstance();
        ODocument script = null;
        try {
            script = dao.getByNameLocked(name);
            if (script == null) throw new ScriptException("Script not found");
            ODocument retScript = before ? script.copy() : script;

            ODocument storage = script.<ODocument>field(ScriptsDao.LOCAL_STORAGE);

            Optional<ODocument> storage1 = Optional.ofNullable(storage);
View Full Code Here

        List<ODocument> scripts = dao.getAll(paramsFromQueryString);
        return scripts;
    }

    public static ScriptStatus update(String name,JsonNode code) throws ScriptException{
        if (code == null) throw new ScriptException("missing code");
        JsonNode codeNode = code.get(ScriptsDao.CODE);
        if (codeNode == null|| !codeNode.isTextual()){
            throw new ScriptException("missing code");
        }
        String source = codeNode.asText();
        return update(name,source);
    }
View Full Code Here

                doc.delete();
            }
        } catch (ScriptEvalException e){
            if (Logger.isDebugEnabled()) Logger.debug("Script installation failed: deleting - " + ExceptionUtils.getStackTrace(e));
            doc.delete();
            throw new ScriptException(e);
        }
        if (Logger.isTraceEnabled()) Logger.trace("Method end");
        return status;
    }
View Full Code Here

    public static ODocument get(String name,boolean onlyvalid,boolean active) throws ScriptException {
        ScriptsDao dao = ScriptsDao.getInstance();
        ODocument script = dao.getByName(name);
        if (script != null){
            if (onlyvalid && script.<Boolean>field(ScriptsDao.INVALID)){
                throw new ScriptException("Script is in invalid state");
            }
            if (active && !(script.<Boolean>field(ScriptsDao.ACTIVE))){
                throw new ScriptEvalException("Script is not active");
            }
        }
View Full Code Here


    public ODocument update(String name, String code) throws ScriptException{
        ODocument doc = getByName(name);
        if (doc == null){
            throw new ScriptException("Script: "+name+" does not exists");
        }
        OTrackedList<String> codeVersions =doc.field(CODE);
        codeVersions.add(0, code);
        save(doc);
        return doc;
View Full Code Here

TOP

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

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.