コード例 #1
0
  // 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);
    }
  }
コード例 #2
0
  // 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));
  }
コード例 #3
0
  // 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());
  }