if (file == null) List<VirtualFile> matched = vfsDeploymentUnit.getMetaDataFiles(name, suffix, getMetaDataTypeFilter(unit)); if (matched != null && matched.isEmpty() == false)
/** * Get metadata file. * First try altDD, then fallback to original name. * * @param unit the vfs deployment unit * @param altExpectedClass the expected class of altDD * @param originalName the original file name * @param checkMetaDataFile should we fall back to metadata file * @return metadata file or null if it doesn't exist */ protected VirtualFile getMetadataFile(VFSDeploymentUnit unit, Class<?> altExpectedClass, String originalName, boolean checkMetaDataFile) { String altPrefix = (altExpectedClass != null ? altExpectedClass.getName() : originalName); VirtualFile file = unit.getAttachment(altPrefix + ".altDD", VirtualFile.class); if (file != null && altExpectedClass != null) { Map<String, Class<?>> altMappingsMap = getAltMappings(unit); if (altMappingsMap == null) { altMappingsMap = new HashMap<String, Class<?>>(); unit.addAttachment(ALT_MAPPINGS_MAP_KEY, altMappingsMap, Map.class); } altMappingsMap.put(file.getName(), altExpectedClass); } if(checkMetaDataFile && file == null) file = unit.getMetaDataFile(originalName, getMetaDataTypeFilter(unit)); return file; }
@Override protected T parse(DeploymentUnit unit, String name, String suffix, T root) throws Exception { // Should we include the deployment // The infrastructure will only check leafs anyway so no need to check here if (name == null && isIncludeDeploymentFile()) name = unit.getName(); // Try to find the metadata VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit; // let's check altDD first VirtualFile file = getMetadataFile(vfsDeploymentUnit, getOutput(), name, false); if (file != null) return parseAndInit(vfsDeploymentUnit, file, root, true); // try all name+suffix matches List<VirtualFile> files = vfsDeploymentUnit.getMetaDataFiles(name, suffix, getMetaDataTypeFilter(unit)); switch (files.size()) { case 0 : return null; case 1 : return parseAndInit(vfsDeploymentUnit, files.get(0), root, true); default : return handleMultipleFiles(vfsDeploymentUnit, root, files); } }