try
{
ConcreteElement result = null;
Profile baseProfile = null;
ProfileLocator baseLocator = Profiler.createLocator();
int rootType = JetspeedLink.DEFAULT;
String rootValue = null;
int elementType = JetspeedLink.DEFAULT;
String elementValue = null;
// Create locator to retrieve profile settings
if (this.psml != null)
{
baseLocator.createFromPath(this.psml);
if (baseLocator.getUser() != null)
{
rootType = JetspeedLink.USER;
rootValue = baseLocator.getUserName();
}
else if (baseLocator.getRole() != null)
{
rootType = JetspeedLink.ROLE;
rootValue = baseLocator.getRoleName();
}
else if (baseLocator.getGroup() != null)
{
rootType = JetspeedLink.GROUP;
rootValue = baseLocator.getGroupName();
}
}
else
{
rootType = JetspeedLink.CURRENT;
rootValue = "";
baseProfile = data.getProfile();
baseLocator.createFromPath(baseProfile.getPath());
}
// Determine search method
if (baseLocator != null)
{
// search by portlet name
if (this.name != null)
{
elementType = JetspeedLink.PORTLET_ID_QUERY;
elementValue = this.name;
}
else if (this.jspeid != null)
{
elementType = JetspeedLink.PORTLET_ID;
elementValue = this.jspeid;
}
// Build the link
JetspeedLink link = JetspeedLinkFactory.getInstance(data);
DynamicURI uri = link.getLink(rootType,
rootValue,
baseLocator.getName(),
elementType,
elementValue,
this.action == null ? "controls.Maximize" : this.action,
null,
baseLocator.getMediaType(),
baseLocator.getLanguage(),
baseLocator.getCountry());
result = new StringElement(uri.toString());
JetspeedLinkFactory.putInstance(link);
}
// Output the result