All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jbake.util.DataFileUtil Maven / Gradle / Ivy

Go to download

JBake is a Java based open source static site/blog generator for developers.

There is a newer version: 2.7.0-rc.7
Show newest version
package org.jbake.util;

import org.jbake.app.ContentStore;
import org.jbake.app.DocumentList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

public class DataFileUtil {

    private static final Logger LOGGER = LoggerFactory.getLogger(DataFileUtil.class);

    private ContentStore db;
    private String defaultDocType;

    public DataFileUtil(ContentStore db, String defaultDocType) {
        this.db = db;
        this.defaultDocType = defaultDocType;
    }

    public Map get(String ref) {
        Map result = new HashMap<>();
        DocumentList docs = db.getDocumentByUri(ref);
        if (docs.isEmpty()) {
            LOGGER.warn("Unable to locate content for ref: {}", ref);
        } else {
            if (docs.size() == 1) {
                result = (Map) docs.get(0);
            } else {
                LOGGER.warn("Located multiple hits for ref: {}", ref);
            }
        }
        return result;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy