Program: 60964
Project: 60964
Buggy source:
/** 
 * Constructor.
 * @param callerPageRef
 * @param window
 * @param roleTO
 * @param createFlag
 */
public RoleModalPage(final PageReference callerPageRef,final ModalWindow window,final RoleTO roleTO,final boolean createFlag){
  super();
  if (!createFlag) {
    cloneOldRoleTO(roleTO);
  }
  final Form form=new Form("String_Node_Str");
  add(new Label("String_Node_Str",roleTO.getId() != 0 ? roleTO.getDisplayName() : "String_Node_Str"));
  form.setModel(new CompoundPropertyModel(roleTO));
  final AjaxTextFieldPanel name=new AjaxTextFieldPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<String>(roleTO,"String_Node_Str"),false);
  name.addRequiredLabel();
  form.add(name);
  form.add(new AttributesPanel("String_Node_Str",roleTO,form));
  final AjaxCheckBoxPanel inheritAttributes=new AjaxCheckBoxPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<Boolean>(roleTO,"String_Node_Str"),false);
  form.add(inheritAttributes);
  form.add(new DerivedAttributesPanel("String_Node_Str",roleTO));
  final CheckBox inheritDerivedAttributes=new CheckBox("String_Node_Str");
  inheritDerivedAttributes.setOutputMarkupId(true);
  form.add(inheritDerivedAttributes);
  form.add(new VirtualAttributesPanel("String_Node_Str",roleTO));
  final CheckBox inheritVirtualAttributes=new CheckBox("String_Node_Str");
  inheritVirtualAttributes.setOutputMarkupId(true);
  form.add(inheritVirtualAttributes);
  form.add(new ResourcesPanel("String_Node_Str",roleTO));
  ListModel<String> selectedEntitlements=new ListModel<String>(roleTO.getEntitlements());
  ListModel<String> availableEntitlements=new ListModel<String>(entitlementRestClient.getAllEntitlements());
  final Palette<String> entitlementsPalette=new Palette("String_Node_Str",selectedEntitlements,availableEntitlements,new SelectChoiceRenderer(),20,false);
  form.add(entitlementsPalette);
  submit=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){
      final RoleTO roleTO=(RoleTO)form.getDefaultModelObject();
      try {
        final List<String> entitlementList=new ArrayList<String>(entitlementsPalette.getModelCollection().size());
        for (        String entitlement : entitlementsPalette.getModelCollection()) {
          entitlementList.add(entitlement);
        }
        roleTO.setEntitlements(entitlementList);
        if (createFlag) {
          roleRestClient.createRole(roleTO);
        }
 else {
          setupRoleMod(roleTO);
          if (roleMod != null) {
            roleRestClient.updateRole(roleMod);
          }
        }
        ((Roles)callerPageRef.getPage()).setOperationResult(true);
        window.close(target);
      }
 catch (      Exception 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);
    }
  }
;
  String allowedRoles;
  if (createFlag) {
    allowedRoles=xmlRolesReader.getAllAllowedRoles("String_Node_Str","String_Node_Str");
  }
 else {
    allowedRoles=xmlRolesReader.getAllAllowedRoles("String_Node_Str","String_Node_Str");
  }
  MetaDataRoleAuthorizationStrategy.authorize(submit,ENABLE,allowedRoles);
  form.add(submit);
  add(form);
}

Fixed version (ground truth):
/** 
 * Constructor.
 * @param callerPageRef
 * @param window
 * @param roleTO
 * @param createFlag
 */
public RoleModalPage(final PageReference callerPageRef,final ModalWindow window,final RoleTO roleTO,final boolean createFlag){
  super();
  if (!createFlag) {
    cloneOldRoleTO(roleTO);
  }
  final Form form=new Form("String_Node_Str");
  add(new Label("String_Node_Str",roleTO.getId() != 0 ? roleTO.getDisplayName() : "String_Node_Str"));
  form.setModel(new CompoundPropertyModel(roleTO));
  final AjaxTextFieldPanel name=new AjaxTextFieldPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<String>(roleTO,"String_Node_Str"),false);
  name.addRequiredLabel();
  form.add(name);
  form.add(new AttributesPanel("String_Node_Str",roleTO,form));
  final AjaxCheckBoxPanel inhAttributes=new AjaxCheckBoxPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<Boolean>(roleTO,"String_Node_Str"),false);
  form.add(inhAttributes);
  form.add(new DerivedAttributesPanel("String_Node_Str",roleTO));
  final AjaxCheckBoxPanel inhDerivedAttributes=new AjaxCheckBoxPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<Boolean>(roleTO,"String_Node_Str"),false);
  inhDerivedAttributes.setOutputMarkupId(true);
  form.add(inhDerivedAttributes);
  form.add(new VirtualAttributesPanel("String_Node_Str",roleTO));
  final AjaxCheckBoxPanel inhVirtualAttributes=new AjaxCheckBoxPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<Boolean>(roleTO,"String_Node_Str"),false);
  inhVirtualAttributes.setOutputMarkupId(true);
  form.add(inhVirtualAttributes);
  form.add(new ResourcesPanel("String_Node_Str",roleTO));
  ListModel<String> selectedEntitlements=new ListModel<String>(roleTO.getEntitlements());
  ListModel<String> availableEntitlements=new ListModel<String>(entitlementRestClient.getAllEntitlements());
  final Palette<String> entitlementsPalette=new Palette("String_Node_Str",selectedEntitlements,availableEntitlements,new SelectChoiceRenderer(),20,false);
  form.add(entitlementsPalette);
  submit=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){
      final RoleTO roleTO=(RoleTO)form.getDefaultModelObject();
      try {
        final List<String> entitlementList=new ArrayList<String>(entitlementsPalette.getModelCollection().size());
        for (        String entitlement : entitlementsPalette.getModelCollection()) {
          entitlementList.add(entitlement);
        }
        roleTO.setEntitlements(entitlementList);
        if (createFlag) {
          roleRestClient.createRole(roleTO);
        }
 else {
          setupRoleMod(roleTO);
          if (roleMod != null) {
            roleRestClient.updateRole(roleMod);
          }
        }
        ((Roles)callerPageRef.getPage()).setOperationResult(true);
        window.close(target);
      }
 catch (      Exception 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);
    }
  }
;
  String allowedRoles;
  if (createFlag) {
    allowedRoles=xmlRolesReader.getAllAllowedRoles("String_Node_Str","String_Node_Str");
  }
 else {
    allowedRoles=xmlRolesReader.getAllAllowedRoles("String_Node_Str","String_Node_Str");
  }
  MetaDataRoleAuthorizationStrategy.authorize(submit,ENABLE,allowedRoles);
  form.add(submit);
  add(form);
}