Program: 60638
Project: 60638
Buggy source:
public ResourceModalPage(final PageReference callPageRef,final ModalWindow window,final ResourceTO resourceTO,final boolean createFlag){
  super();
  this.resourceTO=resourceTO;
  uSchemaAttrNames=schemaRestClient.getSchemaNames("String_Node_Str");
  uDerSchemaAttrNames=schemaRestClient.getDerivedSchemaNames("String_Node_Str");
  uVirSchemaAttrNames=schemaRestClient.getVirtualSchemaNames("String_Node_Str");
  final IModel<List<ConnInstanceTO>> connectors=new LoadableDetachableModel<List<ConnInstanceTO>>(){
    private static final long serialVersionUID=5275935387613157437L;
    @Override protected List<ConnInstanceTO> load(){
      return connectorRestClient.getAllConnectors();
    }
  }
;
  final IModel<List<IntMappingType>> intMappingTypes=new LoadableDetachableModel<List<IntMappingType>>(){
    private static final long serialVersionUID=5275935387613157437L;
    @Override protected List<IntMappingType> load(){
      return Arrays.asList(IntMappingType.values());
    }
  }
;
  final IModel<List<ConnConfProperty>> connectorPropertiesModel=new LoadableDetachableModel<List<ConnConfProperty>>(){
    private static final long serialVersionUID=5275935387613157437L;
    @Override protected List<ConnConfProperty> load(){
      Set<ConnConfProperty> props=resourceTO.getConnectorConfigurationProperties();
      if (props == null || props.isEmpty() || createFlag) {
        props=overridableConnectorProperties;
      }
      return new ArrayList<ConnConfProperty>(props);
    }
  }
;
  updateResourceSchemaNames(resourceTO);
  updateConnectorProperties(resourceTO.getConnectorId());
  final ConnInstanceTO connectorTO=new ConnInstanceTO();
  if (!createFlag) {
    connectorTO.setId(resourceTO.getConnectorId());
  }
  final Form form=new Form("String_Node_Str");
  form.setModel(new CompoundPropertyModel(resourceTO));
  final AjaxTextFieldPanel resourceName=new AjaxTextFieldPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<String>(resourceTO,"String_Node_Str"),false);
  resourceName.setEnabled(createFlag);
  resourceName.addRequiredLabel();
  form.add(resourceName);
  final AjaxTextFieldPanel accountLink=new AjaxTextFieldPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<String>(resourceTO,"String_Node_Str"),false);
  form.add(accountLink);
  final AjaxCheckBoxPanel forceMandatoryConstraint=new AjaxCheckBoxPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<Boolean>(resourceTO,"String_Node_Str"),false);
  form.add(forceMandatoryConstraint);
  final AjaxCheckBoxPanel propagationPrimary=new AjaxCheckBoxPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<Boolean>(resourceTO,"String_Node_Str"),false);
  form.add(propagationPrimary);
  final AjaxNumberFieldPanel propagationPriority=new AjaxNumberFieldPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<Number>(resourceTO,"String_Node_Str"),Integer.class,false);
  form.add(propagationPriority);
  final AjaxDropDownChoicePanel<PropagationMode> propagationMode=new AjaxDropDownChoicePanel<PropagationMode>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(resourceTO,"String_Node_Str"),false);
  propagationMode.setChoices(Arrays.asList(PropagationMode.values()));
  form.add(propagationMode);
  final AjaxDropDownChoicePanel<TraceLevel> createTraceLevel=new AjaxDropDownChoicePanel<TraceLevel>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(resourceTO,"String_Node_Str"),false);
  createTraceLevel.setChoices(Arrays.asList(TraceLevel.values()));
  form.add(createTraceLevel);
  final AjaxDropDownChoicePanel<TraceLevel> updateTraceLevel=new AjaxDropDownChoicePanel<TraceLevel>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(resourceTO,"String_Node_Str"),false);
  updateTraceLevel.setChoices(Arrays.asList(TraceLevel.values()));
  form.add(updateTraceLevel);
  final AjaxDropDownChoicePanel<TraceLevel> deleteTraceLevel=new AjaxDropDownChoicePanel<TraceLevel>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(resourceTO,"String_Node_Str"),false);
  deleteTraceLevel.setChoices(Arrays.asList(TraceLevel.values()));
  form.add(deleteTraceLevel);
  final AjaxDropDownChoicePanel<TraceLevel> syncTraceLevel=new AjaxDropDownChoicePanel<TraceLevel>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(resourceTO,"String_Node_Str"),false);
  syncTraceLevel.setChoices(Arrays.asList(TraceLevel.values()));
  form.add(syncTraceLevel);
  final AjaxCheckBoxPanel resetToken=new AjaxCheckBoxPanel("String_Node_Str",getString("String_Node_Str"),new Model(null),false);
  resetToken.getField().add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
    private static final long serialVersionUID=-1107858522700306810L;
    @Override protected void onUpdate(    final AjaxRequestTarget art){
      if (resetToken.getModelObject()) {
        resourceTO.setSyncToken(null);
      }
    }
  }
);
  form.add(resetToken);
  mappingContainer=new WebMarkupContainer("String_Node_Str");
  mappingContainer.setOutputMarkupId(true);
  form.add(mappingContainer);
  connectorPropertiesContainer=new WebMarkupContainer("String_Node_Str");
  connectorPropertiesContainer.setOutputMarkupId(true);
  form.add(connectorPropertiesContainer);
  final AjaxDropDownChoicePanel<ConnInstanceTO> connector=new AjaxDropDownChoicePanel<ConnInstanceTO>("String_Node_Str",getString("String_Node_Str"),new Model<ConnInstanceTO>(connectorTO),false);
  connector.setChoices(connectors.getObject());
  connector.setChoiceRenderer(new ChoiceRenderer("String_Node_Str","String_Node_Str"));
  connector.getField().setModel(new IModel<ConnInstanceTO>(){
    private static final long serialVersionUID=-4202872830392400310L;
    @Override public ConnInstanceTO getObject(){
      return connectorTO;
    }
    @Override public void setObject(    final ConnInstanceTO connector){
      resourceTO.setConnectorId(connector.getId());
    }
    @Override public void detach(){
    }
  }
);
  connector.addRequiredLabel();
  connector.setEnabled(createFlag);
  form.add(connector);
  mappings=new ListView<SchemaMappingTO>("String_Node_Str",resourceTO.getMappings()){
    private static final long serialVersionUID=4949588177564901031L;
    @Override protected void populateItem(    final ListItem<SchemaMappingTO> item){
      final SchemaMappingTO mappingTO=item.getModelObject();
      item.add(new AjaxDecoratedCheckbox("String_Node_Str",new Model(Boolean.FALSE)){
        private static final long serialVersionUID=7170946748485726506L;
        @Override protected void onUpdate(        final AjaxRequestTarget target){
          int index=-1;
          for (int i=0; i < resourceTO.getMappings().size() && index == -1; i++) {
            if (mappingTO.equals(resourceTO.getMappings().get(i))) {
              index=i;
            }
          }
          if (index != -1) {
            resourceTO.getMappings().remove(index);
            item.getParent().removeAll();
            target.add(mappingContainer);
          }
        }
        @Override protected IAjaxCallDecorator getAjaxCallDecorator(){
          return new AjaxPreprocessingCallDecorator(super.getAjaxCallDecorator()){
            private static final long serialVersionUID=-7927968187160354605L;
            @Override public CharSequence preDecorateScript(            final CharSequence script){
              return "String_Node_Str" + getString("String_Node_Str") + "String_Node_Str"+ "String_Node_Str"+ script+ "String_Node_Str"+ "String_Node_Str";
            }
          }
;
        }
      }
);
      final AjaxDropDownChoicePanel intAttrNames=new AjaxDropDownChoicePanel<String>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(mappingTO,"String_Node_Str"),true);
      intAttrNames.setChoices(resourceSchemaNames);
      intAttrNames.setRequired(true);
      intAttrNames.setStyleShet("String_Node_Str");
      if (mappingTO.getIntMappingType() == null) {
        intAttrNames.setChoices(Collections.EMPTY_LIST);
      }
 else {
switch (mappingTO.getIntMappingType()) {
case UserSchema:
          intAttrNames.setChoices(uSchemaAttrNames);
        break;
case UserDerivedSchema:
      intAttrNames.setChoices(uDerSchemaAttrNames);
    break;
case UserVirtualSchema:
  intAttrNames.setChoices(uVirSchemaAttrNames);
break;
case SyncopeUserId:
intAttrNames.setEnabled(false);
intAttrNames.setRequired(false);
intAttrNames.setChoices(Collections.EMPTY_LIST);
mappingTO.setIntAttrName("String_Node_Str");
break;
case Password:
intAttrNames.setEnabled(false);
intAttrNames.setRequired(false);
intAttrNames.setChoices(Collections.EMPTY_LIST);
mappingTO.setIntAttrName("String_Node_Str");
break;
case Username:
intAttrNames.setEnabled(false);
intAttrNames.setRequired(false);
intAttrNames.setChoices(Collections.EMPTY_LIST);
mappingTO.setIntAttrName("String_Node_Str");
break;
default :
intAttrNames.setChoices(Collections.EMPTY_LIST);
}
}
item.add(intAttrNames);
final IntMappingTypesDropDownChoice mappingTypesPanel=new IntMappingTypesDropDownChoice("String_Node_Str",getString("String_Node_Str"),new PropertyModel<IntMappingType>(mappingTO,"String_Node_Str"),intAttrNames);
mappingTypesPanel.setRequired(true);
mappingTypesPanel.setChoices(intMappingTypes.getObject());
mappingTypesPanel.setStyleShet("String_Node_Str");
item.add(mappingTypesPanel);
final FieldPanel extAttrName;
if (resourceSchemaNames.isEmpty()) {
extAttrName=new AjaxTextFieldPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<String>(mappingTO,"String_Node_Str"),true);
}
 else {
extAttrName=new AjaxDropDownChoicePanel<String>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(mappingTO,"String_Node_Str"),true);
((AjaxDropDownChoicePanel)extAttrName).setChoices(resourceSchemaNames);
}
boolean required=mappingTO != null && !mappingTO.isAccountid() && !mappingTO.isPassword();
extAttrName.setRequired(required);
extAttrName.setEnabled(required);
extAttrName.setStyleShet("String_Node_Str");
item.add(extAttrName);
final AjaxTextFieldPanel mandatoryCondition=new AjaxTextFieldPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel(mappingTO,"String_Node_Str"),true);
mandatoryCondition.setChoices(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"}));
mandatoryCondition.setStyleShet("String_Node_Str");
item.add(mandatoryCondition);
final AjaxCheckBoxPanel accountId=new AjaxCheckBoxPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel(mappingTO,"String_Node_Str"),false);
accountId.getField().add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
private static final long serialVersionUID=-1107858522700306810L;
@Override protected void onUpdate(AjaxRequestTarget target){
extAttrName.setEnabled(!accountId.getModelObject() && !mappingTO.isPassword());
extAttrName.setModelObject(null);
extAttrName.setRequired(!accountId.getModelObject());
target.add(extAttrName);
}
}
);
item.add(accountId);
final AjaxCheckBoxPanel password=new AjaxCheckBoxPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel(mappingTO,"String_Node_Str"),true);
password.getField().add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
private static final long serialVersionUID=-1107858522700306810L;
@Override protected void onUpdate(AjaxRequestTarget target){
extAttrName.setEnabled(!mappingTO.isAccountid() && !password.getModelObject());
extAttrName.setModelObject(null);
extAttrName.setRequired(!password.getModelObject());
target.add(extAttrName);
}
}
);
item.add(password);
}
}
;
mappings.setReuseItems(true);
mappingContainer.add(mappings);
addSchemaMappingBtn=new IndicatingAjaxButton("String_Node_Str",new ResourceModel("String_Node_Str")){
private static final long serialVersionUID=-4804368561204623354L;
@Override protected void onSubmit(final AjaxRequestTarget target,final Form form){
resourceTO.getMappings().add(new SchemaMappingTO());
target.add(mappingContainer);
}
@Override protected void onError(AjaxRequestTarget target,Form<?> form){
}
}
;
addSchemaMappingBtn.setDefaultFormProcessing(false);
addSchemaMappingBtn.setEnabled(!createFlag);
mappingContainer.add(addSchemaMappingBtn);
connectorPropertiesContainer.add(new ListView<ConnConfProperty>("String_Node_Str",connectorPropertiesModel){
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;
boolean isArray=false;
if (GUARDED_STRING.equalsIgnoreCase(property.getSchema().getType()) || GUARDED_BYTE_ARRAY.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 {
Class propertySchemaClass;
try {
propertySchemaClass=ClassUtils.forName(property.getSchema().getType(),ClassUtils.getDefaultClassLoader());
}
 catch (Exception e) {
LOG.error("String_Node_Str",e);
propertySchemaClass=String.class;
}
if (NUMBER.contains(propertySchemaClass)) {
field=new AjaxNumberFieldPanel("String_Node_Str",label.getDefaultModelObjectAsString(),new Model(),ClassUtils.resolvePrimitiveIfNecessary(propertySchemaClass),true);
required=property.getSchema().isRequired();
}
 else if (Boolean.class.equals(propertySchemaClass) || boolean.class.equals(propertySchemaClass)) {
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();
}
if (String[].class.equals(propertySchemaClass)) {
isArray=true;
}
}
field.setTitle(property.getSchema().getHelpMessage());
if (isArray) {
field.removeRequiredLabel();
if (property.getValues().isEmpty()) {
property.getValues().add(null);
}
final MultiValueSelectorPanel multiFields=new MultiValueSelectorPanel<String>("String_Node_Str",new PropertyModel<List<String>>(property,"String_Node_Str"),String.class,field,true);
item.add(multiFields);
}
 else {
if (required) {
field.addRequiredLabel();
}
field.getField().add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
private static final long serialVersionUID=-1107858522700306810L;
@Override protected void onUpdate(final AjaxRequestTarget target){
send(getPage(),Broadcast.BREADTH,new MultiValueSelectorEvent(target));
}
}
);
field.setNewModel(property.getValues());
item.add(field);
}
resourceTO.getConnectorConfigurationProperties().add(property);
}
}
);
connector.getField().add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
private static final long serialVersionUID=-1107858522700306810L;
@Override protected void onUpdate(AjaxRequestTarget target){
mappings.removeAll();
addSchemaMappingBtn.setEnabled(resourceTO.getConnectorId() != null && resourceTO.getConnectorId() > 0);
updateResourceSchemaNames(resourceTO);
target.add(mappingContainer);
updateConnectorProperties(resourceTO.getConnectorId());
target.add(connectorPropertiesContainer);
}
}
);
form.add(new ResourceSecurityPanel("String_Node_Str",resourceTO));
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){
ResourceTO resourceTO=(ResourceTO)form.getDefaultModelObject();
int accountIdCount=0;
for (SchemaMappingTO mapping : resourceTO.getMappings()) {
if (mapping.isAccountid()) {
accountIdCount++;
}
}
if (accountIdCount == 0 || accountIdCount > 1) {
error(getString("String_Node_Str"));
target.add(feedbackPanel);
}
 else {
try {
if (createFlag) {
restClient.create(resourceTO);
}
 else {
restClient.update(resourceTO);
}
((Resources)callPageRef.getPage()).setModalResult(true);
window.close(target);
}
 catch (SyncopeClientCompositeErrorException e) {
LOG.error("String_Node_Str",resourceTO);
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);
}
}
;
form.add(submit);
add(form);
MetaDataRoleAuthorizationStrategy.authorize(submit,ENABLE,xmlRolesReader.getAllAllowedRoles("String_Node_Str",createFlag ? "String_Node_Str" : "String_Node_Str"));
}

Fixed version (ground truth):
public ResourceModalPage(final PageReference callPageRef,final ModalWindow window,final ResourceTO resourceTO,final boolean createFlag){
  super();
  this.resourceTO=resourceTO;
  uSchemaAttrNames=schemaRestClient.getSchemaNames("String_Node_Str");
  uDerSchemaAttrNames=schemaRestClient.getDerivedSchemaNames("String_Node_Str");
  uVirSchemaAttrNames=schemaRestClient.getVirtualSchemaNames("String_Node_Str");
  final IModel<List<ConnInstanceTO>> connectors=new LoadableDetachableModel<List<ConnInstanceTO>>(){
    private static final long serialVersionUID=5275935387613157437L;
    @Override protected List<ConnInstanceTO> load(){
      return connectorRestClient.getAllConnectors();
    }
  }
;
  final IModel<List<IntMappingType>> intMappingTypes=new LoadableDetachableModel<List<IntMappingType>>(){
    private static final long serialVersionUID=5275935387613157437L;
    @Override protected List<IntMappingType> load(){
      return Arrays.asList(IntMappingType.values());
    }
  }
;
  final IModel<List<ConnConfProperty>> connectorPropertiesModel=new LoadableDetachableModel<List<ConnConfProperty>>(){
    private static final long serialVersionUID=5275935387613157437L;
    @Override protected List<ConnConfProperty> load(){
      Set<ConnConfProperty> props=resourceTO.getConnectorConfigurationProperties();
      if (props == null || props.isEmpty() || createFlag) {
        props=overridableConnectorProperties;
      }
      return new ArrayList<ConnConfProperty>(props);
    }
  }
;
  updateResourceSchemaNames(resourceTO);
  updateConnectorProperties(resourceTO.getConnectorId());
  final ConnInstanceTO connectorTO=new ConnInstanceTO();
  if (!createFlag) {
    connectorTO.setId(resourceTO.getConnectorId());
  }
  final Form form=new Form("String_Node_Str");
  form.setModel(new CompoundPropertyModel(resourceTO));
  final AjaxTextFieldPanel resourceName=new AjaxTextFieldPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<String>(resourceTO,"String_Node_Str"),false);
  resourceName.setEnabled(createFlag);
  resourceName.addRequiredLabel();
  form.add(resourceName);
  final AjaxTextFieldPanel accountLink=new AjaxTextFieldPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<String>(resourceTO,"String_Node_Str"),false);
  form.add(accountLink);
  final AjaxCheckBoxPanel forceMandatoryConstraint=new AjaxCheckBoxPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<Boolean>(resourceTO,"String_Node_Str"),false);
  form.add(forceMandatoryConstraint);
  final AjaxCheckBoxPanel propagationPrimary=new AjaxCheckBoxPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<Boolean>(resourceTO,"String_Node_Str"),false);
  form.add(propagationPrimary);
  final AjaxNumberFieldPanel propagationPriority=new AjaxNumberFieldPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<Number>(resourceTO,"String_Node_Str"),Integer.class,false);
  form.add(propagationPriority);
  final AjaxDropDownChoicePanel<PropagationMode> propagationMode=new AjaxDropDownChoicePanel<PropagationMode>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(resourceTO,"String_Node_Str"),false);
  propagationMode.setChoices(Arrays.asList(PropagationMode.values()));
  form.add(propagationMode);
  final AjaxDropDownChoicePanel<TraceLevel> createTraceLevel=new AjaxDropDownChoicePanel<TraceLevel>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(resourceTO,"String_Node_Str"),false);
  createTraceLevel.setChoices(Arrays.asList(TraceLevel.values()));
  form.add(createTraceLevel);
  final AjaxDropDownChoicePanel<TraceLevel> updateTraceLevel=new AjaxDropDownChoicePanel<TraceLevel>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(resourceTO,"String_Node_Str"),false);
  updateTraceLevel.setChoices(Arrays.asList(TraceLevel.values()));
  form.add(updateTraceLevel);
  final AjaxDropDownChoicePanel<TraceLevel> deleteTraceLevel=new AjaxDropDownChoicePanel<TraceLevel>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(resourceTO,"String_Node_Str"),false);
  deleteTraceLevel.setChoices(Arrays.asList(TraceLevel.values()));
  form.add(deleteTraceLevel);
  final AjaxDropDownChoicePanel<TraceLevel> syncTraceLevel=new AjaxDropDownChoicePanel<TraceLevel>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(resourceTO,"String_Node_Str"),false);
  syncTraceLevel.setChoices(Arrays.asList(TraceLevel.values()));
  form.add(syncTraceLevel);
  final AjaxCheckBoxPanel resetToken=new AjaxCheckBoxPanel("String_Node_Str",getString("String_Node_Str"),new Model(null),false);
  resetToken.getField().add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
    private static final long serialVersionUID=-1107858522700306810L;
    @Override protected void onUpdate(    final AjaxRequestTarget art){
      if (resetToken.getModelObject()) {
        resourceTO.setSyncToken(null);
      }
    }
  }
);
  form.add(resetToken);
  mappingContainer=new WebMarkupContainer("String_Node_Str");
  mappingContainer.setOutputMarkupId(true);
  form.add(mappingContainer);
  connectorPropertiesContainer=new WebMarkupContainer("String_Node_Str");
  connectorPropertiesContainer.setOutputMarkupId(true);
  form.add(connectorPropertiesContainer);
  final AjaxDropDownChoicePanel<ConnInstanceTO> connector=new AjaxDropDownChoicePanel<ConnInstanceTO>("String_Node_Str",getString("String_Node_Str"),new Model<ConnInstanceTO>(connectorTO),false);
  connector.setChoices(connectors.getObject());
  connector.setChoiceRenderer(new ChoiceRenderer("String_Node_Str","String_Node_Str"));
  connector.getField().setModel(new IModel<ConnInstanceTO>(){
    private static final long serialVersionUID=-4202872830392400310L;
    @Override public ConnInstanceTO getObject(){
      return connectorTO;
    }
    @Override public void setObject(    final ConnInstanceTO connector){
      resourceTO.setConnectorId(connector.getId());
    }
    @Override public void detach(){
    }
  }
);
  connector.addRequiredLabel();
  connector.setEnabled(createFlag);
  form.add(connector);
  mappings=new ListView<SchemaMappingTO>("String_Node_Str",resourceTO.getMappings()){
    private static final long serialVersionUID=4949588177564901031L;
    @Override protected void populateItem(    final ListItem<SchemaMappingTO> item){
      final SchemaMappingTO mappingTO=item.getModelObject();
      item.add(new AjaxDecoratedCheckbox("String_Node_Str",new Model(Boolean.FALSE)){
        private static final long serialVersionUID=7170946748485726506L;
        @Override protected void onUpdate(        final AjaxRequestTarget target){
          int index=-1;
          for (int i=0; i < resourceTO.getMappings().size() && index == -1; i++) {
            if (mappingTO.equals(resourceTO.getMappings().get(i))) {
              index=i;
            }
          }
          if (index != -1) {
            resourceTO.getMappings().remove(index);
            item.getParent().removeAll();
            target.add(mappingContainer);
          }
        }
        @Override protected IAjaxCallDecorator getAjaxCallDecorator(){
          return new AjaxPreprocessingCallDecorator(super.getAjaxCallDecorator()){
            private static final long serialVersionUID=-7927968187160354605L;
            @Override public CharSequence preDecorateScript(            final CharSequence script){
              return "String_Node_Str" + getString("String_Node_Str") + "String_Node_Str"+ "String_Node_Str"+ script+ "String_Node_Str"+ "String_Node_Str";
            }
          }
;
        }
      }
);
      final AjaxDropDownChoicePanel intAttrNames=new AjaxDropDownChoicePanel<String>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(mappingTO,"String_Node_Str"),true);
      intAttrNames.setChoices(resourceSchemaNames);
      intAttrNames.setRequired(true);
      intAttrNames.setStyleShet("String_Node_Str");
      if (mappingTO.getIntMappingType() == null) {
        intAttrNames.setChoices(Collections.EMPTY_LIST);
      }
 else {
switch (mappingTO.getIntMappingType()) {
case UserSchema:
          intAttrNames.setChoices(uSchemaAttrNames);
        break;
case UserDerivedSchema:
      intAttrNames.setChoices(uDerSchemaAttrNames);
    break;
case UserVirtualSchema:
  intAttrNames.setChoices(uVirSchemaAttrNames);
break;
case SyncopeUserId:
intAttrNames.setEnabled(false);
intAttrNames.setRequired(false);
intAttrNames.setChoices(Collections.EMPTY_LIST);
mappingTO.setIntAttrName("String_Node_Str");
break;
case Password:
intAttrNames.setEnabled(false);
intAttrNames.setRequired(false);
intAttrNames.setChoices(Collections.EMPTY_LIST);
mappingTO.setIntAttrName("String_Node_Str");
break;
case Username:
intAttrNames.setEnabled(false);
intAttrNames.setRequired(false);
intAttrNames.setChoices(Collections.EMPTY_LIST);
mappingTO.setIntAttrName("String_Node_Str");
break;
default :
intAttrNames.setChoices(Collections.EMPTY_LIST);
}
}
item.add(intAttrNames);
final IntMappingTypesDropDownChoice mappingTypesPanel=new IntMappingTypesDropDownChoice("String_Node_Str",getString("String_Node_Str"),new PropertyModel<IntMappingType>(mappingTO,"String_Node_Str"),intAttrNames);
mappingTypesPanel.setRequired(true);
mappingTypesPanel.setChoices(intMappingTypes.getObject());
mappingTypesPanel.setStyleShet("String_Node_Str");
item.add(mappingTypesPanel);
final FieldPanel extAttrName;
if (resourceSchemaNames.isEmpty()) {
extAttrName=new AjaxTextFieldPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel<String>(mappingTO,"String_Node_Str"),true);
}
 else {
extAttrName=new AjaxDropDownChoicePanel<String>("String_Node_Str",getString("String_Node_Str"),new PropertyModel(mappingTO,"String_Node_Str"),true);
((AjaxDropDownChoicePanel)extAttrName).setChoices(resourceSchemaNames);
}
boolean required=mappingTO != null && !mappingTO.isAccountid() && !mappingTO.isPassword();
extAttrName.setRequired(required);
extAttrName.setEnabled(required);
extAttrName.setStyleShet("String_Node_Str");
item.add(extAttrName);
final AjaxTextFieldPanel mandatoryCondition=new AjaxTextFieldPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel(mappingTO,"String_Node_Str"),true);
mandatoryCondition.setChoices(Arrays.asList(new String[]{"String_Node_Str","String_Node_Str"}));
mandatoryCondition.setStyleShet("String_Node_Str");
item.add(mandatoryCondition);
final AjaxCheckBoxPanel accountId=new AjaxCheckBoxPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel(mappingTO,"String_Node_Str"),false);
accountId.getField().add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
private static final long serialVersionUID=-1107858522700306810L;
@Override protected void onUpdate(AjaxRequestTarget target){
extAttrName.setEnabled(!accountId.getModelObject() && !mappingTO.isPassword());
extAttrName.setModelObject(null);
extAttrName.setRequired(!accountId.getModelObject());
target.add(extAttrName);
}
}
);
item.add(accountId);
final AjaxCheckBoxPanel password=new AjaxCheckBoxPanel("String_Node_Str",getString("String_Node_Str"),new PropertyModel(mappingTO,"String_Node_Str"),true);
password.getField().add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
private static final long serialVersionUID=-1107858522700306810L;
@Override protected void onUpdate(AjaxRequestTarget target){
extAttrName.setEnabled(!mappingTO.isAccountid() && !password.getModelObject());
extAttrName.setModelObject(null);
extAttrName.setRequired(!password.getModelObject());
target.add(extAttrName);
}
}
);
item.add(password);
}
}
;
mappings.setReuseItems(true);
mappingContainer.add(mappings);
addSchemaMappingBtn=new IndicatingAjaxButton("String_Node_Str",new ResourceModel("String_Node_Str")){
private static final long serialVersionUID=-4804368561204623354L;
@Override protected void onSubmit(final AjaxRequestTarget target,final Form form){
resourceTO.getMappings().add(new SchemaMappingTO());
target.add(mappingContainer);
}
@Override protected void onError(AjaxRequestTarget target,Form<?> form){
}
}
;
addSchemaMappingBtn.setDefaultFormProcessing(false);
addSchemaMappingBtn.setEnabled(!createFlag);
mappingContainer.add(addSchemaMappingBtn);
connectorPropertiesContainer.add(new ListView<ConnConfProperty>("String_Node_Str",connectorPropertiesModel){
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;
boolean isArray=false;
if (GUARDED_STRING.equalsIgnoreCase(property.getSchema().getType()) || GUARDED_BYTE_ARRAY.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 {
Class propertySchemaClass;
try {
propertySchemaClass=ClassUtils.forName(property.getSchema().getType(),ClassUtils.getDefaultClassLoader());
}
 catch (Exception e) {
LOG.error("String_Node_Str",e);
propertySchemaClass=String.class;
}
if (NUMBER.contains(propertySchemaClass)) {
field=new AjaxNumberFieldPanel("String_Node_Str",label.getDefaultModelObjectAsString(),new Model(),ClassUtils.resolvePrimitiveIfNecessary(propertySchemaClass),true);
required=property.getSchema().isRequired();
}
 else if (Boolean.class.equals(propertySchemaClass) || boolean.class.equals(propertySchemaClass)) {
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();
}
if (String[].class.equals(propertySchemaClass)) {
isArray=true;
}
}
field.setTitle(property.getSchema().getHelpMessage());
if (isArray) {
field.removeRequiredLabel();
if (property.getValues().isEmpty()) {
property.getValues().add(null);
}
final MultiValueSelectorPanel multiFields=new MultiValueSelectorPanel<String>("String_Node_Str",new PropertyModel<List<String>>(property,"String_Node_Str"),String.class,field,true);
item.add(multiFields);
}
 else {
if (required) {
field.addRequiredLabel();
}
field.getField().add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
private static final long serialVersionUID=-1107858522700306810L;
@Override protected void onUpdate(final AjaxRequestTarget target){
send(getPage(),Broadcast.BREADTH,new MultiValueSelectorEvent(target));
}
}
);
field.setNewModel(property.getValues());
item.add(field);
}
resourceTO.getConnectorConfigurationProperties().add(property);
}
}
);
connector.getField().add(new AjaxFormComponentUpdatingBehavior("String_Node_Str"){
private static final long serialVersionUID=-1107858522700306810L;
@Override protected void onUpdate(AjaxRequestTarget target){
mappings.removeAll();
addSchemaMappingBtn.setEnabled(resourceTO.getConnectorId() != null && resourceTO.getConnectorId() > 0);
updateResourceSchemaNames(resourceTO);
target.add(mappingContainer);
updateConnectorProperties(resourceTO.getConnectorId());
target.add(connectorPropertiesContainer);
}
}
);
final AjaxLink check=new IndicatingAjaxLink("String_Node_Str",new ResourceModel("String_Node_Str")){
private static final long serialVersionUID=-4199438518229098169L;
@Override public void onClick(final AjaxRequestTarget target){
ConnInstanceTO connectorTO=connectorRestClient.read(resourceTO.getConnectorId());
connectorTO.setConfiguration(ConnConfPropUtils.joinConnInstanceProperties(connectorTO.getConfigurationMap(),ConnConfPropUtils.getConnConfPropertyMap(resourceTO.getConnectorConfigurationProperties())));
if (connectorRestClient.check(connectorTO).booleanValue()) {
info(getString("String_Node_Str"));
}
 else {
error(getString("String_Node_Str"));
}
target.add(feedbackPanel);
}
}
;
check.setEnabled(!connectorPropertiesModel.getObject().isEmpty());
connectorPropertiesContainer.add(check);
form.add(new ResourceSecurityPanel("String_Node_Str",resourceTO));
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){
ResourceTO resourceTO=(ResourceTO)form.getDefaultModelObject();
int accountIdCount=0;
for (SchemaMappingTO mapping : resourceTO.getMappings()) {
if (mapping.isAccountid()) {
accountIdCount++;
}
}
if (accountIdCount == 0 || accountIdCount > 1) {
error(getString("String_Node_Str"));
target.add(feedbackPanel);
}
 else {
try {
if (createFlag) {
restClient.create(resourceTO);
}
 else {
restClient.update(resourceTO);
}
((Resources)callPageRef.getPage()).setModalResult(true);
window.close(target);
}
 catch (SyncopeClientCompositeErrorException e) {
LOG.error("String_Node_Str",resourceTO);
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);
}
}
;
form.add(submit);
add(form);
MetaDataRoleAuthorizationStrategy.authorize(submit,ENABLE,xmlRolesReader.getAllAllowedRoles("String_Node_Str",createFlag ? "String_Node_Str" : "String_Node_Str"));
}