Hello,
As I am extending SitetreeFragmentGenerator.java, I need to know if a
node is live or not. What's the best way to do this? So far, the only
option I found is this, but it is heavy and ugly:
protected boolean isLive(SiteTreeNode node) {
ServiceSelector selector = null;
DocumentBuilder builder = null;
try {
selector = (ServiceSelector)
this.manager.lookup(DocumentBuilder.ROLE + "Selector");
String hint = this.publication.getDocumentBuilderHint();
builder = (DocumentBuilder) selector.select(hint);
String lang = node.getLabels()[0].getLanguage();
DocumentIdentifier identifier = new
DocumentIdentifier(this.publication, this.area, node.getAbsoluteId(), lang);
Document document = builder.buildDocument(this.identityMap,
identifier);
//String workflowstate =
document.getMetaDataManager().getLenyaMetaData().getFirstValue("workflowVersion");
String [] workflowstate =
document.getMetaDataManager().getLenyaMetaData().getValues("workflowVersion");
if (workflowstate.length == 0) {
return false;
}
String lastworkflowstate = workflowstate[workflowstate.length -1];
boolean isLive = lastworkflowstate.endsWith("var:is_live=true");
return isLive;
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (selector != null) {
if (builder != null) {
selector.release(builder);
}
this.manager.release(selector);
}
}
}
Any hints welcome :-)
Thanks,
Renaud
--
Renaud Richardet
COO America
Wyona Inc. - Open Source Content Management - Apache Lenya
office +1 857 776-3195 mobile +1 617 230 9112
renaud.richardet <at> wyona.com http://www.wyona.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]