* @throws DotDataException
* @throws DotSecurityException
*/
public void save(Permission permission, Permissionable permissionable, User user, boolean respectFrontendRoles) throws DotDataException, DotSecurityException {
if(!doesUserHavePermission(permissionable, PermissionAPI.PERMISSION_EDIT_PERMISSIONS, user))
throw new DotSecurityException("User id: " + user.getUserId() + " does not have permission to alter permissions on asset " + permissionable.getPermissionId());
RoleAPI roleAPI = APILocator.getRoleAPI();
Role role = roleAPI.loadRoleById(permission.getRoleId());
if(!role.isEditPermissions())
throw new DotSecurityException("Role id " + role.getId() + " is locked for editing permissions");
try {
List<Permission> currentIndividualPermissions = getPermissions(permissionable, true, true);
if(currentIndividualPermissions.size() == 0) {
//We need to ensure locked roles get saved as permissions too
List<Permission> currentInheritedPermissions = getPermissions(permissionable, true);