opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java
@@ -408,6 +408,12 @@ /** The value for the hidden testonly argument. */ public static final String OPTION_LONG_TESTONLY_ARGUMENT = "testOnly"; /** The value for the backend type long option. */ public static final String OPTION_LONG_BACKEND_TYPE = "backendType"; /** The value for the backend type short option. */ public static final Character OPTION_SHORT_BACKEND_TYPE = 't'; /** Prevent instantiation. */ private ArgumentConstants() { } opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/MemoryBackend.java
@@ -20,7 +20,7 @@ * * CDDL HEADER END * * Copyright 2013-2014 ForgeRock AS. * Copyright 2013-2015 ForgeRock AS. */ package org.forgerock.opendj.ldap; @@ -239,7 +239,7 @@ final DN parent = dn.parent(); if (entries.containsKey(dn)) { throw newLdapException(ResultCode.ENTRY_ALREADY_EXISTS, "The entry '" + dn + "' already exists"); } else if (!entries.containsKey(parent)) { } else if (parent != null && !entries.containsKey(parent)) { noSuchObject(parent); } else { entries.put(dn, request); opendj-sdk/opendj-server-legacy/resource/config/config.ldif
@@ -20,8 +20,8 @@ # CDDL HEADER END # # Copyright 2006-2010 Sun Microsystems, Inc. # Portions Copyright 2010-2014 ForgeRock AS. # Portions Copyright 2012-2014 Manuel Gaupp # Portions Copyright 2010-2015 ForgeRock AS. # # # This file contains the primary Directory Server configuration. It must not @@ -186,134 +186,6 @@ objectClass: ds-cfg-branch cn: Backends dn: ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-backend objectClass: ds-cfg-local-db-backend ds-cfg-enabled: true ds-cfg-java-class: org.opends.server.backends.jeb.BackendImpl ds-cfg-backend-id: userRoot ds-cfg-writability-mode: enabled ds-cfg-base-dn: dc=example,dc=com ds-cfg-db-directory: db ds-cfg-db-directory-permissions: 700 ds-cfg-index-entry-limit: 4000 ds-cfg-preload-time-limit: 0 seconds ds-cfg-entries-compressed: false ds-cfg-compact-encoding: true ds-cfg-db-cache-percent: 50 ds-cfg-db-cache-size: 0 megabytes ds-cfg-db-txn-no-sync: false ds-cfg-db-txn-write-no-sync: true ds-cfg-db-run-cleaner: true ds-cfg-db-cleaner-min-utilization: 50 ds-cfg-db-evictor-lru-only: false ds-cfg-db-evictor-nodes-per-scan: 10 ds-cfg-db-evictor-core-threads: 1 ds-cfg-db-evictor-max-threads: 10 ds-cfg-db-evictor-keep-alive: 600 seconds ds-cfg-db-log-file-max: 100 megabytes ds-cfg-db-log-filecache-size: 100 ds-cfg-db-logging-file-handler-on: true ds-cfg-db-logging-level: CONFIG ds-cfg-db-checkpointer-bytes-interval: 500 megabytes ds-cfg-db-checkpointer-wakeup-interval: 30 seconds ds-cfg-disk-full-threshold: 100 megabytes ds-cfg-disk-low-threshold: 200 megabytes dn: cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-branch cn: Index dn: ds-cfg-attribute=aci,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: aci ds-cfg-index-type: presence dn: ds-cfg-attribute=cn,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: cn ds-cfg-index-type: equality ds-cfg-index-type: substring dn: ds-cfg-attribute=ds-sync-hist,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: ds-sync-hist ds-cfg-index-type: ordering dn: ds-cfg-attribute=ds-sync-conflict,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: ds-sync-conflict ds-cfg-index-type: equality dn: ds-cfg-attribute=entryUUID,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: entryUUID ds-cfg-index-type: equality dn: ds-cfg-attribute=givenName,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: givenName ds-cfg-index-type: equality ds-cfg-index-type: substring dn: ds-cfg-attribute=mail,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: mail ds-cfg-index-type: equality ds-cfg-index-type: substring dn: ds-cfg-attribute=member,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: member ds-cfg-index-type: equality dn: ds-cfg-attribute=objectClass,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: objectClass ds-cfg-index-type: equality dn: ds-cfg-attribute=sn,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: sn ds-cfg-index-type: equality ds-cfg-index-type: substring dn: ds-cfg-attribute=telephoneNumber,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: telephoneNumber ds-cfg-index-type: equality ds-cfg-index-type: substring dn: ds-cfg-attribute=uid,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: uid ds-cfg-index-type: equality dn: ds-cfg-attribute=uniqueMember,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: uniqueMember ds-cfg-index-type: equality dn: cn=VLV Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-branch cn: VLV Index dn: ds-cfg-backend-id=backup,cn=Backends,cn=config objectClass: top objectClass: ds-cfg-backend opendj-sdk/opendj-server-legacy/src/main/java/org/opends/quicksetup/UserData.java
@@ -72,6 +72,8 @@ private boolean enableWindowsService; private String backendType; private NewSuffixOptions newSuffixOptions; private DataReplicationOptions replicationOptions; @@ -353,6 +355,28 @@ } /** * Returns the new userRoot backend type. * * @return the new userRoot backend type. */ public String getBackendType() { return backendType; } /** * Sets the new userRoot backend type. * * @param backendType * The new backend type. This string must be compatible with * dsconfig tool. */ public void setBackendType(final String backendType) { this.backendType = backendType; } /** * Returns the NewSuffixOptions object representing the data in the New Suffix * Data Options panel. * @return the NewSuffixOptions object representing the data in the New Suffix opendj-sdk/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/Installer.java
@@ -26,8 +26,6 @@ */ package org.opends.quicksetup.installer; import static com.forgerock.opendj.cli.Utils.*; import static org.forgerock.util.Utils.*; import static org.opends.admin.ads.ServerDescriptor.*; import static org.opends.admin.ads.ServerDescriptor.ServerProperty.*; @@ -36,6 +34,9 @@ import static org.opends.quicksetup.Step.*; import static org.opends.quicksetup.util.Utils.*; import static com.forgerock.opendj.cli.ArgumentConstants.*; import static com.forgerock.opendj.cli.Utils.*; import java.awt.event.WindowEvent; import java.io.BufferedWriter; import java.io.File; @@ -871,6 +872,9 @@ argList.add("-w"); argList.add(getUserData().getDirectoryManagerPwd()); argList.add("--" + OPTION_LONG_BACKEND_TYPE); argList.add(getUserData().getBackendType()); if (createNotReplicatedSuffix()) { LinkedList<String> baseDns = opendj-sdk/opendj-server-legacy/src/main/java/org/opends/server/backends/persistit/PersistItStorage.java
@@ -1005,6 +1005,11 @@ @Override public void removeStorageFiles() throws StorageRuntimeException { if (!backendDirectory.exists()) { return; } if (!backendDirectory.isDirectory()) { LocalizableMessage msg = ERR_JEB_DIRECTORY_INVALID.get(backendDirectory.getPath()); @@ -1025,6 +1030,7 @@ LocalizableMessage message = ERR_JEB_REMOVE_FAIL.get(e.getMessage()); throw new StorageRuntimeException(message.toString(), e); } } @Override opendj-sdk/opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureDS.java
@@ -26,9 +26,6 @@ */ package org.opends.server.tools; import static com.forgerock.opendj.cli.ArgumentConstants.*; import static com.forgerock.opendj.cli.Utils.*; import static org.opends.messages.ConfigMessages.*; import static org.opends.messages.ExtensionMessages.*; import static org.opends.messages.ProtocolMessages.*; @@ -37,7 +34,14 @@ import static org.opends.server.util.ServerConstants.*; import static org.opends.server.util.StaticUtils.*; import static com.forgerock.opendj.cli.ArgumentConstants.*; import static com.forgerock.opendj.cli.Utils.*; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.OutputStream; import java.io.PrintStream; import java.io.StringReader; @@ -45,12 +49,39 @@ import java.security.GeneralSecurityException; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Set; import javax.crypto.Cipher; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.config.LDAPProfile; import org.forgerock.opendj.config.ManagedObjectDefinition; import org.forgerock.opendj.config.client.ManagementContext; import org.forgerock.opendj.config.client.ldap.LDAPManagementContext; import org.forgerock.opendj.ldap.Connection; import org.forgerock.opendj.ldap.Connections; import org.forgerock.opendj.ldap.MemoryBackend; import org.forgerock.opendj.ldap.schema.Schema; import org.forgerock.opendj.ldif.LDIF; import org.forgerock.opendj.ldif.LDIFEntryReader; import org.forgerock.opendj.ldif.LDIFEntryWriter; import org.forgerock.opendj.server.config.client.BackendCfgClient; import org.forgerock.opendj.server.config.client.BackendIndexCfgClient; import org.forgerock.opendj.server.config.client.LocalDBBackendCfgClient; import org.forgerock.opendj.server.config.client.LocalDBIndexCfgClient; import org.forgerock.opendj.server.config.client.PluggableBackendCfgClient; import org.forgerock.opendj.server.config.client.RootCfgClient; import org.forgerock.opendj.server.config.meta.BackendCfgDefn.WritabilityMode; import org.forgerock.opendj.server.config.meta.BackendIndexCfgDefn; import org.forgerock.opendj.server.config.meta.BackendIndexCfgDefn.IndexType; import org.forgerock.opendj.server.config.meta.LocalDBBackendCfgDefn; import org.forgerock.opendj.server.config.meta.LocalDBIndexCfgDefn; import org.forgerock.opendj.server.config.server.BackendCfg; import org.opends.quicksetup.Installation; import org.opends.quicksetup.installer.Installer; import org.opends.server.admin.DefaultBehaviorProvider; import org.opends.server.admin.DefinedDefaultBehaviorProvider; import org.opends.server.admin.StringPropertyDefinition; @@ -214,6 +245,40 @@ /** The DN of the DIGEST-MD5 SASL mechanism handler. */ public static final String DN_DIGEST_MD5_SASL_MECHANISM = "cn=DIGEST-MD5,cn=SASL Mechanisms,cn=config"; /** Describes an attribute index which should be created during installation. */ private static final class DefaultIndex { private final String name; private final boolean shouldCreateSubstringIndex; private DefaultIndex(final String name, final boolean substringIndex) { this.name = name; this.shouldCreateSubstringIndex = substringIndex; } private static DefaultIndex withEqualityAndSubstring(final String name) { return new DefaultIndex(name, true); } private static DefaultIndex withEquality(final String name) { return new DefaultIndex(name, false); } } private static final DefaultIndex[] DEFAULT_INDEXES = { DefaultIndex.withEqualityAndSubstring("cn"), DefaultIndex.withEqualityAndSubstring("givenName"), DefaultIndex.withEqualityAndSubstring("mail"), DefaultIndex.withEqualityAndSubstring("member"), DefaultIndex.withEqualityAndSubstring("sn"), DefaultIndex.withEqualityAndSubstring("telephoneNumber"), DefaultIndex.withEquality("uid"), DefaultIndex.withEquality("uniqueMember") }; private static int SUCCESS = 0; private static int ERROR = 1; @@ -277,6 +342,7 @@ private StringArgument certNickName; private StringArgument keyManagerPath; private StringArgument serverRoot; private StringArgument backendType; private final String serverLockFileName = LockFileManager.getServerLockFileName(); private final StringBuilder failureReason = new StringBuilder(); @@ -307,10 +373,11 @@ checkArgumentsConsistency(); checkPortArguments(); initializeDirectoryServer(); tryAcquireExclusiveLocks(); updateBaseDNs(parseProvidedBaseDNs()); final LinkedList<DN> baseDNs = parseProvidedBaseDNs(); initializeDirectoryServer(); final DN rootDN = parseRootDN(); final String rootPW = parseRootDNPassword(); @@ -328,7 +395,6 @@ throw new ConfigureDSException(message); } updateBaseDNs(baseDNs); updateLdapPort(); updateAdminConnectorPort(); updateLdapSecurePort(); @@ -480,6 +546,13 @@ null, null, null); serverRoot.setHidden(true); argParser.addArgument(serverRoot); backendType = new StringArgument( OPTION_LONG_BACKEND_TYPE.toLowerCase(), null, OPTION_LONG_BACKEND_TYPE, false, false, true, INFO_INSTALLDS_BACKEND_TYPE_PLACEHOLDER.get(), null, OPTION_LONG_BACKEND_TYPE, INFO_INSTALLDS_DESCRIPTION_BACKEND_TYPE.get() ); argParser.addArgument(backendType); } catch (final ArgumentException ae) { @@ -601,21 +674,20 @@ } } private LinkedList<DN> parseProvidedBaseDNs() throws ConfigureDSException private LinkedList<org.forgerock.opendj.ldap.DN> parseProvidedBaseDNs() throws ConfigureDSException { LinkedList<DN> baseDNs = null; LinkedList<org.forgerock.opendj.ldap.DN> baseDNs = new LinkedList<org.forgerock.opendj.ldap.DN>(); if (baseDNString.isPresent()) { baseDNs = new LinkedList<DN>(); for (final String dnString : baseDNString.getValues()) { try { baseDNs.add(DN.valueOf(dnString)); baseDNs.add(org.forgerock.opendj.ldap.DN.valueOf(dnString)); } catch (final DirectoryException de) catch (final Exception e) { throw new ConfigureDSException(de, ERR_CONFIGDS_CANNOT_PARSE_BASE_DN.get(dnString, de.getMessageObject())); throw new ConfigureDSException(e, ERR_CONFIGDS_CANNOT_PARSE_BASE_DN.get(dnString, e.getMessage())); } } } @@ -727,24 +799,112 @@ } } private void updateBaseDNs(final LinkedList<DN> baseDNs) throws ConfigureDSException @SuppressWarnings("unchecked") private void updateBaseDNs(final List<org.forgerock.opendj.ldap.DN> baseDNs) throws ConfigureDSException { if (baseDNs != null) if (!baseDNs.isEmpty()) { final String backendTypeName = backendType.getValue(); final ManagedObjectDefinition<?, ?> backend = InstallDS.retrieveBackendTypeFromName(backendTypeName); if (backend == null) { throw new ConfigureDSException( ERR_CONFIGDS_BACKEND_TYPE_UNKNOWN.get(backendTypeName, InstallDS.getBackendTypeNames())); } BufferedReader configReader = null; BufferedWriter configWriter = null; try { final DN jeBackendDN = DN.valueOf(DN_JE_BACKEND); final ConfigEntry configEntry = configHandler.getConfigEntry(jeBackendDN); final File configurationFile = Installation.getLocal().getCurrentConfigurationFile(); configReader = new BufferedReader(new FileReader(configurationFile)); final DNConfigAttribute baseDNAttr = new DNConfigAttribute( ATTR_BACKEND_BASE_DN, INFO_CONFIG_BACKEND_ATTR_DESCRIPTION_BASE_DNS.get(), true, true, false, baseDNs); configEntry.putConfigAttribute(baseDNAttr); final MemoryBackend memoryBackend = new MemoryBackend(new LDIFEntryReader(configReader)); final Connection co = Connections.newInternalConnection(memoryBackend); // We need to add the root dse entry to make the configuration framework work. co.add(LDIFEntryReader.valueOfLDIFEntry("dn:", "objectClass:top", "objectClass:ds-root-dse")); final ManagementContext context = LDAPManagementContext.newManagementContext(co, LDAPProfile.getInstance()); createBackend(context.getRootConfiguration(), baseDNs, (ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg>) backend); final Iterator<org.forgerock.opendj.ldap.Entry> entries = memoryBackend.getAll().iterator(); entries.next(); // skip RootDSE configWriter = new BufferedWriter(new FileWriter(configurationFile)); LDIF.copyTo(LDIF.newEntryIteratorReader(entries), new LDIFEntryWriter(configWriter)); } catch (final Exception e) { throw new ConfigureDSException(e, ERR_CONFIGDS_CANNOT_UPDATE_BASE_DN.get(e)); throw new ConfigureDSException(ERR_CONFIGDS_SET_BACKEND_TYPE.get(backendTypeName, e.getMessage())); } finally { close(configReader, configWriter); } } } private void createBackend(final RootCfgClient rootConfiguration, final List<org.forgerock.opendj.ldap.DN> baseDNs, final ManagedObjectDefinition<?, ?> backend) throws Exception { final BackendCfgClient backendCfgClient = rootConfiguration.createBackend( (ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg>) backend, Installer.ROOT_BACKEND_NAME, null); backendCfgClient.setEnabled(true); backendCfgClient.setBaseDN(baseDNs); backendCfgClient.setWritabilityMode(WritabilityMode.ENABLED); backendCfgClient.commit(); //FIXME: Remove once local-db backend will be pluggable. if (backend instanceof LocalDBBackendCfgDefn) { addJEIndexes((LocalDBBackendCfgClient) backendCfgClient); return; } addBackendIndexes((PluggableBackendCfgClient) backendCfgClient); } private void addBackendIndexes(PluggableBackendCfgClient backendCfgClient) throws Exception { for (DefaultIndex defaultIndex : DEFAULT_INDEXES) { final BackendIndexCfgClient index = backendCfgClient.createBackendIndex(BackendIndexCfgDefn.getInstance(), defaultIndex.name, null); index.setAttribute(Schema.getCoreSchema().getAttributeType(defaultIndex.name)); final List<IndexType> indexTypes = new LinkedList<IndexType>(); indexTypes.add(IndexType.EQUALITY); if (defaultIndex.shouldCreateSubstringIndex) { indexTypes.add(IndexType.SUBSTRING); } index.setIndexType(indexTypes); index.commit(); } } // FIXME: Remove once local-db backend will be pluggable. private void addJEIndexes(final LocalDBBackendCfgClient jeBackendCfgClient) throws Exception { for (DefaultIndex defaultIndex : DEFAULT_INDEXES) { final LocalDBIndexCfgClient jeIndex = jeBackendCfgClient.createLocalDBIndex(LocalDBIndexCfgDefn.getInstance(), defaultIndex.name, null); jeIndex.setAttribute(Schema.getCoreSchema().getAttributeType(defaultIndex.name)); final List<org.forgerock.opendj.server.config.meta.LocalDBIndexCfgDefn.IndexType> indexTypes = new LinkedList<org.forgerock.opendj.server.config.meta.LocalDBIndexCfgDefn.IndexType>(); indexTypes.add(org.forgerock.opendj.server.config.meta.LocalDBIndexCfgDefn.IndexType.EQUALITY); if (defaultIndex.shouldCreateSubstringIndex) { indexTypes.add(org.forgerock.opendj.server.config.meta.LocalDBIndexCfgDefn.IndexType.SUBSTRING); } jeIndex.setIndexType(indexTypes); jeIndex.commit(); } } opendj-sdk/opendj-server-legacy/src/main/java/org/opends/server/tools/InstallDS.java
@@ -27,15 +27,15 @@ */ package org.opends.server.tools; import static com.forgerock.opendj.cli.Utils.*; import static com.forgerock.opendj.util.OperatingSystem.*; import static org.forgerock.util.Utils.*; import static org.opends.messages.AdminToolMessages.*; import static org.opends.messages.QuickSetupMessages.*; import static org.opends.messages.ToolMessages.*; import static org.opends.messages.UtilityMessages.*; import static com.forgerock.opendj.cli.Utils.*; import static com.forgerock.opendj.util.OperatingSystem.*; import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -50,6 +50,8 @@ import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.naming.ldap.LdapName; @@ -57,6 +59,14 @@ import org.forgerock.i18n.LocalizableMessageDescriptor.Arg0; import org.forgerock.i18n.LocalizableMessageDescriptor.Arg1; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.config.AbstractManagedObjectDefinition; import org.forgerock.opendj.config.ConfigurationFramework; import org.forgerock.opendj.config.ManagedObjectDefinition; import org.forgerock.opendj.config.server.ConfigException; import org.forgerock.opendj.server.config.client.BackendCfgClient; import org.forgerock.opendj.server.config.meta.LocalDBBackendCfgDefn; import org.forgerock.opendj.server.config.meta.PluggableBackendCfgDefn; import org.forgerock.opendj.server.config.server.BackendCfg; import org.opends.messages.QuickSetupMessages; import org.opends.messages.ToolMessages; import org.opends.quicksetup.ApplicationException; @@ -207,6 +217,7 @@ /** Different variables we use when the user decides to provide data again. */ private NewSuffixOptions.Type lastResetPopulateOption; private String lastResetBackendType; private String lastResetImportFile; private String lastResetRejectedFile; @@ -222,6 +233,8 @@ private Boolean lastResetEnableWindowsService; private Boolean lastResetStartServer; private List<ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg>> availableBackendTypes; private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); /** The argument parser. */ @@ -366,6 +379,9 @@ return InstallReturnCode.ERROR_LICENSE_NOT_ACCEPTED.getReturnCode(); } initializeConfigurationFramework(); availableBackendTypes = getBackendTypes(); final UserData uData = new UserData(); InstallReturnCode fillUserDataRC; try @@ -410,6 +426,24 @@ return InstallReturnCode.SUCCESSFUL.getReturnCode(); } private void initializeConfigurationFramework() { if (!ConfigurationFramework.getInstance().isInitialized()) { try { ConfigurationFramework.getInstance().initialize(); } catch (ConfigException e) { final LocalizableMessage message = LocalizableMessage.raw( "Error occured while loading the configuration framework: " + e.getLocalizedMessage()); logger.error(message); throw new RuntimeException(message.toString()); } } } private InstallReturnCode fillUserData(UserData uData, String[] args) throws UserDataException { if (!isInteractive()) @@ -685,6 +719,7 @@ uData.setConnectTimeout(getConnectTimeout()); final List<LocalizableMessage> errorMessages = new LinkedList<LocalizableMessage>(); setBackendType(uData, errorMessages); final List<String> baseDNs = checkBaseDNs(errorMessages); setDirectoryManagerData(uData, errorMessages); setPorts(uData, errorMessages); @@ -698,6 +733,19 @@ } } private void setBackendType(final UserData uData, final List<LocalizableMessage> errorMessages) { final String filledBackendType = argParser.backendTypeArg.getValue(); if (retrieveBackendTypeFromName(filledBackendType) != null) { uData.setBackendType(filledBackendType); } else { errorMessages.add(ERR_INSTALLDS_NO_SUCH_BACKEND_TYPE.get(filledBackendType, getBackendTypeNames())); } } private List<String> checkBaseDNs(List<LocalizableMessage> errorMessages) { final List<String> baseDNs = argParser.baseDNArg.getValues(); @@ -940,7 +988,7 @@ promptIfRequiredForDirectoryManager(uData); promptIfRequiredForPortData(uData); uData.setNewSuffixOptions(promptIfRequiredForImportData()); uData.setNewSuffixOptions(promptIfRequiredForImportData(uData)); uData.setSecurityOptions(promptIfRequiredForSecurityData(uData)); uData.setEnableWindowsService(promptIfRequiredForWindowsService()); uData.setStartServer(promptIfRequiredForStartServer()); @@ -1217,11 +1265,13 @@ * some data or if the provided data is not valid, it prompts the user to * provide it. * * @param uData * The UserData object to be updated. * @return the NewSuffixOptions telling how to import data * @throws UserDataException * if something went wrong checking the data. */ private NewSuffixOptions promptIfRequiredForImportData() throws UserDataException private NewSuffixOptions promptIfRequiredForImportData(final UserData uData) throws UserDataException { boolean prompt = true; if (!argParser.baseDNArg.isPresent()) @@ -1243,6 +1293,8 @@ return NewSuffixOptions.createEmpty(new LinkedList<String>()); } uData.setBackendType(getOrPromptForBackendType()); // Add default value for base DN on first prompt if (argParser.baseDNArg.getDefaultValue() == null) { @@ -1254,6 +1306,63 @@ } private String getOrPromptForBackendType() { if (argParser.backendTypeArg.isPresent()) { if (retrieveBackendTypeFromName(argParser.backendTypeArg.getValue().toLowerCase()) != null) { return argParser.backendTypeArg.getValue(); } println(); println(ERR_INSTALLDS_NO_SUCH_BACKEND_TYPE.get(argParser.backendTypeArg.getValue(), getBackendTypeNames())); } int backendTypeIndex = 1; try { final MenuResult<Integer> m = getBackendTypeMenu().run(); if (m.isSuccess()) { backendTypeIndex = m.getValue(); } } catch (final ClientException ce) { logger.warn(LocalizableMessage.raw("Error reading input: " + ce, ce)); } return availableBackendTypes.get(backendTypeIndex - 1).getName(); } private Menu<Integer> getBackendTypeMenu() { final MenuBuilder<Integer> builder = new MenuBuilder<Integer>(this); builder.setPrompt(INFO_INSTALLDS_PROMPT_BACKEND_TYPE.get()); int index = 1; for (AbstractManagedObjectDefinition<?, ?> backendType : availableBackendTypes) { final String printableBackendName = filterSchemaBackendName(backendType.getName()); builder.addNumberedOption(LocalizableMessage.raw(printableBackendName), MenuResult.success(index++)); } final int printableIndex = getPromptedBackendTypeIndex(); builder.setDefault(LocalizableMessage.raw(Integer.toString(printableIndex)), MenuResult.success(printableIndex)); final Menu<Integer> menu = builder.toMenu(); return menu; } private int getPromptedBackendTypeIndex() { if (lastResetBackendType != null) { ManagedObjectDefinition<?, ?> backend = InstallDS.retrieveBackendTypeFromName(lastResetBackendType); return availableBackendTypes.indexOf(backend) + 1; } return 1; } private NewSuffixOptions promptIfRequiredForDataOptions(List<String> baseDNs) { NewSuffixOptions dataOptions; @@ -2507,6 +2616,7 @@ lastResetEnableWindowsService = uData.getEnableWindowsService(); lastResetStartServer = uData.getStartServer(); lastResetBackendType = uData.getBackendType(); } catch (final Throwable t) { @@ -2551,4 +2661,66 @@ return argParser.getConnectTimeout(); } static ManagedObjectDefinition<?, ?> retrieveBackendTypeFromName(final String backendTypeStr) { for (ManagedObjectDefinition<?, ?> backendType : getBackendTypes()) { final String name = backendType.getName(); if (backendTypeStr.equalsIgnoreCase(name) || backendTypeStr.equalsIgnoreCase(filterSchemaBackendName(name))) { return backendType; } } return null; } @SuppressWarnings("unchecked") static List<ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg>> getBackendTypes() { final List<ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg>> backendTypes = new LinkedList<ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg>>(); backendTypes.add(LocalDBBackendCfgDefn.getInstance()); for (AbstractManagedObjectDefinition<?, ?> backendType : PluggableBackendCfgDefn.getInstance().getAllChildren()) { // Filtering out only the non-abstract backends to avoid users attempt to create abstract ones if (backendType instanceof ManagedObjectDefinition) { backendTypes.add((ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg>) backendType); } } return backendTypes; } static String getBackendTypeNames() { String backendTypeNames = ""; for (ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg> backendType : getBackendTypes()) { backendTypeNames += filterSchemaBackendName(backendType.getName()) + ", "; } if (backendTypeNames.isEmpty()) { return "Impossible to retrieve supported backend type list"; } return backendTypeNames.substring(0, backendTypeNames.length() - 2); } static String filterSchemaBackendName(final String dsCfgBackendName) { final String cfgNameRegExp = "(.*)-backend.*"; final Matcher regExpMatcher = Pattern.compile(cfgNameRegExp, Pattern.CASE_INSENSITIVE).matcher(dsCfgBackendName); if (regExpMatcher.matches()) { return regExpMatcher.group(1); } return dsCfgBackendName; } } opendj-sdk/opendj-server-legacy/src/main/java/org/opends/server/tools/InstallDSArgumentParser.java
@@ -26,11 +26,11 @@ */ package org.opends.server.tools; import static org.opends.messages.ToolMessages.*; import static com.forgerock.opendj.cli.ArgumentConstants.*; import static com.forgerock.opendj.util.OperatingSystem.*; import static org.opends.messages.ToolMessages.*; import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashSet; @@ -39,6 +39,7 @@ import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.LocalizableMessageDescriptor.Arg1; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.server.config.meta.LocalDBBackendCfgDefn; import org.opends.quicksetup.Constants; import org.opends.quicksetup.Installation; import org.opends.quicksetup.UserData; @@ -105,6 +106,7 @@ StringArgument progNameArg; IntegerArgument connectTimeoutArg; BooleanArgument acceptLicense; StringArgument backendTypeArg; /** * The default constructor for this class. @@ -392,6 +394,17 @@ showUsageArg = CommonArguments.getShowUsage(); addArgument(showUsageArg); setUsageArgument(showUsageArg); backendTypeArg = new StringArgument( OPTION_LONG_BACKEND_TYPE.toLowerCase(), OPTION_SHORT_BACKEND_TYPE, OPTION_LONG_BACKEND_TYPE, false, false, true, INFO_INSTALLDS_BACKEND_TYPE_PLACEHOLDER.get(), LocalDBBackendCfgDefn.getInstance().getName(), OPTION_LONG_BACKEND_TYPE, INFO_INSTALLDS_DESCRIPTION_BACKEND_TYPE.get() ); addArgument(backendTypeArg); } /** @@ -588,7 +601,7 @@ final boolean noBaseDNProvided = !baseDNArg.isPresent() && baseDNArg.getDefaultValue() == null; if (noPromptArg.isPresent() && noBaseDNProvided) { Argument[] args = {importLDIFArg, addBaseEntryArg, sampleDataArg}; final Argument[] args = {importLDIFArg, addBaseEntryArg, sampleDataArg, backendTypeArg}; for (Argument arg : args) { if (arg.isPresent()) opendj-sdk/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
@@ -3040,3 +3040,12 @@ </para> INFO_ARGUMENT_DESCRIPTION_TESTONLY_20005=Just verify that the JVM can be \ started properly INFO_INSTALLDS_BACKEND_TYPE_PLACEHOLDER_20006={backendType} INFO_INSTALLDS_DESCRIPTION_BACKEND_TYPE_20007=The type of the userRoot backend INFO_INSTALLDS_PROMPT_BACKEND_TYPE_20008=Provide the backend type: ERR_INSTALLDS_NO_SUCH_BACKEND_TYPE_20009=The backend type '%s' is not recognized. \ The supported backend types are %s. ERR_CONFIGDS_BACKEND_TYPE_UNKNOWN_20010=The backend type '%s' is not recognized. \ The supported backend types are %s. ERR_CONFIGDS_SET_BACKEND_TYPE_20011=An error occured while trying to create userRoot \ backend type %s. Error message: %s opendj-sdk/opendj-server-legacy/tests/unit-tests-testng/resource/config-changes.ldif
@@ -436,6 +436,150 @@ ds-cfg-db-cache-percent: 2 ds-cfg-db-run-cleaner: false dn: ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-backend objectClass: ds-cfg-local-db-backend ds-cfg-enabled: true ds-cfg-java-class: org.opends.server.backends.jeb.BackendImpl ds-cfg-backend-id: userRoot ds-cfg-writability-mode: enabled ds-cfg-base-dn: dc=example,dc=com ds-cfg-db-directory: db ds-cfg-db-directory-permissions: 700 ds-cfg-index-entry-limit: 4000 ds-cfg-preload-time-limit: 0 seconds ds-cfg-entries-compressed: false ds-cfg-compact-encoding: true ds-cfg-db-cache-percent: 50 ds-cfg-db-cache-size: 0 megabytes ds-cfg-db-txn-no-sync: false ds-cfg-db-txn-write-no-sync: true ds-cfg-db-run-cleaner: true ds-cfg-db-cleaner-min-utilization: 50 ds-cfg-db-evictor-lru-only: false ds-cfg-db-evictor-nodes-per-scan: 10 ds-cfg-db-evictor-core-threads: 1 ds-cfg-db-evictor-max-threads: 10 ds-cfg-db-evictor-keep-alive: 600 seconds ds-cfg-db-log-file-max: 100 megabytes ds-cfg-db-log-filecache-size: 100 ds-cfg-db-logging-file-handler-on: true ds-cfg-db-logging-level: CONFIG ds-cfg-db-checkpointer-bytes-interval: 500 megabytes ds-cfg-db-checkpointer-wakeup-interval: 30 seconds ds-cfg-disk-full-threshold: 100 megabytes ds-cfg-disk-low-threshold: 200 megabytes dn: cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-branch cn: Index dn: ds-cfg-attribute=aci,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: aci ds-cfg-index-type: presence dn: ds-cfg-attribute=cn,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: cn ds-cfg-index-type: equality ds-cfg-index-type: substring dn: ds-cfg-attribute=ds-sync-hist,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: ds-sync-hist ds-cfg-index-type: ordering dn: ds-cfg-attribute=ds-sync-conflict,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: ds-sync-conflict ds-cfg-index-type: equality dn: ds-cfg-attribute=entryUUID,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: entryUUID ds-cfg-index-type: equality dn: ds-cfg-attribute=givenName,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: givenName ds-cfg-index-type: equality ds-cfg-index-type: substring dn: ds-cfg-attribute=mail,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: mail ds-cfg-index-type: equality ds-cfg-index-type: substring dn: ds-cfg-attribute=member,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: member ds-cfg-index-type: equality dn: ds-cfg-attribute=objectClass,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: objectClass ds-cfg-index-type: equality dn: ds-cfg-attribute=sn,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: sn ds-cfg-index-type: equality ds-cfg-index-type: substring dn: ds-cfg-attribute=telephoneNumber,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: telephoneNumber ds-cfg-index-type: equality ds-cfg-index-type: substring dn: ds-cfg-attribute=uid,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: uid ds-cfg-index-type: equality dn: ds-cfg-attribute=uniqueMember,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-local-db-index ds-cfg-attribute: uniqueMember ds-cfg-index-type: equality dn: cn=VLV Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top objectClass: ds-cfg-branch cn: VLV Index dn: ds-cfg-attribute=oncRpcNumber,cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config changetype: add objectClass: top