@SuppressWarnings("unchecked")
public void execute(Environment env, Map params, TemplateModel[] loopVars,
TemplateDirectiveBody body) throws TemplateException, IOException {
BeanModel userModel = (BeanModel) params.get("user");
BeanModel projectModel = (BeanModel) params.get("project");
TemplateScalarModel entityModel = (TemplateScalarModel) params.get("entity");
TemplateScalarModel existModel = (TemplateScalarModel) params.get("exist");
Assert.notNull(entityModel, "Parameter entity can not be null!");
Assert.notNull(userModel, "Parameter user can not be null!");
Assert.notNull(projectModel, "Parameter project can not be null!");
String entity = (String) entityModel.getAsString();
User user = (User) userModel.getWrappedObject();
Project project = (Project) projectModel.getWrappedObject();
String exist = existModel!=null ? existModel.getAsString() : null;
Object value = null;
if(Profile.NAME.equals(entity)) {
value = linkService.getLink(user.getProjectId(), project.getProfileId(), entity);
} else if (TeamMember.NAME.equals(entity)) {
value = memberService.getMember(project, user, Boolean.FALSE);