Program: 61208
Project: 61208
Buggy source:
/** 
 * @param basePage base
 * @param modalWindow modal window
 * @param connectorTO
 * @param create : set to true only if a CREATE operation is required
 */
public UserModalPage(final BasePage basePage,final ModalWindow window,final UserTO userTO,final boolean createFlag){
  if (!createFlag) {
    cloneOldUserTO(userTO);
  }
  setupRolesMap();
  add(createUserWin=new ModalWindow("String_Node_Str"));
  createUserWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
  createUserWin.setPageMapName("String_Node_Str");
  createUserWin.setCookieName("String_Node_Str");
  Form userForm=new Form("String_Node_Str");
  userForm.setModel(new CompoundPropertyModel(userTO));
  setupSchemaWrappers(createFlag,userTO);
  setupMemberships(createFlag,userTO);
  final ListView userAttributesView=new ListView("String_Node_Str",schemaWrappers){
    @Override protected void populateItem(    ListItem item){
      final SchemaWrapper schemaWrapper=(SchemaWrapper)item.getDefaultModelObject();
      final SchemaTO schemaTO=schemaWrapper.getSchemaTO();
      item.add(new Label("String_Node_Str",schemaWrapper.getSchemaTO().getName()));
      item.add(new ListView("String_Node_Str",schemaWrapper.getValues()){
        Panel panel;
        @Override protected void populateItem(        final ListItem item){
          String mandatoryCondition=schemaTO.getMandatoryCondition();
          boolean required=false;
          if (mandatoryCondition.equalsIgnoreCase("String_Node_Str"))           required=true;
          if (schemaTO.getType().getClassName().equals("String_Node_Str")) {
            panel=new AjaxTextFieldPanel("String_Node_Str",schemaTO.getName(),new Model(){
              @Override public Serializable getObject(){
                return (String)item.getModelObject();
              }
              @Override public void setObject(              Serializable object){
                item.setModelObject((String)object);
              }
            }
,required,schemaTO.isReadonly());
          }
 else           if (schemaTO.getType().getClassName().equals("String_Node_Str")) {
            panel=new AjaxCheckBoxPanel("String_Node_Str",schemaTO.getName(),new Model(){
              @Override public Serializable getObject(){
                return (String)item.getModelObject();
              }
              @Override public void setObject(              Serializable object){
                Boolean val=(Boolean)object;
                item.setModelObject(val.toString());
              }
            }
,required,schemaTO.isReadonly());
          }
 else           if (schemaTO.getType().getClassName().equals("String_Node_Str")) {
            panel=new DateFieldPanel("String_Node_Str",schemaTO.getName(),new Model(){
              @Override public Serializable getObject(){
                DateFormat formatter=new SimpleDateFormat(schemaTO.getConversionPattern());
                Date date=new Date();
                try {
                  String dateValue=(String)item.getModelObject();
                  if (!dateValue.equals("String_Node_Str"))                   date=formatter.parse(dateValue);
                }
 catch (                ParseException ex) {
                  Logger.getLogger(RoleModalPage.class.getName()).log(Level.SEVERE,null,ex);
                }
                return date;
              }
              @Override public void setObject(              Serializable object){
                Date date=(Date)object;
                Format formatter=new SimpleDateFormat(schemaTO.getConversionPattern());
                String val=formatter.format(date);
                item.setModelObject(val);
              }
            }
,schemaTO.getConversionPattern(),required,schemaTO.isReadonly());
          }
 else {
            panel=new AjaxTextFieldPanel("String_Node_Str",schemaTO.getName(),new Model(){
              @Override public Serializable getObject(){
                return (String)item.getModelObject();
              }
              @Override public void setObject(              Serializable object){
                item.setModelObject((String)object);
              }
            }
,required,schemaTO.isReadonly());
          }
          item.add(panel);
        }
      }
);
      AjaxButton addButton=new AjaxButton("String_Node_Str",new Model(getString("String_Node_Str"))){
        @Override protected void onSubmit(        AjaxRequestTarget target,        Form form){
          schemaWrapper.getValues().add("String_Node_Str");
          target.addComponent(container);
        }
      }
;
      AjaxButton dropButton=new AjaxButton("String_Node_Str",new Model(getString("String_Node_Str"))){
        @Override protected void onSubmit(        AjaxRequestTarget target,        Form form){
          schemaWrapper.getValues().remove(schemaWrapper.getValues().size() - 1);
          target.addComponent(container);
        }
      }
;
      if (schemaTO.getType().getClassName().equals("String_Node_Str")) {
        addButton.setVisible(false);
        dropButton.setVisible(false);
      }
      addButton.setDefaultFormProcessing(false);
      addButton.setVisible(schemaTO.isMultivalue());
      dropButton.setDefaultFormProcessing(false);
      dropButton.setVisible(schemaTO.isMultivalue());
      if (schemaWrapper.getValues().size() == 1) {
        dropButton.setVisible(false);
      }
      if (schemaTO.isReadonly()) {
        addButton.setEnabled(false);
        dropButton.setEnabled(false);
      }
      item.add(addButton);
      item.add(dropButton);
    }
  }
;
  userForm.add(userAttributesView);
  ListModel<ResourceTO> selectedResources=new ListModel<ResourceTO>();
  selectedResources.setObject(getSelectedResources(userTO));
  ListModel<ResourceTO> availableResources=new ListModel<ResourceTO>();
  availableResources.setObject(getAvailableResources(userTO));
  ChoiceRenderer paletteRenderer=new ChoiceRenderer("String_Node_Str","String_Node_Str");
  final Palette resourcesPalette=new Palette("String_Node_Str",selectedResources,availableResources,paletteRenderer,8,false);
  userForm.add(resourcesPalette);
  container=new WebMarkupContainer("String_Node_Str");
  container.add(userAttributesView);
  PasswordTextField password=new PasswordTextField("String_Node_Str");
  password.setRequired(createFlag);
  password.setResetPassword(false);
  container.add(password);
  container.setOutputMarkupId(true);
  userForm.add(container);
  submit=new AjaxButton("String_Node_Str",new Model(getString("String_Node_Str"))){
    @Override protected void onSubmit(    AjaxRequestTarget target,    Form form){
      UserTO userTO=(UserTO)form.getDefaultModelObject();
      boolean res=false;
      try {
        userTO.setResources(getResourcesSet(resourcesPalette.getModelCollection()));
        userTO.setAttributes(getUserAttributesList());
        userTO.setMemberships(getMembershipsSet());
        if (createFlag) {
          usersRestClient.createUser(userTO);
        }
 else {
          setupUserMod(userTO);
          if (userMod != null) {
            res=usersRestClient.updateUser(userMod);
            if (!res)             error(getString("String_Node_Str"));
            Users callerPage=(Users)basePage;
            callerPage.setOperationResult(true);
          }
        }
        window.close(target);
      }
 catch (      Exception e) {
        error(getString("String_Node_Str") + "String_Node_Str" + e.getMessage());
      }
    }
    @Override protected void onError(    AjaxRequestTarget target,    Form form){
      target.addComponent(form.get("String_Node_Str"));
    }
  }
;
  userForm.add(submit);
  userForm.add(new FeedbackPanel("String_Node_Str").setOutputMarkupId(true));
  SyncopeRoleTree roleTree=new SyncopeRoleTree(rolesRestClient);
  BaseTree tree;
  tree=new LinkTree("String_Node_Str",roleTree.createTreeModel()){
    @Override protected IModel<Object> getNodeTextModel(    IModel<Object> model){
      return new PropertyModel(model,"String_Node_Str");
    }
    @Override protected void onNodeLinkClicked(    final Object node,    final BaseTree tree,    final AjaxRequestTarget target){
      DefaultMutableTreeNode syncopeTreeNode=(DefaultMutableTreeNode)node;
      final TreeModelBean treeModel=(TreeModelBean)syncopeTreeNode.getUserObject();
      if (treeModel.getTreeNode() != null) {
        createUserWin.setPageCreator(new ModalWindow.PageCreator(){
          MembershipTO membershipTO;
          @Override public Page createPage(){
            membershipTO=new MembershipTO();
            membershipTO.setRoleId(treeModel.getTreeNode().getId());
            String title=treeModel.getTreeNode().getName();
            MembershipModalPage form=new MembershipModalPage(getPage(),createUserWin,membershipTO,true);
            return form;
          }
        }
);
        createUserWin.show(target);
      }
    }
  }
;
  tree.getTreeState().expandAll();
  tree.updateTree();
  userForm.add(tree);
  ListView membershipsView=new ListView("String_Node_Str",membershipTOs){
    @Override protected void populateItem(    final ListItem item){
      final MembershipTO membershipTO=(MembershipTO)item.getDefaultModelObject();
      item.add(new Label("String_Node_Str",new Model(membershipTO.getRoleId())));
      item.add(new Label("String_Node_Str",new Model((String)rolesMap.get(membershipTO.getRoleId()))));
      AjaxLink editLink=new AjaxLink("String_Node_Str"){
        @Override public void onClick(        AjaxRequestTarget target){
          createUserWin.setPageCreator(new ModalWindow.PageCreator(){
            public Page createPage(){
              MembershipModalPage form=new MembershipModalPage(getPage(),createUserWin,membershipTO,false);
              return form;
            }
          }
);
          createUserWin.show(target);
        }
      }
;
      item.add(editLink);
      AjaxLink deleteLink=new AjaxLink("String_Node_Str"){
        @Override public void onClick(        AjaxRequestTarget target){
          int componentId=new Integer(getParent().getId());
          membershipTOs.remove(componentId);
          target.addComponent(membershipsContainer);
        }
      }
;
      item.add(deleteLink);
    }
  }
;
  membershipsContainer=new WebMarkupContainer("String_Node_Str");
  membershipsContainer.add(membershipsView);
  membershipsContainer.setOutputMarkupId(true);
  setWindowClosedCallback(createUserWin,membershipsContainer);
  userForm.add(membershipsContainer);
  add(userForm);
}

Fixed version (ground truth):
/** 
 * @param basePage base
 * @param modalWindow modal window
 * @param connectorTO
 * @param create : set to true only if a CREATE operation is required
 */
public UserModalPage(final BasePage basePage,final ModalWindow window,final UserTO userTO,final boolean createFlag){
  if (!createFlag) {
    cloneOldUserTO(userTO);
  }
  setupRolesMap();
  add(createUserWin=new ModalWindow("String_Node_Str"));
  createUserWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
  createUserWin.setPageMapName("String_Node_Str");
  createUserWin.setCookieName("String_Node_Str");
  Form userForm=new Form("String_Node_Str");
  userForm.setModel(new CompoundPropertyModel(userTO));
  setupSchemaWrappers(createFlag,userTO);
  setupMemberships(createFlag,userTO);
  final ListView userAttributesView=new ListView("String_Node_Str",schemaWrappers){
    @Override protected void populateItem(    ListItem item){
      final SchemaWrapper schemaWrapper=(SchemaWrapper)item.getDefaultModelObject();
      final SchemaTO schemaTO=schemaWrapper.getSchemaTO();
      item.add(new Label("String_Node_Str",schemaWrapper.getSchemaTO().getName()));
      item.add(new ListView("String_Node_Str",schemaWrapper.getValues()){
        Panel panel;
        @Override protected void populateItem(        final ListItem item){
          String mandatoryCondition=schemaTO.getMandatoryCondition();
          boolean required=false;
          if (mandatoryCondition.equalsIgnoreCase("String_Node_Str"))           required=true;
          if (schemaTO.getType().getClassName().equals("String_Node_Str")) {
            panel=new AjaxTextFieldPanel("String_Node_Str",schemaTO.getName(),new Model(){
              @Override public Serializable getObject(){
                return (String)item.getModelObject();
              }
              @Override public void setObject(              Serializable object){
                item.setModelObject((String)object);
              }
            }
,required,schemaTO.isReadonly());
          }
 else           if (schemaTO.getType().getClassName().equals("String_Node_Str")) {
            panel=new AjaxCheckBoxPanel("String_Node_Str",schemaTO.getName(),new Model(){
              @Override public Serializable getObject(){
                return (String)item.getModelObject();
              }
              @Override public void setObject(              Serializable object){
                Boolean val=(Boolean)object;
                item.setModelObject(val.toString());
              }
            }
,required,schemaTO.isReadonly());
          }
 else           if (schemaTO.getType().getClassName().equals("String_Node_Str")) {
            panel=new DateFieldPanel("String_Node_Str",schemaTO.getName(),new Model(){
              @Override public Serializable getObject(){
                DateFormat formatter=new SimpleDateFormat(schemaTO.getConversionPattern());
                Date date=new Date();
                try {
                  String dateValue=(String)item.getModelObject();
                  if (!dateValue.equals("String_Node_Str"))                   date=formatter.parse(dateValue);
                }
 catch (                ParseException ex) {
                  Logger.getLogger(RoleModalPage.class.getName()).log(Level.SEVERE,null,ex);
                }
                return date;
              }
              @Override public void setObject(              Serializable object){
                Date date=(Date)object;
                Format formatter=new SimpleDateFormat(schemaTO.getConversionPattern());
                String val=formatter.format(date);
                item.setModelObject(val);
              }
            }
,schemaTO.getConversionPattern(),required,schemaTO.isReadonly());
          }
 else {
            panel=new AjaxTextFieldPanel("String_Node_Str",schemaTO.getName(),new Model(){
              @Override public Serializable getObject(){
                return (String)item.getModelObject();
              }
              @Override public void setObject(              Serializable object){
                item.setModelObject((String)object);
              }
            }
,required,schemaTO.isReadonly());
          }
          item.add(panel);
        }
      }
);
      AjaxButton addButton=new AjaxButton("String_Node_Str",new Model(getString("String_Node_Str"))){
        @Override protected void onSubmit(        AjaxRequestTarget target,        Form form){
          schemaWrapper.getValues().add("String_Node_Str");
          target.addComponent(container);
        }
      }
;
      AjaxButton dropButton=new AjaxButton("String_Node_Str",new Model(getString("String_Node_Str"))){
        @Override protected void onSubmit(        AjaxRequestTarget target,        Form form){
          schemaWrapper.getValues().remove(schemaWrapper.getValues().size() - 1);
          target.addComponent(container);
        }
      }
;
      if (schemaTO.getType().getClassName().equals("String_Node_Str")) {
        addButton.setVisible(false);
        dropButton.setVisible(false);
      }
      addButton.setDefaultFormProcessing(false);
      addButton.setVisible(schemaTO.isMultivalue());
      dropButton.setDefaultFormProcessing(false);
      dropButton.setVisible(schemaTO.isMultivalue());
      if (schemaWrapper.getValues().size() == 1) {
        dropButton.setVisible(false);
      }
      if (schemaTO.isReadonly()) {
        addButton.setEnabled(false);
        dropButton.setEnabled(false);
      }
      item.add(addButton);
      item.add(dropButton);
    }
  }
;
  userForm.add(userAttributesView);
  ListModel<ResourceTO> selectedResources=new ListModel<ResourceTO>();
  selectedResources.setObject(getSelectedResources(userTO));
  ListModel<ResourceTO> availableResources=new ListModel<ResourceTO>();
  availableResources.setObject(getAvailableResources(userTO));
  ChoiceRenderer paletteRenderer=new ChoiceRenderer("String_Node_Str","String_Node_Str");
  final Palette resourcesPalette=new Palette("String_Node_Str",selectedResources,availableResources,paletteRenderer,8,false);
  userForm.add(resourcesPalette);
  container=new WebMarkupContainer("String_Node_Str");
  container.add(userAttributesView);
  PasswordTextField password=new PasswordTextField("String_Node_Str");
  password.setRequired(createFlag);
  password.setResetPassword(false);
  container.add(password);
  container.setOutputMarkupId(true);
  userForm.add(container);
  submit=new AjaxButton("String_Node_Str",new Model(getString("String_Node_Str"))){
    @Override protected void onSubmit(    AjaxRequestTarget target,    Form form){
      UserTO userTO=(UserTO)form.getDefaultModelObject();
      boolean res=false;
      try {
        userTO.setResources(getResourcesSet(resourcesPalette.getModelCollection()));
        userTO.setAttributes(getUserAttributesList());
        userTO.setMemberships(getMembershipsSet());
        if (createFlag) {
          usersRestClient.createUser(userTO);
        }
 else {
          setupUserMod(userTO);
          if (userMod != null) {
            res=usersRestClient.updateUser(userMod);
            if (!res)             error(getString("String_Node_Str"));
            Users callerPage=(Users)basePage;
            callerPage.setOperationResult(true);
          }
        }
        window.close(target);
      }
 catch (      SyncopeClientCompositeErrorException e) {
        e.printStackTrace();
        error(getString("String_Node_Str") + "String_Node_Str" + e.getMessage());
      }
    }
    @Override protected void onError(    AjaxRequestTarget target,    Form form){
      target.addComponent(form.get("String_Node_Str"));
    }
  }
;
  userForm.add(submit);
  userForm.add(new FeedbackPanel("String_Node_Str").setOutputMarkupId(true));
  SyncopeRoleTree roleTree=new SyncopeRoleTree(rolesRestClient);
  BaseTree tree;
  tree=new LinkTree("String_Node_Str",roleTree.createTreeModel()){
    @Override protected IModel<Object> getNodeTextModel(    IModel<Object> model){
      return new PropertyModel(model,"String_Node_Str");
    }
    @Override protected void onNodeLinkClicked(    final Object node,    final BaseTree tree,    final AjaxRequestTarget target){
      DefaultMutableTreeNode syncopeTreeNode=(DefaultMutableTreeNode)node;
      final TreeModelBean treeModel=(TreeModelBean)syncopeTreeNode.getUserObject();
      if (treeModel.getTreeNode() != null) {
        createUserWin.setPageCreator(new ModalWindow.PageCreator(){
          MembershipTO membershipTO;
          @Override public Page createPage(){
            membershipTO=new MembershipTO();
            membershipTO.setRoleId(treeModel.getTreeNode().getId());
            String title=treeModel.getTreeNode().getName();
            MembershipModalPage form=new MembershipModalPage(getPage(),createUserWin,membershipTO,true);
            return form;
          }
        }
);
        createUserWin.show(target);
      }
    }
  }
;
  tree.getTreeState().expandAll();
  tree.updateTree();
  userForm.add(tree);
  ListView membershipsView=new ListView("String_Node_Str",membershipTOs){
    @Override protected void populateItem(    final ListItem item){
      final MembershipTO membershipTO=(MembershipTO)item.getDefaultModelObject();
      item.add(new Label("String_Node_Str",new Model(membershipTO.getRoleId())));
      item.add(new Label("String_Node_Str",new Model((String)rolesMap.get(membershipTO.getRoleId()))));
      AjaxLink editLink=new AjaxLink("String_Node_Str"){
        @Override public void onClick(        AjaxRequestTarget target){
          createUserWin.setPageCreator(new ModalWindow.PageCreator(){
            public Page createPage(){
              MembershipModalPage window=new MembershipModalPage(getPage(),createUserWin,membershipTO,false);
              return window;
            }
          }
);
          createUserWin.show(target);
        }
      }
;
      item.add(editLink);
      AjaxLink deleteLink=new AjaxLink("String_Node_Str"){
        @Override public void onClick(        AjaxRequestTarget target){
          int componentId=new Integer(getParent().getId());
          membershipTOs.remove(componentId);
          target.addComponent(membershipsContainer);
        }
      }
;
      item.add(deleteLink);
    }
  }
;
  membershipsContainer=new WebMarkupContainer("String_Node_Str");
  membershipsContainer.add(membershipsView);
  membershipsContainer.setOutputMarkupId(true);
  setWindowClosedCallback(createUserWin,membershipsContainer);
  userForm.add(membershipsContainer);
  add(userForm);
}