FileObject designFile = _dir.resolveFile(designName + ARCHIVED_DESIGN_EXTENSION);
if (!designFile.exists()) {
return null;
}
WGADesign design = new WGADesign();
design.setSource(this);
design.setName(name);
design.setTitle(designFile.getName().getBaseName());
design.setDescription("Design at location " + designFile.getURL().toString());
return design;
}
// Additional directory
else if (name.startsWith(DESIGNNAMEPREFIX_ADDITIONALDIR)) {
String designName = name.substring(DESIGNNAMEPREFIX_ADDITIONALDIR.length());
String dirPath = _additionalDirs.get(designName);
if (dirPath == null) {
return null;
}
FileObject dir = VFS.getManager().resolveFile((String) dirPath);
if (!dir.exists() || !dir.getType().equals(FileType.FOLDER)) {
return null;
}
FileObject syncInfo = DesignDirectory.getDesignDefinitionFile(dir);
// Non-empty directories without syncinfo may not be used as design directories
if (syncInfo == null && dir.getChildren().length != 0) {
return null;
}
WGADesign design = new WGADesign();
design.setSource(this);
design.setName(DESIGNNAMEPREFIX_ADDITIONALDIR + name);
design.setTitle(dir.getName().getBaseName());
design.setDescription("Design at location " + dir.getURL().toString());
design.setConfig(loadConfig(syncInfo));
return design;
}
// Regular design in configured directory
else {
_dir.refresh();
FileObject child = _dir.getChild(name);
if (child == null) {
return null;
}
FileObject resolvedChild = WGUtils.resolveDirLink(child);
if (!resolvedChild.getType().equals(FileType.FOLDER)) {
return null;
}
FileObject syncInfo = DesignDirectory.getDesignDefinitionFile(resolvedChild);
// Non-empty directories without syncinfo may not be used as design directories
if (syncInfo == null && child.getChildren().length != 0) {
return null;
}
WGADesign design = new WGADesign();
design.setSource(this);
design.setName(child.getName().getBaseName());
design.setTitle(child.getName().getBaseName());
design.setDescription("Design at location " + child.getURL().toString());
design.setConfig(loadConfig(syncInfo));
return design;
}
}
catch (FileSystemException e) {
throw new WGADesignRetrievalException("Exception retrieving file system designs", e);