Package com.baasbox.commands.exceptions

Examples of com.baasbox.commands.exceptions.CommandExecutionException


            CollectionService.drop(coll);
            return BooleanNode.getTrue();
        } catch (InvalidCollectionException e) {
            return BooleanNode.getFalse();
        } catch (Exception e){
            throw new CommandExecutionException(command,"Error dropping collection: "+e.getMessage());
        }
    }
View Full Code Here


        }
    }

    private static void checkPreconditions(JsonNode command,boolean nonTransactional) throws CommandExecutionException {
        if (!DbHelper.isConnectedAsAdmin(false)){
            throw new CommandExecutionException(command,"non authorized");
        }
        if (nonTransactional && DbHelper.isInTransaction()){
            throw new CommandExecutionException(command,"cannot alter collections during transaction");
        }
    }
View Full Code Here

        String coll = extractCollectionName(command);
        try {
            boolean res =CollectionService.exists(coll);
            return res? BooleanNode.getTrue():BooleanNode.getFalse();
        } catch (SqlInjectionException e) {
            throw new CommandExecutionException(command,e.getMessage());
        } catch (InvalidCollectionException e) {
            throw new CommandExecutionException(command,"Invalid collection '"+coll+"':"+e.getMessage());
        }
    }
View Full Code Here

            CollectionService.create(coll);
            return BooleanNode.getTrue();
        } catch (CollectionAlreadyExistsException e) {
            return BooleanNode.getFalse();
        } catch (InvalidCollectionException e){
            throw new CommandExecutionException(command,"Invalid collection name: "+e.getMessage());
        } catch (Throwable e) {
            throw new CommandExecutionException(command,"Error creating collection: "+e.getMessage());
        }
    }
View Full Code Here

        DbHelper.commitTransaction();
        return NullNode.getInstance();
    }

    private static JsonNode switchUser(JsonNode command,JsonCallback callback) throws CommandException {
        if (DbHelper.isInTransaction()) throw new CommandExecutionException(command,"Cannot switch to admin during a transaction");
        try {
            DbHelper.reconnectAsAdmin();
            return callback.call(NullNode.getInstance());
        } finally {
            DbHelper.reconnectAsAuthenticatedUser();
View Full Code Here

                Logger.error("error",e);
                throw  e;
            }
        } catch (UserNotFoundException e) {

            throw new CommandExecutionException(command,"user not found exception");
        } catch (DocumentNotFoundException e) {
            throw new CommandExecutionException(command,"document not found exception");
        } catch (InvalidCollectionException e) {
            throw new CommandExecutionException(command,"invalid colleciton exception");
        } catch (InvalidModelException e) {
            throw new CommandExecutionException(command,"invalid model exception");
        } catch (RoleNotFoundException e) {
            throw new CommandExecutionException(command,"role not found exception");
        } catch (RidNotFoundException e) {
            throw new CommandExecutionException(command,"document "+id+" not found");
        }
        return BooleanNode.getTrue();
    }
View Full Code Here

            return null;
        }
        try {
            DocumentService.delete(coll,rid);
        } catch (OSecurityException e) {
            throw new CommandExecutionException(command, "you don't have permissions to delete: "+id);
        } catch (ODatabaseException e){
            return null;
        } catch (Throwable e){
            throw new CommandExecutionException(command,"error executing delete command on "+id+ " message: "+e.getMessage());
        }
        return null;
    }
View Full Code Here

            ObjectNode node = (ObjectNode)Json.mapper().readTree(json);
            node.remove(TO_REMOVE);
            node.remove("@rid");
            return node;
        } catch (RidNotFoundException e) {
            throw new CommandExecutionException(command,"document: "+id+" does not exists");
        } catch (UpdateOldVersionException e) {
            throw new CommandExecutionException(command,"document: "+id+" has a more recent version");
        } catch (DocumentNotFoundException e) {
            throw new CommandExecutionException(command,"document: "+id+" does not exists");
        } catch (InvalidCollectionException e) {
            throw new CommandExecutionException(command,"invalid collection: "+coll);
        } catch (InvalidModelException e) {
            throw new CommandExecutionException(command,"error updating document: "+id+" message: "+e.getMessage());
        } catch (JsonProcessingException e) {
            throw new CommandExecutionException(command,"data do not represents a valid document, message: "+e.getMessage());
        } catch (IOException e) {
            throw new CommandExecutionException(command,"error updating document: "+id+" message:"+e.getMessage());
        }
    }
View Full Code Here

            ObjectNode n =(ObjectNode)node;
            n.remove(TO_REMOVE).remove("@rid");
//            n.remove("@rid");
            return n;
        } catch (InvalidCollectionException throwable) {
            throw new CommandExecutionException(command,"invalid collection: "+collection);
        } catch (InvalidModelException e) {
            throw new CommandExecutionException(command,"error creating document: "+e.getMessage());
        } catch (Throwable e) {
            throw new CommandExecutionException(command,"error creating document: "+e.getMessage());
        }
    }
View Full Code Here

            String s = JSONFormats.prepareDocToJson(docs, JSONFormats.Formats.DOCUMENT_PUBLIC);
            ArrayNode lst = (ArrayNode)Json.mapper().readTree(s);
            lst.forEach((j)->((ObjectNode)j).remove(TO_REMOVE).remove("@rid"));
            return lst;
        } catch (SqlInjectionException | IOException e) {
            throw new CommandExecutionException(command,"error executing command: "+e.getMessage(),e);
        } catch (InvalidCollectionException e) {
            throw new CommandExecutionException(command,"invalid collection: "+collection,e);
        }
    }
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.