Program: 60740
Project: 60740
Buggy source:
private void setupEditPanel(){
  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 :
userTO=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 {
userTO=userRestClient.update(userMod);
if (userRequestTO != null) {
requestRestClient.delete(userRequestTO.getId());
}
}
}
}
if (callerPageRef.getPage() instanceof BasePage) {
((BasePage)callerPageRef.getPage()).setModalResult(true);
}
switch (mode) {
case ADMIN:
case SELF:
setResponsePage(new UserModalPage(callerPageRef,window,userTO,mode,form.isSubmitted()));
break;
case TEMPLATE:
default :
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);
}
fragment.add(form);
form.add(submit);
}

Fixed version (ground truth):
private void setupEditPanel(){
  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 (userTO == null) {
userTO=new UserTO();
syncTaskTO.setUserTemplate(userTO);
}
}
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 :
userTO=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 {
userTO=userRestClient.update(userMod);
if (userRequestTO != null) {
requestRestClient.delete(userRequestTO.getId());
}
}
}
}
if (callerPageRef.getPage() instanceof BasePage) {
((BasePage)callerPageRef.getPage()).setModalResult(true);
}
switch (mode) {
case ADMIN:
case SELF:
setResponsePage(new UserModalPage(callerPageRef,window,userTO,mode,form.isSubmitted()));
break;
case TEMPLATE:
default :
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);
}
fragment.add(form);
form.add(submit);
}