@Override
  protected Serializable onApplyInternal(final Serializable modelObject) {
    ConnInstanceTO connInstanceTO = ConnInstanceTO.class.cast(modelObject);
    ConnBundleTO bundleTO = ConnectorWizardBuilder.getBundle(connInstanceTO, bundles);

    connInstanceTO.setConnectorName(bundleTO.getConnectorName());
    connInstanceTO.setBundleName(bundleTO.getBundleName());
    connInstanceTO.setVersion(bundleTO.getVersion());

    // Reset pool configuration if all fields are null
    if (connInstanceTO.getPoolConf() != null
        && connInstanceTO.getPoolConf().getMaxIdle() == null
        && connInstanceTO.getPoolConf().getMaxObjects() == null
        && connInstanceTO.getPoolConf().getMaxWait() == null
        && connInstanceTO.getPoolConf().getMinEvictableIdleTimeMillis() == null
        && connInstanceTO.getPoolConf().getMinIdle() == null) {

      connInstanceTO.setPoolConf(null);
    }

    ConnInstanceTO res;
    if (mode == AjaxWizard.Mode.CREATE) {
      res = connectorRestClient.create(connInstanceTO);
    } else {
      connectorRestClient.update(connInstanceTO);
      res = connInstanceTO;
    }

    return res;
  }
  public ConnectorWizardBuilder(final ConnInstanceTO defaultItem, final PageReference pageRef) {
    super(defaultItem, pageRef);
    this.bundles =
        CollectionUtils.select(
            connectorRestClient.getAllBundles(),
            new Predicate<ConnBundleTO>() {

              @Override
              public boolean evaluate(final ConnBundleTO object) {
                return object.getLocation().equals(defaultItem.getLocation());
              }
            },
            new ArrayList<ConnBundleTO>());
  }