try {
Element resourcesEle = XMLUtil.parseToElement(resource.getFile());
List<Element> resourceEles = XMLUtil.getChildElements(resourcesEle, "resource");
for(Element resourceEle : resourceEles) {
String code = XMLUtil.getAttribute(resourceEle, "code");
Resource r = getResource(code);
if(r==null) {
r = new Resource();
}
r.setCode(code);
r.setName(XMLUtil.getAttribute(resourceEle, "name"));
r.setDescription(XMLUtil.getAttribute(resourceEle, "description"));
Boolean enabled = StringUtils.equals(XMLUtil.getAttribute(resourceEle, "enabled"), "true");
r.setEnabled(enabled);
updateResource(r);
}
} catch (IOException e) {
e.printStackTrace();
}