use of org.eweb4j.util.xml.XMLReader in project eweb4j-framework by laiweiwei.
the class ORMConfig method check.
public static synchronized String check() {
String error = null;
ConfigBean cb = (ConfigBean) SingleBeanCache.get(ConfigBean.class.getName());
if (cb == null)
return null;
List<String> ormXmlFilePaths = cb.getOrm().getOrmXmlFiles().getPath();
for (String filePath : ormXmlFilePaths) {
if (filePath == null || filePath.length() == 0)
continue;
File configFile = new File(ConfigConstant.CONFIG_BASE_PATH + filePath);
try {
XMLReader reader = BeanXMLUtil.getBeanXMLReader(configFile);
reader.setBeanName("orm");
reader.setClass("orm", ORMConfigBean.class);
List<ORMConfigBean> ormList = reader.read();
if (ormList == null || ormList.isEmpty()) {
error = rebuildXmlFile(configFile, ConfigInfoCons.CANNOT_READ_ANY_CONFIG_INFO);
} else {
for (ORMConfigBean orm : ormList) {
String error1 = CheckConfigBean.checkORM(orm, filePath);
if (error1 != null)
if (error == null)
error = error1;
else
error += error1;
String error2 = CheckConfigBean.checkORMProperty(orm.getProperty(), ormList, orm.getId(), filePath);
if (error2 != null)
if (error == null)
error = error2;
else
error += error2;
}
if (error == null) {
for (ORMConfigBean orm : ormList) {
if (!"".equals(orm.getClazz()))
ORMConfigBeanCache.add(orm.getClazz(), orm);
}
}
}
} catch (Exception e) {
e.printStackTrace();
error = rebuildXmlFile(configFile, CommonUtil.getExceptionString(e));
}
}
if (error != null)
ORMConfigBeanCache.clear();
else
log.debug(ConfigInfoCons.READ_CONFIG_INFO_SUCCESS);
return error;
}
Aggregations