List of usage examples for com.fasterxml.jackson.databind.node ObjectNode put
public ObjectNode put(String paramString1, String paramString2)
From source file:controllers.api.v1.Flow.java
public static Result getFlowListViewFlows(String application, String project) { ObjectNode result = Json.newObject(); result.put("status", "ok"); result.set("nodes", Json.toJson(FlowsDAO.getFlowListViewFlows(application, project))); return ok(result); }
From source file:de.qaware.cloud.deployer.commons.config.util.ContentTreeUtil.java
/** * Adds a new field with the specified name and value to a object tree. * * @param contentObjectTree The object tree which will contain the new field. * @param fieldName The name of the field. * @param value The value of the field. * @throws ResourceConfigException If the object tree or the field name or the value is null/empty. */// www . java 2s. co m public static void addField(JsonNode contentObjectTree, String fieldName, String value) throws ResourceConfigException { if (contentObjectTree == null) { throw new ResourceConfigException( COMMONS_MESSAGE_BUNDLE.getMessage("DEPLOYER_COMMONS_ERROR_EMPTY_CONTENT")); } else if (fieldName == null || fieldName.isEmpty() || value == null || value.isEmpty()) { throw new ResourceConfigException( COMMONS_MESSAGE_BUNDLE.getMessage("DEPLOYER_COMMONS_ERROR_DURING_FIELD_ADDING")); } ObjectNode objectNode = (ObjectNode) contentObjectTree; objectNode.put(fieldName, value); }
From source file:com.baasbox.commands.ScriptsResource.java
private static JsonNode log(JsonNode command, JsonCallback callback) throws CommandException { JsonNode idOfTheModule = command.get(ScriptCommand.MAIN); JsonNode par = command.get(ScriptCommand.PARAMS); if (idOfTheModule == null) { idOfTheModule = command.get(ScriptCommand.ID); }//from w w w .j a v a 2s . c o m ObjectNode message = Json.mapper().createObjectNode(); message.put("message", par.get("message")); message.put("args", par.get("args")); message.put("script", idOfTheModule); message.put("date", SDF.format(new Date())); int publish = EventsService.publish(EventsService.StatType.SCRIPT, message); return IntNode.valueOf(publish); }
From source file:com.baasbox.service.scripting.js.Api.java
public static String execCommand(String commandStr, JsonCallback callback) { BaasBoxLogger.debug("Command to execute: " + commandStr); try {/*from w ww .j a va 2 s. c om*/ JsonNode node = Json.mapper().readTree(commandStr); if (!node.isObject()) { BaasBoxLogger.error("Command is not an object"); throw ECMAErrors.typeError("Invalid command"); } ObjectNode o = (ObjectNode) node; String main = mainModule(); if (main != null) { o.put("main", main); } JsonNode exec = CommandRegistry.execute(node, callback); String res = exec == null ? null : exec.toString(); BaasBoxLogger.debug("Command result: " + res); return res; } catch (IOException e) { BaasBoxLogger.error("IoError " + ExceptionUtils.getMessage(e), e); throw ECMAErrors.typeError(e, "Invalid command definition"); } catch (CommandException e) { BaasBoxLogger.error("CommandError: " + ExceptionUtils.getMessage(e), e); throw new ECMAException(ExceptionUtils.getMessage(e), e); } }
From source file:mobile.service.AuthService.java
/** * /*from w w w.j a va2s. c o m*/ * * @param username ?? * @param password ? * @param timeZoneOffset ?????+8480 */ public static ServiceVOResult<CommonVO> login(String username, String password, Integer timeZoneOffset) { Session session = Context.current().session(); TimeZoneUtils.setTimeZoneOffset2Session(session, timeZoneOffset); ObjectNodeResult loginResult = User.login(username, password, false); ServiceVOResult<CommonVO> serviceVOResult = ServiceVOResult.create(loginResult); if (serviceVOResult.isSuccess()) { User user = loginResult.getUser(); CommonVO vo = CommonVO.create(); ObjectNode userNode = Json.newObject(); userNode.put("id", user.getId()); userNode.put("name", user.getName()); userNode.put("avatar_190", user.getAvatar(190)); userNode.put("avatar_70", user.getAvatar(70)); userNode.put("avatar_22", user.getAvatar(22)); userNode.put("phoneNumber", StringUtils.defaultIfBlank(loginResult.getUser().phoneNumber, null)); vo.set("user", userNode); vo.set("token", UserAuthService.getTokenInSession(session)); serviceVOResult.setVo(vo); } return serviceVOResult; }
From source file:mobile.service.AuthService.java
/** * /* www. j a v a 2s. c o m*/ * * @param username ?? * @param password ? * @param timeZoneOffset ?????+8480 * @param gender ?0:1: * @return */ public static ServiceVOResult<CommonVO> register(String username, String password, Integer timeZoneOffset, Integer gender) { Gender genderObj = gender == Integer.valueOf(1) ? Gender.WOMAN : Gender.MAN; Session session = Context.current().session(); TimeZoneUtils.setTimeZoneOffset2Session(session, timeZoneOffset); ObjectNodeResult objectNodeResult = User.registerFromMobile(username, password, genderObj); ServiceVOResult<CommonVO> serviceVOResult = ServiceVOResult.create(objectNodeResult); if (serviceVOResult.isSuccess()) { User user = objectNodeResult.getUser(); CommonVO vo = CommonVO.create(); ObjectNode userNode = Json.newObject(); userNode.put("id", user.getId()); userNode.put("name", user.getName()); userNode.put("avatar_190", user.getAvatar(190)); userNode.put("avatar_70", user.getAvatar(70)); userNode.put("avatar_22", user.getAvatar(22)); vo.set("user", userNode); serviceVOResult.setVo(vo); } return serviceVOResult; }
From source file:org.apache.taverna.gis.ui.serviceprovider.GisServiceProvider.java
private static Configuration defaultConfig() { Configuration c = new Configuration(); ObjectNode conf = c.getJsonAsObjectNode(); conf.put("osgiServiceUri", "http://localhost:8080/geoserver/ows"); conf.put("processIdentifier", "gs:StringConcatWPS"); return c;// w w w . ja va 2 s . c o m }
From source file:controllers.api.v1.AdvSearch.java
public static Result getFlowNames() { ObjectNode result = Json.newObject(); String apps = request().getQueryString("apps"); result.put("status", "ok"); result.set("flowNames", Json.toJson(AdvSearchDAO.getFlowNames(apps))); return ok(result); }
From source file:de.cubeisland.engine.core.util.McUUID.java
private static void getProfiles(List<Profile> profiles, LinkedList<String> players) { int amount = players.size(); CubeEngine.getLog().debug("Query UUID for: " + StringUtils.implode(",", players)); ArrayNode node = mapper.createArrayNode(); while (!players.isEmpty()) { ObjectNode criteria = mapper.createObjectNode(); criteria.put("name", players.poll()); criteria.put("agent", AGENT); node.add(criteria);//from w w w . ja va 2 s. com } int page = 1; try { CubeEngine.getLog().info("Query Mojang for {} UUIDs", amount); while (amount > 0) { int read = readProfilesFromInputStream(postQuery(node, page++).getInputStream(), profiles); if (read == 0) { CubeEngine.getLog().info("No Answer for {} players", amount); } else if (read != amount) { amount -= read; continue; } return; } } catch (IOException e) { CubeEngine.getLog().error(e, "Could not retrieve UUID for given names!"); } }
From source file:controllers.api.v1.AdvSearch.java
public static Result getDatasetTableNames() { ObjectNode result = Json.newObject(); String scopes = request().getQueryString("scopes"); result.put("status", "ok"); result.set("tables", Json.toJson(AdvSearchDAO.getTableNames(scopes))); return ok(result); }