Program: 60607
Project: 60607
Buggy source:
public ResourceModalPage(final PageReference pageref,final ModalWindow window,final ResourceTO resourceTO,final boolean createFlag){
  super();
  final Form form=new Form("String_Node_Str");
  form.setModel(new CompoundPropertyModel(resourceTO));
  form.add(new ResourceDetailsPanel("String_Node_Str",resourceTO,restClient.getPropagationActionsClasses(),createFlag));
  form.add(new ResourceMappingPanel("String_Node_Str",resourceTO,AttributableType.USER));
  form.add(new ResourceMappingPanel("String_Node_Str",resourceTO,AttributableType.ROLE));
  form.add(new ResourceConnConfPanel("String_Node_Str",resourceTO,createFlag));
  form.add(new ResourceSecurityPanel("String_Node_Str",resourceTO));
  final AjaxButton submit=new IndicatingAjaxButton("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str")){
    private static final long serialVersionUID=-958724007591692537L;
    @Override protected void onSubmit(    final AjaxRequestTarget target,    final Form<?> form){
      final ResourceTO resourceTO=(ResourceTO)form.getDefaultModelObject();
      boolean accountIdError=false;
      if (resourceTO.getUmapping().getItems().isEmpty()) {
        resourceTO.setUmapping(null);
      }
 else {
        int uAccountIdCount=0;
        for (        MappingItemTO item : resourceTO.getUmapping().getItems()) {
          if (item.isAccountid()) {
            uAccountIdCount++;
          }
        }
        accountIdError=uAccountIdCount != 1;
      }
      if (resourceTO.getRmapping().getItems().isEmpty()) {
        resourceTO.setRmapping(null);
      }
 else {
        int rAccountIdCount=0;
        for (        MappingItemTO item : resourceTO.getRmapping().getItems()) {
          if (item.isAccountid()) {
            rAccountIdCount++;
          }
        }
        accountIdError|=rAccountIdCount != 1;
      }
      if (accountIdError) {
        error(new ResourceModel("String_Node_Str","String_Node_Str").getObject());
        target.add(feedbackPanel);
      }
 else {
        try {
          if (createFlag) {
            restClient.create(resourceTO);
          }
 else {
            restClient.update(resourceTO);
          }
          ((Resources)pageref.getPage()).setModalResult(true);
          window.close(target);
        }
 catch (        Exception e) {
          LOG.error("String_Node_Str",resourceTO,e);
          error(new ResourceModel("String_Node_Str","String_Node_Str").getObject() + "String_Node_Str" + e.getMessage());
          target.add(feedbackPanel);
        }
      }
    }
    @Override protected void onError(    final AjaxRequestTarget target,    final Form<?> form){
      target.add(feedbackPanel);
    }
  }
;
  form.add(submit);
  final AjaxButton cancel=new IndicatingAjaxButton("String_Node_Str",new ResourceModel("String_Node_Str")){
    private static final long serialVersionUID=-958724007591692537L;
    @Override protected void onSubmit(    final AjaxRequestTarget target,    final Form<?> form){
      window.close(target);
    }
    @Override protected void onError(    final AjaxRequestTarget target,    final Form<?> form){
    }
  }
;
  cancel.setDefaultFormProcessing(false);
  form.add(cancel);
  add(form);
  MetaDataRoleAuthorizationStrategy.authorize(submit,ENABLE,xmlRolesReader.getAllAllowedRoles("String_Node_Str",createFlag ? "String_Node_Str" : "String_Node_Str"));
}

Fixed version (ground truth):
public ResourceModalPage(final PageReference pageref,final ModalWindow window,final ResourceTO resourceTO,final boolean createFlag){
  super();
  final Form form=new Form("String_Node_Str");
  form.setModel(new CompoundPropertyModel(resourceTO));
  form.add(new ResourceDetailsPanel("String_Node_Str",resourceTO,restClient.getPropagationActionsClasses(),createFlag));
  form.add(new ResourceMappingPanel("String_Node_Str",resourceTO,AttributableType.USER));
  form.add(new ResourceMappingPanel("String_Node_Str",resourceTO,AttributableType.ROLE));
  form.add(new ResourceConnConfPanel("String_Node_Str",resourceTO,createFlag));
  form.add(new ResourceSecurityPanel("String_Node_Str",resourceTO));
  final AjaxButton submit=new IndicatingAjaxButton("String_Node_Str",new ResourceModel("String_Node_Str","String_Node_Str")){
    private static final long serialVersionUID=-958724007591692537L;
    @Override protected void onSubmit(    final AjaxRequestTarget target,    final Form<?> form){
      final ResourceTO resourceTO=(ResourceTO)form.getDefaultModelObject();
      boolean accountIdError=false;
      if (resourceTO.getUmapping().getItems().isEmpty()) {
        resourceTO.setUmapping(null);
      }
 else {
        int uAccountIdCount=0;
        for (        MappingItemTO item : resourceTO.getUmapping().getItems()) {
          if (item.isAccountid()) {
            uAccountIdCount++;
          }
        }
        accountIdError=uAccountIdCount != 1;
      }
      if (resourceTO.getRmapping().getItems().isEmpty()) {
        resourceTO.setRmapping(null);
      }
 else {
        int rAccountIdCount=0;
        for (        MappingItemTO item : resourceTO.getRmapping().getItems()) {
          if (item.isAccountid()) {
            rAccountIdCount++;
          }
        }
        accountIdError|=rAccountIdCount != 1;
      }
      if (accountIdError) {
        error(getString("String_Node_Str"));
        target.add(feedbackPanel);
      }
 else {
        try {
          if (createFlag) {
            restClient.create(resourceTO);
          }
 else {
            restClient.update(resourceTO);
          }
          ((Resources)pageref.getPage()).setModalResult(true);
          window.close(target);
        }
 catch (        Exception e) {
          LOG.error("String_Node_Str",resourceTO,e);
          error(getString("String_Node_Str") + "String_Node_Str" + e.getMessage());
          target.add(feedbackPanel);
        }
      }
    }
    @Override protected void onError(    final AjaxRequestTarget target,    final Form<?> form){
      target.add(feedbackPanel);
    }
  }
;
  form.add(submit);
  final AjaxButton cancel=new IndicatingAjaxButton("String_Node_Str",new ResourceModel("String_Node_Str")){
    private static final long serialVersionUID=-958724007591692537L;
    @Override protected void onSubmit(    final AjaxRequestTarget target,    final Form<?> form){
      window.close(target);
    }
    @Override protected void onError(    final AjaxRequestTarget target,    final Form<?> form){
    }
  }
;
  cancel.setDefaultFormProcessing(false);
  form.add(cancel);
  add(form);
  MetaDataRoleAuthorizationStrategy.authorize(submit,ENABLE,xmlRolesReader.getAllAllowedRoles("String_Node_Str",createFlag ? "String_Node_Str" : "String_Node_Str"));
}