Program: 60666
Project: 60666
Buggy source:
public ApprovalModalPage(final PageReference callerPageRef,final ModalWindow window,final WorkflowFormTO formTO){
  super();
  IModel<List<WorkflowFormPropertyTO>> formProps=new LoadableDetachableModel<List<WorkflowFormPropertyTO>>(){
    private static final long serialVersionUID=3169142472626817508L;
    @Override protected List<WorkflowFormPropertyTO> load(){
      return formTO.getProperties();
    }
  }
;
  final ListView<WorkflowFormPropertyTO> propView=new ListView<WorkflowFormPropertyTO>("String_Node_Str",formProps){
    private static final long serialVersionUID=9101744072914090143L;
    @Override protected void populateItem(    final ListItem<WorkflowFormPropertyTO> item){
      final WorkflowFormPropertyTO prop=item.getModelObject();
      Label label=new Label("String_Node_Str",prop.getName() == null ? prop.getId() : prop.getName());
      item.add(label);
      FieldPanel field=null;
switch (prop.getType()) {
case Boolean:
        field=new AjaxDropDownChoicePanel("String_Node_Str",label.getDefaultModelObjectAsString(),new Model(Boolean.valueOf(prop.getValue())),true).setChoices(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"}));
      break;
case Date:
    SimpleDateFormat df=StringUtils.isNotBlank(prop.getDatePattern()) ? new SimpleDateFormat(prop.getDatePattern()) : new SimpleDateFormat();
  Date parsedDate=null;
if (StringUtils.isNotBlank(prop.getValue())) {
  try {
    parsedDate=df.parse(prop.getValue());
  }
 catch (  ParseException e) {
    LOG.error("String_Node_Str",prop.getValue(),e);
  }
}
field=new DateTimeFieldPanel("String_Node_Str",label.getDefaultModelObjectAsString(),new Model(parsedDate),true,df.toLocalizedPattern());
break;
case Enum:
MapChoiceRenderer<String,String> enumCR=new MapChoiceRenderer<String,String>(prop.getEnumValues());
field=new AjaxDropDownChoicePanel("String_Node_Str",label.getDefaultModelObjectAsString(),new Model(prop.getValue()),true).setChoiceRenderer(enumCR).setChoices(new Model(){
private static final long serialVersionUID=-858521070366432018L;
@Override public Serializable getObject(){
return new ArrayList(prop.getEnumValues().keySet());
}
}
);
break;
case Long:
field=new AjaxNumberFieldPanel("String_Node_Str",label.getDefaultModelObjectAsString(),new Model(Long.valueOf(prop.getValue())),true);
break;
case String:
default :
field=new AjaxTextFieldPanel("String_Node_Str",PARENT_PATH,new Model(prop.getValue()),true);
break;
}
field.setReadOnly(!prop.isWritable());
if (prop.isRequired()) {
field.addRequiredLabel();
}
item.add(field);
}
}
;
final AjaxButton submit=new IndicatingAjaxButton("String_Node_Str",new Model(getString("String_Node_Str"))){
private static final long serialVersionUID=-958724007591692537L;
@Override protected void onSubmit(final AjaxRequestTarget target,final Form<?> form){
Map<String,WorkflowFormPropertyTO> props=formTO.getPropertiesAsMap();
for (int i=0; i < propView.size(); i++) {
ListItem<WorkflowFormPropertyTO> item=(ListItem<WorkflowFormPropertyTO>)propView.get(i);
String input=((FieldPanel)item.get("String_Node_Str")).getField().getInput();
if (!props.containsKey(item.getModelObject().getId())) {
props.put(item.getModelObject().getId(),new WorkflowFormPropertyTO());
}
if (item.getModelObject().isWritable()) {
switch (item.getModelObject().getType()) {
case Boolean:
props.get(item.getModelObject().getId()).setValue(String.valueOf(input.equals("String_Node_Str")));
break;
case Date:
case Enum:
case String:
case Long:
default :
props.get(item.getModelObject().getId()).setValue(input);
break;
}
}
}
formTO.setProperties(props.values());
try {
restClient.submitForm(formTO);
((Todo)callerPageRef.getPage()).setModalResult(true);
window.close(target);
}
 catch (SyncopeClientCompositeErrorException e) {
error(getString("String_Node_Str") + "String_Node_Str" + e.getMessage());
LOG.error("String_Node_Str",formTO,e);
target.add(feedbackPanel);
}
}
@Override protected void onError(final AjaxRequestTarget target,final Form<?> form){
target.add(feedbackPanel);
}
}
;
Form form=new Form("String_Node_Str");
form.add(propView);
form.add(submit);
MetaDataRoleAuthorizationStrategy.authorize(form,ENABLE,xmlRolesReader.getAllAllowedRoles("String_Node_Str","String_Node_Str"));
add(form);
}

Fixed version (ground truth):
public ApprovalModalPage(final PageReference callerPageRef,final ModalWindow window,final WorkflowFormTO formTO){
  super();
  IModel<List<WorkflowFormPropertyTO>> formProps=new LoadableDetachableModel<List<WorkflowFormPropertyTO>>(){
    private static final long serialVersionUID=3169142472626817508L;
    @Override protected List<WorkflowFormPropertyTO> load(){
      return formTO.getProperties();
    }
  }
;
  final ListView<WorkflowFormPropertyTO> propView=new ListView<WorkflowFormPropertyTO>("String_Node_Str",formProps){
    private static final long serialVersionUID=9101744072914090143L;
    @Override protected void populateItem(    final ListItem<WorkflowFormPropertyTO> item){
      final WorkflowFormPropertyTO prop=item.getModelObject();
      Label label=new Label("String_Node_Str",prop.getName() == null ? prop.getId() : prop.getName());
      item.add(label);
      FieldPanel field=null;
switch (prop.getType()) {
case Boolean:
        field=new AjaxDropDownChoicePanel("String_Node_Str",label.getDefaultModelObjectAsString(),new Model(Boolean.valueOf(prop.getValue())),true).setChoices(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"}));
      break;
case Date:
    SimpleDateFormat df=StringUtils.isNotBlank(prop.getDatePattern()) ? new SimpleDateFormat(prop.getDatePattern()) : new SimpleDateFormat();
  Date parsedDate=null;
if (StringUtils.isNotBlank(prop.getValue())) {
  try {
    parsedDate=df.parse(prop.getValue());
  }
 catch (  ParseException e) {
    LOG.error("String_Node_Str",prop.getValue(),e);
  }
}
field=new DateTimeFieldPanel("String_Node_Str",label.getDefaultModelObjectAsString(),new Model(parsedDate),true,df.toLocalizedPattern());
break;
case Enum:
MapChoiceRenderer<String,String> enumCR=new MapChoiceRenderer<String,String>(prop.getEnumValues());
field=new AjaxDropDownChoicePanel("String_Node_Str",label.getDefaultModelObjectAsString(),new Model(prop.getValue()),true).setChoiceRenderer(enumCR).setChoices(new Model(){
private static final long serialVersionUID=-858521070366432018L;
@Override public Serializable getObject(){
return new ArrayList(prop.getEnumValues().keySet());
}
}
);
break;
case Long:
field=new AjaxNumberFieldPanel("String_Node_Str",label.getDefaultModelObjectAsString(),new Model(Long.valueOf(prop.getValue())),Long.class,true);
break;
case String:
default :
field=new AjaxTextFieldPanel("String_Node_Str",PARENT_PATH,new Model(prop.getValue()),true);
break;
}
field.setReadOnly(!prop.isWritable());
if (prop.isRequired()) {
field.addRequiredLabel();
}
item.add(field);
}
}
;
final AjaxButton submit=new IndicatingAjaxButton("String_Node_Str",new Model(getString("String_Node_Str"))){
private static final long serialVersionUID=-958724007591692537L;
@Override protected void onSubmit(final AjaxRequestTarget target,final Form<?> form){
Map<String,WorkflowFormPropertyTO> props=formTO.getPropertiesAsMap();
for (int i=0; i < propView.size(); i++) {
ListItem<WorkflowFormPropertyTO> item=(ListItem<WorkflowFormPropertyTO>)propView.get(i);
String input=((FieldPanel)item.get("String_Node_Str")).getField().getInput();
if (!props.containsKey(item.getModelObject().getId())) {
props.put(item.getModelObject().getId(),new WorkflowFormPropertyTO());
}
if (item.getModelObject().isWritable()) {
switch (item.getModelObject().getType()) {
case Boolean:
props.get(item.getModelObject().getId()).setValue(String.valueOf(input.equals("String_Node_Str")));
break;
case Date:
case Enum:
case String:
case Long:
default :
props.get(item.getModelObject().getId()).setValue(input);
break;
}
}
}
formTO.setProperties(props.values());
try {
restClient.submitForm(formTO);
((Todo)callerPageRef.getPage()).setModalResult(true);
window.close(target);
}
 catch (SyncopeClientCompositeErrorException e) {
error(getString("String_Node_Str") + "String_Node_Str" + e.getMessage());
LOG.error("String_Node_Str",formTO,e);
target.add(feedbackPanel);
}
}
@Override protected void onError(final AjaxRequestTarget target,final Form<?> form){
target.add(feedbackPanel);
}
}
;
Form form=new Form("String_Node_Str");
form.add(propView);
form.add(submit);
MetaDataRoleAuthorizationStrategy.authorize(form,ENABLE,xmlRolesReader.getAllAllowedRoles("String_Node_Str","String_Node_Str"));
add(form);
}