| | |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.guitools.controlpanel.util.Utilities.*; |
| | |
| | | import org.opends.server.admin.std.meta.LocalDBVLVIndexCfgDefn.Scope; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.OpenDsException; |
| | |
| | | /** |
| | | * Panel that appears when the user defines a new VLV index. |
| | | */ |
| | | public class NewVLVIndexPanel extends AbstractVLVIndexPanel |
| | | class NewVLVIndexPanel extends AbstractVLVIndexPanel |
| | | { |
| | | private static final long serialVersionUID = 1554866540747530939L; |
| | | |
| | |
| | | * the component relative to which the dialog containing this panel |
| | | * will be centered. |
| | | */ |
| | | public NewVLVIndexPanel(String backendName, Component relativeComponent) |
| | | NewVLVIndexPanel(String backendName, Component relativeComponent) |
| | | { |
| | | super(backendName, relativeComponent); |
| | | createBasicLayout(this, new GridBagConstraints(), false); |
| | |
| | | * @param backend |
| | | * the backend where the index will be created. |
| | | */ |
| | | public void update(BackendDescriptor backend) |
| | | void update(BackendDescriptor backend) |
| | | { |
| | | updateBaseDNCombo(backend); |
| | | backendName.setText(backend.getBackendID()); |
| | |
| | | } |
| | | |
| | | /** The task in charge of creating the VLV index. */ |
| | | protected class NewVLVIndexTask extends Task |
| | | private class NewVLVIndexTask extends Task |
| | | { |
| | | private final Set<String> backendSet; |
| | | private final String indexName; |
| | |
| | | * @param dlg |
| | | * the progress dialog that shows the progress of the task. |
| | | */ |
| | | public NewVLVIndexTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | private NewVLVIndexTask(ControlPanelInfo info, ProgressDialog dlg) |
| | | { |
| | | super(info, dlg); |
| | | backendSet = new HashSet<String>(); |
| | |
| | | @Override |
| | | public boolean canLaunch(Task taskToBeLaunched, Collection<LocalizableMessage> incompatibilityReasons) |
| | | { |
| | | boolean canLaunch = true; |
| | | if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched)) |
| | | { |
| | | // All the operations are incompatible if they apply to this |
| | |
| | | if (backends.size() > 0) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | canLaunch = false; |
| | | return false; |
| | | } |
| | | } |
| | | return canLaunch; |
| | | return true; |
| | | } |
| | | |
| | | private void updateConfiguration() throws OpenDsException |
| | |
| | | LDIFImportConfig ldifImportConfig = null; |
| | | try |
| | | { |
| | | final String topEntryDN = |
| | | "cn=VLV Index," + getRDNString("ds-cfg-backend-id", backendName.getText()) + ",cn=Backends,cn=config"; |
| | | final boolean topEntryExists = DirectoryServer.getConfigHandler().entryExists(DN.valueOf(topEntryDN)); |
| | | |
| | | if (!topEntryExists) |
| | | { |
| | | final String completeLDIF = |
| | | makeLdif("dn: " + topEntryDN, "objectClass: top", "objectClass: ds-cfg-branch", "cn: VLV Index", "") |
| | | + ldif; |
| | | ldifImportConfig = new LDIFImportConfig(new StringReader(completeLDIF)); |
| | | } |
| | | else |
| | | { |
| | | ldifImportConfig = new LDIFImportConfig(new StringReader(ldif)); |
| | | } |
| | | ldifImportConfig = new LDIFImportConfig(new StringReader(getLDIF())); |
| | | |
| | | final LDIFReader reader = new LDIFReader(ldifImportConfig); |
| | | Entry backendConfigEntry; |
| | |
| | | } |
| | | } |
| | | |
| | | private String getLDIF() throws DirectoryException |
| | | { |
| | | final String topEntryDN = |
| | | "cn=VLV Index," + getRDNString("ds-cfg-backend-id", backendName.getText()) + ",cn=Backends,cn=config"; |
| | | final boolean topEntryExists = DirectoryServer.getConfigHandler().entryExists(DN.valueOf(topEntryDN)); |
| | | |
| | | if (!topEntryExists) |
| | | { |
| | | return makeLdif( |
| | | "dn: " + topEntryDN, |
| | | "objectClass: top", |
| | | "objectClass: ds-cfg-branch", |
| | | "cn: VLV Index", |
| | | "") |
| | | + ldif; |
| | | } |
| | | return ldif; |
| | | } |
| | | |
| | | private void createIndex(InitialLdapContext ctx) throws OpenDsException |
| | | { |
| | | final ManagementContext mCtx = LDAPManagementContext.createFromContext(JNDIDirContextAdaptor.adapt(ctx)); |