public JiraJdbcDirectoryConfiguration toJiraJdbcConfiguration(Directory directory) {
   JiraJdbcDirectoryConfiguration configuration = new JiraJdbcDirectoryConfiguration();
   configuration.setDirectoryId(directory.getId() != null ? directory.getId() : 0);
   configuration.setActive(directory.isActive());
   configuration.setName(directory.getName());
   configuration.setDatasourceJndiName(
       directory.getAttributes().get(JiraJdbcDirectoryConfiguration.JNDI_NAME_ATTRIBUTE_KEY));
   return configuration;
 }
  public Directory buildJiraJdbcDirectory(JiraJdbcDirectoryConfiguration configuration) {
    ImmutableDirectory.Builder builder = createBuilder();
    builder.setAllowedOperations(EnumSet.of(OperationType.UPDATE_USER));
    builder.setActive(configuration.isActive());
    builder.setId(configuration.getDirectoryId());
    builder.setImplementationClass(JiraJdbcDirectoryConfiguration.DIRECTORY_CLASS);
    builder.setName(configuration.getName());
    builder.setType(DirectoryType.CUSTOM);

    builder.setAttributes(
        Collections.singletonMap(
            JiraJdbcDirectoryConfiguration.JNDI_NAME_ATTRIBUTE_KEY,
            configuration.getDatasourceJndiName()));

    return builder.toDirectory();
  }