List of usage examples for io.vertx.core.json JsonObject getBoolean
public Boolean getBoolean(String key, Boolean def)
From source file:org.entcore.timeline.services.impl.DefaultTimelineConfigService.java
License:Open Source License
/** * Retrieves stored properties for a single notification. * * @param notificationKey : Name of the notification * @param handler : Handles the properties *//*from w w w . j av a 2 s .co m*/ @Override public void getNotificationProperties(final String notificationKey, final Handler<Either<String, JsonObject>> handler) { this.list(new Handler<Either<String, JsonArray>>() { public void handle(Either<String, JsonArray> event) { if (event.isLeft()) { handler.handle(new Either.Left<String, JsonObject>(event.left().getValue())); return; } final String notificationStr = registeredNotifications.get(notificationKey.toLowerCase()); if (notificationStr == null) { handler.handle(new Either.Left<String, JsonObject>("invalid.notification.key")); return; } final JsonObject notification = new JsonObject(notificationStr); for (Object notifConfigObj : event.right().getValue()) { JsonObject notifConfig = (JsonObject) notifConfigObj; if (notifConfig.getString("key", "").equals(notificationKey.toLowerCase())) { notification.put("defaultFrequency", notifConfig.getString("defaultFrequency", "")); notification.put("push-notif", notifConfig.getBoolean("push-notif", notification.getBoolean("push-notif"))); notification.put("restriction", notifConfig.getString("restriction", "")); break; } } handler.handle(new Either.Right<String, JsonObject>(notification)); } }); }
From source file:org.entcore.workspace.service.WorkspaceService.java
License:Open Source License
private void updateStorage(JsonArray addeds, JsonArray removeds, final Handler<Either<String, JsonObject>> handler) { Map<String, Long> sizes = new HashMap<>(); if (addeds != null) { for (Object o : addeds) { if (!(o instanceof JsonObject)) continue; JsonObject added = (JsonObject) o; Long size = added.getJsonObject("metadata", new JsonObject()).getLong("size", 0l); String userId = (added.containsKey("to")) ? added.getString("to") : added.getString("owner"); if (userId == null) { log.info("UserId is null when update storage size"); log.info(added.encode()); continue; }// w w w. j a va 2 s. c om Long old = sizes.get(userId); if (old != null) { size += old; } sizes.put(userId, size); } } if (removeds != null) { for (Object o : removeds) { if (!(o instanceof JsonObject)) continue; JsonObject removed = (JsonObject) o; Long size = removed.getJsonObject("metadata", new JsonObject()).getLong("size", 0l); String userId = (removed.containsKey("to")) ? removed.getString("to") : removed.getString("owner"); if (userId == null) { log.info("UserId is null when update storage size"); log.info(removed.encode()); continue; } Long old = sizes.get(userId); if (old != null) { old -= size; } else { old = -1l * size; } sizes.put(userId, old); } } for (final Map.Entry<String, Long> e : sizes.entrySet()) { quotaService.incrementStorage(e.getKey(), e.getValue(), threshold, new Handler<Either<String, JsonObject>>() { @Override public void handle(Either<String, JsonObject> r) { if (r.isRight()) { JsonObject j = r.right().getValue(); UserUtils.addSessionAttribute(eb, e.getKey(), "storage", j.getLong("storage"), null); if (j.getBoolean("notify", false)) { notifyEmptySpaceIsSmall(e.getKey()); } } else { log.error(r.left().getValue()); } if (handler != null) { handler.handle(r); } } }); } }
From source file:pt.davidafsilva.slacker.server.HttpServerConfiguration.java
License:Open Source License
/** * Sets up the http server configuration based on the available environment variables (SLACK_*) * and current configuration via the json configuration file. * * @param config the current configuration * @return the configured server options *//*from ww w .ja va2s .c o m*/ static HttpServerOptions setup(final JsonObject config) { // evaluate the environment variables evaluateEnvironmentVariables(config); // create the http server options final HttpServerOptions options = new HttpServerOptions().setIdleTimeout(IDLE_TIMEOUT) .setPort(config.getInteger(ConfigurationVariable.HTTP_PORT.name(), DEFAULT_HTTP_PORT)) .setSsl(config.getBoolean(ConfigurationVariable.USE_SSL.name(), DEFAULT_USE_SSL)); // setup the required SSL parameters if (options.isSsl()) { // validate the configuration validateOptions(config, ConfigurationVariable.KEY_STORE_FILE, ConfigurationVariable.KEY_STORE_PASS); // add the enabled cipher suites CIPHER_SUITES.stream().forEach(options::addEnabledCipherSuite); // set the both keystore location and keystore password options.setKeyStoreOptions( new JksOptions().setPath(config.getString(ConfigurationVariable.KEY_STORE_FILE.name())) .setPassword(config.getString(ConfigurationVariable.KEY_STORE_PASS.name()))); } return options; }