Example usage for io.vertx.core.json JsonObject fieldNames

List of usage examples for io.vertx.core.json JsonObject fieldNames

Introduction

In this page you can find the example usage for io.vertx.core.json JsonObject fieldNames.

Prototype

public Set<String> fieldNames() 

Source Link

Document

Return the set of field names in the JSON objects

Usage

From source file:org.entcore.workspace.service.WorkspaceService.java

License:Open Source License

private void createThumbnailIfNeeded(final String collection, final JsonObject srcFile, final String documentId,
        final JsonObject oldThumbnail, final List<String> thumbs, final Handler<Message<JsonObject>> callback) {
    if (documentId != null && thumbs != null && !documentId.trim().isEmpty() && !thumbs.isEmpty()
            && srcFile != null && isImage(srcFile) && srcFile.getString("_id") != null) {
        createThumbnails(thumbs, srcFile, collection, documentId, callback);
    } else {//w  ww .  j  a  v a  2 s .  c  o m
        callback.handle(null);
    }
    if (oldThumbnail != null) {
        for (final String attr : oldThumbnail.fieldNames()) {
            storage.removeFile(oldThumbnail.getString(attr), new Handler<JsonObject>() {
                @Override
                public void handle(JsonObject event) {
                    if (!"ok".equals(event.getString("status"))) {
                        log.error("Error removing thumbnail " + oldThumbnail.getString(attr) + " : "
                                + event.getString("message"));
                    }
                }
            });
        }
    }
}

From source file:org.sfs.auth.SimpleAuthProvider.java

License:Apache License

@Override
public Observable<Void> open(VertxContext<Server> vertxContext) {
    JsonObject config = vertxContext.verticle().config();
    JsonObject jsonObject = config.getJsonObject("auth");
    if (jsonObject != null) {
        for (String roleName : jsonObject.fieldNames()) {
            Role role = fromValueIfExists(roleName);
            checkState(role != null, "%s is not a valid role", roleName);
            JsonArray jsonUsers = jsonObject.getJsonArray(roleName);
            if (jsonUsers != null) {
                for (Object o : jsonUsers) {
                    JsonObject jsonUser = (JsonObject) o;
                    String id = getField(jsonUser, "id");
                    String username = getField(jsonUser, "username");
                    String password = getField(jsonUser, "password");
                    roles.put(role, new User(id, username, password));
                }/*from w  ww . j  a v  a 2  s .  c o m*/
            }
        }
    } else {
        roles.clear();
    }
    return aVoid();
}