/** * Apply metadata on root to create context. * * @param context the structure context * @param metaDataPaths the metadata paths * @return the context info */ protected ContextInfo applyMetadataPaths(StructureContext context, String[] metaDataPaths) { if (context == null) throw new IllegalArgumentException("Null context"); VirtualFile root = context.getFile(); List<String> metaDataPath = CollectionsFactory.createLazyList(); // Determine whether the metadata paths exists if (metaDataPaths != null && metaDataPaths.length > 0) { for(String path : metaDataPaths) { VirtualFile child = root.getChild(path); if (child.exists()) metaDataPath.add(path); } } // Create and link the context if (metaDataPath.isEmpty()) return StructureMetaDataFactory.createContextInfo("", null); else return StructureMetaDataFactory.createContextInfo("", metaDataPath, null); }