public static Map getDefaultMetadata()

in src/main/java/com/amazonaws/schemamanager/repo/RepoUtils.java [115:152]


	public static Map<String, DefaultSchemaMetadata> getDefaultMetadata(String path) {
		Map<String, DefaultSchemaMetadata> defaults = new HashMap<>();
		Path basePath = Paths.get(path);
		
		if (!basePath.toFile().exists()) {
			log.info(path + " does not exist.");
			return null;
		}
		
		try (Stream<Path> walk = Files.walk(Paths.get(path))) {
            // We want to find only regular files
            walk.filter(Files::isDirectory)
                    .forEach(x -> {
                    	Path parent = x.getParent();
                    	DefaultSchemaMetadata parentDefaults = defaults.get(parent.toString());
                    	File __defaults = new File(x.toString() + SEPARATOR + DEAFULTS_FILENAME);
                    	DefaultSchemaMetadata nodeDefaults;
                    	if (!__defaults.exists()) {
                    		nodeDefaults = new DefaultSchemaMetadata(parentDefaults);
                    	}else {
                    		Yaml yaml = new Yaml();
                            try( InputStream in = Files.newInputStream( __defaults.toPath() ) ) {
                            	nodeDefaults = yaml.loadAs(in, DefaultSchemaMetadata.class);
                            } catch (IOException e) {
                            	log.error("Couldn't read file " + __defaults.toPath(), e);
                            	nodeDefaults = new DefaultSchemaMetadata(parentDefaults);
							}
                    	}
                    	
                    	defaults.put(basePath.relativize(x.toAbsolutePath()).toString(), nodeDefaults);
                    	nodeDefaults.setParent(parentDefaults);
                    });
        } catch (IOException e) {
        	log.error("ERROR: ", e);
			return null;
        }
		return defaults;
	}