Search in sources :

Example 1 with BindingKey

use of org.n52.iceland.binding.BindingKey in project arctic-sea by 52North.

the class JsonActivationDao method setBindingStatus.

@Override
public void setBindingStatus(BindingKey key, boolean active) {
    writeLock().lock();
    try {
        ObjectNode node = getConfiguration().with(JsonConstants.ACTIVATION).with(JsonConstants.BINDINGS);
        if (key instanceof PathBindingKey) {
            node = node.with(JsonConstants.BY_PATH);
        } else if (key instanceof MediaTypeBindingKey) {
            node = node.with(JsonConstants.BY_MEDIA_TYPE);
        }
        node.put(key.getKeyAsString(), active);
    } finally {
        writeLock().unlock();
    }
    configuration().scheduleWrite();
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PathBindingKey(org.n52.iceland.binding.PathBindingKey) MediaTypeBindingKey(org.n52.iceland.binding.MediaTypeBindingKey)

Example 2 with BindingKey

use of org.n52.iceland.binding.BindingKey in project arctic-sea by 52North.

the class JsonActivationDao method getBindingKeys.

@Override
public Set<BindingKey> getBindingKeys() {
    readLock().lock();
    try {
        JsonNode node = getConfiguration().path(JsonConstants.ACTIVATION).path(JsonConstants.BINDINGS);
        Set<BindingKey> keys = new HashSet<>(node.size());
        node.path(JsonConstants.BY_PATH).fieldNames().forEachRemaining(k -> keys.add(new PathBindingKey(k)));
        node.path(JsonConstants.BY_MEDIA_TYPE).fieldNames().forEachRemaining(k -> keys.add(new MediaTypeBindingKey(MediaType.parse(k))));
        return keys;
    } finally {
        readLock().unlock();
    }
}
Also used : BindingKey(org.n52.iceland.binding.BindingKey) PathBindingKey(org.n52.iceland.binding.PathBindingKey) MediaTypeBindingKey(org.n52.iceland.binding.MediaTypeBindingKey) PathBindingKey(org.n52.iceland.binding.PathBindingKey) JsonNode(com.fasterxml.jackson.databind.JsonNode) MediaTypeBindingKey(org.n52.iceland.binding.MediaTypeBindingKey) HashSet(java.util.HashSet)

Aggregations

MediaTypeBindingKey (org.n52.iceland.binding.MediaTypeBindingKey)2 PathBindingKey (org.n52.iceland.binding.PathBindingKey)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 HashSet (java.util.HashSet)1 BindingKey (org.n52.iceland.binding.BindingKey)1