public ActionForward changeMemberTypeCode(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   IdentityManagementRoleDocumentForm roleDocumentForm = (IdentityManagementRoleDocumentForm) form;
   roleDocumentForm.getMember().setMemberId("");
   return refresh(mapping, roleDocumentForm, request, response);
 }
  public ActionForward addMember(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    IdentityManagementRoleDocumentForm roleDocumentForm = (IdentityManagementRoleDocumentForm) form;
    KimDocumentRoleMember newMember = roleDocumentForm.getMember();

    // See if possible to add with just Group Details filled in (not returned from lookup)
    if (StringUtils.equals(
            newMember.getMemberTypeCode(),
            KimConstants.KimGroupMemberTypes.GROUP_MEMBER_TYPE.getCode())
        && StringUtils.isEmpty(newMember.getMemberId())
        && !newMember.isMemberNameNull()
        && !newMember.isMemberNameSpaceCodeNull()) {
      Group tempGroup =
          KimApiServiceLocator.getGroupService()
              .getGroupByNamespaceCodeAndName(
                  newMember.getMemberNamespaceCode(), newMember.getMemberName());
      if (tempGroup != null) {
        newMember.setMemberId(tempGroup.getId());
      }
    }

    // See if possible to grab details for Principal
    if (StringUtils.equals(
            newMember.getMemberTypeCode(),
            KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE.getCode())
        && StringUtils.isEmpty(newMember.getMemberId())
        && StringUtils.isNotEmpty(newMember.getMemberName())) {
      Principal principal =
          KimApiServiceLocator.getIdentityService()
              .getPrincipalByPrincipalName(newMember.getMemberName());
      if (principal != null) {
        newMember.setMemberId(principal.getPrincipalId());
        String fullName = checkMemberFullName(principal.getPrincipalId());
        if (fullName != null) {
          newMember.setMemberFullName(fullName);
        }
      }
    } else if (StringUtils.equals(
            newMember.getMemberTypeCode(),
            KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE.getCode())
        && StringUtils.isNotEmpty(newMember.getMemberId())
        && StringUtils.isNotEmpty(newMember.getMemberName())) {
      String fullName = checkMemberFullName(newMember.getMemberId());
      if (fullName != null) {
        newMember.setMemberFullName(fullName);
      }
    }

    if (checkKimDocumentRoleMember(newMember)
        && KRADServiceLocatorWeb.getKualiRuleService()
            .applyRules(new AddMemberEvent("", roleDocumentForm.getRoleDocument(), newMember))) {
      newMember.setDocumentNumber(roleDocumentForm.getDocument().getDocumentNumber());
      roleDocumentForm.getRoleDocument().addMember(newMember);
      roleDocumentForm.setMember(roleDocumentForm.getRoleDocument().getBlankMember());
    }
    return mapping.findForward(RiceConstants.MAPPING_BASIC);
  }