* @see net.sf.sitstart.svc.internal.LinkFactory#create(net.sf.sitstart.dto.Asset, java.lang.String)
*/
public Link create(Asset source, String targetLinkTag)
{
Link result = null;
Asset target = null;
URI targetURI = null;
Link.LinkTagType linkTagType = null;
// PRECONDITIONS
assert source != null : "source must not be null.";
assert targetLinkTag != null : "targetLinkTag must not be null.";
assert targetLinkTag.trim().length() > 0 : "targetLinkTag must not be empty or blank.";
// Body
targetURI = parseLinkTag(targetLinkTag);
target = assetRetriever.retrieve(targetURI).getAsset();
try
{
result = linkClass.newInstance();
}
catch (RuntimeException re)
{
throw re;
}
catch (Exception e)
{
throw new RuntimeException(e);
}
result.setSource(source);
result.setTarget(target);
result.setLinkTag(targetLinkTag.trim());
result.setLinkTagType(linkTagType);
// Don't forget to link everything up
target.addIncomingLink(result);
source.addIncomingLink(result);
return(result);
}