| | |
| | | import org.forgerock.opendj.config.PropertyException; |
| | | import org.forgerock.opendj.config.client.ManagementContext; |
| | | import org.forgerock.opendj.config.client.ldap.LDAPManagementContext; |
| | | 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.meta.BackendIndexCfgDefn; |
| | | import org.forgerock.opendj.server.config.meta.LocalDBIndexCfgDefn; |
| | | import org.opends.guitools.controlpanel.datamodel.IndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.IndexTypeDescriptor; |
| | | import org.opends.guitools.controlpanel.ui.components.TitlePanel; |
| | | import org.opends.guitools.controlpanel.ui.renderer.CustomListCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.quicksetup.Installation; |
| | | import org.opends.server.backends.jeb.RemoveOnceLocalDBBackendIsPluggable; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.OpenDsException; |
| | |
| | | |
| | | /** Minimum value for entry limit. */ |
| | | static final int MIN_ENTRY_LIMIT = |
| | | LocalDBIndexCfgDefn.getInstance().getIndexEntryLimitPropertyDefinition().getLowerLimit(); |
| | | BackendIndexCfgDefn.getInstance().getIndexEntryLimitPropertyDefinition().getLowerLimit(); |
| | | /** Maximum value for entry limit. */ |
| | | static final int MAX_ENTRY_LIMIT = |
| | | LocalDBIndexCfgDefn.getInstance().getIndexEntryLimitPropertyDefinition().getUpperLimit(); |
| | | BackendIndexCfgDefn.getInstance().getIndexEntryLimitPropertyDefinition().getUpperLimit(); |
| | | |
| | | /** LocalizableMessage to be displayed to indicate that an index is not configurable. */ |
| | | static final LocalizableMessage NON_CONFIGURABLE_INDEX = INFO_CTRL_PANEL_NON_CONFIGURABLE_INDEX_LABEL.get(); |
| | |
| | | final LDAPProfile ldapProfile = LDAPProfile.getInstance(); |
| | | try (ManagementContext context = LDAPManagementContext.newLDIFManagementContext(configFile, ldapProfile)) |
| | | { |
| | | final BackendCfgClient backend = context.getRootConfiguration().getBackend(backendName); |
| | | if (backend instanceof LocalDBBackendCfgClient) |
| | | { |
| | | updateLocalDBIndexOffline( |
| | | (LocalDBBackendCfgClient) backend, indexToModify, attributeName, indexTypes, indexEntryLimit); |
| | | } |
| | | else |
| | | { |
| | | updateBackendIndexOnline( |
| | | (PluggableBackendCfgClient) backend, indexToModify, attributeName, indexTypes, indexEntryLimit); |
| | | } |
| | | final PluggableBackendCfgClient backend = |
| | | (PluggableBackendCfgClient) context.getRootConfiguration().getBackend(backendName); |
| | | updateBackendIndexOnline(backend, indexToModify, attributeName, indexTypes, indexEntryLimit); |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | |
| | | index.commit(); |
| | | Utilities.throwFirstFrom(exceptions); |
| | | } |
| | | |
| | | @RemoveOnceLocalDBBackendIsPluggable |
| | | private void updateLocalDBIndexOffline(final LocalDBBackendCfgClient backend, final IndexDescriptor indexToModify, |
| | | final String attributeName, final Set<IndexTypeDescriptor> indexTypes, final int indexEntryLimit) |
| | | throws Exception |
| | | { |
| | | final boolean isCreation = indexToModify == null; |
| | | final List<PropertyException> exceptions = new ArrayList<>(); |
| | | final LocalDBIndexCfgClient index = isCreation |
| | | ? backend.createLocalDBIndex(LocalDBIndexCfgDefn.getInstance(), attributeName, exceptions) |
| | | : backend.getLocalDBIndex(attributeName); |
| | | |
| | | if (isCreation || indexTypes.equals(indexToModify.getTypes())) |
| | | { |
| | | index.setIndexType(IndexTypeDescriptor.toNewConfigLocalDBIndexTypes(indexTypes)); |
| | | } |
| | | |
| | | if (indexEntryLimit != index.getIndexEntryLimit()) |
| | | { |
| | | index.setIndexEntryLimit(indexEntryLimit); |
| | | } |
| | | index.commit(); |
| | | Utilities.throwFirstFrom(exceptions); |
| | | } |
| | | |
| | | } |