final List<IProperty> properties = PropertiesImplUtil.findPropertiesByKey(project, name);
String value = null;
// 1. default.properties from struts2-core.jar
final IProperty strutsDefaultProperty = ContainerUtil.find(properties, new Condition<IProperty>() {
public boolean value(final IProperty property) {
final VirtualFile virtualFile = property.getPropertiesFile().getVirtualFile();
return virtualFile != null &&
virtualFile.getFileSystem() instanceof JarFileSystem &&
StringUtil.endsWith(virtualFile.getPath(), STRUTS_DEFAULT_PROPERTIES) &&
ModuleUtilCore.moduleContainsFile(module, virtualFile, true);
}
});
if (strutsDefaultProperty != null) {
value = strutsDefaultProperty.getValue();
}
// 2. <constant> from StrutsModel
final Condition<Constant> constantNameCondition = new Condition<Constant>() {
public boolean value(final Constant constant) {
return Comparing.equal(constant.getName().getStringValue(), name);
}
};
final List<DomFileElement<StrutsRoot>> domFileElements = new ArrayList<DomFileElement<StrutsRoot>>();
collectStrutsXmls(domFileElements, strutsModel, "struts-default.xml", true);
collectStrutsXmls(domFileElements, strutsModel, "struts-plugin.xml", true);
collectStrutsXmls(domFileElements, strutsModel, "struts.xml", false);
for (final DomFileElement<StrutsRoot> domFileElement : domFileElements) {
final Constant constant = ContainerUtil.find(domFileElement.getRootElement().getConstants(),
constantNameCondition);
final String strutsXmlValue = constant != null ? constant.getValue().getStringValue() : null;
if (strutsXmlValue != null) {
value = strutsXmlValue;
}
}
// 3. struts.properties in current module
final IProperty strutsProperty = ContainerUtil.find(properties, new Condition<IProperty>() {
public boolean value(final IProperty property) {
final VirtualFile virtualFile = property.getPropertiesFile().getVirtualFile();
return virtualFile != null &&
Comparing.equal(virtualFile.getName(), STRUTS_PROPERTIES_FILENAME) &&
ModuleUtilCore.moduleContainsFile(module, virtualFile, false);
}
});
if (strutsProperty != null) {
value = strutsProperty.getValue();
}
// 4. web.xml
final WebFacet webFacet = WebUtil.getWebFacet(context);
if (webFacet == null) {