ServerParameter.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 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/**
* Functions for handling all dhcpconfig options that manage the DHCP server
* parameters.
*/
public class ServerParameter extends DhcpCfgFunction {
/**
* Options that this DhcpCfgFunction will accept.
*/
static final int supportedOptions[] = {
};
/**
* List of suboptions.
*/
private String subOptions;
/**
* Simple constructor
*/
this.subOptions = subOptions;
} // constructor
/**
* Returns the option flag for this function.
* @returns
* The option flag for this function.
*/
public int getFunctionFlag() {
return DhcpCfg.CONFIGURE_SERVER_PARAMETER;
} // getFunctionFlag
/**
* Parse and execute the options for this function.
* @return
* DhcpCfg.SUCCESS for success and DhcpCfg.FAILURE for failure.
*/
public int execute() throws IllegalArgumentException {
} else {
while (getSubOpt.hasMoreSubOptions()) {
} else {
} else {
}
}
}
}
boolean atLeastOneActionFailed;
try {
} catch (BridgeException be) {
getString("server_parameter_failed_read_params_error"));
}
atLeastOneActionFailed = false;
// Initialise the actions.
atLeastOneActionFailed = true;
}
}
if (atLeastOneActionFailed) {
}
atLeastOneActionFailed = false;
// Execute the actions.
atLeastOneActionFailed = true;
}
}
if (atLeastOneActionFailed) {
}
if (dhcpdOptions.isDirty()) {
try {
} catch (BridgeException e) {
"server_parameter_failed_write_params_error"));
}
}
} // execute
/**
* All functions are carried out through a specific action sub-classed
* from this class.
*/
private interface Action {
/**
* Initialise the action.
*
* @param dhcpdOptions
* The server options that an action manipulates.
*
* @return
* DhcpCfg.SUCCESS for success and DhcpCfg.FAILURE for failure.
*/
/**
* Execute the action.
*
* @return
* DhcpCfg.SUCCESS for success and DhcpCfg.FAILURE for failure.
*/
public int execute();
}
/**
* Shared super class for actions.
*/
private abstract class ActionImpl implements Action {
/**
* The server parameter this action works upon. Could be null.
*/
/**
* The value this action works upon. Could be null.
*/
/**
* The qualifier for the server parameter. If the keyword is null
* the qualifier will be null. The general rule is that if keyword is
* not null, qualifier must not be null. If it is then the keyword
* is not a recognised server parameter.
*/
/**
* Server parameters.
*/
protected DhcpdOptions dhcpdOptions;
/**
* Construct an action for the given server parameter keyword and
* value. The constructor will find the appropriate qualifier that
* matches the keyword if the keyword is not null. Note that no
* checking on the validity of the keyword contents is made at this
* point.
*
* @param keyword
* The server parameter this action works upon. Could be null.
* @param value
* The value this action works upon. Could be null.
*/
} // constructor
/**
* Get the keyword.
*
* @return
* The keyword this action operates upon.
*/
public String getKeyword() {
return keyword;
}
/**
* Validate and initialise the action. A sub-classed action is passed
* execution control via the doExecute() callback method.
*
* @return
* DhcpCfg.SUCCESS for success and DhcpCfg.FAILURE for failure.
*/
if (dhcpdOptions == null) {
}
this.dhcpdOptions = dhcpdOptions;
"server_parameter_keyword_bad_keyword_error"),
}
}
return doInit();
} // execute
/**
* Sub-classed action callback method. Once validation has been
* performed initialisation is continued in the action sub-class
* by calling this method.
*
* @return
* DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure.
*/
protected abstract int doInit();
/**
* Validate and execute the action. A sub-classed action is passed
* execution control via the doExecute() callback method.
*
* @return
* DhcpCfg.SUCCESS for success and DhcpCfg.FAILURE for failure.
*/
public final int execute() {
if (dhcpdOptions == null) {
}
return doExecute();
} // execute
/**
* Sub-classed action callback method. Once validation has been
* performed execution is continued in the action sub-class by calling
* this method.
*
* @return
* DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure.
*/
protected abstract int doExecute();
}
/**
* Set a parameter action.
*/
private class ActionSet extends ActionImpl {
/**
* Construct an add action.
*
* @param keyword
* The server parameter this action works upon.
* @param value
* The value this action works upon.
*/
} // constructor
protected int doInit() {
if (qualifier.isReadOnly()) {
"server_parameter_keyword_set_read_only_error"),
}
"server_parameter_keyword_set_bad_value_error"),
}
}
/**
* Set the parameters value.
*
* @return
* DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure.
*/
protected int doExecute() {
} // doExecute
}
/**
* Get a parameter action.
*/
private class ActionGet extends ActionImpl {
/**
* This field controls the displaying of the keyword in addition
* to the keywords value. The default is to not show the keyword.
*/
protected boolean showKeyword = false;
/**
* Construct a get action
*
* @param keyword
* The server parameter this action works upon.
*/
} // constructor
protected int doInit() {
getString("server_parameter_keyword_not_set_error"),
}
}
/**
* Get the parameters value.
*
* @return
* DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure.
*/
protected int doExecute() {
if (showKeyword) {
getString("server_parameter_get_keyword_value"),
} else {
}
} // doExecute
/**
* This method controls the displaying of the keyword in addition
* to the keywords value.
*
* @param showKeyword
* If true the keyword is shown with the value, otherwise only the
* the value is shown.
*/
public void setShowKeyword(boolean showKeyword) {
this.showKeyword = showKeyword;
}
}
/**
* Get all parameters action.
*/
private class ActionGetAll extends ActionImpl {
protected List subActions;
/**
* Construct a get all action.
*/
public ActionGetAll() {
subActions = new ArrayList();
} // constructor
protected int doInit() {
boolean atLeastOneSubActionFailed = false;
"server_parameter_keyword_bad_keyword_error"),
continue;
}
continue;
}
subAction.setShowKeyword(true);
atLeastOneSubActionFailed = true;
}
}
if (atLeastOneSubActionFailed) {
} else {
}
}
/**
* Get all the parameters and their values.
*
* @return
* DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure.
*/
protected int doExecute() {
}
}
} // doExecute
}
/**
* Delete a parameter action.
*/
private class ActionDelete extends ActionImpl {
/**
* Construct a get delete action
*
* @param keyword
* The server parameter this action works upon.
*/
} // constructor
protected int doInit() {
getString("server_parameter_keyword_not_set_error"),
}
if (qualifier.isReadOnly()) {
"server_parameter_keyword_delete_read_only_error"),
}
}
/**
* Delete the parameter and its value.
*
* @return
* DhcpCfg.SUCCESS for success, otherwise DhcpCfg.FAILURE for failure.
*/
protected int doExecute() {
} // doExecute
}
} // ServerParameter