ConvertWizard.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 usr/src/OPENSOLARIS.LICENSE
* 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 usr/src/OPENSOLARIS.LICENSE.
* 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
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright 2001-2002 by Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/**
* This wizard converts the DHCP service data store.
*/
public class ConvertWizard extends DSWizard {
/**
* Handle to the service server.
*/
private DhcpServiceMgr svcServer;
/**
* Handle to the dhcptab table server.
*/
private DhcptabMgr dhcptabServer;
/**
* Handle to the network tables server.
*/
private DhcpNetMgr netServer;
/**
* The DHCP defaults.
*/
private DhcpdOptions dhcpdOptions;
/**
* The old data store config.
*/
private DSConf defaultDsconf;
/**
* The save tables wizard step
*/
private SaveTablesStep saveTablesStep;
/**
* List of networks to be converted.
*/
/**
* This class is the wizard step that presents the user with
* the option to save the tables after conversion.
*/
protected class SaveTablesStep implements WizardStep {
/**
* The component provided to the wizard.
*/
/**
* The checkbox that determines whether the DHCP tables should be
* saved after conversion.
*/
private JCheckBox saveTables;
/**
* Basic constructor.
*/
public SaveTablesStep() {
// Explanatory text at the top
//
// Add the checkbox.
//
saveTables = new JCheckBox(
} // constructor
public String getDescription() {
} // getDescription
public Component getComponent() {
return stepBox;
} // getComponent
setForwardEnabled(true);
} // setActive
public boolean setInactive(int direction) {
return true;
} // setInactive
public boolean isSaveTablesSelected() {
return saveTables.isSelected();
}
} // SaveTablesStep
/**
* This class provides the review step for the conversion wizard.
*/
class ReviewStep implements WizardStep {
/**
* The label for the old data store.
*/
private JLabel oldStoreLabel;
/**
* The label for the new data store.
*/
private JLabel newStoreLabel;
/**
* The label for saving tables.
*/
/**
* The component to provide to the conversion wizard.
*/
/**
* The panel used to create the review information.
*/
/**
* The constructor for the step.
*/
public ReviewStep() {
3, 45));
} // constructor
/**
* Adds a label to the review panel.
* @param s the label string.
*/
return addLbl;
} // addLabel
/**
* Adds a field to the review panel.
* @param s the field value.
* @return the label of which the field consists.
*/
return l;
} // addField
public String getDescription() {
} // getDescription
public Component getComponent() {
return stepBox;
} // getComponent
setFinishEnabled(true);
/**
* If no bean exists for the default data store, then use the
* name of the data store as the description.
*/
if (defaultDsconf != null) {
} else {
}
if (saveTablesStep.isSaveTablesSelected()) {
} else {
}
} // setActive
public boolean setInactive(int direction) {
return true;
} // setInactive
} // ReviewStep
/**
* Constructor for the ConvertWizard.
* @param owner owner of the wizard.
* @param title title of the wizard.
*/
// Go ahead and grab handles to the different servers and
// read the server defaults.
//
try {
} catch (Throwable e) {
e.printStackTrace();
return;
}
// Create the DSConfList and determine the default. Note that
// if the current data store has no management bean, then the
// defaultDsconf is null.
//
dsconfList = new DSConfList();
// If no bean exists for the default data store, then use the
// name of the data store as the description.
//
if (defaultDsconf != null) {
} else {
}
// Build the wizard explanation message.
//
// Add the steps for the wizard.
//
addStep(new DatastoreModuleStep());
addStep(new ReviewStep());
}
public void doFinish() {
/*
* To convert the data store, we have to do the following items:
* 2. Convert the dhcptab
* 3. Convert the network tables
* 4. Modify the DHCP defaults
* 5. Delete old tables if necessary
*/
getDsconf().setLocation();
return;
}
// Create the new location if it does not exist.
//
try {
} catch (ExistsException e) {
// this is o.k.
} catch (Throwable e) {
msg,
return;
}
// Go get a list of the network tables to convert.
//
try {
}
} catch (Throwable e) {
msg,
reallyFinish();
return;
}
// Add 1 to tables count for dhcptab
// One update per table, plus one per table if deleting
int updates =
// Add: one for shutdown, one for updating dhcpsvc.conf
updates += 2;
// If daemon will be restarted, then add 1 for start
if (dhcpdOptions.isDaemonEnabled()) {
++updates;
}
// Called when doFinish() is really finished
// (i.e., the thread completes).
//
public void run() {
reallyFinish();
}
};
// Here's the thread which does the conversion.
//
public void run() {
boolean saveTables =
// This is final so it can be used in the
// errorDisplay Runnable.
//
String.class);
// Shutdown the server.
//
int counter = 0;
try {
"cvt_wiz_server_shutdown");
} catch (Throwable e) {
message =
saveTables = true;
} finally {
try {
} catch (InterruptedException e) {
return;
}
}
// Convert the dhcptab.
//
try {
"cvt_wiz_progress_dhcptab_cvt");
} catch (Throwable e) {
"cvt_wiz_progress_dhcptab_cvt_err");
"cvt_wiz_dhcptab"), e.getMessage());
saveTables = true;
} finally {
try {
} catch (InterruptedException e) {
return;
}
}
// Convert the network tables.
//
"cvt_wiz_progress_network_cvt"));
"cvt_wiz_progress_network_cvt_err"));
try {
} catch (Throwable e) {
saveTables = true;
} finally {
try {
} catch (InterruptedException e) {
return;
}
}
}
// Update the DHCP defaults file with the new values.
//
try {
"cvt_wiz_progress_defaults");
} catch (Throwable e) {
"cvt_wiz_progress_defaults_err");
"cvt_wiz_defaults"), e.getMessage());
saveTables = true;
} finally {
try {
} catch (InterruptedException e) {
return;
}
}
if (!saveTables) {
// Delete the network tables
//
"cvt_wiz_progress_network_del"));
"cvt_wiz_progress_network_del_err"));
try {
} catch (Throwable e) {
} finally {
try {
} catch (InterruptedException e) {
return;
}
}
}
// Delete the dhcptab
//
try {
"cvt_wiz_progress_dhcptab_del");
} catch (Throwable e) {
"cvt_wiz_progress_dhcptab_del_err");
"cvt_wiz_dhcptab"), e.getMessage());
} finally {
try {
} catch (InterruptedException e) {
return;
}
}
} else if (!saveTablesStep.isSaveTablesSelected()) {
try {
} catch (InterruptedException e) {
return;
}
}
// Start the server.
//
if (dhcpdOptions.isDaemonEnabled()) {
try {
"cvt_wiz_server_started");
} catch (Throwable e) {
message =
} finally {
try {
} catch (InterruptedException e) {
return;
}
}
}
// If any errors occurred, display them all at once.
//
if (!failedTable.isEmpty()) {
public void run() {
objs[0] =
new JScrollPane(failedTable);
// Resize the table to something kind of small
//
Dimension d =
d.height = 80;
objs,
}
};
try {
} catch (Throwable e) {
e.printStackTrace();
}
}
}
};
}
public void doHelp() {
}
/**
* Called by the worker thread upon completion to exec the Wizard
* doFinish().
*/
protected void reallyFinish() {
super.doFinish();
} // reallyFinish
} // ConvertWizard