1. After everything we try we cannot seem to get the correct combination to simply update the document in the JCR. To that end, we have taken to removing the object from the JCR and then recreating it.
2. We we try to publish the node, we get the error: Unable to perform a versioning operation on a non versionable node: /content/documents/subsite/sites/test-site/test-site
public Site updateSite(final Site site,
final WorkflowPersistenceManager wpm,
final HstRequestContext requestContext) throws DaoException {
LOG.warn(site.toString());
try {
final HstQueryManager queryManager = requestContext
.getQueryManager(requestContext.getSession());
final HstQuery query = queryManager.createQuery(
requestContext.getSiteContentBaseBean(), Site.class, true);
final Filter filter = query.createFilter();
filter.addEqualTo(Site.Attribute.SITE_ID.key, site.getSiteId());
query.setFilter(filter);
final HippoBeanIterator hippoBeans = query.execute()
.getHippoBeans();
if (hippoBeans.hasNext()) {
Site bean = (Site) hippoBeans.next();
if (bean.getSiteId() != null
&& bean.getSiteId().equals(site.getSiteId())) {
String path = bean.getNode().getParent().getPath();
Node pathNode = bean.getNode();
while (!pathNode.getPrimaryNodeType().getName()
.equals("hippostd:folder")) {
LOG.warn(pathNode.getPath() + "::"
+ pathNode.getPrimaryNodeType().getName());
pathNode = pathNode.getParent();
}
LOG.warn("Queried Bean Path::" + path);
Object obj = wpm.getObject(path);
if (obj != null) {
// delete the doc and recreate
wpm.remove(obj);
wpm.save();
LOG.warn("REMOVED DOC");
}
String beanPath = wpm.createAndReturn(pathNode.getPath(),
Site.NODE_TYPE, bean.getName(), true);
LOG.warn("New Bean Path::" + beanPath);
Site node = (Site) wpm.getObject(beanPath);
bindDocumentToNode(site, node.getNode());
wpm.update(node);
wpm.save();
publishDoc(wpm, node);
}
}
} catch (IllegalStateException | RepositoryException | QueryException
| ObjectBeanManagerException e) {
LOG.warn("Exception while updating Site document.", e);
}
return null;
}
protected void publishDoc(WorkflowPersistenceManager wpm, T docBean)
throws ObjectBeanPersistenceException {
wpm.setWorkflowCallbackHandler(new BaseWorkflowCallbackHandler<DocumentWorkflow>() {
public void processWorkflow(DocumentWorkflow wf)
throws RepositoryException, RemoteException,
WorkflowException {
wf.publish();
}
});
wpm.update(docBean);
wpm.save();
}