/*
  * Transfer the server Datasource properties to the repo object
  */
 private void setRepoDatasourceProperties(Datasource repoSource, Properties serverDsProperties)
     throws Exception {
   for (String key : serverDsProperties.stringPropertyNames()) {
     String value = serverDsProperties.getProperty(key);
     if (key.equals(TeiidInstance.DATASOURCE_JNDINAME)) {
       repoSource.setJndiName(getTransaction(), value);
     } else if (key.equals(TeiidInstance.DATASOURCE_DRIVERNAME)) {
       repoSource.setDriverName(getTransaction(), value);
     } else if (key.equals(TeiidInstance.DATASOURCE_CLASSNAME)) {
       repoSource.setClassName(getTransaction(), value);
       repoSource.setJdbc(getTransaction(), false);
     } else {
       repoSource.setProperty(getTransaction(), key, value);
     }
   }
 }
  /**
   * {@inheritDoc}
   *
   * @see org.komodo.shell.BuiltInShellCommand#doExecute()
   */
  @Override
  protected CommandResult doExecute() {
    CommandResult result = null;

    try {
      final String name =
          requiredArgument(0, I18n.bind(WorkspaceCommandsI18n.missingPropertyNameValue));
      final String value =
          requiredArgument(1, I18n.bind(WorkspaceCommandsI18n.missingPropertyNameValue));

      final Datasource datasource = getDatasource();
      final UnitOfWork transaction = getTransaction();
      String errorMsg = null;

      switch (name) {
        case JNDI_NAME:
          datasource.setJndiName(transaction, value);
          break;
        case DRIVER_NAME:
          datasource.setDriverName(transaction, value);
          break;
        case CLASS_NAME:
          datasource.setClassName(transaction, value);
          break;
        case PROFILE_NAME:
          datasource.setProfileName(transaction, value);
          break;
        case JDBC:
          if (Boolean.TRUE.toString().equals(value) || Boolean.FALSE.toString().equals(value)) {
            datasource.setJdbc(transaction, Boolean.parseBoolean(value));
          } else {
            errorMsg = I18n.bind(WorkspaceCommandsI18n.invalidBooleanPropertyValue, JDBC);
          }

          break;
        case PREVIEW:
          if (Boolean.TRUE.toString().equals(value) || Boolean.FALSE.toString().equals(value)) {
            datasource.setPreview(transaction, Boolean.parseBoolean(value));
          } else {
            errorMsg = I18n.bind(WorkspaceCommandsI18n.invalidBooleanPropertyValue, PREVIEW);
          }

          break;
        default:
          errorMsg =
              I18n.bind(
                  WorkspaceCommandsI18n.invalidPropertyName,
                  name,
                  Datasource.class.getSimpleName());
          break;
      }

      if (StringUtils.isBlank(errorMsg)) {
        result = new CommandResultImpl(I18n.bind(WorkspaceCommandsI18n.setPropertySuccess, name));
      } else {
        result = new CommandResultImpl(false, errorMsg, null);
      }
    } catch (final Exception e) {
      result = new CommandResultImpl(e);
    }

    return result;
  }