Search in sources :

Example 1 with Yaml2Json

use of com.artipie.front.misc.Yaml2Json in project front by artipie.

the class GetRepository method handle.

@Override
public String handle(final Request request, final Response response) {
    final JsonObject repo = new Yaml2Json().apply(new String(this.stn.value(GetRepository.NAME_PARAM.parse(request), RequestAttr.Standard.USER_ID.readOrThrow(request)), StandardCharsets.UTF_8)).asJsonObject().getJsonObject(GetRepository.REPO);
    JsonObjectBuilder builder = Json.createObjectBuilder();
    for (final Map.Entry<String, JsonValue> item : repo.entrySet()) {
        if (!"permissions".equals(item.getKey())) {
            builder = builder.add(item.getKey(), item.getValue());
        }
    }
    response.type("application/json");
    return Json.createObjectBuilder().add(GetRepository.REPO, builder.build()).build().toString();
}
Also used : Yaml2Json(com.artipie.front.misc.Yaml2Json) JsonValue(javax.json.JsonValue) JsonObject(javax.json.JsonObject) JsonObjectBuilder(javax.json.JsonObjectBuilder) Map(java.util.Map)

Aggregations

Yaml2Json (com.artipie.front.misc.Yaml2Json)1 Map (java.util.Map)1 JsonObject (javax.json.JsonObject)1 JsonObjectBuilder (javax.json.JsonObjectBuilder)1 JsonValue (javax.json.JsonValue)1