NewBaseDNPanel.java revision 998747bfaaa3c6b28bbfaf0e282e6c0ccbf46bc0
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2009 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
/**
* The class that appears when the user clicks on 'New Base DN'.
*
*/
public class NewBaseDNPanel extends StatusGenericPanel
{
private static final long serialVersionUID = -2680821576362341119L;
private JTextField newBackend;
private JTextField baseDN;
private JRadioButton onlyCreateBaseEntry;
private JRadioButton leaveDatabaseEmpty;
private JRadioButton importDataFromLDIF;
private JRadioButton importAutomaticallyGenerated;
private JTextField path;
private JTextField numberOfEntries;
private JLabel lRemoteFileHelp;
private JButton browseImportPath;
private JLabel lDirectoryBaseDN;
private JLabel lNumberOfEntries;
private JLabel lDirectoryData;
private DocumentListener documentListener;
/**
* The default constructor.
*
*/
public NewBaseDNPanel()
{
super();
createLayout();
}
/**
* {@inheritDoc}
*/
public LocalizableMessage getTitle()
{
return INFO_CTRL_PANEL_NEW_BASE_DN_TITLE.get();
}
/**
* {@inheritDoc}
*/
public Component getPreferredFocusComponent()
{
return baseDN;
}
/**
* {@inheritDoc}
*/
public void toBeDisplayed(boolean visible)
{
if (visible)
{
}
}
/**
* Creates the layout of the panel (but the contents are not populated here).
*/
private void createLayout()
{
NEW_BACKEND}));
{
/**
* {@inheritDoc}
*/
{
}
};
documentListener = new DocumentListener()
{
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
{
}
};
onlyCreateBaseEntry.setSelected(false);
leaveDatabaseEmpty.setSelected(false);
importDataFromLDIF.setSelected(false);
{
/**
* {@inheritDoc}
*/
{
}
};
while (buttons.hasMoreElements())
{
}
onlyCreateBaseEntry.setSelected(true);
}
/**
* {@inheritDoc}
*/
{
{
if (!backend.isConfigBackend())
{
}
}
{
}
super.updateComboBoxModel(newElements,
isLocal() ?
{
public void run()
{
}
});
}
private JPanel createPathPanel()
{
new BrowseActionListener(path,
return panel;
}
private JPanel createNumberOfUsersPanel()
{
return panel;
}
/**
* {@inheritDoc}
*/
public void cancelClicked()
{
super.cancelClicked();
}
/**
* {@inheritDoc}
*/
protected void checkOKButtonEnable()
{
}
/**
* {@inheritDoc}
*/
public void okClicked()
{
if (o == null)
{
}
else if (o.equals(NEW_BACKEND))
{
{
}
else
{
// Check that the backend is not already defined.
{
{
break;
}
}
}
}
{
}
else
{
try
{
// Check that the DN is not defined.
boolean baseDNAlreadyDefined = false;
{
{
{
baseDNAlreadyDefined = true;
break;
}
{
{
baseDNAlreadyDefined = true;
break;
}
}
{
{
baseDNAlreadyDefined = true;
break;
}
}
}
if (baseDNAlreadyDefined)
{
break;
}
}
}
catch (OpenDsException oe)
{
}
}
// TODO: what happens with sub-suffixes?
if (importDataFromLDIF.isSelected())
{
{
{
}
}
{
int minValue = 1;
}
{
getInfo());
{
}
{
null,
progressDialog.setVisible(true);
}
}
{
}
}
private String getBackendName()
{
{
}
else if (backendName != null)
{
return backendName.toString();
}
else
{
return null;
}
}
private boolean isNewBackend()
{
}
/**
* The task in charge of creating the base DN (and if required, the backend).
*
*/
protected class NewBaseDNTask extends Task
{
private int progressAfterConfigurationUpdate = -1;
/**
* The constructor of the task.
* @param info the control panel info.
* @param dlg the progress dialog that shows the progress of the task.
*/
{
if (onlyCreateBaseEntry.isSelected())
{
}
else if (leaveDatabaseEmpty.isSelected())
{
}
else if (importAutomaticallyGenerated.isSelected())
{
if (nEntries < 500)
{
}
else if (nEntries < 3000)
{
}
else
{
}
}
}
/**
* {@inheritDoc}
*/
{
return Type.NEW_BASEDN;
}
/**
* {@inheritDoc}
*/
public LocalizableMessage getTaskDescription()
{
}
/**
* {@inheritDoc}
*/
{
boolean canLaunch = true;
{
// All the operations are incompatible if they apply to this
// backend.
{
canLaunch = false;
}
}
return canLaunch;
}
/**
* Returns the equivalent command-line to generate the data.
* @return the equivalent command-line to generate the data.
*/
private String getDataCommandLineToDisplay()
{
{
}
}
/**
* Returns the path of the command-line to be used to generate the data.
* @return the path of the command-line to be used to generate the data.
*/
private String getDataCommandLineName()
{
if (!leaveDatabaseEmpty.isSelected())
{
if (isLocal())
{
}
else
{
}
}
else
{
cmdLineName = null;
}
return cmdLineName;
}
/**
* Returns the arguments of the command-line that can be used to generate
* the data.
* @param ldifFile the LDIF file.
* @param useTemplate whether to use a template or not.
* @return the arguments of the command-line that can be used to generate
* the data.
*/
boolean useTemplate)
{
if (!leaveDatabaseEmpty.isSelected())
{
if (isLocal())
{
if (!useTemplate)
{
}
else
{
}
}
else
{
// If we are not local, we use ldapmodify to update the contents.
}
if (isServerRunning() && isLocal())
{
}
}
return args;
}
{
boolean configHandlerUpdated = false;
try
{
if (!isServerRunning())
{
getInfo().stopPooling();
if (getInfo().mustDeregisterConfig())
{
}
getInfo().setMustDeregisterConfig(true);
configHandlerUpdated = true;
}
else
{
{
/**
* {@inheritDoc}
*/
public void run()
{
}
});
}
if (isNewBackend())
{
{
/**
* {@inheritDoc}
*/
public void run()
{
getBackendName(), newBaseDN);
}
});
if (isServerRunning())
{
}
else
{
}
}
else
{
{
/**
* {@inheritDoc}
*/
public void run()
{
newBaseDN, getBackendName());
}
});
if (isServerRunning())
{
}
else
{
}
}
{
/**
* {@inheritDoc}
*/
public void run()
{
"<br><br>");
}
});
if (isNewBackend() && isServerRunning())
{
// Create additional indexes and display the equivalent command.
// Everything is done in the method createAdditionalIndexes
}
if (progressAfterConfigurationUpdate > 0)
{
{
/**
* {@inheritDoc}
*/
public void run()
{
}
});
}
}
finally
{
if (configHandlerUpdated)
{
getInfo().startPooling();
}
}
}
/**
* Creates the data in the new base DN.
* @throws OpenDsException if there is an error importing contents.
* @throws IOException if there is an err
*/
{
if (leaveEmpty)
{
}
else
{
if (importLDIF)
{
{
public void run()
{
}
});
}
else if (createBaseEntry)
{
{
public void run()
{
}
});
ldifFile = f.getAbsolutePath();
}
else
{
{
public void run()
{
if (isLocal())
{
}
else
{
}
}
});
if (!isLocal())
{
".ldif");
// Create the LDIF file locally using make-ldif
"MakeLDIF");
f.delete();
if (returnCode != 0)
{
throw new OnlineUpdateException(
null);
}
}
else
{
ldifFile = f.getAbsolutePath();
}
}
if (createBaseEntry || !isLocal())
{
outPrintStream.setNotifyListeners(false);
errorPrintStream.setNotifyListeners(false);
}
try
{
if (isServerRunning())
{
if (isLocal() || importLDIF)
{
}
else
{
}
}
else
{
}
}
finally
{
{
outPrintStream.setNotifyListeners(true);
}
}
if (returnCode != 0)
{
}
else
{
{
{
public void run()
{
}
});
}
}
}
}
{
backendName, null);
backend.setEnabled(true);
}
{
",cn=Backends,cn=config";
"dn: "+dn,
"objectClass: top",
"objectClass: ds-cfg-backend",
"objectClass: ds-cfg-local-db-backend",
"ds-cfg-base-dn: "+newBaseDN,
"ds-cfg-enabled: true",
"ds-cfg-writability-mode: enabled",
"ds-cfg-java-class: " +
"ds-cfg-backend-id: " + backendName,
"ds-cfg-db-directory: db",
"",
"dn: cn=Index,"+dn,
"objectClass: top",
"objectClass: ds-cfg-branch",
"cn: Index",
"",
"dn: ds-cfg-attribute=aci,cn=Index,"+dn,
"objectClass: ds-cfg-local-db-index",
"objectClass: top",
"ds-cfg-attribute: aci",
"ds-cfg-index-type: presence",
"",
"dn: ds-cfg-attribute=ds-sync-hist,cn=Index,"+dn,
"objectClass: ds-cfg-local-db-index",
"objectClass: top",
"ds-cfg-attribute: ds-sync-hist",
"ds-cfg-index-type: ordering",
"",
"dn: ds-cfg-attribute=entryUUID,cn=Index,"+dn,
"objectClass: ds-cfg-local-db-index",
"objectClass: top",
"ds-cfg-attribute: entryUUID",
"ds-cfg-index-type: equality",
"",
"dn: ds-cfg-attribute=objectClass,cn=Index,"+dn,
"objectClass: ds-cfg-local-db-index",
"objectClass: top",
"ds-cfg-attribute: objectClass",
"ds-cfg-index-type: equality"
);
}
{
"dn: ds-cfg-attribute=cn,cn=Index,"+dn,
"objectClass: ds-cfg-local-db-index",
"objectClass: top",
"ds-cfg-attribute: cn",
"ds-cfg-index-type: equality",
"ds-cfg-index-type: substring",
"",
"dn: ds-cfg-attribute=givenName,cn=Index,"+dn,
"objectClass: ds-cfg-local-db-index",
"objectClass: top",
"ds-cfg-attribute: givenName",
"ds-cfg-index-type: equality",
"ds-cfg-index-type: substring",
"",
"dn: ds-cfg-attribute=mail,cn=Index,"+dn,
"objectClass: ds-cfg-local-db-index",
"objectClass: top",
"ds-cfg-attribute: mail",
"ds-cfg-index-type: equality",
"ds-cfg-index-type: substring",
"",
"dn: ds-cfg-attribute=member,cn=Index,"+dn,
"objectClass: ds-cfg-local-db-index",
"objectClass: top",
"ds-cfg-attribute: member",
"ds-cfg-index-type: equality",
"",
"dn: ds-cfg-attribute=sn,cn=Index,"+dn,
"objectClass: ds-cfg-local-db-index",
"objectClass: top",
"ds-cfg-attribute: sn",
"ds-cfg-index-type: equality",
"ds-cfg-index-type: substring",
"",
"dn: ds-cfg-attribute=telephoneNumber,cn=Index,"+dn,
"objectClass: ds-cfg-local-db-index",
"objectClass: top",
"ds-cfg-attribute: telephoneNumber",
"ds-cfg-index-type: equality",
"ds-cfg-index-type: substring",
"",
"dn: ds-cfg-attribute=uid,cn=Index,"+dn,
"objectClass: ds-cfg-local-db-index",
"objectClass: top",
"ds-cfg-attribute: uid",
"ds-cfg-index-type: equality",
"",
"dn: ds-cfg-attribute=uniqueMember,cn=Index,"+dn,
"objectClass: ds-cfg-local-db-index",
"objectClass: top",
"ds-cfg-attribute: uniqueMember",
"ds-cfg-index-type: equality"
);
}
throws OpenDsException
{
try
{
{
}
}
catch (IOException ioe)
{
throw new OfflineUpdateException(
}
finally
{
if (ldifImportConfig != null)
{
}
}
}
throws OpenDsException
{
try
{
{
}
}
catch (IOException ioe)
{
throw new OfflineUpdateException(
}
finally
{
if (ldifImportConfig != null)
{
}
}
}
{
// Instead of adding indexes using management framework, use this approach
// so that we have to define the additional indexes only in the method
// getBackendLdif.
try
{
{
{
}
{
{
}
{
}
{
{
}
}
}
}
{
}
{
public void run()
{
}
});
{
}
{
public void run()
{
"<br><br>");
}
});
}
catch (Throwable t)
{
throw new OnlineUpdateException(
}
finally
{
if (ldifImportConfig != null)
{
}
}
}
throws OpenDsException, ConfigException
{
for (BackendDescriptor backend :
{
{
{
}
break;
}
}
",cn=Backends,cn=config";
new DNConfigAttribute(
true, true, false, baseDNs);
}
{
}
/**
* {@inheritDoc}
*/
protected String getCommandLinePath()
{
return null;
}
/**
* {@inheritDoc}
*/
{
}
/**
* Returns the configuration command-line full path.
* @return the configuration command-line full path.
*/
private String getConfigCommandLineFullPath()
{
if (isServerRunning())
{
return getCommandLinePath("dsconfig");
}
else
{
return null;
}
}
/**
* Returns the configuration command-line arguments.
* @return the configuration command-line arguments.
*/
{
if (isServerRunning())
{
if (isNewBackend())
{
}
else
{
}
}
return args;
}
/**
* {@inheritDoc}
*/
public void runTask()
{
try
{
updateData();
}
catch (Throwable t)
{
lastException = t;
}
}
/**
* {@inheritDoc}
*/
{
return backendSet;
}
}
}