Hi folks,
I could use some hints regarding this issue:
My macro looks something like this:
public class UseravatarMacro extends
AbstractMacro<UseravatarMacroParameters>
{
/**
* The description of the macro.
*/
private static final String DESCRIPTION = "Allows displaying the
avatar for a specific user.";
/**
* Injected by the Component Manager.
*/
private DocumentAccessBridge documentAccessBridge;
//....................................................................
public List<Block> execute(UseravatarMacroParameters parameters,
String content, MacroTransformationContext context)
throws MacroExecutionException
{
String atachment = null;
String userName = parameters.getUsername();
Block resultedBlock = null;
try {
atachment = documentAccessBridge.getProperty(userName,
"XWiki.XWikiUsers", "avatar");
Image image = new Image(userName, atachment);
resultedBlock = new ImageBlock(image, false);
}
catch {
//....................................................................
}
return Collections.singletonList(resultedBlock);
}
//....................................................................
}
Now, the problem is that, if the user doesn't have an avatar, I need to
display the default one (noavatar.png) from the current skin. In
velocity, it was something like this: $xwiki.getSkinFile("noavatar.png").
Any ideas on how to get the current XWikiContext in my macro in order to
be able to access the skin?
Tnx.