List of usage examples for io.vertx.core.json JsonObject getJsonObject
public JsonObject getJsonObject(String key)
From source file:io.engagingspaces.graphql.marshaller.schema.decorators.DataFetcherDO.java
License:Open Source License
private DataFetcherDO(DataFetcher dataFetcher, JsonObject dataFetcherJson, GraphQLFieldDefinition parent, SchemaContext schemaContext) {//from w ww . ja v a 2 s . c om this.dataFetcherJson = dataFetcherJson; this.parent = parent; this.context = schemaContext; this.id = dataFetcherJson == null ? UUID.randomUUID().toString() : dataFetcherJson.getString(ID); if (dataFetcher == null) { if (id != null && context.getDataFetchers().containsKey(id)) { this.dataFetcher = context.getDataFetchers().get(id); } else { this.dataFetcher = (environment -> null); } } else { this.dataFetcher = dataFetcher; } if (dataFetcherJson == null) { this.staticValue = dataFetcher instanceof StaticDataFetcher ? new JsonObject().put(STATIC_VALUE, dataFetcher.get(null)) : null; } else { this.staticValue = dataFetcherJson.getJsonObject(STATIC_VALUE); } this.jsonReference = context.registerDataFetcher(this); }
From source file:io.engagingspaces.graphql.marshaller.schema.decorators.GraphQLFieldDefinitionDO.java
License:Open Source License
/** * Creates the GraphQL object from its json serialization data using the provided schema context. * * @param json the json data/*from w w w . j a va 2s.co m*/ * @param context the schema context * @param parent the parent graphql type */ @SuppressWarnings("unused") public GraphQLFieldDefinitionDO(JsonObject json, SchemaContext context, GraphQLType parent) { this(null, json, parent, context); context.unmarshall(json.getJsonObject(DATA_FETCHER), this); arguments = context.unmarshallList(json, ARGUMENTS, this); }
From source file:io.engagingspaces.graphql.marshaller.schema.decorators.GraphQLInterfaceTypeDO.java
License:Open Source License
/** * Creates the GraphQL object from its json serialization data using the provided schema context. * * @param json the json data/* w w w .ja v a 2s.com*/ * @param context the schema context */ @SuppressWarnings("unused") public GraphQLInterfaceTypeDO(JsonObject json, SchemaContext context) { this(null, json, context); context.unmarshall(json.getJsonObject(TYPE_RESOLVER), this); fields = context.unmarshallList(json, FIELD_DEFINITIONS, this); }
From source file:io.engagingspaces.graphql.marshaller.schema.decorators.GraphQLUnionTypeDO.java
License:Open Source License
/** * Creates the GraphQL object from its json serialization data using the provided schema context. * * @param json the json data//from www . j a v a2s . com * @param context the schema context */ @SuppressWarnings("unused") public GraphQLUnionTypeDO(JsonObject json, SchemaContext context) { this(null, json, context); context.unmarshall(json.getJsonObject(TYPE_RESOLVER), this); context.unmarshallList(json, TYPES); }
From source file:io.engagingspaces.graphql.marshaller.schema.impl.SchemaContextImpl.java
License:Open Source License
@Override @SuppressWarnings("unchecked") public <T extends SchemaDecorator, U extends SchemaDecorator> T dereference(Object jsonData, U parent) { if (decoratedTypes.containsKey(jsonData)) { return (T) decoratedTypes.get(jsonData); } else {//w ww .ja v a 2 s . c o m JsonObject json = (JsonObject) jsonData; String reference = json.getString(REF_KEY); if (reference != null) { String[] referencePath = json.getString(REF_KEY).substring(ROOT_REFERENCE.length()).split(SLASH); json = rootJson; for (String ref : referencePath) { json = json.getJsonObject(ref); } return unmarshall(json, parent); } } return null; }
From source file:io.engagingspaces.graphql.schema.SchemaDefinitionOptions.java
License:Open Source License
/** * Creates a {@link SchemaDefinitionOptions} from its json representation. * * @param json the serialized options instance *//*from ww w. j av a 2 s .c om*/ public SchemaDefinitionOptions(JsonObject json) { Objects.requireNonNull(json, "Schema definition options json cannot be null"); this.schemaName = json.getString("schemaName"); this.deliveryOptions = new DeliveryOptions(json.getJsonObject("deliveryOptions")); this.proxyType = Enum.valueOf(SchemaProxyType.class, json.getString("proxyType")); this.isInternal = json.getBoolean("isInternal"); }
From source file:io.flowly.auth.ExtJwtAuthProvider.java
License:Open Source License
public ExtJwtAuthProvider(Vertx vertx, JsonObject config) { this.permissionsClaimKey = config.getString("permissionsClaimKey", "permissions"); final JsonObject keyStore = config.getJsonObject("keyStore"); try {// w w w .j av a2 s . co m if (keyStore != null) { KeyStore ks = KeyStore.getInstance(keyStore.getString("type", "jceks")); VertxInternal vertxInternal = (VertxInternal) vertx; try (InputStream in = new FileInputStream(vertxInternal.resolveFile(keyStore.getString("path")))) { ks.load(in, keyStore.getString(io.flowly.core.security.User.PASSWORD).toCharArray()); } this.jwt = new JWT(ks, keyStore.getString(io.flowly.core.security.User.PASSWORD).toCharArray()); } else { this.jwt = new JWT(null, null); } } catch (KeyStoreException | IOException | CertificateException | NoSuchAlgorithmException e) { throw new RuntimeException(e); } }
From source file:io.github.cdelmas.spike.vertx.infrastructure.auth.FacebookOauthTokenVerifier.java
License:Apache License
@Override public void authenticate(JsonObject credentials, Handler<AsyncResult<User>> resultHandler) { String token = credentials.getString("token"); httpClient.getAbs("https://graph.facebook.com:443/v2.4/me?access_token=" + token) .handler(response -> response.bodyHandler(buffer -> { JsonObject json = new JsonObject(buffer.toString()); if (response.statusCode() != 200) { String message = json.getJsonObject("error").getString("message"); resultHandler.handle(Future.failedFuture(message)); } else { resultHandler.handle(Future.succeededFuture( new MyUser(Long.parseLong(json.getString("id")), json.getString("name"), token))); }/*from www .j a v a 2 s.co m*/ })).exceptionHandler(error -> resultHandler.handle(Future.failedFuture(error.getMessage()))).end(); }
From source file:io.github.pflima92.plyshare.microservice.utility.MailServiceVertxProxyHandler.java
License:Apache License
public void handle(Message<JsonObject> msg) { try {/* w w w . j a v a 2s. c om*/ JsonObject json = msg.body(); String action = msg.headers().get("action"); if (action == null) { throw new IllegalStateException("action not specified"); } accessed(); switch (action) { case "send": { service.send(json.getJsonObject("message") == null ? null : new io.vertx.ext.mail.MailMessage(json.getJsonObject("message")), res -> { if (res.failed()) { if (res.cause() instanceof ServiceException) { msg.reply(res.cause()); } else { msg.reply(new ServiceException(-1, res.cause().getMessage())); } } else { msg.reply(res.result() == null ? null : res.result().toJson()); } }); break; } default: { throw new IllegalStateException("Invalid action: " + action); } } } catch (Throwable t) { msg.reply(new ServiceException(500, t.getMessage())); throw t; } }
From source file:io.hijynx.ensemble.identity.PrivilegeServiceVertxProxyHandler.java
License:Apache License
public void handle(Message<JsonObject> msg) { try {/*from w w w . java2 s.c om*/ JsonObject json = msg.body(); String action = msg.headers().get("action"); if (action == null) { throw new IllegalStateException("action not specified"); } accessed(); switch (action) { case "addPrivilege": { service.addPrivilege( json.getJsonObject("privilege") == null ? null : new io.hijynx.ensemble.identity.Privilege(json.getJsonObject("privilege")), createHandler(msg)); break; } case "retrievePrivilege": { service.retrievePrivilege((java.lang.String) json.getValue("id"), res -> { if (res.failed()) { if (res.cause() instanceof ServiceException) { msg.reply(res.cause()); } else { msg.reply(new ServiceException(-1, res.cause().getMessage())); } } else { msg.reply(res.result() == null ? null : res.result().toJson()); } }); break; } case "retrievePrivilegeByName": { service.retrievePrivilegeByName((java.lang.String) json.getValue("privilegeName"), res -> { if (res.failed()) { if (res.cause() instanceof ServiceException) { msg.reply(res.cause()); } else { msg.reply(new ServiceException(-1, res.cause().getMessage())); } } else { msg.reply(res.result() == null ? null : res.result().toJson()); } }); break; } case "retrieveAllPrivileges": { service.retrieveAllPrivileges(res -> { if (res.failed()) { if (res.cause() instanceof ServiceException) { msg.reply(res.cause()); } else { msg.reply(new ServiceException(-1, res.cause().getMessage())); } } else { msg.reply(new JsonArray( res.result().stream().map(Privilege::toJson).collect(Collectors.toList()))); } }); break; } case "updatePrivilege": { service.updatePrivilege( json.getJsonObject("privilege") == null ? null : new io.hijynx.ensemble.identity.Privilege(json.getJsonObject("privilege")), res -> { if (res.failed()) { if (res.cause() instanceof ServiceException) { msg.reply(res.cause()); } else { msg.reply(new ServiceException(-1, res.cause().getMessage())); } } else { msg.reply(res.result() == null ? null : res.result().toJson()); } }); break; } case "deletePrivilege": { service.deletePrivilege((java.lang.String) json.getValue("id"), createHandler(msg)); break; } default: { throw new IllegalStateException("Invalid action: " + action); } } } catch (Throwable t) { msg.reply(new ServiceException(500, t.getMessage())); throw t; } }