// Create a list of ActionGroups associated with the user by retrieving each role's ActionGroups // (and proceed to Step4). // Use only as 'Step3' of 'UpdateIsENGINEUser' public void UpdateUserActionGroups(Object targetObject, java.util.ArrayList<Guid> roleIdList) { for (Guid roleID : roleIdList) { AsyncDataProvider.GetRoleActionGroupsByRoleId( new AsyncQuery( targetObject, new INewAsyncCallback() { @Override public void OnSuccess(Object target, Object returnValue) { UserPortalLoginModel loginModel = (UserPortalLoginModel) target; java.util.ArrayList<ActionGroup> roleActionGroupList = (java.util.ArrayList<ActionGroup>) returnValue; for (ActionGroup actionGroup : roleActionGroupList) { if (!loginModel.getLoggedUserActionGroupList().contains(actionGroup)) { loginModel.getLoggedUserActionGroupList().add(actionGroup); } } loginModel.setRolesCounter(loginModel.getRolesCounter() - 1); if (loginModel.getRolesCounter() == 0) { CheckIsENGINEUser(loginModel); } } }), roleID); } }
private void Edit() { if (getWindow() != null) { return; } VmInterfaceModel model = new VmInterfaceModel(); setWindow(model); model.setTitle("Edit Network Interface"); AsyncDataProvider.GetClusterNetworkList( new AsyncQuery( this, new INewAsyncCallback() { @Override public void OnSuccess(Object target, Object returnValue) { TemplateInterfaceListModel vmInterfaceListModel = (TemplateInterfaceListModel) target; java.util.ArrayList<network> network_list = returnValue != null ? (java.util.ArrayList<network>) returnValue : new java.util.ArrayList<network>(); vmInterfaceListModel.PostGetClusterNetworkList_Edit(network_list); } }), getEntityStronglyTyped().getvds_group_id()); }
public void New() { if (getWindow() != null) { return; } ClusterNetworkModel clusterModel = new ClusterNetworkModel(); setWindow(clusterModel); clusterModel.setTitle("New Logical Network"); clusterModel.setHashName("new_logical_network"); clusterModel.setIsNew(true); if (getEntity().getstorage_pool_id() != null) { AsyncQuery _asyncQuery = new AsyncQuery(); _asyncQuery.setModel(clusterModel); _asyncQuery.asyncCallback = new INewAsyncCallback() { public void OnSuccess(Object model, Object result) { ClusterNetworkModel clusterNetworkModel = (ClusterNetworkModel) model; storage_pool dataCenter = (storage_pool) result; clusterNetworkModel.setDataCenterName(dataCenter.getname()); } }; AsyncDataProvider.GetDataCenterById(_asyncQuery, getEntity().getstorage_pool_id().getValue()); } UICommand tempVar = new UICommand("OnSave", this); tempVar.setTitle("OK"); tempVar.setIsDefault(true); clusterModel.getCommands().add(tempVar); UICommand tempVar2 = new UICommand("Cancel", this); tempVar2.setTitle("Cancel"); tempVar2.setIsCancel(true); clusterModel.getCommands().add(tempVar2); }
public void Manage() { if (getWindow() != null) { return; } Guid storagePoolId = (getEntity().getstorage_pool_id() != null) ? getEntity().getstorage_pool_id().getValue() : Guid.Empty; AsyncQuery _asyncQuery = new AsyncQuery(); _asyncQuery.setModel(this); _asyncQuery.asyncCallback = new INewAsyncCallback() { public void OnSuccess(Object model, Object result) { ClusterNetworkListModel clusterNetworkListModel = (ClusterNetworkListModel) model; java.util.ArrayList<network> networkList = (java.util.ArrayList<network>) result; ListModel listModel = new ListModel(); clusterNetworkListModel.setWindow(listModel); listModel.setTitle("Assign/Detach Networks"); listModel.setHashName("assign_networks"); clusterNetworkListModel.PostManage(networkList, listModel); } }; AsyncDataProvider.GetNetworkList(_asyncQuery, storagePoolId); }
// Update IsENGINEUser flag. // Get 'ENGINEUser' role's ActionGroups (and proceed to Step2). public void UpdateIsENGINEUser(VdcUser LoggedUser) { setENGINEUserActionGroupList(new java.util.ArrayList<ActionGroup>()); this.setLoggedUser(LoggedUser); AsyncDataProvider.GetRoleActionGroupsByRoleId( new AsyncQuery( this, new INewAsyncCallback() { @Override public void OnSuccess(Object target, Object returnValue) { UserPortalLoginModel loginModel = (UserPortalLoginModel) target; loginModel.setENGINEUserActionGroupList( (java.util.ArrayList<ActionGroup>) returnValue); loginModel.GetUserRoles(loginModel); } }), new Guid(ENGINEUserRoleId)); }
// Get logged user's permissions and create a list of roles associated with the user (and proceed // to Step3). // Use only as 'Step2' of 'UpdateIsENGINEUser' public void GetUserRoles(Object targetObject) { UserPortalLoginModel loginModel = (UserPortalLoginModel) targetObject; AsyncDataProvider.GetPermissionsByAdElementId( new AsyncQuery( targetObject, new INewAsyncCallback() { @Override public void OnSuccess(Object target, Object returnValue) { java.util.ArrayList<permissions> permissions = (java.util.ArrayList<permissions>) returnValue; java.util.ArrayList<Guid> roleIdList = new java.util.ArrayList<Guid>(); boolean everyoneBlankPermission = false; for (permissions permission : permissions) { if (!everyoneBlankPermission) { everyoneBlankPermission = permission.getad_element_id().getValue().equals(Everyone) && permission.getObjectId().getValue().equals(Blank) && permission.getrole_id().getValue().equals(UserTemplateBasedVM) && permission.getObjectType().equals(VdcObjectType.VmTemplate); if (everyoneBlankPermission) { continue; } } if (!roleIdList.contains(permission.getrole_id())) { roleIdList.add(permission.getrole_id()); } } UserPortalLoginModel loginModel1 = (UserPortalLoginModel) target; loginModel1.setLoggedUserActionGroupList(new java.util.ArrayList<ActionGroup>()); if (roleIdList.size() > 0) { loginModel1.setRolesCounter(roleIdList.size()); loginModel1.UpdateUserActionGroups(loginModel1, roleIdList); } else { CheckIsENGINEUser(loginModel1); } } }), loginModel.getLoggedUser().getUserId()); }