Package com.baasbox.commands.exceptions

Examples of com.baasbox.commands.exceptions.CommandExecutionException


        } catch (RidNotFoundException e) {
            return null;
        } catch (DocumentNotFoundException e) {
            return null;
        } catch (InvalidCollectionException e) {
            throw new CommandExecutionException(command,"invalid collection: "+collection);
        } catch (InvalidModelException e) {
            throw new CommandExecutionException(command,"error executing command: "+e.getMessage());
        } catch (JsonProcessingException e) {
            throw new CommandExecutionException(command,"error executing command: "+e.getMessage());
        } catch (IOException e) {
            throw new CommandExecutionException(command,"error executing command: "+e.getMessage());
        }
    }
View Full Code Here


    private static JsonNode wsCall(JsonNode command,JsonCallback callback) throws CommandException{
        try {
            return ScriptingService.callJsonSync(command.get(ScriptCommand.PARAMS));
        } catch (Exception e) {
            throw new CommandExecutionException(command,e.getMessage(),e);
        }
    }
View Full Code Here

        if ("get".equals(action)){
            try {
                result = ScriptingService.getStore(id);
             } catch (ScriptException e) {
                //should never happen
                throw new CommandExecutionException(command,"script does not exists");
            }
        } else if ("set".equals(action)){
            JsonNode args = params.get("args");
            if (args==null){
                args = NullNode.getInstance();
            }
            if (!args.isObject()||!args.isNull()){
                throw new CommandExecutionException(command,"Stored values should be objects or null");
            }
            try {
                result = ScriptingService.resetStore(id,args);
            } catch (ScriptException e) {
                throw new CommandExecutionException(command,"script does not exists");
            }
        } else if ("swap".equals(action)){
            if (callback==null) throw new CommandExecutionException(command,"missing function callback");
            try {
                result = ScriptingService.swap(id,callback);
            } catch (ScriptException e) {
                throw new CommandExecutionException(command,e.getMessage(),e);
            }
        } else if ("trade".equals(action)){
            if (callback==null) throw new CommandExecutionException(command,"missing function callback");
            try {
                result = ScriptingService.trade(id,callback);
            } catch (ScriptException e) {
                throw new CommandExecutionException(command,e.getMessage(),e);
            }
        } else {
            throw new CommandParsingException(command,"unknown action: "+action);
        }
        if (result == null){
            return NullNode.getInstance();
        } else {
            String s = result.toJSON();
            try {
                JsonNode jsonNode = Json.mapper().readTree(s);
                return jsonNode;
            } catch (IOException e) {
                throw new CommandExecutionException(command,"error converting result",e);
            }
        }
    }
View Full Code Here

                        FriendShipService.getFriendsOf(user.asText(), qparams);
                String s = JSONFormats.prepareDocToJson(res, JSONFormats.Formats.USER);

                return Json.mapper().readTreeOrMissing(s);
            } catch (SqlInjectionException e){
                throw new CommandExecutionException(command,e.getMessage(),e);
            }
        };
    }
View Full Code Here

    private JsonNode doUnfollow(JsonNode command,String from,String to) throws CommandExecutionException{
        try {
            return BooleanNode.valueOf(FriendShipService.unfollow(from, to));
        } catch (Exception e) {
            throw new CommandExecutionException(command,e.getMessage(),e);
        }
    }
View Full Code Here

        try {
            ODocument followed = FriendShipService.follow(from, to);
            String s = JSONFormats.prepareDocToJson(followed, JSONFormats.Formats.USER);
            return Json.mapper().readTree(s);
        } catch (UserNotFoundException e) {
            throw new CommandExecutionException(command,e.getMessage(),e);
        } catch (AlreadyFriendsException e) {
            return NullNode.getInstance();
        } catch (SqlInjectionException e) {
            throw new CommandExecutionException(command,e.getMessage(),e);
        } catch (Exception e) {
            throw new CommandExecutionException(command,e.getMessage(),e);
        }
    }
View Full Code Here

            if (inTransaction){
                return BooleanNode.getFalse();
            }
            UserService.disableUser(username);
        } catch (UserNotFoundException e) {
            throw new CommandExecutionException(command,"User "+username+" does not exists");
        } catch (OpenTransactionException e){
            return BooleanNode.getFalse();
            //throw new CommandExecutionException(command,"Transaction still open during suspend");
        }
        return BooleanNode.getTrue();
View Full Code Here

        }

        String username = id.asText();
        boolean internalUsername = UserService.isInternalUsername(username);
        if (internalUsername){
            throw new CommandExecutionException(command,"invalid user: "+username);
        }
        return username;
    }
View Full Code Here

        try {
            if (DbHelper.isInTransaction()) return BooleanNode.getFalse();
            UserService.enableUser(username);

        } catch (UserNotFoundException e) {
            throw new CommandExecutionException(command,"user "+username+ " does not exists");
        } catch (OpenTransactionException e){
            return BooleanNode.getFalse();
            //throw new CommandExecutionException(command,"transaction still open while altering user status");
        }
        return BooleanNode.getTrue();
View Full Code Here

        try {
            ODocument doc = UserService.updateProfile(username, role, anonymousVisible, userVisible, friendsVisible, registeredVisible);
            String s = JSONFormats.prepareDocToJson(doc, JSONFormats.Formats.USER);
            return Json.mapper().readTree(s);
        } catch (Exception e) {
            throw new CommandExecutionException(command,"Error updating user: "+e.getMessage());
        }
    }
View Full Code Here

TOP

Related Classes of com.baasbox.commands.exceptions.CommandExecutionException

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.