} else if (name.equals(LINK_ELEM)) {
PortalService portalService = null;
try {
portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
final LinkService linkService = portalService.getComponentManager().getLinkService();
final String format = attr.getValue("format");
AttributesImpl newAttrs = new AttributesImpl();
newAttrs.setAttributes(attr);
newAttrs.removeAttribute("format");
if ( attr.getValue("href") != null ) {
final CopletInstanceData cid = this.getCopletInstanceData();
ChangeCopletInstanceAspectDataEvent event = new ChangeCopletInstanceAspectDataEvent(cid, null, null);
String value = linkService.getLinkURI(event);
if (value.indexOf('?') == -1) {
value = value + '?' + attr.getValue("href");
} else {
value = value + '&' + attr.getValue("href");
}
newAttrs.removeAttribute("href");
this.output(value, format, newAttrs );
} else {
final String path = attr.getValue("path");
final String value = attr.getValue("value");
newAttrs.removeAttribute("path");
newAttrs.removeAttribute("value");
JXPathEvent event;
if ( attr.getValue("layout") != null ) {
newAttrs.removeAttribute("layout");
final String layoutId = attr.getValue("layout");
Object layout = portalService.getComponentManager().getProfileManager().getPortalLayout(null, layoutId);
event = new JXPathEvent(layout, path, value);
} else {
String copletId = attr.getValue("coplet");
newAttrs.removeAttribute("coplet");
final CopletInstanceData cid = this.getCopletInstanceData(copletId);
event = new CopletJXPathEvent(cid, path, value);
}
if ( this.insideLinks ) {
this.collectedEvents.add(event);
} else {
final String href = linkService.getLinkURI(event);
this.output(href, format, newAttrs );
}
}
} catch (ServiceException e) {
throw new SAXException("Error getting portal service.", e);