Program: 60687
Project: 60687
Buggy source:
public ConnectorModalPage(final PageReference callerPageRef,final ModalWindow window,final ConnInstanceTO connectorTO,final boolean createFlag){
  super();
  selectedCapabilities=new ArrayList(createFlag ? EnumSet.noneOf(ConnectorCapability.class) : connectorTO.getCapabilities());
  IModel<List<ConnConfProperty>> selectedBundleProperties=new LoadableDetachableModel<List<ConnConfProperty>>(){
    private static final long serialVersionUID=5275935387613157437L;
    @Override protected List<ConnConfProperty> load(){
      List<ConnConfProperty> result;
      if (createFlag) {
        connectorTO.setConnectorName(selectedBundleTO.getConnectorName());
        connectorTO.setVersion(selectedBundleTO.getVersion());
        result=new ArrayList<ConnConfProperty>();
        ConnConfProperty propertyTO;
        for (        ConnConfPropSchema key : selectedBundleTO.getProperties()) {
          propertyTO=new ConnConfProperty();
          propertyTO.setSchema(key);
          result.add(propertyTO);
        }
      }
 else {
        selectedBundleTO.setBundleName(connectorTO.getBundleName());
        selectedBundleTO.setVersion(connectorTO.getVersion());
        result=new ArrayList<ConnConfProperty>(connectorTO.getConfiguration());
      }
      if (result != null && !result.isEmpty()) {
        Collections.sort(result);
      }
      return result;
    }
  }
;
  final AjaxTextFieldPanel connectorName=new AjaxTextFieldPanel("String_Node_Str","String_Node_Str",new PropertyModel<String>(connectorTO,"String_Node_Str"),false);
  connectorName.setOutputMarkupId(true);
  connectorName.setEnabled(false);
  final AjaxTextFieldPanel displayName=new AjaxTextFieldPanel("String_Node_Str","String_Node_Str",new PropertyModel<String>(connectorTO,"String_Node_Str"),false);
  displayName.setOutputMarkupId(true);
  displayName.addRequiredLabel();
  final AjaxTextFieldPanel version=new AjaxTextFieldPanel("String_Node_Str","String_Node_Str",new PropertyModel<String>(connectorTO,"String_Node_Str"),false);
  displayName.setOutputMarkupId(true);
  version.setEnabled(false);
  final IModel<List<ConnBundleTO>> bundles=new LoadableDetachableModel<List<ConnBundleTO>>(){
    private static final long serialVersionUID=5275935387613157437L;
    @Override protected List<ConnBundleTO> load(){
      return restClient.getAllBundles();
    }
  }
;
  final AjaxDropDownChoicePanel<ConnBundleTO> bundle=new AjaxDropDownChoicePanel<ConnBundleTO>("String_Node_Str","String_Node_Str",new Model(null),false);
  bundle.setStyleShet("String_Node_Str");
  bundle.setChoices(bundles.getObject());
  bundle.setChoiceRenderer(new ChoiceRenderer<ConnBundleTO>(){
    private static final long serialVersionUID=-1945543182376191187L;
    @Override public Object getDisplayValue(    final ConnBundleTO object){
      return object.getBundleName() + "String_Node_Str" + object.getVersion();
    }
    @Override public String getIdValue(    final ConnBundleTO object,    final int index){
      return object.getBundleName() + "String_Node_Str" + object.getVersion();
    }
  }
);
  ((DropDownChoice)bundle.getField()).setNullValid(true);
  bundle.setRequired(true);
  bundle.getField().add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
    private static final long serialVersionUID=-1107858522700306810L;
    @Override protected void onUpdate(    final AjaxRequestTarget target){
      connectorTO.setConfiguration(new HashSet<ConnConfProperty>());
      DropDownChoice bundleChoice=(DropDownChoice)bundle.getField();
      bundleChoice.setNullValid(false);
      target.add(bundle.getField());
      target.add(propertiesContainer);
      target.add(connectorName);
      target.add(version);
    }
  }
);
  bundle.getField().setModel(new IModel<ConnBundleTO>(){
    private static final long serialVersionUID=-3736598995576061229L;
    @Override public ConnBundleTO getObject(){
      return selectedBundleTO;
    }
    @Override public void setObject(    final ConnBundleTO object){
      selectedBundleTO=object;
    }
    @Override public void detach(){
    }
  }
);
  bundle.addRequiredLabel();
  bundle.setEnabled(createFlag);
  final ListView<ConnConfProperty> propView=new ListView<ConnConfProperty>("String_Node_Str",selectedBundleProperties){
    private static final long serialVersionUID=9101744072914090143L;
    @Override protected void populateItem(    final ListItem<ConnConfProperty> item){
      final ConnConfProperty property=item.getModelObject();
      final Label label=new Label("String_Node_Str",property.getSchema().getDisplayName() == null || property.getSchema().getDisplayName().isEmpty() ? property.getSchema().getName() : property.getSchema().getDisplayName());
      item.add(label);
      final FieldPanel field;
      if (GUARDED_STRING.equals(property.getSchema().getType())) {
        field=new AjaxPasswordFieldPanel("String_Node_Str",label.getDefaultModelObjectAsString(),new PropertyModel<String>(property,"String_Node_Str"),true).setRequired(property.getSchema().isRequired()).setTitle(property.getSchema().getHelpMessage());
        ((PasswordTextField)field.getField()).setResetPassword(false);
      }
 else {
        field=new AjaxTextFieldPanel("String_Node_Str",label.getDefaultModelObjectAsString(),new PropertyModel<String>(property,"String_Node_Str"),true).setRequired(property.getSchema().isRequired()).setTitle(property.getSchema().getHelpMessage());
        if (property.getSchema().isRequired()) {
          field.addRequiredLabel();
        }
      }
      item.add(field);
      final AjaxDropDownChoicePanel<Boolean> overridable=new AjaxDropDownChoicePanel<Boolean>("String_Node_Str","String_Node_Str",new PropertyModel(property,"String_Node_Str"),false);
      overridable.setChoiceRenderer(new OverridableRenderer());
      overridable.setChoices(Arrays.asList(new Boolean[]{ConnParameterType.NOT_OVERRIDABLE.getOverridable(),ConnParameterType.OVERRIDABLE.getOverridable()}));
      overridable.setStyleShet("String_Node_Str" + "String_Node_Str");
      item.add(overridable);
      connectorTO.getConfiguration().add(property);
    }
  }
;
  propertiesContainer=new WebMarkupContainer("String_Node_Str");
  propertiesContainer.setOutputMarkupId(true);
  propertiesContainer.add(propView);
  Form connectorForm=new Form("String_Node_Str");
  connectorForm.setModel(new CompoundPropertyModel(connectorTO));
  connectorForm.add(propertiesContainer);
  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){
      final ConnInstanceTO connector=(ConnInstanceTO)form.getDefaultModelObject();
      ConnBundleTO bundleTO=(ConnBundleTO)bundle.getModelObject();
      connector.setBundleName(bundleTO.getBundleName());
      if (!selectedCapabilities.isEmpty()) {
        connector.setCapabilities(EnumSet.copyOf(selectedCapabilities));
      }
 else {
        connector.setCapabilities(EnumSet.noneOf(ConnectorCapability.class));
      }
      try {
        if (createFlag) {
          restClient.create(connector);
        }
 else {
          restClient.update(connector);
        }
        ((Resources)callerPageRef.getPage()).setModalResult(true);
        window.close(target);
      }
 catch (      SyncopeClientCompositeErrorException e) {
        error(getString("String_Node_Str") + "String_Node_Str" + e.getMessage());
        target.add(feedbackPanel);
        ((Resources)callerPageRef.getPage()).setModalResult(false);
        LOG.error("String_Node_Str" + connector);
      }
    }
    @Override protected void onError(    final AjaxRequestTarget target,    final Form form){
      target.add(feedbackPanel);
    }
  }
;
  String allowedRoles=createFlag ? xmlRolesReader.getAllAllowedRoles("String_Node_Str","String_Node_Str") : xmlRolesReader.getAllAllowedRoles("String_Node_Str","String_Node_Str");
  MetaDataRoleAuthorizationStrategy.authorize(submit,ENABLE,allowedRoles);
  connectorForm.add(connectorName);
  connectorForm.add(displayName);
  connectorForm.add(bundle);
  connectorForm.add(version);
  final IModel<List<ConnectorCapability>> capabilities=new LoadableDetachableModel<List<ConnectorCapability>>(){
    private static final long serialVersionUID=5275935387613157437L;
    @Override protected List<ConnectorCapability> load(){
      return Arrays.asList(ConnectorCapability.values());
    }
  }
;
  capabilitiesPalette=new CheckBoxMultipleChoice("String_Node_Str",new PropertyModel(this,"String_Node_Str"),capabilities);
  connectorForm.add(capabilitiesPalette);
  connectorForm.add(submit);
  add(connectorForm);
}

Fixed version (ground truth):
public ConnectorModalPage(final PageReference callerPageRef,final ModalWindow window,final ConnInstanceTO connectorTO,final boolean createFlag){
  super();
  selectedCapabilities=new ArrayList(createFlag ? EnumSet.noneOf(ConnectorCapability.class) : connectorTO.getCapabilities());
  IModel<List<ConnConfProperty>> selectedBundleProperties=new LoadableDetachableModel<List<ConnConfProperty>>(){
    private static final long serialVersionUID=5275935387613157437L;
    @Override protected List<ConnConfProperty> load(){
      List<ConnConfProperty> result;
      if (createFlag) {
        connectorTO.setConnectorName(selectedBundleTO.getConnectorName());
        connectorTO.setVersion(selectedBundleTO.getVersion());
        result=new ArrayList<ConnConfProperty>();
        ConnConfProperty propertyTO;
        for (        ConnConfPropSchema key : selectedBundleTO.getProperties()) {
          propertyTO=new ConnConfProperty();
          propertyTO.setSchema(key);
          result.add(propertyTO);
        }
      }
 else {
        selectedBundleTO.setBundleName(connectorTO.getBundleName());
        selectedBundleTO.setVersion(connectorTO.getVersion());
        result=new ArrayList<ConnConfProperty>(connectorTO.getConfiguration());
      }
      if (result != null && !result.isEmpty()) {
        Collections.sort(result);
      }
      return result;
    }
  }
;
  final AjaxTextFieldPanel connectorName=new AjaxTextFieldPanel("String_Node_Str","String_Node_Str",new PropertyModel<String>(connectorTO,"String_Node_Str"),false);
  connectorName.setOutputMarkupId(true);
  connectorName.setEnabled(false);
  final AjaxTextFieldPanel displayName=new AjaxTextFieldPanel("String_Node_Str","String_Node_Str",new PropertyModel<String>(connectorTO,"String_Node_Str"),false);
  displayName.setOutputMarkupId(true);
  displayName.addRequiredLabel();
  final AjaxTextFieldPanel version=new AjaxTextFieldPanel("String_Node_Str","String_Node_Str",new PropertyModel<String>(connectorTO,"String_Node_Str"),false);
  displayName.setOutputMarkupId(true);
  version.setEnabled(false);
  final IModel<List<ConnBundleTO>> bundles=new LoadableDetachableModel<List<ConnBundleTO>>(){
    private static final long serialVersionUID=5275935387613157437L;
    @Override protected List<ConnBundleTO> load(){
      return restClient.getAllBundles();
    }
  }
;
  final AjaxDropDownChoicePanel<ConnBundleTO> bundle=new AjaxDropDownChoicePanel<ConnBundleTO>("String_Node_Str","String_Node_Str",new Model(null),false);
  bundle.setStyleShet("String_Node_Str");
  bundle.setChoices(bundles.getObject());
  bundle.setChoiceRenderer(new ChoiceRenderer<ConnBundleTO>(){
    private static final long serialVersionUID=-1945543182376191187L;
    @Override public Object getDisplayValue(    final ConnBundleTO object){
      return object.getBundleName() + "String_Node_Str" + object.getVersion();
    }
    @Override public String getIdValue(    final ConnBundleTO object,    final int index){
      return object.getBundleName() + "String_Node_Str" + object.getVersion();
    }
  }
);
  ((DropDownChoice)bundle.getField()).setNullValid(true);
  bundle.setRequired(true);
  bundle.getField().add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
    private static final long serialVersionUID=-1107858522700306810L;
    @Override protected void onUpdate(    final AjaxRequestTarget target){
      connectorTO.setConfiguration(new HashSet<ConnConfProperty>());
      DropDownChoice bundleChoice=(DropDownChoice)bundle.getField();
      bundleChoice.setNullValid(false);
      target.add(bundle.getField());
      target.add(propertiesContainer);
      target.add(connectorName);
      target.add(version);
    }
  }
);
  bundle.getField().setModel(new IModel<ConnBundleTO>(){
    private static final long serialVersionUID=-3736598995576061229L;
    @Override public ConnBundleTO getObject(){
      return selectedBundleTO;
    }
    @Override public void setObject(    final ConnBundleTO object){
      selectedBundleTO=object;
    }
    @Override public void detach(){
    }
  }
);
  bundle.addRequiredLabel();
  bundle.setEnabled(createFlag);
  final ListView<ConnConfProperty> propView=new ListView<ConnConfProperty>("String_Node_Str",selectedBundleProperties){
    private static final long serialVersionUID=9101744072914090143L;
    @Override protected void populateItem(    final ListItem<ConnConfProperty> item){
      final ConnConfProperty property=item.getModelObject();
      final Label label=new Label("String_Node_Str",property.getSchema().getDisplayName() == null || property.getSchema().getDisplayName().isEmpty() ? property.getSchema().getName() : property.getSchema().getDisplayName());
      item.add(label);
      final FieldPanel field;
      boolean required=false;
      if (GUARDED_STRING.equalsIgnoreCase(property.getSchema().getType())) {
        field=new AjaxPasswordFieldPanel("String_Node_Str",label.getDefaultModelObjectAsString(),new Model(),true);
        ((PasswordTextField)field.getField()).setResetPassword(false);
        required=property.getSchema().isRequired();
      }
 else       if (BOOLEAN.equalsIgnoreCase(property.getSchema().getType())) {
        field=new AjaxCheckBoxPanel("String_Node_Str",label.getDefaultModelObjectAsString(),new Model(),true);
      }
 else {
        field=new AjaxTextFieldPanel("String_Node_Str",label.getDefaultModelObjectAsString(),new Model(),true);
        required=property.getSchema().isRequired();
      }
      field.setTitle(property.getSchema().getHelpMessage());
      if (required) {
        field.addRequiredLabel();
      }
      if (STRING_ARRAY.equalsIgnoreCase(property.getSchema().getType())) {
        field.removeRequiredLabel();
        item.add(new MultiValueSelectorPanel<String>("String_Node_Str",new PropertyModel<List<String>>(property,"String_Node_Str"),String.class,field));
      }
 else {
        field.setNewModel(property.getValues());
        item.add(field);
      }
      final AjaxCheckBoxPanel overridable=new AjaxCheckBoxPanel("String_Node_Str","String_Node_Str",new PropertyModel(property,"String_Node_Str"),true);
      item.add(overridable);
      connectorTO.getConfiguration().add(property);
    }
  }
;
  propertiesContainer=new WebMarkupContainer("String_Node_Str");
  propertiesContainer.setOutputMarkupId(true);
  propertiesContainer.add(propView);
  Form connectorForm=new Form("String_Node_Str");
  connectorForm.setModel(new CompoundPropertyModel(connectorTO));
  connectorForm.add(propertiesContainer);
  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){
      final ConnInstanceTO connector=(ConnInstanceTO)form.getDefaultModelObject();
      ConnBundleTO bundleTO=(ConnBundleTO)bundle.getModelObject();
      connector.setBundleName(bundleTO.getBundleName());
      if (!selectedCapabilities.isEmpty()) {
        connector.setCapabilities(EnumSet.copyOf(selectedCapabilities));
      }
 else {
        connector.setCapabilities(EnumSet.noneOf(ConnectorCapability.class));
      }
      try {
        if (createFlag) {
          restClient.create(connector);
        }
 else {
          restClient.update(connector);
        }
        ((Resources)callerPageRef.getPage()).setModalResult(true);
        window.close(target);
      }
 catch (      SyncopeClientCompositeErrorException e) {
        error(getString("String_Node_Str") + "String_Node_Str" + e.getMessage());
        target.add(feedbackPanel);
        ((Resources)callerPageRef.getPage()).setModalResult(false);
        LOG.error("String_Node_Str" + connector);
      }
    }
    @Override protected void onError(    final AjaxRequestTarget target,    final Form form){
      target.add(feedbackPanel);
    }
  }
;
  String allowedRoles=createFlag ? xmlRolesReader.getAllAllowedRoles("String_Node_Str","String_Node_Str") : xmlRolesReader.getAllAllowedRoles("String_Node_Str","String_Node_Str");
  MetaDataRoleAuthorizationStrategy.authorize(submit,ENABLE,allowedRoles);
  connectorForm.add(connectorName);
  connectorForm.add(displayName);
  connectorForm.add(bundle);
  connectorForm.add(version);
  final IModel<List<ConnectorCapability>> capabilities=new LoadableDetachableModel<List<ConnectorCapability>>(){
    private static final long serialVersionUID=5275935387613157437L;
    @Override protected List<ConnectorCapability> load(){
      return Arrays.asList(ConnectorCapability.values());
    }
  }
;
  capabilitiesPalette=new CheckBoxMultipleChoice("String_Node_Str",new PropertyModel(this,"String_Node_Str"),capabilities);
  connectorForm.add(capabilitiesPalette);
  connectorForm.add(submit);
  add(connectorForm);
}