}
public void saveRoleLayouts(String roleId, String[] layoutIds) throws DotDataException {
LayoutAPI layoutAPI = APILocator.getLayoutAPI();
RoleAPI roleAPI = APILocator.getRoleAPI();
Role role = roleAPI.loadRoleById(roleId);
List<Layout> layouts = layoutAPI.loadLayoutsForRole(role);
//Looking for removed layouts
for(Layout l : layouts) {
boolean found = false;
for(String changedLayout: layoutIds) {
if(changedLayout.equals(l.getId())) {
found = true;
break;
}
}
if(!found) {
roleAPI.removeLayoutFromRole(l, role);
}
}
//Looking for added layouts
for(String changedLayout : layoutIds) {
boolean found = false;
for(Layout l : layouts) {
if(changedLayout.equals(l.getId())) {
found = true;
break;
}
}
Layout layout = layoutAPI.loadLayout(changedLayout);
if(!found) {
roleAPI.addLayoutToRole(layout, role);
}
}
}