*/
void extractEntryFromDocument(final Element branchElement, final Branch targetBranch)
throws XPathExpressionException
{
final XPath xpath = XPathFactory.newInstance().newXPath();
final EntryDAO entryDao = getDaoFacade().getEntryDAO();
final BranchDAO branchDao = getDaoFacade().getBranchDAO();
final Branch subListParent = branchDao.read(targetBranch.getBranchId());
final Element entriesElement = (Element) xpath.evaluate(TAG_ENTRIES, branchElement, XPathConstants.NODE);
if (entriesElement != null) {
final NodeList entryList = (NodeList) xpath.evaluate(TAG_ENTRY, entriesElement, XPathConstants.NODESET);
final String[] entryProperties = BeanUtils.getProperties(new Entry(), EXCLUDED_PROPS);
final Entry entry = new Entry();
for (int i = 0; entryList != null && i < entryList.getLength(); i++) {
for (final String property : entryProperties) {
final Object val = getElementPropValue((Element) entryList.item(i),
BeanUtils.getPropertyType(entry, property), property);
if (val != null) {
try {
org.apache.commons.beanutils.BeanUtils.setProperty(entry, property, val);
} catch (final Exception e) {
throw new JournalException(e.getMessage(), e);
}
}
}
if (null == entryDao.readByTitle(entry.getTitle(), subListParent.getBranchId())) {
entry.setBranch(subListParent);
entry.setNodeId(0);
entryDao.save(entry);
}
}
}
}