Search in sources :

Example 1 with CustomClassLoaderConstructor

use of org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor in project ovirt-engine by oVirt.

the class RsdlManager method loadMetaData.

private static MetaData loadMetaData(InputStream in) throws IOException {
    Constructor constructor = new CustomClassLoaderConstructor(Thread.currentThread().getContextClassLoader());
    MetaData metaData = (MetaData) new Yaml(constructor).load(in);
    if (metaData == null) {
        throw new IOException("Can't load metadata from input stream");
    }
    // Make sure that the loaded metadata contains default values:
    assignDefaults(metaData);
    // Remove leading slashes from all the action names:
    for (Action action : metaData.getActions()) {
        String name = action.getName();
        name = name.replaceAll("^/?", "");
        action.setName(name);
    }
    return metaData;
}
Also used : Constructor(org.yaml.snakeyaml.constructor.Constructor) CustomClassLoaderConstructor(org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor) CustomClassLoaderConstructor(org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor) IOException(java.io.IOException) Yaml(org.yaml.snakeyaml.Yaml)

Aggregations

IOException (java.io.IOException)1 Yaml (org.yaml.snakeyaml.Yaml)1 Constructor (org.yaml.snakeyaml.constructor.Constructor)1 CustomClassLoaderConstructor (org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor)1