| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.admin.client.cli; |
| | | |
| | |
| | | import org.opends.admin.ads.ADSContextException; |
| | | import org.opends.admin.ads.ADSContext.ServerProperty; |
| | | import org.opends.admin.ads.ADSContextException.ErrorType; |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageBuilder; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.opends.server.tools.dsconfig.ArgumentExceptionFactory; |
| | | import org.opends.server.util.args.Argument; |
| | | import org.opends.server.util.args.ArgumentException; |
| | |
| | | public class DsFrameworkCliServer implements DsFrameworkCliSubCommandGroup |
| | | { |
| | | // Strings used in property help. |
| | | private final static Message DESCRIPTION_OPTIONS_TITLE = |
| | | private final static LocalizableMessage DESCRIPTION_OPTIONS_TITLE = |
| | | INFO_DSCFG_HELP_DESCRIPTION_OPTION.get(); |
| | | |
| | | private final static Message DESCRIPTION_OPTIONS_READ = |
| | | private final static LocalizableMessage DESCRIPTION_OPTIONS_READ = |
| | | INFO_DSCFG_HELP_DESCRIPTION_READ.get(); |
| | | |
| | | private final static Message DESCRIPTION_OPTIONS_WRITE = |
| | | private final static LocalizableMessage DESCRIPTION_OPTIONS_WRITE = |
| | | INFO_DSCFG_HELP_DESCRIPTION_WRITE.get(); |
| | | |
| | | private final static Message DESCRIPTION_OPTIONS_MANDATORY = |
| | | private final static LocalizableMessage DESCRIPTION_OPTIONS_MANDATORY = |
| | | INFO_DSCFG_HELP_DESCRIPTION_MANDATORY.get(); |
| | | |
| | | private final static Message DESCRIPTION_OPTIONS_SINGLE = |
| | | private final static LocalizableMessage DESCRIPTION_OPTIONS_SINGLE = |
| | | INFO_DSCFG_HELP_DESCRIPTION_SINGLE_VALUED.get(); |
| | | |
| | | /** |
| | |
| | | ServerProperty prop = ServerProperty.ID; |
| | | String attName = prop.getAttributeName(); |
| | | StringArgument arg = new StringArgument(attName, null, |
| | | prop.getAttributeName(), false, false, true, Message.raw(""), null, |
| | | prop.getAttributeName(), false, false, true, LocalizableMessage.raw(""), null, |
| | | null, null); |
| | | serverProperties.put(prop, arg); |
| | | } |
| | |
| | | String attName = prop.getAttributeName(); |
| | | readonlyServerProperties.add(prop); |
| | | StringArgument arg = new StringArgument(attName, null, attName, true, |
| | | false, true, Message.raw(""), "localhost", null, null); |
| | | false, true, LocalizableMessage.raw(""), "localhost", null, null); |
| | | serverProperties.put(prop, arg); |
| | | } |
| | | |
| | |
| | | ServerProperty prop = ServerProperty.LDAP_PORT; |
| | | String attName = prop.getAttributeName(); |
| | | IntegerArgument arg = new IntegerArgument(attName, null, attName, true, |
| | | true, true, Message.raw(attName), 389, null, null); |
| | | true, true, LocalizableMessage.raw(attName), 389, null, null); |
| | | serverProperties.put(prop, arg); |
| | | } |
| | | |
| | |
| | | ServerProperty prop = ServerProperty.JMX_PORT; |
| | | String attName = prop.getAttributeName(); |
| | | IntegerArgument arg = new IntegerArgument(attName, null, attName, |
| | | false, true, Message.raw(attName), null); |
| | | false, true, LocalizableMessage.raw(attName), null); |
| | | arg.setMultiValued(true); |
| | | serverProperties.put(prop, arg); |
| | | } |
| | |
| | | ServerProperty prop = ServerProperty.JMXS_PORT; |
| | | String attName = prop.getAttributeName(); |
| | | IntegerArgument arg = new IntegerArgument(attName, null, attName, |
| | | false, true, Message.raw(attName), null); |
| | | false, true, LocalizableMessage.raw(attName), null); |
| | | arg.setMultiValued(true); |
| | | serverProperties.put(prop, arg); |
| | | } |
| | |
| | | ServerProperty prop = ServerProperty.LDAPS_PORT; |
| | | String attName = prop.getAttributeName(); |
| | | IntegerArgument arg = new IntegerArgument(attName, null, attName, |
| | | false, true, Message.raw(attName), null); |
| | | false, true, LocalizableMessage.raw(attName), null); |
| | | arg.setMultiValued(true); |
| | | serverProperties.put(prop, arg); |
| | | } |
| | |
| | | ServerProperty prop = ServerProperty.CERTIFICATE; |
| | | String attName = prop.getAttributeName(); |
| | | StringArgument arg = new StringArgument(attName, null, attName, false, |
| | | false, true, Message.raw(attName), null, null, null); |
| | | false, true, LocalizableMessage.raw(attName), null, null, null); |
| | | serverProperties.put(prop, arg); |
| | | } |
| | | |
| | |
| | | ServerProperty prop = ServerProperty.INSTANCE_PATH; |
| | | String attName = prop.getAttributeName(); |
| | | StringArgument arg = new StringArgument(attName, null, attName, false, |
| | | false, true, Message.raw(attName), null, null, null); |
| | | false, true, LocalizableMessage.raw(attName), null, null, null); |
| | | serverProperties.put(prop, arg); |
| | | } |
| | | |
| | |
| | | ServerProperty prop = ServerProperty.DESCRIPTION; |
| | | String attName = prop.getAttributeName(); |
| | | StringArgument arg = new StringArgument(attName, null, attName, false, |
| | | false, true, Message.raw(attName), null, null, null); |
| | | false, true, LocalizableMessage.raw(attName), null, null, null); |
| | | serverProperties.put(prop, arg); |
| | | } |
| | | |
| | |
| | | ServerProperty prop = ServerProperty.HOST_OS; |
| | | String attName = prop.getAttributeName(); |
| | | StringArgument arg = new StringArgument(attName, null, attName, false, |
| | | false, true, Message.raw(attName), null, null, null); |
| | | false, true, LocalizableMessage.raw(attName), null, null, null); |
| | | serverProperties.put(prop, arg); |
| | | } |
| | | |
| | |
| | | ServerProperty prop = ServerProperty.LOCATION; |
| | | String attName = prop.getAttributeName(); |
| | | StringArgument arg = new StringArgument(attName, null, attName, false, |
| | | false, true, Message.raw(attName), null, null, null); |
| | | false, true, LocalizableMessage.raw(attName), null, null, null); |
| | | serverProperties.put(prop, arg); |
| | | } |
| | | |
| | |
| | | ServerProperty prop = ServerProperty.GROUPS; |
| | | String attName = prop.getAttributeName(); |
| | | StringArgument arg = new StringArgument(attName, null, attName, false, |
| | | true, true, Message.raw(attName), null, null, null); |
| | | true, true, LocalizableMessage.raw(attName), null, null, null); |
| | | arg.setHidden(true); |
| | | serverProperties.put(prop, arg); |
| | | } |
| | |
| | | ServerProperty prop = ServerProperty.INSTANCE_KEY_ID; |
| | | String attName = prop.getAttributeName(); |
| | | StringArgument arg = new StringArgument(attName, null, prop |
| | | .getAttributeName(), false, false, true, Message.raw(""), null, null, |
| | | .getAttributeName(), false, false, true, LocalizableMessage.raw(""), null, null, |
| | | null); |
| | | serverProperties.put(prop, arg); |
| | | } |
| | |
| | | ServerProperty prop = ServerProperty.INSTANCE_PUBLIC_KEY_CERTIFICATE; |
| | | String attName = prop.getAttributeName(); |
| | | StringArgument arg = new StringArgument(attName, null, prop |
| | | .getAttributeName(), false, false, true, Message.raw(""), null, null, |
| | | .getAttributeName(), false, false, true, LocalizableMessage.raw(""), null, null, |
| | | null); |
| | | serverProperties.put(prop, arg); |
| | | } |
| | |
| | | .getServerPropFromName(propertyName); |
| | | if (serverProperty == null) |
| | | { |
| | | Message message = ERR_CLI_ERROR_PROPERTY_UNRECOGNIZED.get(propertyName); |
| | | LocalizableMessage message = ERR_CLI_ERROR_PROPERTY_UNRECOGNIZED.get(propertyName); |
| | | throw new ArgumentException(message); |
| | | } |
| | | |
| | | // Check that propName is not hidden. |
| | | if (serverProperties.get(serverProperty).isHidden()) |
| | | { |
| | | Message message = ERR_CLI_ERROR_PROPERTY_UNRECOGNIZED.get(propertyName); |
| | | LocalizableMessage message = ERR_CLI_ERROR_PROPERTY_UNRECOGNIZED.get(propertyName); |
| | | throw new ArgumentException(message); |
| | | } |
| | | |
| | | // Check the property Syntax. |
| | | MessageBuilder invalidReason = new MessageBuilder(); |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | Argument arg = serverProperties.get(serverProperty) ; |
| | | if ( ! arg.valueIsAcceptable(value, invalidReason)) |
| | | { |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_CLI_ERROR_INVALID_PROPERTY_VALUE.get(propertyName, value); |
| | | throw new ArgumentException(message); |
| | | } |
| | |
| | | // but not yet is the map. Check if we have a default value. |
| | | if (arg.getDefaultValue() == null) |
| | | { |
| | | Message message = |
| | | LocalizableMessage message = |
| | | ERR_CLI_ERROR_MISSING_PROPERTY.get(s.getAttributeName()); |
| | | throw new ArgumentException(message); |
| | | } |