Program: 60752
Project: 60752
Buggy source:
private void setupModalPage(){
  if (userRequestTO != null) {
switch (userRequestTO.getType()) {
case CREATE:
      userTO=userRequestTO.getUserTO();
    break;
case UPDATE:
  initialUserTO=userRestClient.read(userRequestTO.getUserMod().getId());
userTO=AttributableOperations.apply(initialUserTO,userRequestTO.getUserMod());
break;
case DELETE:
default :
}
}
if (syncTaskTO != null) {
userTO=syncTaskTO.getUserTemplate();
}
if (initialUserTO == null && userTO.getId() > 0) {
initialUserTO=AttributableOperations.clone(userTO);
}
add(new Label("String_Node_Str",userTO.getId() == 0 ? "String_Node_Str" : userTO.getUsername()));
add(new Label("String_Node_Str",userTO.getId() == 0 ? getString("String_Node_Str") : "String_Node_Str"));
final Form form=new Form("String_Node_Str");
form.setModel(new CompoundPropertyModel(userTO));
form.add(new UserDetailsPanel("String_Node_Str",userTO,form,userRequestTO == null,mode == Mode.TEMPLATE));
form.add(new AttributesPanel("String_Node_Str",userTO,form,mode == Mode.TEMPLATE));
form.add(new DerivedAttributesPanel("String_Node_Str",userTO));
form.add(new VirtualAttributesPanel("String_Node_Str",userTO,mode == Mode.TEMPLATE));
form.add(new ResourcesPanel("String_Node_Str",userTO));
form.add(new RolesPanel("String_Node_Str",userTO,mode == Mode.TEMPLATE));
final AjaxButton 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 UserTO updatedUserTO=(UserTO)form.getModelObject();
try {
if (updatedUserTO.getId() == 0) {
switch (mode) {
case SELF:
  requestRestClient.requestCreate(updatedUserTO);
break;
case ADMIN:
default :
userRestClient.create(updatedUserTO);
if (userRequestTO != null) {
requestRestClient.delete(userRequestTO.getId());
}
break;
case TEMPLATE:
syncTaskTO.setUserTemplate(updatedUserTO);
taskRestClient.updateSyncTask(syncTaskTO);
break;
}
}
 else {
UserMod userMod=AttributableOperations.diff(updatedUserTO,initialUserTO);
if (!userMod.isEmpty()) {
if (mode == Mode.SELF) {
requestRestClient.requestUpdate(userMod);
}
 else {
userRestClient.update(userMod);
if (userRequestTO != null) {
requestRestClient.delete(userRequestTO.getId());
}
}
}
}
if (callerPageRef.getPage() instanceof BasePage) {
((BasePage)callerPageRef.getPage()).setModalResult(true);
}
window.close(target);
}
 catch (SyncopeClientCompositeErrorException e) {
LOG.error("String_Node_Str",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);
}
}
;
if (mode == Mode.ADMIN) {
String allowedRoles=userTO.getId() == 0 ? xmlRolesReader.getAllAllowedRoles("String_Node_Str","String_Node_Str") : xmlRolesReader.getAllAllowedRoles("String_Node_Str","String_Node_Str");
MetaDataRoleAuthorizationStrategy.authorize(submit,RENDER,allowedRoles);
}
form.add(submit);
add(form);
}

Fixed version (ground truth):
private void setupModalPage(){
  fragment=new Fragment("String_Node_Str",!submitted ? "String_Node_Str" : "String_Node_Str",this);
  fragment.setOutputMarkupId(true);
  if (!submitted) {
    if (userRequestTO != null) {
switch (userRequestTO.getType()) {
case CREATE:
        userTO=userRequestTO.getUserTO();
      break;
case UPDATE:
    initialUserTO=userRestClient.read(userRequestTO.getUserMod().getId());
  userTO=AttributableOperations.apply(initialUserTO,userRequestTO.getUserMod());
break;
case DELETE:
default :
}
}
if (syncTaskTO != null) {
userTO=syncTaskTO.getUserTemplate();
}
if (initialUserTO == null && userTO.getId() > 0) {
initialUserTO=AttributableOperations.clone(userTO);
}
fragment.add(new Label("String_Node_Str",userTO.getId() == 0 ? "String_Node_Str" : userTO.getUsername()));
fragment.add(new Label("String_Node_Str",userTO.getId() == 0 ? getString("String_Node_Str") : "String_Node_Str"));
final Form form=new Form("String_Node_Str");
form.setModel(new CompoundPropertyModel(userTO));
form.add(new UserDetailsPanel("String_Node_Str",userTO,form,userRequestTO == null,mode == Mode.TEMPLATE));
form.add(new AttributesPanel("String_Node_Str",userTO,form,mode == Mode.TEMPLATE));
form.add(new DerivedAttributesPanel("String_Node_Str",userTO));
form.add(new VirtualAttributesPanel("String_Node_Str",userTO,mode == Mode.TEMPLATE));
form.add(new ResourcesPanel("String_Node_Str",userTO));
form.add(new RolesPanel("String_Node_Str",userTO,mode == Mode.TEMPLATE));
final AjaxButton 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 UserTO updatedUserTO=(UserTO)form.getModelObject();
try {
if (updatedUserTO.getId() == 0) {
switch (mode) {
case SELF:
    requestRestClient.requestCreate(updatedUserTO);
  break;
case ADMIN:
default :
summaryUserTO=userRestClient.create(updatedUserTO);
if (userRequestTO != null) {
requestRestClient.delete(userRequestTO.getId());
}
break;
case TEMPLATE:
syncTaskTO.setUserTemplate(updatedUserTO);
taskRestClient.updateSyncTask(syncTaskTO);
break;
}
}
 else {
UserMod userMod=AttributableOperations.diff(updatedUserTO,initialUserTO);
if (!userMod.isEmpty()) {
if (mode == Mode.SELF) {
requestRestClient.requestUpdate(userMod);
}
 else {
summaryUserTO=userRestClient.update(userMod);
if (userRequestTO != null) {
requestRestClient.delete(userRequestTO.getId());
}
}
}
}
if (callerPageRef.getPage() instanceof BasePage) {
((BasePage)callerPageRef.getPage()).setModalResult(true);
}
setResponsePage(new UserModalPage(callerPageRef,window,summaryUserTO,form.isSubmitted()));
}
 catch (SyncopeClientCompositeErrorException e) {
LOG.error("String_Node_Str",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);
}
}
;
if (mode == Mode.ADMIN) {
String allowedRoles=userTO.getId() == 0 ? xmlRolesReader.getAllAllowedRoles("String_Node_Str","String_Node_Str") : xmlRolesReader.getAllAllowedRoles("String_Node_Str","String_Node_Str");
MetaDataRoleAuthorizationStrategy.authorize(submit,RENDER,allowedRoles);
}
fragment.add(form);
form.add(submit);
}
 else {
final UserSummaryPanel userSummaryPanel=new UserSummaryPanel("String_Node_Str",window,summaryUserTO);
userSummaryPanel.setOutputMarkupId(true);
fragment.add(userSummaryPanel);
}
add(fragment);
}