use of org.alfresco.web.ui.repo.component.UINodePath in project acs-community-packaging by Alfresco.
the class NodePathLinkRenderer method encodeEnd.
/**
* @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
*/
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
// always check for this flag - as per the spec
if (!component.isRendered()) {
return;
}
Writer out = context.getResponseWriter();
// make sure we have a NodeRef or Path from the 'value' property ValueBinding
Path path = null;
NodeRef nodeRef = null;
Object val = ((UINodePath) component).getValue();
if (val instanceof NodeRef) {
nodeRef = (NodeRef) val;
} else if (val instanceof Path) {
path = (Path) val;
} else if (val != null) {
throw new IllegalArgumentException("UINodePath component 'value' " + "property must resolve to a NodeRef " + "or Path. Got a " + val.getClass().getName());
}
if (val != null) {
boolean isBreadcrumb = false;
Boolean breadcrumb = (Boolean) component.getAttributes().get("breadcrumb");
if (breadcrumb != null) {
isBreadcrumb = breadcrumb.booleanValue();
}
boolean isDisabled = false;
Boolean disabled = (Boolean) component.getAttributes().get("disabled");
if (disabled != null) {
isDisabled = disabled.booleanValue();
}
boolean showLeaf = false;
Boolean showLeafBool = (Boolean) component.getAttributes().get("showLeaf");
if (showLeafBool != null) {
showLeaf = showLeafBool.booleanValue();
}
// use Spring JSF integration to get the node service bean
NodeService service = getNodeService(context);
UserTransaction tx = null;
try {
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance(), true);
tx.begin();
if (path == null) {
path = service.getPath(nodeRef);
}
if (isBreadcrumb == false || isDisabled == true) {
out.write(buildPathAsSingular(context, component, path, showLeaf, isDisabled));
} else {
out.write(buildPathAsBreadcrumb(context, component, path, showLeaf));
}
tx.commit();
} catch (InvalidNodeRefException refErr) {
// this error simply means we cannot output the path
try {
if (tx != null) {
tx.rollback();
}
} catch (Exception tex) {
}
} catch (AccessDeniedException accessErr) {
// this error simply means we cannot output the path
try {
if (tx != null) {
tx.rollback();
}
} catch (Exception tex) {
}
} catch (Throwable err) {
try {
if (tx != null) {
tx.rollback();
}
} catch (Exception tex) {
}
throw new RuntimeException(err);
}
}
}
Aggregations