/**
  * add new proxy to descriptor to configuration descriptor
  *
  * @param proxyDescriptor - new proxy descriptor
  */
 private void addNewProxy(ProxyDescriptor proxyDescriptor) {
   boolean isDefaultProxy = proxyDescriptor.isDefaultProxy();
   MutableCentralConfigDescriptor configDescriptor = centralConfigService.getMutableDescriptor();
   configDescriptor.proxyChanged(proxyDescriptor, isDefaultProxy);
   configDescriptor.addProxy(proxyDescriptor, isDefaultProxy);
   centralConfigService.saveEditedDescriptorAndReload(configDescriptor);
 }
  public LdapCreateUpdatePanel(CreateUpdateAction action, LdapSetting ldapDescriptor) {
    /**
     * Creating a local copy of the original descriptor so that we can fool around with it without
     * changing the original until we need to save
     */
    super(action, new LdapSetting(ldapDescriptor));
    originalDescriptor = ldapDescriptor;
    setWidth(500);

    add(form);

    TitledBorder border = new TitledBorder("border");
    form.add(border);

    // Ldap key
    RequiredTextField<String> ldapKeyField = new RequiredTextField<String>("key");
    setDefaultFocusField(ldapKeyField);
    ldapKeyField.setEnabled(isCreate()); // don't allow key update
    if (isCreate()) {
      ldapKeyField.add(new XsdNCNameValidator("Invalid LDAP key '%s'"));
      ldapKeyField.add(new UniqueXmlIdValidator(centralConfigService.getMutableDescriptor()));
    }
    border.add(ldapKeyField);
    border.add(new SchemaHelpBubble("key.help"));

    border.add(new StyledCheckbox("enabled"));

    TextField<String> ldapUrlField = new RequiredTextField<String>("ldapUrl");
    ldapUrlField.add(new UriValidator("ldap", "ldaps"));
    border.add(ldapUrlField);
    border.add(new SchemaHelpBubble("ldapUrl.help"));

    TitledBorder borderDn = new TitledBorder("borderDn");
    form.add(borderDn);
    borderDn.add(new TextField("userDnPattern"));
    borderDn.add(new TextField("emailAttribute"));
    borderDn.add(new SchemaHelpBubble("emailAttribute.help"));
    borderDn.add(new StyledCheckbox("autoCreateUser"));
    borderDn.add(new SchemaHelpBubble("autoCreateUser.help"));
    borderDn.add(new SchemaHelpBubble("userDnPattern.help"));

    addSearchFields(borderDn);

    addTestConnectionFields();

    // Cancel button
    form.add(new ModalCloseLink("cancel"));

    // Submit button
    TitledAjaxSubmitLink submitButton = createSubmitButton();
    form.add(submitButton);
    form.add(new DefaultButtonBehavior(submitButton));

    add(form);
  }
 private P2Repo resolveLocalP2RepoFromUrl(String url) {
   String rpp = StringUtils.removeStart(url, "local://");
   // rpp = rpp.substring(0, rpp.indexOf('/'));
   RepoPath repoPath = RepoPathFactory.create(rpp);
   LocalRepoDescriptor localRepoDescriptor =
       centralConfig.getMutableDescriptor().getLocalRepositoriesMap().get(repoPath.getRepoKey());
   if (localRepoDescriptor != null) {
     return new P2Repo(null, repoPath.getRepoKey(), url);
   }
   return null;
 }