Package com.fasterxml.jackson.databind

Examples of com.fasterxml.jackson.databind.JsonNode.asText()


   
    if (bodyJson==null) return badRequest("The body payload cannot be empty.");     
    JsonNode passwordNode=bodyJson.findValue("password");
   
    if (passwordNode==null) return badRequest("The body payload doesn't contain password field");
    String password=passwordNode.asText();   
   
    try{
      UserService.changePassword(username, password);
    } catch (UserNotFoundException e) {
        Logger.debug("Username not found " + username, e);
View Full Code Here


    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

        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");
        }
    }

    public static Result list(){
View Full Code Here

    private static String extractCollectionName(JsonNode command) throws CommandParsingException {
        JsonNode node = command.get(ScriptCommand.PARAMS);
        if (!node.isTextual()){
            throw new CommandParsingException(command,"expeceted params to be the name of a collection");
        }
        return node.asText();
    }


}
View Full Code Here

        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);
    }

    public static ScriptStatus update(String name,String code) throws ScriptException {
        ScriptsDao dao = ScriptsDao.getInstance();
View Full Code Here

        JsonNode params = command.get(ScriptCommand.PARAMS);
        JsonNode collNode = params.get(COLLECTION);
        if (collNode == null|| !collNode.isTextual()){
            throw new CommandParsingException(command,"invalid collection param: "+(collNode==null?"null":collNode.toString()));
        }
        return collNode.asText();
    }


    @Override
    protected JsonNode put(JsonNode command) throws CommandException{
View Full Code Here

        JsonNode node = command.get(ScriptCommand.PARAMS).get(AUTHOR);
        if (node != null && !node.isTextual()){
            throw new CommandParsingException(command,"author must be a string");

        } else if (node != null){
            return node.asText();
        }
        return null;
    }

    private JsonNode getData(JsonNode command) throws CommandParsingException {
View Full Code Here

        JsonNode params = command.get(ScriptCommand.PARAMS);
        JsonNode id = params.get("id");
        if (id==null||!id.isTextual()){
            throw new CommandParsingException(command,"missing document id");
        }
        String idString = id.asText();
        try{
            UUID.fromString(idString);
        } catch (IllegalArgumentException e){
            throw new CommandParsingException(command,"document id: "+id+" must be a valid uuid");
        }
View Full Code Here

    JsonNode collapse_KeyNode=bodyJson.findValue("collapse_key");
    String collapse_key=null;

    if(!(collapse_KeyNode==null)) {
      if(!(collapse_KeyNode.isTextual())) throw new PushCollapseKeyFormatException("Collapse_key MUST be a String");
      collapse_key=collapse_KeyNode.asText();
    }
    else collapse_key="";

    JsonNode timeToLiveNode=bodyJson.findValue("time_to_live");
    int time_to_live = 0;
View Full Code Here

      JsonNode categoryNode=bodyJson.findValue("category");
      String category = null;
      if(!(categoryNode == null)) {
        if(!(categoryNode.isTextual())) throw new PushCategoryFormatException("Category MUST be a String");
        category=categoryNode.asText();
      }

      JsonNode soundNode=bodyJson.findValue("sound");
      String sound =null;
      if (!(soundNode==null)) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.