template.setName(Utils.safeString(templateNameTextBox.getValue()));
template.setShared(chkbxShared.getValue());
template.clearDetails();
for (TemplateData data : permissionStore.getModels())
{
TemplateDetail templateDetail = (TemplateDetail)data.get(Constants.TEMPLATEDETAIL);
String newAccessLevel = ((AccessLevel)data.get(Constants.ACCESSLEVEL)).name();
if (!newAccessLevel.equals(templateDetail.getAccessLevel()))
{
// if user changed the access level value in the GUI, treat it like a new permission
templateDetail = new TemplateDetail(templateDetail.getSubject(), AccessLevel.valueOf(newAccessLevel));
}
template.addDetail(templateDetail);
}
final AsyncCallback<Boolean> callbackCheck = new AsyncCallback<Boolean>()