List of usage examples for io.vertx.core.json JsonObject fieldNames
public Set<String> fieldNames()
From source file:io.techcode.logbulk.pipeline.output.SyslogOutput.java
License:Open Source License
@Override public void onStart() { // Setup mapping JsonObject map = config.getJsonObject(CONF_MAPPING, new JsonObject()); mapping = Maps.newEnumMap(SyslogHeader.class); for (String entry : map.fieldNames()) { mapping.put(SyslogHeader.byName(entry), map.getString(entry)); }// w ww. jav a2 s. c o m // Setup framing String framing = config.getString(CONF_FRAMING); if ("delimited".equals(framing)) { delimiter = config.getString(CONF_DELIMITER); } }
From source file:net.kuujo.vertigo.network.impl.InputConfigImpl.java
License:Apache License
@Override public void update(JsonObject output) { for (String key : output.fieldNames()) { ports.put(key, new InputPortConfigImpl(output.getJsonObject(key)).setName(key)); }//from w w w .ja va 2 s. com }
From source file:net.kuujo.vertigo.network.impl.NetworkImpl.java
License:Apache License
@Override public void update(JsonObject network) { this.name = network.getString(NETWORK_NAME); if (this.name == null) { throw new NetworkFormatException("Network name is mandatory."); }/*from w w w . j a v a2s.co m*/ JsonObject components = network.getJsonObject(NETWORK_COMPONENTS); if (components != null) { for (String name : components.fieldNames()) { this.components.add( NetworkConfig.component(components.getJsonObject(name)).setName(name).setNetwork(this)); } } JsonArray connections = network.getJsonArray(NETWORK_CONNECTIONS); if (connections != null) { for (Object connection : connections) { ConnectionConfig connectionConfig = NetworkConfig.connection((JsonObject) connection); SourceConfig source = connectionConfig.getSource(); if (!source.getIsNetwork()) { String componentName = connectionConfig.getSource().getComponent(); if (componentName == null) { throw new NetworkFormatException("A connection source does not specify a component."); } ComponentConfig component = this.getComponent(componentName); if (component == null) { throw new NetworkFormatException("No component with name " + componentName + " was found while trying to create source vertigo connection."); } OutputConfig output = component.getOutput(); if (output.getPort(source.getPort()) == null) { output.addPort(source.getPort()); } } TargetConfig target = connectionConfig.getTarget(); if (!target.getIsNetwork()) { String componentName = connectionConfig.getTarget().getComponent(); if (componentName == null) { throw new NetworkFormatException("A connection target does not specify a component."); } ComponentConfig component = this.getComponent(componentName); if (component == null) { throw new NetworkFormatException("No target component with name " + componentName + " was found while trying to create target vertigo connection."); } InputConfig input = component.getInput(); if (input.getPort(target.getPort()) == null) { input.addPort(target.getPort()); } } this.connections.add(connectionConfig); } } }
From source file:net.kuujo.vertigo.network.impl.OutputConfigImpl.java
License:Apache License
@Override public void update(JsonObject output) { for (String key : output.fieldNames()) { ports.put(key, new OutputPortConfigImpl(output.getJsonObject(key)).setName(key)); }/*from w ww . j a v a 2 s. c o m*/ }
From source file:org.entcore.auth.services.impl.DefaultConfigurationService.java
License:Open Source License
@Override public void getWelcomeMessage(String domain, String language, final Handler<Either<String, JsonObject>> handler) { final JsonObject q = new JsonObject().put("type", WELCOME_MESSAGE_TYPE); JsonObject keys = null;/* www. j a v a2 s . c o m*/ if (isNotEmpty(domain) && isNotEmpty(language)) { keys = new JsonObject(); keys.put("_id", 0); keys.put(domain.replaceAll("\\.", "_") + "." + language, 1); keys.put(domain.replaceAll("\\.", "_") + ".enabled", 1); } else if (isNotEmpty(domain)) { keys = new JsonObject(); keys.put("_id", 0); keys.put(domain.replaceAll("\\.", "_"), 1); } mongoDb.findOne(PLATEFORM_COLLECTION, q, keys, new Handler<Message<JsonObject>>() { @Override public void handle(Message<JsonObject> res) { if ("ok".equals(res.body().getString("status"))) { JsonObject r = res.body().getJsonObject("result", new JsonObject()); JsonObject j = new JsonObject(); for (String attr : r.fieldNames()) { j.put(attr.replaceAll("_", "."), r.getValue(attr)); } handler.handle(new Either.Right<String, JsonObject>(j)); } else { handler.handle(new Either.Left<String, JsonObject>(res.body().getString("message", ""))); } } }); }
From source file:org.entcore.auth.services.impl.DefaultOpenIdServiceProviderFactory.java
License:Open Source License
public DefaultOpenIdServiceProviderFactory(Vertx vertx, JsonObject domains) { for (String domain : domains.fieldNames()) { JsonObject c = domains.getJsonObject(domain); OpenIdConnectServiceProvider provider; if ("France-Connect".equals(c.getString("provider"))) { provider = new FranceConnectServiceProvider(c.getString("iss")); } else {//from w w w .ja v a2s . c om provider = new DefaultOpendIdConnectService(c.getString("iss")); } provider.setSetFederated(c.getBoolean("set-federated", true)); services.put(domain, provider); try { OpenIdConnectClient oic = new OpenIdConnectClient(new URI(c.getString("uri")), c.getString("clientId"), c.getString("secret"), c.getString("authorizeUrn"), c.getString("tokenUrn"), c.getString("redirectUri"), vertx, 16, c.getString("certsUri")); oic.setUserInfoUrn(c.getString("userInfoUrn")); oic.setLogoutUri(c.getString("logoutUri")); oic.setBasic(c.getBoolean("basic-to-get-token", true)); openIdConnectClients.put(domain, oic); } catch (URISyntaxException e) { log.error("Invalid openid server uri", e); } } }
From source file:org.entcore.auth.services.impl.DefaultServiceProviderFactory.java
License:Open Source License
public DefaultServiceProviderFactory(JsonObject confSP) { if (confSP != null) { for (String attr : confSP.fieldNames()) { try { services.put(attr, (SamlServiceProvider) Class.forName(confSP.getString(attr)).newInstance()); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | ClassCastException e) { logger.error("Error loading saml service provider.", e); }/* ww w .j a v a 2 s.co m*/ } } }
From source file:org.entcore.blog.services.impl.DefaultBlogService.java
License:Open Source License
@Override public void update(String blogId, JsonObject blog, final Handler<Either<String, JsonObject>> result) { blog.put("modified", MongoDb.now()); if (blog.getString("comment-type") != null) { try {/*w w w.j a v a2 s. c o m*/ CommentType.valueOf(blog.getString("comment-type").toUpperCase()); blog.put("comment-type", blog.getString("comment-type").toUpperCase()); } catch (IllegalArgumentException | NullPointerException e) { blog.remove("comment-type"); } } if (blog.getString("publish-type") != null) { try { PublishType.valueOf(blog.getString("publish-type").toUpperCase()); blog.put("publish-type", blog.getString("publish-type").toUpperCase()); } catch (IllegalArgumentException | NullPointerException e) { blog.remove("publish-type"); } } JsonObject b = Utils.validAndGet(blog, UPDATABLE_FIELDS, Collections.<String>emptyList()); if (validationError(result, b)) return; QueryBuilder query = QueryBuilder.start("_id").is(blogId); MongoUpdateBuilder modifier = new MongoUpdateBuilder(); for (String attr : b.fieldNames()) { modifier.set(attr, b.getValue(attr)); } mongo.update(BLOG_COLLECTION, MongoQueryBuilder.build(query), modifier.build(), new Handler<Message<JsonObject>>() { @Override public void handle(Message<JsonObject> event) { result.handle(Utils.validResult(event)); } }); }
From source file:org.entcore.blog.services.impl.DefaultBlogTimelineService.java
License:Open Source License
@Override public void notifyShare(final HttpServerRequest request, final String blogId, final UserInfos user, final JsonArray sharedArray, final String resourceUri) { if (sharedArray != null && user != null && blogId != null && request != null && resourceUri != null) { QueryBuilder query = QueryBuilder.start("_id").is(blogId); JsonObject keys = new JsonObject().put("title", 1); mongo.findOne("blogs", MongoQueryBuilder.build(query), keys, new Handler<Message<JsonObject>>() { @Override// w ww . java2 s.c o m public void handle(final Message<JsonObject> event) { if ("ok".equals(event.body().getString("status"))) { List<String> shareIds = getSharedIds(sharedArray); if (!shareIds.isEmpty()) { Map<String, Object> params = new HashMap<>(); params.put("userId", user.getUserId()); neo.send(neoQuery(shareIds), params, new Handler<Message<JsonObject>>() { @Override public void handle(Message<JsonObject> res) { if ("ok".equals(res.body().getString("status"))) { JsonObject r = res.body().getJsonObject("result"); List<String> recipients = new ArrayList<>(); for (String attr : r.fieldNames()) { String id = r.getJsonObject(attr).getString("id"); if (id != null) { recipients.add(id); } } String blogTitle = event.body().getJsonObject("result", new JsonObject()) .getString("title"); JsonObject p = new JsonObject() .put("uri", "/userbook/annuaire#" + user.getUserId() + "#" + user.getType()) .put("username", user.getUsername()).put("blogTitle", blogTitle) .put("resourceUri", resourceUri).put("disableAntiFlood", true); notification.notifyTimeline(request, "blog.share", user, recipients, blogId, p); } } }); } } } }); } }
From source file:org.entcore.blog.services.impl.DefaultBlogTimelineService.java
License:Open Source License
private void findRecipiants(String collection, QueryBuilder query, JsonObject keys, final JsonArray fetch, final String filterRights, final UserInfos user, final Handler<Map<String, Object>> handler) { mongo.findOne(collection, MongoQueryBuilder.build(query), keys, fetch, new Handler<Message<JsonObject>>() { @Override// w w w. j av a 2s . c o m public void handle(Message<JsonObject> event) { if ("ok".equals(event.body().getString("status"))) { final JsonObject blog = event.body().getJsonObject("result", new JsonObject()); JsonArray shared; if (fetch == null) { shared = blog.getJsonArray("shared"); } else { shared = blog.getJsonObject("blog", new JsonObject()).getJsonArray("shared"); } if (shared != null) { shared.add(blog.getJsonObject("blog", new JsonObject()).getJsonObject("author")); //Allows owner to get notified for contributors posts List<String> shareIds = getSharedIds(shared, filterRights); if (!shareIds.isEmpty()) { Map<String, Object> params = new HashMap<>(); params.put("userId", user.getUserId()); neo.send(neoQuery(shareIds), params, new Handler<Message<JsonObject>>() { @Override public void handle(Message<JsonObject> res) { if ("ok".equals(res.body().getString("status"))) { JsonObject r = res.body().getJsonObject("result"); List<String> recipients = new ArrayList<>(); for (String attr : r.fieldNames()) { String id = r.getJsonObject(attr).getString("id"); if (id != null) { recipients.add(id); } } Map<String, Object> t = new HashMap<>(); t.put("recipients", recipients); t.put("blog", blog); handler.handle(t); } else { handler.handle(null); } } }); } else { handler.handle(null); } } else { handler.handle(null); } } else { handler.handle(null); } } }); }