| | |
| | | /** Description for this group of arguments. */ |
| | | private LocalizableMessage description; |
| | | /** List of arguments belonging to this group. */ |
| | | private List<Argument> args; |
| | | private final List<Argument> args = new LinkedList<>(); |
| | | /** Governs groups position within usage statement. */ |
| | | private final Integer priority; |
| | | |
| | |
| | | public ArgumentGroup(final LocalizableMessage description, final int priority) { |
| | | this.description = description; |
| | | this.priority = priority; |
| | | this.args = new LinkedList<Argument>(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | private Argument versionArgument; |
| | | |
| | | /** The set of unnamed trailing arguments that were provided for this parser. */ |
| | | private final ArrayList<String> trailingArguments = new ArrayList<String>(); |
| | | private final ArrayList<String> trailingArguments = new ArrayList<>(); |
| | | |
| | | /** |
| | | * Indicates whether this parser will allow additional unnamed arguments at |
| | |
| | | private VersionHandler versionHandler; |
| | | |
| | | /** The set of arguments defined for this parser, referenced by short ID. */ |
| | | private final HashMap<Character, Argument> shortIDMap = new HashMap<Character, Argument>(); |
| | | private final HashMap<Character, Argument> shortIDMap = new HashMap<>(); |
| | | /** The set of arguments defined for this parser, referenced by long ID. */ |
| | | private final HashMap<String, Argument> longIDMap = new HashMap<String, Argument>(); |
| | | private final HashMap<String, Argument> longIDMap = new HashMap<>(); |
| | | /** The set of arguments defined for this parser, referenced by argument name. */ |
| | | private final HashMap<String, Argument> argumentMap = new HashMap<String, Argument>(); |
| | | private final HashMap<String, Argument> argumentMap = new HashMap<>(); |
| | | /** The total set of arguments defined for this parser. */ |
| | | private final LinkedList<Argument> argumentList = new LinkedList<Argument>(); |
| | | private final LinkedList<Argument> argumentList = new LinkedList<>(); |
| | | |
| | | /** The maximum number of unnamed trailing arguments that may be provided. */ |
| | | private final int maxTrailingArguments; |
| | |
| | | private String[] rawArguments; |
| | | |
| | | /** Set of argument groups. */ |
| | | protected final Set<ArgumentGroup> argumentGroups = new TreeSet<ArgumentGroup>(); |
| | | protected final Set<ArgumentGroup> argumentGroups = new TreeSet<>(); |
| | | |
| | | /** |
| | | * Group for arguments that have not been explicitly grouped. These will |
| | |
| | | + PROPERTY_SCRIPT_NAME + "'."); |
| | | } |
| | | |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | final Map<String, Object> map = new HashMap<>(); |
| | | map.put("locale", Locale.getDefault().getLanguage()); |
| | | map.put("year", new SimpleDateFormat("yyyy").format(new Date())); |
| | | map.put("name", scriptName); |
| | |
| | | * @return The RefSect1 element as a String. |
| | | */ |
| | | protected String getOptionsRefSect1(String scriptName) { |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("name", scriptName); |
| | | map.put("title", REF_TITLE_OPTIONS.get()); |
| | | map.put("intro", REF_INTRO_OPTIONS.get(scriptName)); |
| | | |
| | | Argument helpArgument = null; |
| | | final boolean printHeaders = printUsageGroupHeaders(); |
| | | List<Map<String, Object>> groups = new LinkedList<Map<String, Object>>(); |
| | | List<Map<String, Object>> groups = new LinkedList<>(); |
| | | for (final ArgumentGroup argGroup : argumentGroups) { |
| | | Map<String, Object> group = new HashMap<String, Object>(); |
| | | Map<String, Object> group = new HashMap<>(); |
| | | |
| | | // Add the group's description if any |
| | | if (argGroup.containsArguments() && printHeaders) { |
| | |
| | | } |
| | | } |
| | | |
| | | List<Map<String, Object>> options = new LinkedList<Map<String, Object>>(); |
| | | List<Map<String, Object>> options = new LinkedList<>(); |
| | | final SortedSet<Argument> args = sortArguments(argGroup.getArguments()); |
| | | for (final Argument a : args) { |
| | | if (a.isHidden()) { |
| | |
| | | } |
| | | } |
| | | if (helpArgument != null) { |
| | | Map<String, Object> helpGroup = new HashMap<String, Object>(); |
| | | Map<String, Object> helpGroup = new HashMap<>(); |
| | | helpGroup.put("description", null); |
| | | List<Map<String, Object>> options = new LinkedList<Map<String, Object>>(); |
| | | List<Map<String, Object>> options = new LinkedList<>(); |
| | | options.add(getArgumentMap(helpArgument)); |
| | | helpGroup.put("options", options); |
| | | groups.add(helpGroup); |
| | |
| | | * @return A map containing information about an argument option |
| | | */ |
| | | private Map<String, Object> getArgumentMap(final Argument a) { |
| | | Map<String, Object> option = new HashMap<String, Object>(); |
| | | Map<String, Object> option = new HashMap<>(); |
| | | option.put("synopsis", getOptionSynopsis(a)); |
| | | option.put("description", eolToNewPara(a.getDescription())); |
| | | String dv = a.getDefaultValue(); |
| | |
| | | * @return The set of arguments in sorted order. |
| | | */ |
| | | SortedSet<Argument> sortArguments(final List<Argument> arguments) { |
| | | final SortedSet<Argument> result = new TreeSet<Argument>(new Comparator<Argument>() { |
| | | final SortedSet<Argument> result = new TreeSet<>(new Comparator<Argument>() { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Promise<Connection, LdapException> getConnectionAsync() { |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<Connection>(); |
| | | final AtomicReference<Connection> connectionHolder = new AtomicReference<>(); |
| | | return parentFactory.getConnectionAsync() |
| | | .thenAsync( |
| | | new AsyncFunction<Connection, BindResult, LdapException>() { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package com.forgerock.opendj.cli; |
| | | |
| | |
| | | public class CommandBuilder { |
| | | private String commandName; |
| | | private String subcommandName; |
| | | private ArrayList<Argument> args; |
| | | private HashSet<Argument> obfuscatedArgs; |
| | | private final ArrayList<Argument> args = new ArrayList<>(); |
| | | private final HashSet<Argument> obfuscatedArgs = new HashSet<>(); |
| | | |
| | | /** |
| | | * The separator used to link the lines of the resulting command-lines. |
| | |
| | | public CommandBuilder(String commandName, String subcommandName) { |
| | | this.commandName = commandName; |
| | | this.subcommandName = subcommandName; |
| | | args = new ArrayList<Argument>(); |
| | | obfuscatedArgs = new HashSet<Argument>(); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** Chars that require special treatment when passing them to command-line. */ |
| | | private static final Set<Character> CHARSTOESCAPE = new TreeSet<Character>(Arrays.asList( |
| | | private static final Set<Character> CHARSTOESCAPE = new TreeSet<>(Arrays.asList( |
| | | ' ', '\t', '\n', '|', ';', '<', '>', '(', ')', '$', '`', '\\', '"', '\'')); |
| | | |
| | | /** |
| | |
| | | * If there is a problem with any of the parameters used to create this argument. |
| | | */ |
| | | public static MultiChoiceArgument<SearchScope> getSearchScope() throws ArgumentException { |
| | | final MultiChoiceArgument<SearchScope> searchScope = new MultiChoiceArgument<SearchScope>( |
| | | final MultiChoiceArgument<SearchScope> searchScope = new MultiChoiceArgument<>( |
| | | OPTION_LONG_SEARCHSCOPE, OPTION_SHORT_SEARCHSCOPE, OPTION_LONG_SEARCHSCOPE, false, true, |
| | | INFO_SEARCH_SCOPE_PLACEHOLDER.get(), SearchScope.values(), false, |
| | | INFO_SEARCH_DESCRIPTION_SEARCH_SCOPE.get()); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS |
| | | * Portions copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package com.forgerock.opendj.cli; |
| | | |
| | |
| | | * multiple lines, then only the first line will be read. |
| | | */ |
| | | public final class FileBasedArgument extends Argument { |
| | | /** |
| | | * The mapping between filenames specified and the first lines read |
| | | * from those files. |
| | | */ |
| | | private final LinkedHashMap<String, String> namesToValues; |
| | | /** The mapping between filenames specified and the first lines read from those files. */ |
| | | private final LinkedHashMap<String, String> namesToValues = new LinkedHashMap<>(); |
| | | |
| | | /** |
| | | * Creates a new file-based argument with the provided information. |
| | |
| | | throws ArgumentException { |
| | | super(name, shortIdentifier, longIdentifier, isRequired, isMultiValued, true, |
| | | valuePlaceholder, defaultValue, propertyName, description); |
| | | |
| | | namesToValues = new LinkedHashMap<String, String>(); |
| | | } |
| | | |
| | | /** |
| | |
| | | throws ArgumentException { |
| | | super(name, shortIdentifier, longIdentifier, isRequired, false, true, valuePlaceholder, |
| | | null, null, description); |
| | | |
| | | namesToValues = new LinkedHashMap<String, String>(); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | public MenuResult<T> invoke(ConsoleApplication app) throws ClientException { |
| | | List<T> values = new ArrayList<T>(); |
| | | List<T> values = new ArrayList<>(); |
| | | for (MenuCallback<T> callback : callbacks) { |
| | | MenuResult<T> result = callback.invoke(app); |
| | | if (!result.isSuccess()) { |
| | |
| | | } |
| | | } else if (allowMultiSelect) { |
| | | // Use a composite call-back to collect all the results. |
| | | List<MenuCallback<T>> cl = new ArrayList<MenuCallback<T>>(); |
| | | List<MenuCallback<T>> cl = new ArrayList<>(); |
| | | for (String value : ninput.split(",")) { |
| | | // Make sure that there are no duplicates. |
| | | String nvalue = value.trim(); |
| | | Set<String> choices = new HashSet<String>(); |
| | | Set<String> choices = new HashSet<>(); |
| | | |
| | | if (choices.contains(nvalue)) { |
| | | app.println(); |
| | |
| | | } |
| | | } |
| | | |
| | | return new CompositeCallback<T>(cl); |
| | | return new CompositeCallback<>(cl); |
| | | } else if (!callbacks.containsKey(ninput)) { |
| | | app.println(); |
| | | app.println(ERR_MENU_BAD_CHOICE_SINGLE.get()); |
| | |
| | | private final ConsoleApplication app; |
| | | |
| | | /** The char option call-backs. */ |
| | | private final List<MenuCallback<T>> charCallbacks = new ArrayList<MenuCallback<T>>(); |
| | | private final List<MenuCallback<T>> charCallbacks = new ArrayList<>(); |
| | | |
| | | /** The char option keys (must be single-character messages). */ |
| | | private final List<LocalizableMessage> charKeys = new ArrayList<LocalizableMessage>(); |
| | | private final List<LocalizableMessage> charKeys = new ArrayList<>(); |
| | | /** The synopsis of char options. */ |
| | | private final List<LocalizableMessage> charSynopsis = new ArrayList<LocalizableMessage>(); |
| | | private final List<LocalizableMessage> charSynopsis = new ArrayList<>(); |
| | | |
| | | /** Optional column headings. */ |
| | | private final List<LocalizableMessage> columnHeadings = new ArrayList<LocalizableMessage>(); |
| | | private final List<LocalizableMessage> columnHeadings = new ArrayList<>(); |
| | | /** Optional column widths. */ |
| | | private final List<Integer> columnWidths = new ArrayList<Integer>(); |
| | | private final List<Integer> columnWidths = new ArrayList<>(); |
| | | |
| | | /** The call-back for the optional default action. */ |
| | | private MenuCallback<T> defaultCallback; |
| | |
| | | private LocalizableMessage defaultDescription; |
| | | |
| | | /** The numeric option call-backs. */ |
| | | private final List<MenuCallback<T>> numericCallbacks = new ArrayList<MenuCallback<T>>(); |
| | | private final List<MenuCallback<T>> numericCallbacks = new ArrayList<>(); |
| | | /** The numeric option fields. */ |
| | | private final List<List<LocalizableMessage>> numericFields = new ArrayList<List<LocalizableMessage>>(); |
| | | private final List<List<LocalizableMessage>> numericFields = new ArrayList<>(); |
| | | |
| | | /** The menu title. */ |
| | | private LocalizableMessage title; |
| | |
| | | */ |
| | | public int addNumberedOption(LocalizableMessage description, MenuCallback<T> callback, |
| | | LocalizableMessage... extraFields) { |
| | | List<LocalizableMessage> fields = new ArrayList<LocalizableMessage>(); |
| | | List<LocalizableMessage> fields = new ArrayList<>(); |
| | | fields.add(description); |
| | | if (extraFields != null) { |
| | | fields.addAll(Arrays.asList(extraFields)); |
| | |
| | | */ |
| | | public Menu<T> toMenu() { |
| | | TableBuilder nbuilder = new TableBuilder(); |
| | | Map<String, MenuCallback<T>> callbacks = new HashMap<String, MenuCallback<T>>(); |
| | | Map<String, MenuCallback<T>> callbacks = new HashMap<>(); |
| | | |
| | | // Determine whether multiple columns should be used for numeric options |
| | | boolean useMultipleColumns = threshold >= 0 && numericCallbacks.size() >= threshold; |
| | |
| | | } |
| | | } |
| | | |
| | | return new MenuImpl<T>(app, title, prompt, nbuilder, cbuilder, printer, callbacks, allowMultiSelect, |
| | | return new MenuImpl<>(app, title, prompt, nbuilder, cbuilder, printer, callbacks, allowMultiSelect, |
| | | defaultCallback, defaultDescription, nMaxTries); |
| | | } |
| | | |
| | |
| | | */ |
| | | public final class MenuResult<T> { |
| | | |
| | | /** |
| | | * The type of result returned from the menu. |
| | | */ |
| | | /** The type of result returned from the menu. */ |
| | | private static enum Type { |
| | | /** |
| | | * The user selected an option which did not return a result, |
| | |
| | | * @return Returns a new menu result indicating that the menu should be displayed again. |
| | | */ |
| | | public static <T> MenuResult<T> again() { |
| | | return new MenuResult<T>(Type.AGAIN, Collections.<T> emptyList()); |
| | | return new MenuResult<>(Type.AGAIN, Collections.<T> emptyList()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * back to the previous main menu if applicable. |
| | | */ |
| | | public static <T> MenuResult<T> cancel() { |
| | | return new MenuResult<T>(Type.CANCEL, Collections.<T> emptyList()); |
| | | return new MenuResult<>(Type.CANCEL, Collections.<T> emptyList()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * outstanding tasks. |
| | | */ |
| | | public static <T> MenuResult<T> quit() { |
| | | return new MenuResult<T>(Type.QUIT, Collections.<T> emptyList()); |
| | | return new MenuResult<>(Type.QUIT, Collections.<T> emptyList()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * retrieved using {@link #getValue()} or {@link #getValues()}. |
| | | */ |
| | | public static <T> MenuResult<T> success(Collection<T> values) { |
| | | return new MenuResult<T>(Type.SUCCESS, new ArrayList<T>(values)); |
| | | return new MenuResult<>(Type.SUCCESS, new ArrayList<>(values)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @see #isSuccess() |
| | | */ |
| | | public Collection<T> getValues() { |
| | | return new ArrayList<T>(values); |
| | | return new ArrayList<>(values); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2014 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package com.forgerock.opendj.cli; |
| | | |
| | |
| | | private int titleAlign = CENTER; |
| | | |
| | | private String border; |
| | | private List<String[]> titleTable; |
| | | private List<int[]> titleSpanTable; |
| | | private final List<String[]> titleTable = new Vector<>(); |
| | | private final List<int[]> titleSpanTable = new Vector<>(); |
| | | private final int[] curLength; |
| | | |
| | | private final ConsoleApplication app; |
| | |
| | | */ |
| | | public MultiColumnPrinter(final int numCol, final int gap, final String border, final int align, |
| | | final ConsoleApplication app) { |
| | | |
| | | titleTable = new Vector<String[]>(); |
| | | titleSpanTable = new Vector<int[]>(); |
| | | curLength = new int[numCol]; |
| | | |
| | | this.numCol = numCol; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS |
| | | * Portions copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package com.forgerock.opendj.cli; |
| | | |
| | |
| | | app.println(INFO_LDAP_CONN_PROMPT_SECURITY_TRUST_OPTION.get()); |
| | | app.println(); |
| | | |
| | | final Map<String, TrustOption> menuOptions = new HashMap<String, TrustOption>(); |
| | | final Map<String, TrustOption> menuOptions = new HashMap<>(); |
| | | for (final TrustOption t : TrustOption.values()) { |
| | | menuOptions.put(t.getChoice().toString(), t); |
| | | |
| | |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | package com.forgerock.opendj.cli; |
| | | |
| | |
| | | CLIENT_SIDE_CONNECT_ERROR(91); |
| | | |
| | | private int returnCode; |
| | | private static final Map<Integer, String> RETURNCODE = new HashMap<Integer, String>(); |
| | | private static final Map<Integer, String> RETURNCODE = new HashMap<>(); |
| | | static { |
| | | for (final ReturnCode rc : ReturnCode.values()) { |
| | | RETURNCODE.put(rc.get(), rc.name()); |
| | |
| | | private boolean isHidden; |
| | | |
| | | /** The mapping between the short argument IDs and the arguments for this subcommand. */ |
| | | private HashMap<Character, Argument> shortIDMap; |
| | | private final HashMap<Character, Argument> shortIDMap = new HashMap<>(); |
| | | /** The mapping between the long argument IDs and the arguments for this subcommand. */ |
| | | private HashMap<String, Argument> longIDMap; |
| | | private final HashMap<String, Argument> longIDMap = new HashMap<>(); |
| | | /** The list of arguments associated with this subcommand. */ |
| | | private LinkedList<Argument> arguments; |
| | | private final LinkedList<Argument> arguments = new LinkedList<>(); |
| | | |
| | | /** The description for this subcommand. */ |
| | | private LocalizableMessage description; |
| | |
| | | } |
| | | |
| | | parser.addSubCommand(this); |
| | | shortIDMap = new HashMap<Character, Argument>(); |
| | | longIDMap = new HashMap<String, Argument>(); |
| | | arguments = new LinkedList<Argument>(); |
| | | } |
| | | |
| | | /** |
| | |
| | | private static final String INDENT = " "; |
| | | |
| | | /** The arguments that will be used to trigger the display of usage information for groups of sub-commands. */ |
| | | private final Map<Argument, Collection<SubCommand>> usageGroupArguments = |
| | | new HashMap<Argument, Collection<SubCommand>>(); |
| | | private final Map<Argument, Collection<SubCommand>> usageGroupArguments = new HashMap<>(); |
| | | |
| | | /** The set of global arguments defined for this parser, referenced by short ID. */ |
| | | private final Map<Character, Argument> globalShortIDMap = new HashMap<Character, Argument>(); |
| | | private final Map<Character, Argument> globalShortIDMap = new HashMap<>(); |
| | | /** The set of global arguments defined for this parser, referenced by long ID. */ |
| | | private final Map<String, Argument> globalLongIDMap = new HashMap<String, Argument>(); |
| | | private final Map<String, Argument> globalLongIDMap = new HashMap<>(); |
| | | /** The set of global arguments defined for this parser, referenced by argument name. */ |
| | | private final Map<String, Argument> globalArgumentMap = new HashMap<String, Argument>(); |
| | | private final Map<String, Argument> globalArgumentMap = new HashMap<>(); |
| | | /** The total set of global arguments defined for this parser. */ |
| | | private final List<Argument> globalArgumentList = new LinkedList<Argument>(); |
| | | private final List<Argument> globalArgumentList = new LinkedList<>(); |
| | | /** The set of subcommands defined for this parser, referenced by subcommand name. */ |
| | | private final SortedMap<String, SubCommand> subCommands = new TreeMap<String, SubCommand>(); |
| | | private final SortedMap<String, SubCommand> subCommands = new TreeMap<>(); |
| | | |
| | | /**The subcommand requested by the user as part of the command-line arguments. */ |
| | | private SubCommand subCommand; |
| | |
| | | } |
| | | |
| | | // Model for a FreeMarker template. |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("locale", Locale.getDefault().getLanguage()); |
| | | map.put("year", new SimpleDateFormat("yyyy").format(new Date())); |
| | | map.put("name", scriptName); |
| | |
| | | return ""; |
| | | } |
| | | |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("name", scriptName); |
| | | map.put("info", getDocSubcommandsDescriptionSupplement()); |
| | | if (scriptName.equals("dsconfig")) { |
| | | // Break dsconfig into multiple pages, so use only the list here. |
| | | map.put("isItemizedList", true); |
| | | } |
| | | List<String> scUsageList = new ArrayList<String>(); |
| | | List<String> scUsageList = new ArrayList<>(); |
| | | for (SubCommand subCommand : subCommands) { |
| | | if (scriptName.equals("dsconfig")) { |
| | | scUsageList.add(getSubCommandListItem(scriptName, subCommand)); |
| | |
| | | * @return A DocBook XML ListItem element linking to the subcommand page. |
| | | */ |
| | | private String getSubCommandListItem(String scriptName, SubCommand subCommand) { |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", scriptName + "-" + subCommand.getName()); |
| | | map.put("name", scriptName + " " + subCommand.getName()); |
| | | map.put("description", eolToNewPara(subCommand.getDescription())); |
| | |
| | | */ |
| | | private String toRefSect2(String scriptName, SubCommand subCommand) { |
| | | // Model for a FreeMarker template. |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", scriptName + "-" + subCommand.getName()); |
| | | final String name = scriptName + " " + subCommand.getName(); |
| | | map.put("name", name); |
| | |
| | | */ |
| | | private void setSubCommandOptionsInfo(Map<String, Object> map, SubCommand subCommand) { |
| | | if (!subCommand.getArguments().isEmpty()) { |
| | | List<Map<String, Object>> options = new LinkedList<Map<String, Object>>(); |
| | | List<Map<String, Object>> options = new LinkedList<>(); |
| | | String nameOption = null; |
| | | for (Argument a : subCommand.getArguments()) { |
| | | // Return a generic FQDN for localhost as the default hostname |
| | |
| | | a.setDefaultValue("localhost.localdomain"); |
| | | } |
| | | |
| | | Map<String, Object> option = new HashMap<String, Object>(); |
| | | Map<String, Object> option = new HashMap<>(); |
| | | String optionSynopsis = getOptionSynopsis(a); |
| | | option.put("synopsis", optionSynopsis); |
| | | option.put("description", eolToNewPara(a.getDescription())); |
| | | Map<String, Object> info = new HashMap<String, Object>(); |
| | | Map<String, Object> info = new HashMap<>(); |
| | | if (subCommandUsageHandler != null) { |
| | | if (!doesHandleProperties(a)) { |
| | | nameOption = "<option>" + optionSynopsis + "</option>"; |
| | |
| | | */ |
| | | private void appendSubCommandPages(StringBuilder builder, String scriptName, Collection<SubCommand> subCommands) { |
| | | for (SubCommand subCommand : subCommands) { |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("marker", "@@@" + scriptName + "-" + subCommand.getName() + "@@@"); |
| | | map.put("locale", Locale.getDefault().getLanguage()); |
| | | map.put("year", new SimpleDateFormat("yyyy").format(new Date())); |
| | |
| | | private void appendSubCommandReference(StringBuilder builder, |
| | | String scriptName, |
| | | Collection<SubCommand> subCommands) { |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("marker", "@@@" + scriptName + "-subcommands-ref" + "@@@"); |
| | | map.put("name", scriptName); |
| | | map.put("locale", Locale.getDefault().getLanguage()); |
| | | map.put("title", REF_PART_TITLE_SUBCOMMANDS.get(scriptName)); |
| | | map.put("partintro", REF_PART_INTRO_SUBCOMMANDS.get(scriptName)); |
| | | List<Map<String, Object>> commands = new LinkedList<Map<String, Object>>(); |
| | | List<Map<String, Object>> commands = new LinkedList<>(); |
| | | for (SubCommand subCommand : subCommands) { |
| | | Map<String, Object> scMap = new HashMap<String, Object>(); |
| | | Map<String, Object> scMap = new HashMap<>(); |
| | | scMap.put("id", scriptName + "-" + subCommand.getName()); |
| | | commands.add(scMap); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package com.forgerock.opendj.cli; |
| | | |
| | |
| | | private int column; |
| | | |
| | | /** The current with of each column. */ |
| | | private List<Integer> columnWidths = new ArrayList<Integer>(); |
| | | private List<Integer> columnWidths = new ArrayList<>(); |
| | | |
| | | /** The list of column headings. */ |
| | | private List<LocalizableMessage> header = new ArrayList<LocalizableMessage>(); |
| | | private List<LocalizableMessage> header = new ArrayList<>(); |
| | | |
| | | /** The current number of rows in the table. */ |
| | | private int height; |
| | | |
| | | /** The list of table rows. */ |
| | | private List<List<String>> rows = new ArrayList<List<String>>(); |
| | | private List<List<String>> rows = new ArrayList<>(); |
| | | |
| | | /** The linked list of sort keys comparators. */ |
| | | private List<Comparator<String>> sortComparators = new ArrayList<Comparator<String>>(); |
| | | private List<Comparator<String>> sortComparators = new ArrayList<>(); |
| | | |
| | | /** The linked list of sort keys. */ |
| | | private List<Integer> sortKeys = new ArrayList<Integer>(); |
| | | private List<Integer> sortKeys = new ArrayList<>(); |
| | | |
| | | /** The current number of columns in the table. */ |
| | | private int width; |
| | |
| | | TableSerializer serializer = printer.getSerializer(); |
| | | |
| | | // First sort the table. |
| | | List<List<String>> sortedRows = new ArrayList<List<String>>(rows); |
| | | List<List<String>> sortedRows = new ArrayList<>(rows); |
| | | |
| | | Comparator<List<String>> comparator = new Comparator<List<String>>() { |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package com.forgerock.opendj.cli; |
| | | |
| | |
| | | |
| | | /**The real column widths taking into account size constraints but |
| | | not including padding or separators.*/ |
| | | private final List<Integer> columnWidths = new ArrayList<Integer>(); |
| | | private final List<Integer> columnWidths = new ArrayList<>(); |
| | | |
| | | /** The cells in the current row. */ |
| | | private final List<String> currentRow = new ArrayList<String>(); |
| | | private final List<String> currentRow = new ArrayList<>(); |
| | | |
| | | /** Width of the table in columns. */ |
| | | private int totalColumns; |
| | |
| | | private boolean displayHeadings = true; |
| | | |
| | | /** Table indicating whether or not a column is fixed width. */ |
| | | private final Map<Integer, Integer> fixedColumns = new HashMap<Integer, Integer>(); |
| | | private final Map<Integer, Integer> fixedColumns = new HashMap<>(); |
| | | |
| | | /** The number of characters the table should be indented. */ |
| | | private int indentWidth; |
| | |
| | | // Check that the trailing arguments were retrieved correctly and |
| | | // in the right order. |
| | | if (args.length > 1) { |
| | | List<String> scargs = new ArrayList<String>(); |
| | | List<String> scargs = new ArrayList<>(); |
| | | for (int i = 1; i < args.length; i++) { |
| | | scargs.add(args[i]); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | /** The parent managed object definition if applicable. */ |
| | | private final AbstractManagedObjectDefinition<? super C, ? super S> parent; |
| | | |
| | | /** |
| | | * The set of constraints associated with this managed object |
| | | * definition. |
| | | */ |
| | | private final Collection<Constraint> constraints; |
| | | |
| | | /** |
| | | * The set of property definitions applicable to this managed object |
| | | * definition. |
| | | */ |
| | | private final Map<String, PropertyDefinition<?>> propertyDefinitions; |
| | | |
| | | /** |
| | | * The set of relation definitions applicable to this managed object |
| | | * definition. |
| | | */ |
| | | private final Map<String, RelationDefinition<?, ?>> relationDefinitions; |
| | | |
| | | /** |
| | | * The set of relation definitions directly referencing this managed |
| | | * object definition. |
| | | */ |
| | | private final Set<RelationDefinition<C, S>> reverseRelationDefinitions; |
| | | /** The set of constraints associated with this managed object definition. */ |
| | | private final Collection<Constraint> constraints = new LinkedList<>(); |
| | | /** The set of property definitions applicable to this managed object definition. */ |
| | | private final Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<>(); |
| | | /** The set of relation definitions applicable to this managed object definition. */ |
| | | private final Map<String, RelationDefinition<?, ?>> relationDefinitions = new HashMap<>(); |
| | | /** The set of relation definitions directly referencing this managed object definition. */ |
| | | private final Set<RelationDefinition<C, S>> reverseRelationDefinitions = new HashSet<>(); |
| | | |
| | | /** |
| | | * The set of all property definitions associated with this managed |
| | | * object definition including inherited property definitions. |
| | | */ |
| | | private final Map<String, PropertyDefinition<?>> allPropertyDefinitions; |
| | | |
| | | private final Map<String, PropertyDefinition<?>> allPropertyDefinitions = new HashMap<>(); |
| | | /** |
| | | * The set of all relation definitions associated with this managed |
| | | * object definition including inherited relation definitions. |
| | | */ |
| | | private final Map<String, RelationDefinition<?, ?>> allRelationDefinitions; |
| | | private final Map<String, RelationDefinition<?, ?>> allRelationDefinitions = new HashMap<>(); |
| | | |
| | | /** |
| | | * The set of aggregation property definitions applicable to this |
| | | * managed object definition. |
| | | */ |
| | | private final Map<String, AggregationPropertyDefinition<?, ?>> aggregationPropertyDefinitions; |
| | | /** The set of aggregation property definitions applicable to this managed object definition. */ |
| | | private final Map<String, AggregationPropertyDefinition<?, ?>> aggregationPropertyDefinitions = new HashMap<>(); |
| | | |
| | | /** |
| | | * The set of aggregation property definitions directly referencing this |
| | | * managed object definition. |
| | | */ |
| | | private final Vector<AggregationPropertyDefinition<?, ?>> reverseAggregationPropertyDefinitions; |
| | | /** The set of aggregation property definitions directly referencing this managed object definition. */ |
| | | private final Vector<AggregationPropertyDefinition<?, ?>> reverseAggregationPropertyDefinitions = new Vector<>(); |
| | | |
| | | /** |
| | | * The set of all aggregation property definitions associated with this |
| | | * managed object definition including inherited relation definitions. |
| | | */ |
| | | private final Map<String, AggregationPropertyDefinition<?, ?>> allAggregationPropertyDefinitions; |
| | | private final Map<String, AggregationPropertyDefinition<?, ?>> allAggregationPropertyDefinitions = new HashMap<>(); |
| | | |
| | | /** The set of tags associated with this managed object. */ |
| | | private final Set<Tag> allTags; |
| | | private final Set<Tag> allTags = new HashSet<>(); |
| | | |
| | | /** Options applicable to this definition. */ |
| | | private final Set<ManagedObjectOption> options; |
| | | private final Set<ManagedObjectOption> options = EnumSet.noneOf(ManagedObjectOption.class); |
| | | |
| | | /** The set of managed object definitions which inherit from this definition. */ |
| | | private final Map<String, AbstractManagedObjectDefinition<? extends C, ? extends S>> children; |
| | | private final Map<String, AbstractManagedObjectDefinition<? extends C, ? extends S>> children = new HashMap<>(); |
| | | |
| | | /** |
| | | * Create a new abstract managed object definition. |
| | |
| | | AbstractManagedObjectDefinition<? super C, ? super S> parent) { |
| | | this.name = name; |
| | | this.parent = parent; |
| | | this.constraints = new LinkedList<Constraint>(); |
| | | this.propertyDefinitions = new HashMap<String, PropertyDefinition<?>>(); |
| | | this.relationDefinitions = new HashMap<String, RelationDefinition<?, ?>>(); |
| | | this.reverseRelationDefinitions = new HashSet<RelationDefinition<C, S>>(); |
| | | this.allPropertyDefinitions = new HashMap<String, PropertyDefinition<?>>(); |
| | | this.allRelationDefinitions = new HashMap<String, RelationDefinition<?, ?>>(); |
| | | this.aggregationPropertyDefinitions = new HashMap<String, AggregationPropertyDefinition<?, ?>>(); |
| | | this.reverseAggregationPropertyDefinitions = new Vector<AggregationPropertyDefinition<?, ?>>(); |
| | | this.allAggregationPropertyDefinitions = new HashMap<String, AggregationPropertyDefinition<?, ?>>(); |
| | | this.allTags = new HashSet<Tag>(); |
| | | this.options = EnumSet.noneOf(ManagedObjectOption.class); |
| | | |
| | | this.children = new HashMap<String, AbstractManagedObjectDefinition<? extends C, ? extends S>>(); |
| | | |
| | | // If we have a parent definition then inherit its features. |
| | | if (parent != null) { |
| | |
| | | } |
| | | |
| | | for (AggregationPropertyDefinition<?, ?> apd : parent.getAllAggregationPropertyDefinitions()) { |
| | | |
| | | allAggregationPropertyDefinitions.put(apd.getName(), apd); |
| | | } |
| | | |
| | | // Tag inheritance is performed during preprocessing. |
| | | } |
| | | } |
| | |
| | | * definition. |
| | | */ |
| | | public final Collection<AbstractManagedObjectDefinition<? extends C, ? extends S>> getAllChildren() { |
| | | List<AbstractManagedObjectDefinition<? extends C, ? extends S>> list = |
| | | new ArrayList<AbstractManagedObjectDefinition<? extends C, ? extends S>>(children.values()); |
| | | List<AbstractManagedObjectDefinition<? extends C, ? extends S>> list = new ArrayList<>(children.values()); |
| | | |
| | | for (AbstractManagedObjectDefinition<? extends C, ? extends S> child : children.values()) { |
| | | list.addAll(child.getAllChildren()); |
| | |
| | | */ |
| | | public final Collection<Constraint> getAllConstraints() { |
| | | // This method does not used a cached set of constraints because |
| | | // constraints may be updated after child definitions have been |
| | | // defined. |
| | | List<Constraint> allConstraints = new LinkedList<Constraint>(); |
| | | // constraints may be updated after child definitions have been defined. |
| | | List<Constraint> allConstraints = new LinkedList<>(); |
| | | |
| | | if (parent != null) { |
| | | allConstraints.addAll(parent.getAllConstraints()); |
| | |
| | | */ |
| | | public final Collection<RelationDefinition<? super C, ? super S>> getAllReverseRelationDefinitions() { |
| | | // This method does not used a cached set of relations because |
| | | // relations may be updated after child definitions have been |
| | | // defined. |
| | | List<RelationDefinition<? super C, ? super S>> rdlist = |
| | | new LinkedList<RelationDefinition<? super C, ? super S>>(); |
| | | // relations may be updated after child definitions have been defined. |
| | | List<RelationDefinition<? super C, ? super S>> rdlist = new LinkedList<>(); |
| | | |
| | | if (parent != null) { |
| | | rdlist.addAll(parent.getAllReverseRelationDefinitions()); |
| | |
| | | * caller is free to modify the collection if required. |
| | | */ |
| | | public final Collection<AggregationPropertyDefinition<?, ?>> getAllReverseAggregationPropertyDefinitions() { |
| | | // This method does not used a cached set of aggregation properties |
| | | // because |
| | | // aggregation properties may be updated after child definitions have |
| | | // been |
| | | // defined. |
| | | List<AggregationPropertyDefinition<?, ?>> apdlist = new LinkedList<AggregationPropertyDefinition<?, ?>>(); |
| | | // This method does not used a cached set of aggregation properties because |
| | | // aggregation properties may be updated after child definitions have been defined. |
| | | List<AggregationPropertyDefinition<?, ?>> apdlist = new LinkedList<>(); |
| | | |
| | | if (parent != null) { |
| | | apdlist.addAll(parent.getAllReverseAggregationPropertyDefinitions()); |
| | |
| | | throw new IllegalStateException("Relation definition undefined"); |
| | | } |
| | | |
| | | return new AggregationPropertyDefinition<C, S>(d, propertyName, options, adminAction, defaultBehavior, |
| | | return new AggregationPropertyDefinition<>(d, propertyName, options, adminAction, defaultBehavior, |
| | | parentPathString, rdName, targetNeedsEnablingCondition, targetIsEnabledCondition); |
| | | } |
| | | |
| | |
| | | ServerManagedObject<?> parent = context.getManagedObject(parentPath); |
| | | |
| | | // Create entries in the listener tables. |
| | | List<ReferentialIntegrityDeleteListener> dlist = new LinkedList<ReferentialIntegrityDeleteListener>(); |
| | | List<ReferentialIntegrityDeleteListener> dlist = new LinkedList<>(); |
| | | deleteListeners.put(managedObject.getDN(), dlist); |
| | | |
| | | List<ReferentialIntegrityChangeListener> clist = new LinkedList<ReferentialIntegrityChangeListener>(); |
| | | List<ReferentialIntegrityChangeListener> clist = new LinkedList<>(); |
| | | changeListeners.put(managedObject.getDN(), clist); |
| | | |
| | | for (String name : managedObject.getPropertyValues(AggregationPropertyDefinition.this)) { |
| | |
| | | @SuppressWarnings("unchecked") |
| | | private <C1 extends ConfigurationClient> List<ManagedObject<? extends C1>> findInstances( |
| | | ManagementContext context, AbstractManagedObjectDefinition<C1, ?> mod) throws LdapException { |
| | | List<ManagedObject<? extends C1>> instances = new LinkedList<ManagedObject<? extends C1>>(); |
| | | List<ManagedObject<? extends C1>> instances = new LinkedList<>(); |
| | | |
| | | if (mod == RootCfgDefn.getInstance()) { |
| | | instances.add((ManagedObject<? extends C1>) context.getRootConfigurationManagedObject()); |
| | |
| | | */ |
| | | public static <C extends ConfigurationClient, S extends Configuration> Builder<C, S> createBuilder( |
| | | AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | return new Builder<C, S>(d, propertyName); |
| | | return new Builder<>(d, propertyName); |
| | | } |
| | | |
| | | private static final Logger debugLogger = LoggerFactory.getLogger(AggregationPropertyDefinition.class); |
| | |
| | | * The active server-side referential integrity change listeners |
| | | * associated with this property. |
| | | */ |
| | | private final Map<DN, List<ReferentialIntegrityChangeListener>> changeListeners = |
| | | new HashMap<DN, List<ReferentialIntegrityChangeListener>>(); |
| | | private final Map<DN, List<ReferentialIntegrityChangeListener>> changeListeners = new HashMap<>(); |
| | | |
| | | /** |
| | | * The active server-side referential integrity delete listeners |
| | | * associated with this property. |
| | | */ |
| | | private final Map<DN, List<ReferentialIntegrityDeleteListener>> deleteListeners = |
| | | new HashMap<DN, List<ReferentialIntegrityDeleteListener>>(); |
| | | private final Map<DN, List<ReferentialIntegrityDeleteListener>> deleteListeners = new HashMap<>(); |
| | | |
| | | /** |
| | | * The name of the managed object which is the parent of the |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | * than the standard boolean string parser and supports common true/false |
| | | * synonyms used in configuration. |
| | | */ |
| | | private static final Map<String, Boolean> VALUE_MAP; |
| | | private static final Map<String, Boolean> VALUE_MAP = new HashMap<>(); |
| | | static { |
| | | VALUE_MAP = new HashMap<String, Boolean>(); |
| | | |
| | | // We could have more possibilities but decided against in issue 1960. |
| | | VALUE_MAP.put("false", Boolean.FALSE); |
| | | VALUE_MAP.put("true", Boolean.TRUE); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2013 ForgeRock AS. |
| | | * Portions copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | */ |
| | | public final class ClassPropertyDefinition extends PropertyDefinition<String> { |
| | | |
| | | /** |
| | | * An interface for incrementally constructing class property definitions. |
| | | */ |
| | | /** An interface for incrementally constructing class property definitions. */ |
| | | public static final class Builder extends AbstractBuilder<String, ClassPropertyDefinition> { |
| | | |
| | | /** List of interfaces which property values must implement. */ |
| | | private List<String> instanceOfInterfaces; |
| | | private final List<String> instanceOfInterfaces = new LinkedList<>(); |
| | | |
| | | /** Private constructor. */ |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | |
| | | this.instanceOfInterfaces = new LinkedList<String>(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2014 ForgeRock AS. |
| | | * Portions copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | } |
| | | |
| | | /** Set of registered Jar files. */ |
| | | private Set<File> jarFiles = new HashSet<File>(); |
| | | private Set<File> jarFiles = new HashSet<>(); |
| | | |
| | | /** |
| | | * Underlying class loader used to load classes and resources (null |
| | |
| | | final File libPath = new File(instancePath, LIB_DIR); |
| | | final File extensionsPath = new File(libPath, EXTENSIONS_DIR); |
| | | |
| | | final ArrayList<File> files = new ArrayList<File>(extensions.length); |
| | | final ArrayList<File> files = new ArrayList<>(extensions.length); |
| | | for (final String extension : extensions) { |
| | | final File file = new File(extensionsPath, extension); |
| | | |
| | |
| | | public synchronized void reload() throws ConfigException { |
| | | ensureInitialized(); |
| | | loader = null; |
| | | jarFiles = new HashSet<File>(); |
| | | jarFiles = new HashSet<>(); |
| | | initialize0(); |
| | | } |
| | | |
| | |
| | | |
| | | private void addExtension(final File... extensions) throws ConfigException { |
| | | // First add the Jar files to the class loader. |
| | | final List<JarFile> jars = new LinkedList<JarFile>(); |
| | | final List<JarFile> jars = new LinkedList<>(); |
| | | for (final File extension : extensions) { |
| | | if (jarFiles.contains(extension)) { |
| | | // Skip this file as it is already loaded. |
| | |
| | | */ |
| | | private void loadDefinitionClasses(final InputStream is) throws ConfigException { |
| | | final BufferedReader reader = new BufferedReader(new InputStreamReader(is)); |
| | | final List<AbstractManagedObjectDefinition<?, ?>> definitions = |
| | | new LinkedList<AbstractManagedObjectDefinition<?, ?>>(); |
| | | final List<AbstractManagedObjectDefinition<?, ?>> definitions = new LinkedList<>(); |
| | | while (true) { |
| | | String className; |
| | | try { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | private final ManagedObjectDefinition<C, S> definition; |
| | | |
| | | /** The string encoded default managed object's properties. */ |
| | | private final Map<String, List<String>> propertyStringValues = new HashMap<String, List<String>>(); |
| | | private final Map<String, List<String>> propertyStringValues = new HashMap<>(); |
| | | |
| | | /** |
| | | * Creates a new default managed object builder. |
| | |
| | | * @return Returns the new default managed object. |
| | | */ |
| | | public DefaultManagedObject<C, S> getInstance() { |
| | | return new DefaultManagedObject<C, S>(definition, propertyStringValues); |
| | | return new DefaultManagedObject<>(definition, propertyStringValues); |
| | | } |
| | | |
| | | /** |
| | |
| | | definition.getPropertyDefinition(pd.getName()); |
| | | |
| | | // Do a defensive copy. |
| | | SortedSet<T> values = new TreeSet<T>(pd); |
| | | SortedSet<T> values = new TreeSet<>(pd); |
| | | List<String> stringValues = propertyStringValues.get(pd.getName()); |
| | | if (stringValues != null) { |
| | | for (String stringValue : stringValues) { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | * default values. |
| | | */ |
| | | public Collection<String> getDefaultValues() { |
| | | return new ArrayList<String>(values); |
| | | return new ArrayList<>(values); |
| | | } |
| | | |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | WEEKS(7 * 24 * 60 * 60 * 1000, "w", "weeks"); |
| | | |
| | | /** A lookup table for resolving a unit from its name. */ |
| | | private static final Map<String, DurationUnit> NAME_TO_UNIT; |
| | | private static final Map<String, DurationUnit> NAME_TO_UNIT = new HashMap<>(); |
| | | static { |
| | | NAME_TO_UNIT = new HashMap<String, DurationUnit>(); |
| | | |
| | | for (DurationUnit unit : DurationUnit.values()) { |
| | | NAME_TO_UNIT.put(unit.shortName, unit); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | throw new IllegalStateException("Enumeration class undefined"); |
| | | } |
| | | |
| | | return new EnumPropertyDefinition<E>(d, propertyName, options, adminAction, defaultBehavior, enumClass); |
| | | return new EnumPropertyDefinition<>(d, propertyName, options, adminAction, defaultBehavior, enumClass); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | public static <E extends Enum<E>> Builder<E> createBuilder(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName) { |
| | | return new Builder<E>(d, propertyName); |
| | | return new Builder<>(d, propertyName); |
| | | } |
| | | |
| | | /** The enumeration class. */ |
| | |
| | | this.enumClass = enumClass; |
| | | |
| | | // Initialize the decoding map. |
| | | this.decodeMap = new HashMap<String, E>(); |
| | | this.decodeMap = new HashMap<>(); |
| | | for (E value : EnumSet.<E> allOf(enumClass)) { |
| | | String s = value.toString().trim().toLowerCase(); |
| | | this.decodeMap.put(s, value); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | * instantiable relation definition. |
| | | */ |
| | | private final Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects = |
| | | new HashMap<String, DefaultManagedObject<? extends C, ? extends S>>(); |
| | | new HashMap<>(); |
| | | |
| | | /** |
| | | * Creates a new builder which can be used to incrementally build an |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected InstantiableRelationDefinition<C, S> buildInstance(Common<C, S> common) { |
| | | return new InstantiableRelationDefinition<C, S>(common, pluralName, namingPropertyDefinition, |
| | | return new InstantiableRelationDefinition<>(common, pluralName, namingPropertyDefinition, |
| | | defaultManagedObjects); |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | public final class ManagedObjectDefinitionResource { |
| | | |
| | | /** Mapping from definition to property tables. */ |
| | | private final Map<AbstractManagedObjectDefinition<?, ?>, Properties> properties; |
| | | private final Map<AbstractManagedObjectDefinition<?, ?>, Properties> properties = new HashMap<>(); |
| | | |
| | | /** The resource name prefix. */ |
| | | private final String prefix; |
| | |
| | | |
| | | /** Private constructor. */ |
| | | private ManagedObjectDefinitionResource(String prefix) { |
| | | this.properties = new HashMap<AbstractManagedObjectDefinition<?, ?>, Properties>(); |
| | | this.prefix = prefix; |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | private static <C extends ConfigurationClient, S extends Configuration> InstantiableElement<C, S> create( |
| | | InstantiableRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d, |
| | | String name) { |
| | | return new InstantiableElement<C, S>(r, d, name); |
| | | return new InstantiableElement<>(r, d, name); |
| | | } |
| | | |
| | | /** The name of the managed object. */ |
| | |
| | | /** Factory method. */ |
| | | private static <C extends ConfigurationClient, S extends Configuration> OptionalElement<C, S> create( |
| | | OptionalRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | return new OptionalElement<C, S>(r, d); |
| | | return new OptionalElement<>(r, d); |
| | | } |
| | | |
| | | /** The optional relation. */ |
| | |
| | | /** Factory method. */ |
| | | private static <C extends ConfigurationClient, S extends Configuration> SetElement<C, S> create( |
| | | SetRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | return new SetElement<C, S>(r, d); |
| | | return new SetElement<>(r, d); |
| | | } |
| | | |
| | | /** The set relation. */ |
| | |
| | | /** Factory method. */ |
| | | private static <C extends ConfigurationClient, S extends Configuration> SingletonElement<C, S> create( |
| | | SingletonRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | return new SingletonElement<C, S>(r, d); |
| | | return new SingletonElement<>(r, d); |
| | | } |
| | | |
| | | /** The singleton relation. */ |
| | |
| | | |
| | | /** Single instance of a root path. */ |
| | | private static final ManagedObjectPath<RootCfgClient, RootCfg> EMPTY_PATH = |
| | | new ManagedObjectPath<RootCfgClient, RootCfg>(new LinkedList<Element<?, ?>>(), null, |
| | | RootCfgDefn.getInstance()); |
| | | new ManagedObjectPath<>(new LinkedList<Element<?, ?>>(), null, RootCfgDefn.getInstance()); |
| | | |
| | | /** A regular expression used to parse path elements. */ |
| | | private static final Pattern PE_REGEXP = Pattern.compile("^\\s*relation=\\s*([^+]+)\\s*" |
| | |
| | | } |
| | | |
| | | // Parse the elements. |
| | | LinkedList<Element<?, ?>> elements = new LinkedList<Element<?, ?>>(); |
| | | LinkedList<Element<?, ?>> elements = new LinkedList<>(); |
| | | Element<?, ?> lastElement = null; |
| | | AbstractManagedObjectDefinition<?, ?> definition = RootCfgDefn.getInstance(); |
| | | |
| | |
| | | */ |
| | | private static <C extends ConfigurationClient, S extends Configuration> ManagedObjectPath<C, S> create( |
| | | LinkedList<Element<?, ?>> elements, Element<C, S> lastElement) { |
| | | return new ManagedObjectPath<C, S>(elements, lastElement.getRelationDefinition(), |
| | | return new ManagedObjectPath<>(elements, lastElement.getRelationDefinition(), |
| | | lastElement.getManagedObjectDefinition()); |
| | | } |
| | | |
| | |
| | | if (name.trim().length() == 0) { |
| | | throw new IllegalArgumentException("Empty or blank managed object names are not allowed"); |
| | | } |
| | | LinkedList<Element<?, ?>> celements = new LinkedList<Element<?, ?>>(elements); |
| | | LinkedList<Element<?, ?>> celements = new LinkedList<>(elements); |
| | | celements.add(new InstantiableElement<M, N>(r, d, name)); |
| | | return new ManagedObjectPath<M, N>(celements, r, d); |
| | | return new ManagedObjectPath<>(celements, r, d); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public <M extends ConfigurationClient, N extends Configuration> ManagedObjectPath<M, N> child( |
| | | OptionalRelationDefinition<? super M, ? super N> r, AbstractManagedObjectDefinition<M, N> d) { |
| | | LinkedList<Element<?, ?>> celements = new LinkedList<Element<?, ?>>(elements); |
| | | LinkedList<Element<?, ?>> celements = new LinkedList<>(elements); |
| | | celements.add(new OptionalElement<M, N>(r, d)); |
| | | return new ManagedObjectPath<M, N>(celements, r, d); |
| | | return new ManagedObjectPath<>(celements, r, d); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public <M extends ConfigurationClient, N extends Configuration> ManagedObjectPath<M, N> child( |
| | | SingletonRelationDefinition<? super M, ? super N> r, AbstractManagedObjectDefinition<M, N> d) { |
| | | LinkedList<Element<?, ?>> celements = new LinkedList<Element<?, ?>>(elements); |
| | | LinkedList<Element<?, ?>> celements = new LinkedList<>(elements); |
| | | celements.add(new SingletonElement<M, N>(r, d)); |
| | | return new ManagedObjectPath<M, N>(celements, r, d); |
| | | return new ManagedObjectPath<>(celements, r, d); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public <M extends ConfigurationClient, N extends Configuration> ManagedObjectPath<M, N> child( |
| | | SetRelationDefinition<? super M, ? super N> r, AbstractManagedObjectDefinition<M, N> d) { |
| | | LinkedList<Element<?, ?>> celements = new LinkedList<Element<?, ?>>(elements); |
| | | LinkedList<Element<?, ?>> celements = new LinkedList<>(elements); |
| | | celements.add(new SetElement<M, N>(r, d)); |
| | | return new ManagedObjectPath<M, N>(celements, r, d); |
| | | return new ManagedObjectPath<>(celements, r, d); |
| | | } |
| | | |
| | | /** |
| | |
| | | return emptyPath(); |
| | | } |
| | | |
| | | LinkedList<Element<?, ?>> celements = |
| | | new LinkedList<Element<?, ?>>(elements.subList(0, elements.size() - offset)); |
| | | LinkedList<Element<?, ?>> celements = new LinkedList<>(elements.subList(0, elements.size() - offset)); |
| | | return create(celements, celements.getLast()); |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected OptionalRelationDefinition<C, S> buildInstance(Common<C, S> common) { |
| | | return new OptionalRelationDefinition<C, S>(common, defaultManagedObject); |
| | | return new OptionalRelationDefinition<>(common, defaultManagedObject); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | this.propertyName = propertyName; |
| | | this.options = EnumSet.noneOf(PropertyOption.class); |
| | | this.adminAction = new AdministratorAction(AdministratorAction.Type.NONE, d, propertyName); |
| | | this.defaultBehavior = new UndefinedDefaultBehaviorProvider<T>(); |
| | | this.defaultBehavior = new UndefinedDefaultBehaviorProvider<>(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | return LocalizableMessage.raw(name.substring(i + 1).toUpperCase()); |
| | | } |
| | | } else { |
| | | Set<String> values = new TreeSet<String>(); |
| | | Set<String> values = new TreeSet<>(); |
| | | for (Object value : EnumSet.allOf(d.getEnumClass())) { |
| | | values.add(value.toString().trim().toLowerCase()); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | throw new IllegalArgumentException("Unabled to decode the DN string: \"" + dnAsString + "\""); |
| | | } |
| | | |
| | | return new Reference<C, S>(path, relationDef, name); |
| | | return new Reference<>(path, relationDef, name); |
| | | } |
| | | |
| | | /** |
| | |
| | | throw new IllegalArgumentException("Empty names are not allowed"); |
| | | } |
| | | |
| | | return new Reference<C, S>(p, rd, s); |
| | | return new Reference<>(p, rd, s); |
| | | } |
| | | |
| | | /** The name of the referenced managed object. */ |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | */ |
| | | protected AbstractBuilder(AbstractManagedObjectDefinition<?, ?> pd, String name, |
| | | AbstractManagedObjectDefinition<C, S> cd) { |
| | | this.common = new Common<C, S>(pd, name, cd); |
| | | this.common = new Common<>(pd, name, cd); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | * set relation definition. |
| | | */ |
| | | private final Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects = |
| | | new HashMap<String, DefaultManagedObject<? extends C, ? extends S>>(); |
| | | new HashMap<>(); |
| | | |
| | | /** |
| | | * Creates a new builder which can be used to incrementally build a set |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected SetRelationDefinition<C, S> buildInstance(Common<C, S> common) { |
| | | return new SetRelationDefinition<C, S>(common, pluralName, defaultManagedObjects); |
| | | return new SetRelationDefinition<>(common, pluralName, defaultManagedObjects); |
| | | } |
| | | |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected SingletonRelationDefinition<C, S> buildInstance(Common<C, S> common) { |
| | | return new SingletonRelationDefinition<C, S>(common, defaultManagedObject); |
| | | return new SingletonRelationDefinition<>(common, defaultManagedObject); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | TERA_BYTES(1000L * 1000 * 1000 * 1000, "tb", "terabytes"); |
| | | |
| | | /** A lookup table for resolving a unit from its name. */ |
| | | private static final Map<String, SizeUnit> NAME_TO_UNIT; |
| | | private static final Map<String, SizeUnit> NAME_TO_UNIT = new HashMap<>(); |
| | | static { |
| | | NAME_TO_UNIT = new HashMap<String, SizeUnit>(); |
| | | |
| | | for (SizeUnit unit : SizeUnit.values()) { |
| | | NAME_TO_UNIT.put(unit.shortName, unit); |
| | | NAME_TO_UNIT.put(unit.longName, unit); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | public final class Tag implements Comparable<Tag> { |
| | | |
| | | /** All the tags. */ |
| | | private static final Map<String, Tag> TAGS = new HashMap<String, Tag>(); |
| | | private static final Map<String, Tag> TAGS = new HashMap<>(); |
| | | |
| | | /** |
| | | * Defines a new tag with the specified name. |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.client; |
| | | |
| | |
| | | /** The causes of this exception. */ |
| | | private final Collection<PropertyException> causes; |
| | | |
| | | /** |
| | | * Indicates whether the exception occurred during managed object |
| | | * creation. |
| | | */ |
| | | /** Indicates whether the exception occurred during managed object creation. */ |
| | | private final boolean isCreate; |
| | | |
| | | /** |
| | | * The user friendly name of the component that caused this |
| | | * exception. |
| | | */ |
| | | /** The user friendly name of the component that caused this exception. */ |
| | | private final LocalizableMessage ufn; |
| | | |
| | | /** |
| | |
| | | Collection<PropertyException> causes, boolean isCreate) { |
| | | super(createMessage(causes)); |
| | | |
| | | this.causes = new ArrayList<PropertyException>(causes); |
| | | this.causes = new ArrayList<>(causes); |
| | | this.ufn = ufn; |
| | | this.isCreate = isCreate; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.client; |
| | | |
| | |
| | | /** The type of operation that caused this exception. */ |
| | | private final OperationType type; |
| | | |
| | | /** |
| | | * The user friendly name of the component that caused this |
| | | * exception. |
| | | */ |
| | | /** The user friendly name of the component that caused this exception. */ |
| | | private final LocalizableMessage ufn; |
| | | |
| | | /** |
| | |
| | | Collection<LocalizableMessage> messages) { |
| | | super(getDefaultMessage(messages)); |
| | | |
| | | this.messages = new ArrayList<LocalizableMessage>(messages); |
| | | this.messages = new ArrayList<>(messages); |
| | | this.type = type; |
| | | this.ufn = ufn; |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config.client.ldap; |
| | |
| | | } |
| | | |
| | | /** The list of RDNs in big-endian order. */ |
| | | private final LinkedList<RDN> rdns; |
| | | private final LinkedList<RDN> rdns = new LinkedList<>(); |
| | | |
| | | private final LDAPProfile profile; |
| | | |
| | |
| | | * The LDAP profile which should be used to construct DNs. |
| | | */ |
| | | private DNBuilder(LDAPProfile profile) { |
| | | this.rdns = new LinkedList<RDN>(); |
| | | this.profile = profile; |
| | | } |
| | | |
| | |
| | | * @return rdns in big endian order |
| | | */ |
| | | private List<RDN> getRdnsInBigEndianOrder(DN dn) { |
| | | List<RDN> rdnsOfDn = new ArrayList<RDN>(); |
| | | List<RDN> rdnsOfDn = new ArrayList<>(); |
| | | for (RDN rdn : dn) { |
| | | rdnsOfDn.add(rdn); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock AS. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.client.ldap; |
| | | |
| | |
| | | AbstractManagedObjectDefinition<C, S> d = path.getManagedObjectDefinition(); |
| | | ManagedObjectDefinition<? extends C, ? extends S> mod = getEntryDefinition(d, dn); |
| | | |
| | | ArrayList<String> attrIds = new ArrayList<String>(); |
| | | ArrayList<String> attrIds = new ArrayList<>(); |
| | | for (PropertyDefinition<?> pd : mod.getAllPropertyDefinitions()) { |
| | | String attrId = profile.getAttributeName(mod, pd); |
| | | attrIds.add(attrId); |
| | | attrIds.add(profile.getAttributeName(mod, pd)); |
| | | } |
| | | SearchResultEntry searchResultEntry = |
| | | connection.readEntry(dn, attrIds.toArray(new String[0])); |
| | | |
| | | // Build the managed object's properties. |
| | | List<PropertyException> exceptions = new LinkedList<PropertyException>(); |
| | | List<PropertyException> exceptions = new LinkedList<>(); |
| | | PropertySet newProperties = new PropertySet(); |
| | | for (PropertyDefinition<?> pd : mod.getAllPropertyDefinitions()) { |
| | | String attrID = profile.getAttributeName(mod, pd); |
| | |
| | | Attribute attribute = resultEntry.getAttribute(attrID); |
| | | |
| | | // Decode the values. |
| | | SortedSet<P> values = new TreeSet<P>(propertyDef); |
| | | SortedSet<P> values = new TreeSet<>(propertyDef); |
| | | if (attribute != null) { |
| | | for (ByteString byteValue : attribute) { |
| | | P value = ValueDecoder.decode(propertyDef, byteValue); |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ManagedObject<RootCfgClient> getRootConfigurationManagedObject() { |
| | | return new LDAPManagedObject<RootCfgClient>(this, RootCfgDefn.getInstance(), ManagedObjectPath.emptyPath(), |
| | | return new LDAPManagedObject<>(this, RootCfgDefn.getInstance(), ManagedObjectPath.emptyPath(), |
| | | new PropertySet(), true, null); |
| | | } |
| | | |
| | |
| | | // Retrieve only those entries which are sub-types of the |
| | | // specified definition. |
| | | Filter filter = Filter.equality("objectClass", profile.getObjectClass(d)); |
| | | List<String> children = new ArrayList<String>(); |
| | | List<String> children = new ArrayList<>(); |
| | | try { |
| | | for (DN child : listEntries(dn, filter)) { |
| | | children.add(child.rdn().getFirstAVA().getAttributeValue().toString()); |
| | |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | return children.toArray(new String[children.size()]); |
| | | } |
| | | |
| | |
| | | // Retrieve only those entries which are sub-types of the |
| | | // specified definition. |
| | | Filter filter = Filter.equality("objectClass", profile.getObjectClass(d)); |
| | | List<String> children = new ArrayList<String>(); |
| | | List<String> children = new ArrayList<>(); |
| | | try { |
| | | for (DN child : listEntries(dn, filter)) { |
| | | children.add(child.rdn().getFirstAVA().getAttributeValue().toString()); |
| | |
| | | InstantiableRelationDefinition<?, ?> ird = (InstantiableRelationDefinition<?, ?>) rd; |
| | | pd = ird.getNamingPropertyDefinition(); |
| | | } |
| | | return new LDAPManagedObject<M>(this, d, p.asSubType(d), properties, true, pd); |
| | | return new LDAPManagedObject<>(this, d, p.asSubType(d), properties, true, pd); |
| | | } |
| | | |
| | | /** Create a property using the provided string values. */ |
| | |
| | | PropertyException exception = null; |
| | | |
| | | // Get the property's active values. |
| | | SortedSet<P> activeValues = new TreeSet<P>(propertyDef); |
| | | SortedSet<P> activeValues = new TreeSet<>(propertyDef); |
| | | if (attribute != null) { |
| | | for (ByteString byteValue : attribute) { |
| | | P value = ValueDecoder.decode(propertyDef, byteValue); |
| | |
| | | throw new DefinitionDecodingException(d, Reason.NO_TYPE_INFORMATION); |
| | | } |
| | | |
| | | final Set<String> objectClasses = new HashSet<String>(); |
| | | final Set<String> objectClasses = new HashSet<>(); |
| | | for (ByteString byteValue : objectClassAttr) { |
| | | objectClasses.add(byteValue.toString().toLowerCase().trim()); |
| | | } |
| | |
| | | } |
| | | |
| | | private Collection<DN> listEntries(DN dn, Filter filter) throws LdapException { |
| | | List<DN> names = new LinkedList<DN>(); |
| | | List<DN> names = new LinkedList<>(); |
| | | ConnectionEntryReader reader = |
| | | connection.search(dn.toString(), SearchScope.SINGLE_LEVEL, filter.toString()); |
| | | try { |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config.client.ldap; |
| | |
| | | protected <M extends ConfigurationClient> ManagedObject<M> newInstance(ManagedObjectDefinition<M, ?> d, |
| | | ManagedObjectPath<M, ?> path, PropertySet properties, boolean existsOnServer, |
| | | PropertyDefinition<?> namingPropertyDefinition) { |
| | | return new LDAPManagedObject<M>(driver, d, path, properties, existsOnServer, namingPropertyDefinition); |
| | | return new LDAPManagedObject<>(driver, d, path, properties, existsOnServer, namingPropertyDefinition); |
| | | } |
| | | |
| | | /** Encode a property into LDAP string values. */ |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.client.spi; |
| | | |
| | |
| | | public final void commit() throws ManagedObjectAlreadyExistsException, MissingMandatoryPropertiesException, |
| | | ConcurrentModificationException, OperationRejectedException, LdapException { |
| | | // First make sure all mandatory properties are defined. |
| | | List<PropertyException> exceptions = new LinkedList<PropertyException>(); |
| | | List<PropertyException> exceptions = new LinkedList<>(); |
| | | |
| | | for (PropertyDefinition<?> pd : definition.getAllPropertyDefinitions()) { |
| | | Property<?> p = getProperty(pd); |
| | |
| | | } |
| | | |
| | | // Now enforce any constraints. |
| | | List<LocalizableMessage> messages = new LinkedList<LocalizableMessage>(); |
| | | List<LocalizableMessage> messages = new LinkedList<>(); |
| | | boolean isAcceptable = true; |
| | | ManagementContext context = getDriver().getManagementContext(); |
| | | |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <P> SortedSet<P> getPropertyDefaultValues(PropertyDefinition<P> pd) { |
| | | return new TreeSet<P>(getProperty(pd).getDefaultValues()); |
| | | return new TreeSet<>(getProperty(pd).getDefaultValues()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <P> P getPropertyValue(PropertyDefinition<P> pd) { |
| | | Set<P> values = getProperty(pd).getEffectiveValues(); |
| | | if (values.isEmpty()) { |
| | | return null; |
| | | } else { |
| | | if (!values.isEmpty()) { |
| | | return values.iterator().next(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <P> SortedSet<P> getPropertyValues(PropertyDefinition<P> pd) { |
| | | return new TreeSet<P>(getProperty(pd).getEffectiveValues()); |
| | | return new TreeSet<>(getProperty(pd).getEffectiveValues()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config.client.spi; |
| | |
| | | public MyProperty(PropertyDefinition<T> pd, Collection<T> defaultValues, Collection<T> activeValues) { |
| | | this.d = pd; |
| | | |
| | | SortedSet<T> sortedDefaultValues = new TreeSet<T>(pd); |
| | | SortedSet<T> sortedDefaultValues = new TreeSet<>(pd); |
| | | sortedDefaultValues.addAll(defaultValues); |
| | | this.defaultValues = Collections.unmodifiableSortedSet(sortedDefaultValues); |
| | | |
| | | this.activeValues = new TreeSet<T>(pd); |
| | | this.activeValues = new TreeSet<>(pd); |
| | | this.activeValues.addAll(activeValues); |
| | | |
| | | // Initially the pending values is the same as the active |
| | | // values. |
| | | this.pendingValues = new TreeSet<T>(this.activeValues); |
| | | // Initially the pending values is the same as the active values. |
| | | this.pendingValues = new TreeSet<>(this.activeValues); |
| | | } |
| | | |
| | | /** |
| | | * Makes the pending values active. |
| | | */ |
| | | /** Makes the pending values active. */ |
| | | public void commit() { |
| | | activeValues.clear(); |
| | | activeValues.addAll(pendingValues); |
| | |
| | | } |
| | | |
| | | /** The properties. */ |
| | | private final Map<PropertyDefinition<?>, MyProperty<?>> properties; |
| | | private final Map<PropertyDefinition<?>, MyProperty<?>> properties = new HashMap<>(); |
| | | |
| | | /** |
| | | * Creates a new empty property set. |
| | | */ |
| | | /** Creates a new empty property set. */ |
| | | public PropertySet() { |
| | | this.properties = new HashMap<PropertyDefinition<?>, MyProperty<?>>(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * The set of active values for the property. |
| | | */ |
| | | public <T> void addProperty(PropertyDefinition<T> pd, Collection<T> defaultValues, Collection<T> activeValues) { |
| | | MyProperty<T> p = new MyProperty<T>(pd, defaultValues, activeValues); |
| | | MyProperty<T> p = new MyProperty<>(pd, defaultValues, activeValues); |
| | | properties.put(pd, p); |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.conditions; |
| | | |
| | |
| | | /** Creates the new private implementation. */ |
| | | private <T> void buildImpl(PropertyDefinition<T> pd) { |
| | | T value = pd.decodeValue(propertyStringValue); |
| | | this.impl = new Impl<T>(pd, value); |
| | | this.impl = new Impl<>(pd, value); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config.dsconfig; |
| | |
| | | if (s.trim().length() == 0) { |
| | | return Collections.emptySet(); |
| | | } |
| | | return new LinkedHashSet<String>(Arrays.asList(s.split(","))); |
| | | return new LinkedHashSet<>(Arrays.asList(s.split(","))); |
| | | } |
| | | |
| | | /** |
| | |
| | | AbstractManagedObjectDefinition<?, ?> defn) { |
| | | final LocalizableMessage placeholder = a.getValuePlaceholder(); |
| | | |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | |
| | | final LocalizableMessage name = defn.getUserFriendlyName(); |
| | | map.put("dependencies", REF_DSCFG_SUBTYPE_DEPENDENCIES.get(name, name, placeholder)); |
| | | map.put("typesIntro", REF_DSCFG_SUBTYPE_TYPES_INTRO.get(name)); |
| | | |
| | | List<Map<String, Object>> children = new LinkedList<Map<String, Object>>(); |
| | | List<Map<String, Object>> children = new LinkedList<>(); |
| | | for (AbstractManagedObjectDefinition<?, ?> childDefn : getLeafChildren(defn)) { |
| | | |
| | | Map<String, Object> child = new HashMap<String, Object>(); |
| | | Map<String, Object> child = new HashMap<>(); |
| | | |
| | | child.put("name", childDefn.getName()); |
| | | child.put("default", REF_DSCFG_CHILD_DEFAULT.get(placeholder, childDefn.getUserFriendlyName())); |
| | |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (AbstractManagedObjectDefinition<?, ?> childDefn : getLeafChildren(defn)) { |
| | | final List<PropertyDefinition<?>> props = |
| | | new ArrayList<PropertyDefinition<?>>(childDefn.getAllPropertyDefinitions()); |
| | | final List<PropertyDefinition<?>> props = new ArrayList<>(childDefn.getAllPropertyDefinitions()); |
| | | Collections.sort(props); |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | final String propPrefix = getScriptName() + "-" + sc.getName() + "-" + childDefn.getName(); |
| | | map.put("id", propPrefix); |
| | | map.put("title", childDefn.getUserFriendlyName()); |
| | |
| | | |
| | | private List<AbstractManagedObjectDefinition<?, ?>> getLeafChildren( |
| | | AbstractManagedObjectDefinition<?, ?> defn) { |
| | | final ArrayList<AbstractManagedObjectDefinition<?, ?>> results = |
| | | new ArrayList<AbstractManagedObjectDefinition<?, ?>>(); |
| | | final ArrayList<AbstractManagedObjectDefinition<?, ?>> results = new ArrayList<>(); |
| | | addIfLeaf(results, defn); |
| | | Collections.sort(results, new Comparator<AbstractManagedObjectDefinition<?, ?>>() { |
| | | @Override |
| | |
| | | |
| | | private String toVariableList(List<PropertyDefinition<?>> props, AbstractManagedObjectDefinition<?, ?> defn) { |
| | | StringBuilder b = new StringBuilder(); |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | |
| | | List<Map<String, Object>> properties = new LinkedList<Map<String, Object>>(); |
| | | List<Map<String, Object>> properties = new LinkedList<>(); |
| | | for (PropertyDefinition<?> prop : props) { |
| | | Map<String, Object> property = new HashMap<String, Object>(); |
| | | Map<String, Object> property = new HashMap<>(); |
| | | property.put("term", prop.getName()); |
| | | property.put("descTitle", REF_TITLE_DESCRIPTION.get()); |
| | | property.put("description", getDescriptionString(prop)); |
| | |
| | | } |
| | | |
| | | private StringBuilder appendVarListEntry(StringBuilder b, String term, Object definition) { |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("term", term); |
| | | map.put("definition", definition); |
| | | applyTemplate(b, "dscfgVarListEntry.ftl", map); |
| | |
| | | userFriendlyPluralName = sr.getUserFriendlyPluralName(); |
| | | } |
| | | |
| | | final MenuBuilder<Integer> builder = new MenuBuilder<Integer>(app); |
| | | final MenuBuilder<Integer> builder = new MenuBuilder<>(app); |
| | | |
| | | builder.setTitle(INFO_DSCFG_HEADING_COMPONENT_MENU_TITLE.get(userFriendlyName)); |
| | | builder.setPrompt(INFO_DSCFG_HEADING_COMPONENT_MENU_PROMPT.get()); |
| | |
| | | private SubCommandHandlerFactory handlerFactory; |
| | | |
| | | /** Mapping of sub-commands to their implementations. */ |
| | | private final Map<SubCommand, SubCommandHandler> handlers = new HashMap<SubCommand, SubCommandHandler>(); |
| | | private final Map<SubCommand, SubCommandHandler> handlers = new HashMap<>(); |
| | | |
| | | /** Indicates whether or not a sub-command was provided. */ |
| | | private boolean hasSubCommand = true; |
| | |
| | | } |
| | | }; |
| | | |
| | | Map<Tag, SortedSet<SubCommand>> groups = new TreeMap<Tag, SortedSet<SubCommand>>(); |
| | | SortedSet<SubCommand> allSubCommands = new TreeSet<SubCommand>(c); |
| | | Map<Tag, SortedSet<SubCommand>> groups = new TreeMap<>(); |
| | | SortedSet<SubCommand> allSubCommands = new TreeSet<>(c); |
| | | for (SubCommandHandler handler : handlerFactory.getAllSubCommandHandlers()) { |
| | | SubCommand sc = handler.getSubCommand(); |
| | | |
| | |
| | | for (Tag tag : handler.getTags()) { |
| | | SortedSet<SubCommand> group = groups.get(tag); |
| | | if (group == null) { |
| | | group = new TreeSet<SubCommand>(c); |
| | | group = new TreeSet<>(c); |
| | | groups.put(tag, group); |
| | | } |
| | | group.add(sc); |
| | |
| | | } |
| | | }; |
| | | |
| | | final Set<RelationDefinition<?, ?>> relations = new TreeSet<RelationDefinition<?, ?>>(c); |
| | | final Set<RelationDefinition<?, ?>> relations = new TreeSet<>(c); |
| | | |
| | | final Map<RelationDefinition<?, ?>, CreateSubCommandHandler<?, ?>> createHandlers |
| | | = new HashMap<RelationDefinition<?, ?>, CreateSubCommandHandler<?, ?>>(); |
| | | final Map<RelationDefinition<?, ?>, DeleteSubCommandHandler> deleteHandlers |
| | | = new HashMap<RelationDefinition<?, ?>, DeleteSubCommandHandler>(); |
| | | final Map<RelationDefinition<?, ?>, ListSubCommandHandler> listHandlers |
| | | = new HashMap<RelationDefinition<?, ?>, ListSubCommandHandler>(); |
| | | final Map<RelationDefinition<?, ?>, GetPropSubCommandHandler> getPropHandlers |
| | | = new HashMap<RelationDefinition<?, ?>, GetPropSubCommandHandler>(); |
| | | final Map<RelationDefinition<?, ?>, SetPropSubCommandHandler> setPropHandlers |
| | | = new HashMap<RelationDefinition<?, ?>, SetPropSubCommandHandler>(); |
| | | final Map<RelationDefinition<?, ?>, CreateSubCommandHandler<?, ?>> createHandlers = new HashMap<>(); |
| | | final Map<RelationDefinition<?, ?>, DeleteSubCommandHandler> deleteHandlers = new HashMap<>(); |
| | | final Map<RelationDefinition<?, ?>, ListSubCommandHandler> listHandlers = new HashMap<>(); |
| | | final Map<RelationDefinition<?, ?>, GetPropSubCommandHandler> getPropHandlers = new HashMap<>(); |
| | | final Map<RelationDefinition<?, ?>, SetPropSubCommandHandler> setPropHandlers = new HashMap<>(); |
| | | |
| | | for (final CreateSubCommandHandler<?, ?> ch : handlerFactory.getCreateSubCommandHandlers()) { |
| | | relations.add(ch.getRelationDefinition()); |
| | |
| | | } |
| | | |
| | | // Main menu. |
| | | final MenuBuilder<Integer> builder = new MenuBuilder<Integer>(app); |
| | | final MenuBuilder<Integer> builder = new MenuBuilder<>(app); |
| | | |
| | | builder.setTitle(INFO_DSCFG_HEADING_MAIN_MENU_TITLE.get()); |
| | | builder.setPrompt(INFO_DSCFG_HEADING_MAIN_MENU_PROMPT.get()); |
| | |
| | | private String[] buildCommandArgs(List<String> initialArgs, String batchCommand) { |
| | | final String[] commandArgs = toCommandArgs(batchCommand); |
| | | final int length = commandArgs.length + initialArgs.size(); |
| | | final List<String> allArguments = new ArrayList<String>(length); |
| | | final List<String> allArguments = new ArrayList<>(length); |
| | | Collections.addAll(allArguments, commandArgs); |
| | | allArguments.addAll(initialArgs); |
| | | return allArguments.toArray(new String[length]); |
| | |
| | | private List<String> removeBatchArgs(String[] args) { |
| | | // Build a list of initial arguments, |
| | | // removing the batch file option + its value |
| | | final List<String> initialArgs = new ArrayList<String>(); |
| | | final List<String> initialArgs = new ArrayList<>(); |
| | | Collections.addAll(initialArgs, args); |
| | | for (Iterator<String> it = initialArgs.iterator(); it.hasNext();) { |
| | | final String elem = it.next(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.dsconfig; |
| | | |
| | |
| | | if (propertyNames.isEmpty()) { |
| | | pdList = d.getAllPropertyDefinitions(); |
| | | } else { |
| | | pdList = new LinkedList<PropertyDefinition<?>>(); |
| | | pdList = new LinkedList<>(); |
| | | for (String name : propertyNames) { |
| | | try { |
| | | pdList.add(d.getPropertyDefinition(name)); |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2014 ForgeRock AS. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.dsconfig; |
| | | |
| | |
| | | } |
| | | |
| | | ManagedObject<?> parent = result.getValue(); |
| | | SortedMap<String, ManagedObject<?>> children = new TreeMap<String, ManagedObject<?>>(); |
| | | SortedMap<String, ManagedObject<?>> children = new TreeMap<>(); |
| | | if (relation instanceof InstantiableRelationDefinition) { |
| | | InstantiableRelationDefinition<?, ?> irelation = (InstantiableRelationDefinition<?, ?>) relation; |
| | | try { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.dsconfig; |
| | | |
| | |
| | | |
| | | private PropertyDefinition<T> propertyDefinition; |
| | | private Type type; |
| | | private SortedSet<T> values; |
| | | private SortedSet<T> originalValues; |
| | | private final SortedSet<T> values; |
| | | private final SortedSet<T> originalValues; |
| | | |
| | | /** |
| | | * The private constructor of the PropertyEditorModification. |
| | |
| | | SortedSet<T> originalValues) { |
| | | this.propertyDefinition = propertyDefinition; |
| | | this.type = type; |
| | | this.values = new TreeSet<T>(values); |
| | | this.originalValues = new TreeSet<T>(originalValues); |
| | | this.values = new TreeSet<>(values); |
| | | this.originalValues = new TreeSet<>(originalValues); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | static <T> PropertyEditorModification<T> createResetModification(PropertyDefinition<T> propertyDefinition, |
| | | SortedSet<T> originalValues) { |
| | | return new PropertyEditorModification<T>(propertyDefinition, Type.RESET, new TreeSet<T>(propertyDefinition), |
| | | return new PropertyEditorModification<>(propertyDefinition, Type.RESET, new TreeSet<T>(propertyDefinition), |
| | | originalValues); |
| | | } |
| | | |
| | |
| | | */ |
| | | static <T> PropertyEditorModification<T> createAddModification(PropertyDefinition<T> propertyDefinition, |
| | | SortedSet<T> addedValues, SortedSet<T> originalValues) { |
| | | return new PropertyEditorModification<T>(propertyDefinition, Type.ADD, addedValues, originalValues); |
| | | return new PropertyEditorModification<>(propertyDefinition, Type.ADD, addedValues, originalValues); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | static <T> PropertyEditorModification<T> createSetModification(PropertyDefinition<T> propertyDefinition, |
| | | SortedSet<T> newValues, SortedSet<T> originalValues) { |
| | | return new PropertyEditorModification<T>(propertyDefinition, Type.SET, newValues, originalValues); |
| | | return new PropertyEditorModification<>(propertyDefinition, Type.SET, newValues, originalValues); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | static <T> PropertyEditorModification<T> createRemoveModification(PropertyDefinition<T> propertyDefinition, |
| | | SortedSet<T> removedValues, SortedSet<T> originalValues) { |
| | | return new PropertyEditorModification<T>(propertyDefinition, Type.REMOVE, removedValues, originalValues); |
| | | return new PropertyEditorModification<>(propertyDefinition, Type.REMOVE, removedValues, originalValues); |
| | | } |
| | | |
| | | /** |
| | | * Retuns the property definition associated with this modification. |
| | | * Returns the property definition associated with this modification. |
| | | * |
| | | * @return the property definition associated with this modification. |
| | | */ |
| | |
| | | PropertyDefinition<?> pd2 = mod.getPropertyDefinition(propertyName); |
| | | |
| | | DefaultBehaviorQuery<?> query = query(pd2); |
| | | return new DefaultBehaviorQuery<T>(Type.INHERITED, query.getAliasDescription()); |
| | | return new DefaultBehaviorQuery<>(Type.INHERITED, query.getAliasDescription()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DefaultBehaviorQuery<T> visitAlias(AliasDefaultBehaviorProvider<T> d, |
| | | PropertyDefinition<T> p) { |
| | | return new DefaultBehaviorQuery<T>(Type.ALIAS, d.getSynopsis()); |
| | | return new DefaultBehaviorQuery<>(Type.ALIAS, d.getSynopsis()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DefaultBehaviorQuery<T> visitDefined(DefinedDefaultBehaviorProvider<T> d, |
| | | PropertyDefinition<T> p) { |
| | | return new DefaultBehaviorQuery<T>(Type.DEFINED, null); |
| | | return new DefaultBehaviorQuery<>(Type.DEFINED, null); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | PropertyDefinition<?> pd2 = mod.getPropertyDefinition(propertyName); |
| | | |
| | | DefaultBehaviorQuery<?> query = query(pd2); |
| | | return new DefaultBehaviorQuery<T>(Type.INHERITED, query.getAliasDescription()); |
| | | return new DefaultBehaviorQuery<>(Type.INHERITED, query.getAliasDescription()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DefaultBehaviorQuery<T> visitUndefined(UndefinedDefaultBehaviorProvider<T> d, |
| | | PropertyDefinition<T> p) { |
| | | return new DefaultBehaviorQuery<T>(Type.UNDEFINED, null); |
| | | return new DefaultBehaviorQuery<>(Type.UNDEFINED, null); |
| | | } |
| | | }; |
| | | |
| | |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> MenuResult<Void> visitAggregation( |
| | | AggregationPropertyDefinition<C, S> d, Void p) { |
| | | MenuBuilder<String> builder = new MenuBuilder<String>(app); |
| | | MenuBuilder<String> builder = new MenuBuilder<>(app); |
| | | builder.setMultipleColumnThreshold(MULTI_COLUMN_THRESHOLD); |
| | | |
| | | InstantiableRelationDefinition<C, S> rd = d.getRelationDefinition(); |
| | |
| | | } |
| | | |
| | | // Create a list of possible names. |
| | | Set<String> values = new TreeSet<String>(d); |
| | | Set<String> values = new TreeSet<>(d); |
| | | ManagedObjectPath<?, ?> path = d.getParentPath(); |
| | | try { |
| | | values.addAll(Arrays.asList(context.listManagedObjects(path, rd))); |
| | |
| | | LocalizableMessage option = getPropertyValues(d, Collections.singleton(value)); |
| | | builder.addNumberedOption(option, MenuResult.success(value)); |
| | | } |
| | | MenuCallback<String> callback = new CreateComponentCallback<C, S>(d); |
| | | MenuCallback<String> callback = new CreateComponentCallback<>(d); |
| | | builder.addNumberedOption( |
| | | INFO_EDITOR_OPTION_CREATE_A_NEW_COMPONENT.get(rd.getUserFriendlyName()), callback); |
| | | |
| | |
| | | return MenuResult.cancel(); |
| | | } else { |
| | | Collection<String> newValues = result.getValues(); |
| | | SortedSet<String> oldValues = new TreeSet<String>(mo.getPropertyValues(d)); |
| | | SortedSet<String> oldValues = new TreeSet<>(mo.getPropertyValues(d)); |
| | | mo.setPropertyValues(d, newValues); |
| | | isLastChoiceReset = false; |
| | | registerModification(d, new TreeSet<String>(newValues), oldValues); |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Void> visitBoolean(BooleanPropertyDefinition d, Void p) { |
| | | MenuBuilder<Boolean> builder = new MenuBuilder<Boolean>(app); |
| | | MenuBuilder<Boolean> builder = new MenuBuilder<>(app); |
| | | |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_SELECT_VALUE_SINGLE.get(d.getName())); |
| | | |
| | |
| | | return MenuResult.cancel(); |
| | | } else { |
| | | Collection<Boolean> newValues = result.getValues(); |
| | | SortedSet<Boolean> oldValues = new TreeSet<Boolean>(mo.getPropertyValues(d)); |
| | | SortedSet<Boolean> oldValues = new TreeSet<>(mo.getPropertyValues(d)); |
| | | mo.setPropertyValues(d, newValues); |
| | | isLastChoiceReset = false; |
| | | registerModification(d, new TreeSet<Boolean>(newValues), oldValues); |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <E extends Enum<E>> MenuResult<Void> visitEnum(EnumPropertyDefinition<E> d, Void x) { |
| | | MenuBuilder<E> builder = new MenuBuilder<E>(app); |
| | | MenuBuilder<E> builder = new MenuBuilder<>(app); |
| | | builder.setMultipleColumnThreshold(MULTI_COLUMN_THRESHOLD); |
| | | |
| | | if (d.hasOption(PropertyOption.MULTI_VALUED)) { |
| | |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_SELECT_VALUE_SINGLE.get(d.getName())); |
| | | } |
| | | |
| | | Set<E> values = new TreeSet<E>(d); |
| | | Set<E> values = new TreeSet<>(d); |
| | | values.addAll(EnumSet.allOf(d.getEnumClass())); |
| | | for (E value : values) { |
| | | LocalizableMessage option = getPropertyValues(d, Collections.singleton(value)); |
| | |
| | | return MenuResult.cancel(); |
| | | } else { |
| | | Collection<E> newValues = result.getValues(); |
| | | SortedSet<E> oldValues = new TreeSet<E>(mo.getPropertyValues(d)); |
| | | SortedSet<E> oldValues = new TreeSet<>(mo.getPropertyValues(d)); |
| | | mo.setPropertyValues(d, newValues); |
| | | isLastChoiceReset = false; |
| | | registerModification(d, new TreeSet<E>(newValues), oldValues); |
| | |
| | | // Set the new property value(s). |
| | | try { |
| | | SortedSet<T> values = readPropertyValues(app, mo.getManagedObjectDefinition(), d); |
| | | SortedSet<T> oldValues = new TreeSet<T>(mo.getPropertyValues(d)); |
| | | SortedSet<T> oldValues = new TreeSet<>(mo.getPropertyValues(d)); |
| | | mo.setPropertyValues(d, values); |
| | | isLastChoiceReset = false; |
| | | registerModification(d, values, oldValues); |
| | |
| | | } |
| | | |
| | | // Create a list of possible names. |
| | | final Set<String> values = new TreeSet<String>(d); |
| | | final Set<String> values = new TreeSet<>(d); |
| | | ManagedObjectPath<?, ?> path = d.getParentPath(); |
| | | try { |
| | | values.addAll(Arrays.asList(context.listManagedObjects(path, rd))); |
| | |
| | | |
| | | @Override |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) throws ClientException { |
| | | MenuBuilder<String> builder = new MenuBuilder<String>(app); |
| | | MenuBuilder<String> builder = new MenuBuilder<>(app); |
| | | |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_SELECT_COMPONENTS_ADD.get(ufpn)); |
| | | builder.setAllowMultiSelect(true); |
| | |
| | | LocalizableMessage svalue = getPropertyValues(d, Collections.singleton(value)); |
| | | builder.addNumberedOption(svalue, MenuResult.success(value)); |
| | | } |
| | | MenuCallback<String> callback = new CreateComponentCallback<C, S>(d); |
| | | MenuCallback<String> callback = new CreateComponentCallback<>(d); |
| | | builder.addNumberedOption( |
| | | INFO_EDITOR_OPTION_CREATE_A_NEW_COMPONENT.get(rd.getUserFriendlyName()), callback); |
| | | |
| | |
| | | |
| | | @Override |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) throws ClientException { |
| | | MenuBuilder<String> builder = new MenuBuilder<String>(app); |
| | | MenuBuilder<String> builder = new MenuBuilder<>(app); |
| | | |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_SELECT_COMPONENTS_REMOVE.get(ufpn)); |
| | | builder.setAllowMultiSelect(true); |
| | |
| | | |
| | | @Override |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) throws ClientException { |
| | | MenuBuilder<T> builder = new MenuBuilder<T>(app); |
| | | MenuBuilder<T> builder = new MenuBuilder<>(app); |
| | | |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_SELECT_VALUES_ADD.get()); |
| | | builder.setAllowMultiSelect(true); |
| | |
| | | |
| | | @Override |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) throws ClientException { |
| | | MenuBuilder<T> builder = new MenuBuilder<T>(app); |
| | | MenuBuilder<T> builder = new MenuBuilder<>(app); |
| | | |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_SELECT_VALUES_REMOVE.get()); |
| | | builder.setAllowMultiSelect(true); |
| | |
| | | @Override |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) throws ClientException { |
| | | app.println(); |
| | | SortedSet<T> previousValues = new TreeSet<T>(currentValues); |
| | | SortedSet<T> previousValues = new TreeSet<>(currentValues); |
| | | readPropertyValues(app, mo.getManagedObjectDefinition(), d, currentValues); |
| | | SortedSet<T> addedValues = new TreeSet<T>(currentValues); |
| | | SortedSet<T> addedValues = new TreeSet<>(currentValues); |
| | | addedValues.removeAll(previousValues); |
| | | isLastChoiceReset = false; |
| | | return MenuResult.success(false); |
| | |
| | | |
| | | @Override |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) throws ClientException { |
| | | MenuBuilder<T> builder = new MenuBuilder<T>(app); |
| | | MenuBuilder<T> builder = new MenuBuilder<>(app); |
| | | |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_SELECT_VALUES_REMOVE.get()); |
| | | builder.setAllowMultiSelect(true); |
| | |
| | | final SortedSet<T> defaultValues, final SortedSet<T> oldValues, final SortedSet<T> currentValues, |
| | | MenuCallback<Boolean> addCallback, MenuCallback<Boolean> removeCallback) { |
| | | // Construct a menu of actions. |
| | | MenuBuilder<Boolean> builder = new MenuBuilder<Boolean>(app); |
| | | MenuBuilder<Boolean> builder = new MenuBuilder<>(app); |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_MODIFY_MENU.get(d.getName())); |
| | | |
| | | // First option is for leaving the property unchanged or |
| | |
| | | public <C extends ConfigurationClient, S extends Configuration> MenuResult<Boolean> visitAggregation( |
| | | AggregationPropertyDefinition<C, S> d, Void p) { |
| | | // Construct a menu of actions. |
| | | MenuBuilder<String> builder = new MenuBuilder<String>(app); |
| | | MenuBuilder<String> builder = new MenuBuilder<>(app); |
| | | builder.setMultipleColumnThreshold(MULTI_COLUMN_THRESHOLD); |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_MODIFY_MENU.get(d.getName())); |
| | | |
| | |
| | | builder.setDefault(LocalizableMessage.raw("1"), MenuResult.<String> cancel()); |
| | | |
| | | // Create a list of possible names. |
| | | final Set<String> values = new TreeSet<String>(d); |
| | | final Set<String> values = new TreeSet<>(d); |
| | | ManagedObjectPath<?, ?> path = d.getParentPath(); |
| | | InstantiableRelationDefinition<C, S> rd = d.getRelationDefinition(); |
| | | try { |
| | |
| | | |
| | | builder.addNumberedOption(option, MenuResult.success(value)); |
| | | } |
| | | MenuCallback<String> callback = new CreateComponentCallback<C, S>(d); |
| | | MenuCallback<String> callback = new CreateComponentCallback<>(d); |
| | | builder.addNumberedOption(INFO_EDITOR_OPTION_CREATE_A_NEW_COMPONENT.get(ufn), callback); |
| | | |
| | | // Third option is to reset the value back to its default. |
| | |
| | | @Override |
| | | public MenuResult<Boolean> visitBoolean(BooleanPropertyDefinition d, Void p) { |
| | | // Construct a menu of actions. |
| | | MenuBuilder<Boolean> builder = new MenuBuilder<Boolean>(app); |
| | | MenuBuilder<Boolean> builder = new MenuBuilder<>(app); |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_MODIFY_MENU.get(d.getName())); |
| | | |
| | | DefaultBehaviorQuery<Boolean> query = DefaultBehaviorQuery.query(d); |
| | |
| | | @Override |
| | | public <E extends Enum<E>> MenuResult<Boolean> visitEnum(EnumPropertyDefinition<E> d, Void p) { |
| | | // Construct a menu of actions. |
| | | MenuBuilder<E> builder = new MenuBuilder<E>(app); |
| | | MenuBuilder<E> builder = new MenuBuilder<>(app); |
| | | builder.setMultipleColumnThreshold(MULTI_COLUMN_THRESHOLD); |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_MODIFY_MENU.get(d.getName())); |
| | | |
| | |
| | | builder.setDefault(LocalizableMessage.raw("1"), MenuResult.<E> cancel()); |
| | | |
| | | // Create options for changing to other values. |
| | | Set<E> values = new TreeSet<E>(d); |
| | | Set<E> values = new TreeSet<>(d); |
| | | values.addAll(EnumSet.allOf(d.getEnumClass())); |
| | | for (E value : values) { |
| | | if (value.equals(currentValue) && query.isDefined()) { |
| | |
| | | displayPropertySyntax(app, d); |
| | | |
| | | // Construct a menu of actions. |
| | | MenuBuilder<T> builder = new MenuBuilder<T>(app); |
| | | MenuBuilder<T> builder = new MenuBuilder<>(app); |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_MODIFY_MENU.get(d.getName())); |
| | | |
| | | // First option is for leaving the property unchanged. |
| | |
| | | // Both newValues and oldValues sets need to use the PropertyDefinition |
| | | // as their comparator. Constructing a TreeSet<T> directly with the |
| | | // values collection will fail if the values are e.g. InetAddresses. |
| | | SortedSet<T> newValues = new TreeSet<T>(d); |
| | | SortedSet<T> newValues = new TreeSet<>(d); |
| | | newValues.addAll(values); |
| | | SortedSet<T> oldValues = new TreeSet<T>(mo.getPropertyValues(d)); |
| | | SortedSet<T> oldValues = new TreeSet<>(mo.getPropertyValues(d)); |
| | | mo.setPropertyValues(d, values); |
| | | |
| | | // If there are no values when we do a reset. |
| | |
| | | rows += sz % 2; |
| | | } |
| | | |
| | | List<T> vl = new ArrayList<T>(values); |
| | | List<T> vl = new ArrayList<>(values); |
| | | for (int i = 0, j = rows; i < rows; i++, j++) { |
| | | builder.startRow(); |
| | | builder.appendCell("*)"); |
| | |
| | | /** Read new values for a property. */ |
| | | private static <T> SortedSet<T> readPropertyValues(ConsoleApplication app, ManagedObjectDefinition<?, ?> d, |
| | | PropertyDefinition<T> pd) throws ClientException { |
| | | SortedSet<T> values = new TreeSet<T>(pd); |
| | | SortedSet<T> values = new TreeSet<>(pd); |
| | | readPropertyValues(app, d, pd, values); |
| | | return values; |
| | | } |
| | |
| | | /** |
| | | * The modifications performed: we assume that at most there is one modification per property definition. |
| | | */ |
| | | private final List<PropertyEditorModification<?>> mods = new ArrayList<PropertyEditorModification<?>>(); |
| | | private final List<PropertyEditorModification<?>> mods = new ArrayList<>(); |
| | | |
| | | /** |
| | | * Whether the last type of choice made by the user in a menu is a reset. |
| | | */ |
| | | /** Whether the last type of choice made by the user in a menu is a reset. */ |
| | | private boolean isLastChoiceReset; |
| | | |
| | | /** |
| | |
| | | |
| | | while (true) { |
| | | // Construct the main menu. |
| | | MenuBuilder<Boolean> builder = new MenuBuilder<Boolean>(app); |
| | | MenuBuilder<Boolean> builder = new MenuBuilder<>(app); |
| | | |
| | | String ufn = mo.getManagedObjectPath().getName(); |
| | | if (ufn == null) { |
| | |
| | | registerSetModification(pd, newValues, previousValues); |
| | | } else { |
| | | // Split into two operations: remove and add |
| | | SortedSet<T> removedValues = new TreeSet<T>(previousValues); |
| | | SortedSet<T> removedValues = new TreeSet<>(previousValues); |
| | | removedValues.removeAll(newValues); |
| | | |
| | | PropertyEditorModification<T> removeMod = PropertyEditorModification.createRemoveModification(pd, |
| | | removedValues, previousValues); |
| | | addModification(removeMod); |
| | | |
| | | SortedSet<T> retainedValues = new TreeSet<T>(previousValues); |
| | | SortedSet<T> retainedValues = new TreeSet<>(previousValues); |
| | | retainedValues.retainAll(newValues); |
| | | |
| | | SortedSet<T> addedValues = new TreeSet<T>(newValues); |
| | | SortedSet<T> addedValues = new TreeSet<>(newValues); |
| | | addedValues.removeAll(retainedValues); |
| | | |
| | | PropertyEditorModification<T> addMod = PropertyEditorModification.createAddModification(pd, |
| | |
| | | PropertyEditorModification<?> mod = getModification(pd); |
| | | SortedSet<T> originalValues; |
| | | if (mod != null) { |
| | | originalValues = new TreeSet<T>(pd); |
| | | originalValues = new TreeSet<>(pd); |
| | | castAndAddValues(originalValues, mod.getOriginalValues(), pd); |
| | | removeModification(mod); |
| | | } else { |
| | | originalValues = new TreeSet<T>(previousValues); |
| | | originalValues = new TreeSet<>(previousValues); |
| | | } |
| | | |
| | | addModification(PropertyEditorModification.createResetModification(pd, originalValues)); |
| | |
| | | PropertyEditorModification<?> mod = getModification(pd); |
| | | SortedSet<T> originalValues; |
| | | if (mod != null) { |
| | | originalValues = new TreeSet<T>(pd); |
| | | originalValues = new TreeSet<>(pd); |
| | | castAndAddValues(originalValues, mod.getOriginalValues(), pd); |
| | | removeModification(mod); |
| | | } else { |
| | | originalValues = new TreeSet<T>(previousValues); |
| | | originalValues = new TreeSet<>(previousValues); |
| | | } |
| | | addModification(PropertyEditorModification.createSetModification(pd, newValues, originalValues)); |
| | | } |
| | |
| | | PropertyEditorModification<T> newMod; |
| | | SortedSet<T> originalValues; |
| | | if (mod != null) { |
| | | originalValues = new TreeSet<T>(pd); |
| | | originalValues = new TreeSet<>(pd); |
| | | castAndAddValues(originalValues, mod.getOriginalValues(), pd); |
| | | if (mod.getType() == PropertyEditorModification.Type.ADD) { |
| | | SortedSet<T> addedValues = new TreeSet<T>(newValues); |
| | | SortedSet<T> addedValues = new TreeSet<>(newValues); |
| | | addedValues.removeAll(originalValues); |
| | | newMod = PropertyEditorModification.createAddModification(pd, addedValues, originalValues); |
| | | } else { |
| | |
| | | } |
| | | removeModification(mod); |
| | | } else { |
| | | originalValues = new TreeSet<T>(previousValues); |
| | | SortedSet<T> addedValues = new TreeSet<T>(newValues); |
| | | originalValues = new TreeSet<>(previousValues); |
| | | SortedSet<T> addedValues = new TreeSet<>(newValues); |
| | | addedValues.removeAll(originalValues); |
| | | newMod = PropertyEditorModification.createAddModification(pd, addedValues, originalValues); |
| | | } |
| | |
| | | PropertyEditorModification<T> newMod; |
| | | SortedSet<T> originalValues; |
| | | if (mod != null) { |
| | | originalValues = new TreeSet<T>(pd); |
| | | originalValues = new TreeSet<>(pd); |
| | | castAndAddValues(originalValues, mod.getOriginalValues(), pd); |
| | | if (newValues.isEmpty()) { |
| | | newMod = PropertyEditorModification.createRemoveModification(pd, originalValues, originalValues); |
| | | } else if (mod.getType() == PropertyEditorModification.Type.REMOVE) { |
| | | SortedSet<T> removedValues = new TreeSet<T>(originalValues); |
| | | SortedSet<T> removedValues = new TreeSet<>(originalValues); |
| | | removedValues.removeAll(newValues); |
| | | newMod = PropertyEditorModification.createRemoveModification(pd, removedValues, originalValues); |
| | | } else { |
| | |
| | | } |
| | | removeModification(mod); |
| | | } else { |
| | | originalValues = new TreeSet<T>(previousValues); |
| | | SortedSet<T> removedValues = new TreeSet<T>(originalValues); |
| | | originalValues = new TreeSet<>(previousValues); |
| | | SortedSet<T> removedValues = new TreeSet<>(originalValues); |
| | | removedValues.removeAll(newValues); |
| | | newMod = PropertyEditorModification.createRemoveModification(pd, removedValues, originalValues); |
| | | } |
| | |
| | | while (true) { |
| | | // Interactively set properties if applicable. |
| | | if (app.isInteractive()) { |
| | | SortedSet<PropertyDefinition<?>> properties = new TreeSet<PropertyDefinition<?>>(); |
| | | SortedSet<PropertyDefinition<?>> properties = new TreeSet<>(); |
| | | for (PropertyDefinition<?> pd : d.getAllPropertyDefinitions()) { |
| | | if (pd.hasOption(PropertyOption.HIDDEN)) { |
| | | continue; |
| | |
| | | |
| | | ManagedObject<?> child = result.getValue(); |
| | | ManagedObjectDefinition<?, ?> d = child.getManagedObjectDefinition(); |
| | | Map<String, ModificationType> lastModTypes = new HashMap<String, ModificationType>(); |
| | | Map<PropertyDefinition, Set> changes = new HashMap<PropertyDefinition, Set>(); |
| | | Map<String, ModificationType> lastModTypes = new HashMap<>(); |
| | | Map<PropertyDefinition, Set> changes = new HashMap<>(); |
| | | |
| | | // Reset properties. |
| | | for (String m : propertyResetArgument.getValues()) { |
| | |
| | | } |
| | | break; |
| | | case SET: |
| | | values = new TreeSet<T>(pd); |
| | | values = new TreeSet<>(pd); |
| | | values.add(value); |
| | | break; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.dsconfig; |
| | | |
| | |
| | | } |
| | | |
| | | /** The list of naming arguments. */ |
| | | private final List<StringArgument> arguments = new LinkedList<StringArgument>(); |
| | | private final List<StringArgument> arguments = new LinkedList<>(); |
| | | |
| | | /** |
| | | * Any argument exception thrown when creating the naming arguments. |
| | | */ |
| | | /** Any argument exception thrown when creating the naming arguments. */ |
| | | private ArgumentException e; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static final int MULTI_COLUMN_THRESHOLD = 8; |
| | | |
| | | /** |
| | | * The value for the long option property. |
| | | */ |
| | | /** The value for the long option property. */ |
| | | private static final String OPTION_DSCFG_LONG_PROPERTY = "property"; |
| | | |
| | | /** |
| | | * The value for the long option record. |
| | | */ |
| | | /** The value for the long option record. */ |
| | | private static final String OPTION_DSCFG_LONG_RECORD = "record"; |
| | | |
| | | /** |
| | | * The value for the long option unit-size. |
| | | */ |
| | | /** The value for the long option unit-size. */ |
| | | private static final String OPTION_DSCFG_LONG_UNIT_SIZE = "unit-size"; |
| | | |
| | | /** |
| | | * The value for the long option unit-time. |
| | | */ |
| | | /** The value for the long option unit-time. */ |
| | | private static final String OPTION_DSCFG_LONG_UNIT_TIME = "unit-time"; |
| | | |
| | | /** |
| | | * The value for the short option property. |
| | | */ |
| | | /** The value for the short option property. */ |
| | | private static final Character OPTION_DSCFG_SHORT_PROPERTY = null; |
| | | |
| | | /** |
| | | * The value for the short option record. |
| | | */ |
| | | /** The value for the short option record. */ |
| | | private static final char OPTION_DSCFG_SHORT_RECORD = 'E'; |
| | | |
| | | /** |
| | | * The value for the short option unit-size. |
| | | */ |
| | | /** The value for the short option unit-size. */ |
| | | private static final char OPTION_DSCFG_SHORT_UNIT_SIZE = 'z'; |
| | | |
| | | /** |
| | | * The value for the short option unit-time. |
| | | */ |
| | | /** The value for the short option unit-time. */ |
| | | private static final char OPTION_DSCFG_SHORT_UNIT_TIME = 'm'; |
| | | |
| | | /** |
| | | * The argument which should be used to specify zero or more property names. |
| | | */ |
| | | private StringArgument propertyArgument; |
| | | |
| | | /** The argument which should be used to request record mode. */ |
| | | private BooleanArgument recordModeArgument; |
| | | |
| | | /** The tags associated with this sub-command handler. */ |
| | | private final Set<Tag> tags = new HashSet<Tag>(); |
| | | |
| | | /** The argument which should be used to request specific size units. */ |
| | | private StringArgument unitSizeArgument; |
| | | |
| | | /** The argument which should be used to request specific time units. */ |
| | | private StringArgument unitTimeArgument; |
| | | |
| | | /** The tags associated with this sub-command handler. */ |
| | | private final Set<Tag> tags = new HashSet<>(); |
| | | /** The command builder associated with this handler. */ |
| | | private CommandBuilder commandBuilder; |
| | | |
| | |
| | | */ |
| | | private boolean isCommandBuilderUseful = true; |
| | | |
| | | /** |
| | | * Create a new sub-command handler. |
| | | */ |
| | | /** Create a new sub-command handler. */ |
| | | protected SubCommandHandler() { |
| | | // No implementation required. |
| | | } |
| | |
| | | */ |
| | | protected final List<String> getNamingArgValues(ConsoleApplication app, List<StringArgument> namingArgs) |
| | | throws ArgumentException { |
| | | ArrayList<String> values = new ArrayList<String>(namingArgs.size()); |
| | | ArrayList<String> values = new ArrayList<>(namingArgs.size()); |
| | | for (final StringArgument arg : namingArgs) { |
| | | final String value = arg.getValue(); |
| | | if (value == null && !app.isInteractive()) { |
| | |
| | | */ |
| | | protected final Set<String> getPropertyNames() { |
| | | if (propertyArgument != null) { |
| | | return new LinkedHashSet<String>(propertyArgument.getValues()); |
| | | return new LinkedHashSet<>(propertyArgument.getValues()); |
| | | } |
| | | return Collections.emptySet(); |
| | | } |
| | |
| | | System.out.println(String.format("An error occured %s", e.getMessage())); |
| | | } |
| | | |
| | | SortedMap<String, String> children = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); |
| | | SortedMap<String, String> children = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); |
| | | |
| | | for (String childName : childNames) { |
| | | ManagedObject<?> child; |
| | |
| | | } |
| | | default: { |
| | | // Display a menu. |
| | | MenuBuilder<String> builder = new MenuBuilder<String>(app); |
| | | MenuBuilder<String> builder = new MenuBuilder<>(app); |
| | | builder.setMultipleColumnThreshold(MULTI_COLUMN_THRESHOLD); |
| | | builder.setPrompt(INFO_DSCFG_FINDER_PROMPT_MANY.get(d.getUserFriendlyName())); |
| | | |
| | |
| | | static <C extends ConfigurationClient, S extends Configuration> SortedMap<String, |
| | | ManagedObjectDefinition<? extends C, ? extends S>> getSubTypes( |
| | | AbstractManagedObjectDefinition<C, S> d) { |
| | | SortedMap<String, ManagedObjectDefinition<? extends C, ? extends S>> map; |
| | | map = new TreeMap<String, ManagedObjectDefinition<? extends C, ? extends S>>(); |
| | | SortedMap<String, ManagedObjectDefinition<? extends C, ? extends S>> map = new TreeMap<>(); |
| | | |
| | | // If the top-level definition is instantiable, we use the value |
| | | // "generic" or "custom". |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config.dsconfig; |
| | | |
| | |
| | | } |
| | | |
| | | /** The set of all available sub-commands. */ |
| | | private final SortedSet<SubCommandHandler> allHandlers = new TreeSet<SubCommandHandler>(); |
| | | |
| | | private final SortedSet<SubCommandHandler> allHandlers = new TreeSet<>(); |
| | | /** The set of create-xxx available sub-commands. */ |
| | | private final SortedSet<CreateSubCommandHandler<?, ?>> createHandlers |
| | | = new TreeSet<CreateSubCommandHandler<?, ?>>(); |
| | | |
| | | private final SortedSet<CreateSubCommandHandler<?, ?>> createHandlers = new TreeSet<>(); |
| | | /** The set of delete-xxx available sub-commands. */ |
| | | private final SortedSet<DeleteSubCommandHandler> deleteHandlers = new TreeSet<DeleteSubCommandHandler>(); |
| | | |
| | | /** Any exception that occurred whilst creating the sub-commands. */ |
| | | private ArgumentException exception; |
| | | |
| | | private final SortedSet<DeleteSubCommandHandler> deleteHandlers = new TreeSet<>(); |
| | | /** The set of get-xxx-prop available sub-commands. */ |
| | | private final SortedSet<GetPropSubCommandHandler> getPropHandlers = new TreeSet<GetPropSubCommandHandler>(); |
| | | |
| | | private final SortedSet<GetPropSubCommandHandler> getPropHandlers = new TreeSet<>(); |
| | | /** The help sub-command handler. */ |
| | | private HelpSubCommandHandler helpHandler; |
| | | |
| | | /** The set of list-xxx available sub-commands. */ |
| | | private final SortedSet<ListSubCommandHandler> listHandlers = new TreeSet<ListSubCommandHandler>(); |
| | | private final SortedSet<ListSubCommandHandler> listHandlers = new TreeSet<>(); |
| | | /** The set of set-xxx-prop available sub-commands. */ |
| | | private final SortedSet<SetPropSubCommandHandler> setPropHandlers = new TreeSet<>(); |
| | | |
| | | /** The sub-command argument parser. */ |
| | | private final SubCommandArgumentParser parser; |
| | | |
| | | /** The set of set-xxx-prop available sub-commands. */ |
| | | private final SortedSet<SetPropSubCommandHandler> setPropHandlers = new TreeSet<SetPropSubCommandHandler>(); |
| | | /** Any exception that occurred whilst creating the sub-commands. */ |
| | | private ArgumentException exception; |
| | | |
| | | /** The relation visitor. */ |
| | | private final Visitor visitor = new Visitor(); |
| | |
| | | } |
| | | |
| | | // Let the add listener decide. |
| | | List<LocalizableMessage> reasons = new LinkedList<LocalizableMessage>(); |
| | | List<LocalizableMessage> reasons = new LinkedList<>(); |
| | | if (listener.isConfigurationAddAcceptable(cachedManagedObject, reasons)) { |
| | | return true; |
| | | } else { |
| | |
| | | */ |
| | | public static <T> void find(ManagedObjectPath<?, ?> path, PropertyDefinition<T> pd, |
| | | Collection<DN> dependencies) { |
| | | Visitor<T> v = new Visitor<T>(dependencies); |
| | | Visitor<T> v = new Visitor<>(dependencies); |
| | | DefaultBehaviorProvider<T> db = pd.getDefaultBehaviorProvider(); |
| | | db.accept(v, path); |
| | | } |
| | |
| | | // This change listener should be notified when dependent entries |
| | | // are modified. Determine the dependencies and register change |
| | | // listeners against them. |
| | | this.dependencies = new HashSet<DN>(); |
| | | this.dependencies = new HashSet<>(); |
| | | this.dependencyListener = new ConfigChangeListener() { |
| | | |
| | | public ConfigChangeResult applyConfigurationChange(Entry configEntry) { |
| | |
| | | } |
| | | |
| | | // Let the change listener decide. |
| | | List<LocalizableMessage> reasons = new LinkedList<LocalizableMessage>(); |
| | | List<LocalizableMessage> reasons = new LinkedList<>(); |
| | | if (listener.isConfigurationChangeAcceptable(cachedManagedObject, reasons)) { |
| | | return true; |
| | | } else { |
| | |
| | | * A set of messages describing the changes that were made, any |
| | | * action that may be required, or any problems that were encountered. |
| | | */ |
| | | private final List<LocalizableMessage> messages = new ArrayList<LocalizableMessage>(); |
| | | private final List<LocalizableMessage> messages = new ArrayList<>(); |
| | | |
| | | /** |
| | | * Indicates whether one or more of the changes requires |
| | |
| | | return false; |
| | | } |
| | | |
| | | List<LocalizableMessage> reasons = new LinkedList<LocalizableMessage>(); |
| | | List<LocalizableMessage> reasons = new LinkedList<>(); |
| | | |
| | | // Enforce any constraints. |
| | | boolean isDeleteAllowed = true; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | super(getDefaultMessage(messages)); |
| | | |
| | | this.managedObject = managedObject; |
| | | this.messages = new ArrayList<LocalizableMessage>(messages); |
| | | this.messages = new ArrayList<>(messages); |
| | | } |
| | | |
| | | /** |
| | |
| | | ServerManagedObjectAddListener<M> listener) throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d); |
| | | ConfigAddListener adaptor = new ConfigAddListenerAdaptor<M>(serverContext, path, d, listener); |
| | | ConfigAddListener adaptor = new ConfigAddListenerAdaptor<>(serverContext, path, d, listener); |
| | | registerAddListener(baseDN, adaptor); |
| | | } |
| | | |
| | |
| | | ServerManagedObjectAddListener<M> listener) throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d).parent(); |
| | | ConfigAddListener adaptor = new ConfigAddListenerAdaptor<M>(serverContext, path, d, listener); |
| | | ConfigAddListener adaptor = new ConfigAddListenerAdaptor<>(serverContext, path, d, listener); |
| | | registerAddListener(baseDN, adaptor); |
| | | } |
| | | |
| | |
| | | ServerManagedObjectAddListener<M> listener) throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d); |
| | | ConfigAddListener adaptor = new ConfigAddListenerAdaptor<M>(serverContext, path, d, listener); |
| | | ConfigAddListener adaptor = new ConfigAddListenerAdaptor<>(serverContext, path, d, listener); |
| | | registerAddListener(baseDN, adaptor); |
| | | } |
| | | |
| | |
| | | * The server managed object change listener. |
| | | */ |
| | | public void registerChangeListener(ServerManagedObjectChangeListener<? super S> listener) { |
| | | |
| | | ConfigChangeListener adaptor = new ConfigChangeListenerAdaptor<S>(serverContext, path, listener); |
| | | ConfigChangeListener adaptor = new ConfigChangeListenerAdaptor<>(serverContext, path, listener); |
| | | configRepository.registerChangeListener(configDN, adaptor); |
| | | |
| | | // TODO : go toward this |
| | |
| | | ServerManagedObjectDeleteListener<M> listener) throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d); |
| | | ConfigDeleteListener adaptor = new ConfigDeleteListenerAdaptor<M>(serverContext, path, d, listener); |
| | | ConfigDeleteListener adaptor = new ConfigDeleteListenerAdaptor<>(serverContext, path, d, listener); |
| | | registerDeleteListener(baseDN, adaptor); |
| | | } |
| | | |
| | |
| | | ServerManagedObjectDeleteListener<M> listener) throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d).parent(); |
| | | ConfigDeleteListener adaptor = new ConfigDeleteListenerAdaptor<M>(serverContext, path, d, listener); |
| | | ConfigDeleteListener adaptor = new ConfigDeleteListenerAdaptor<>(serverContext, path, d, listener); |
| | | registerDeleteListener(baseDN, adaptor); |
| | | } |
| | | |
| | |
| | | ServerManagedObjectDeleteListener<M> listener) throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d); |
| | | ConfigDeleteListener adaptor = new ConfigDeleteListenerAdaptor<M>(serverContext, path, d, listener); |
| | | ConfigDeleteListener adaptor = new ConfigDeleteListenerAdaptor<>(serverContext, path, d, listener); |
| | | registerDeleteListener(baseDN, adaptor); |
| | | } |
| | | |
| | |
| | | void ensureIsUsable() throws ConstraintViolationException { |
| | | // Enforce any constraints. |
| | | boolean isUsable = true; |
| | | List<LocalizableMessage> reasons = new LinkedList<LocalizableMessage>(); |
| | | List<LocalizableMessage> reasons = new LinkedList<>(); |
| | | for (Constraint constraint : definition.getAllConstraints()) { |
| | | for (ServerConstraintHandler handler : constraint.getServerConstraintHandlers()) { |
| | | try { |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config.server; |
| | |
| | | @Override |
| | | public Collection<T> visitDefined(DefinedDefaultBehaviorProvider<T> d, Void p) { |
| | | Collection<String> stringValues = d.getDefaultValues(); |
| | | List<T> values = new ArrayList<T>(stringValues.size()); |
| | | List<T> values = new ArrayList<>(stringValues.size()); |
| | | |
| | | for (String stringValue : stringValues) { |
| | | try { |
| | |
| | | |
| | | List<String> attributeValues = getAttributeValues(mod, propDef2, configEntry); |
| | | if (attributeValues.size() > 0) { |
| | | Collection<T> pvalues = new ArrayList<T>(); |
| | | Collection<T> pvalues = new ArrayList<>(); |
| | | for (String value : attributeValues) { |
| | | pvalues.add(ValueDecoder.decode(propDef1, value)); |
| | | } |
| | |
| | | } else { |
| | | // Recursively retrieve this property's default values. |
| | | Collection<T> tmp = find(target, propDef2); |
| | | Collection<T> pvalues = new ArrayList<T>(tmp.size()); |
| | | Collection<T> pvalues = new ArrayList<>(tmp.size()); |
| | | for (T value : tmp) { |
| | | propDef1.validateValue(value); |
| | | pvalues.add(value); |
| | |
| | | rootObject = root; |
| | | if (rootObject == null) { |
| | | root = rootObject = |
| | | new ServerManagedObject<RootCfg>(ManagedObjectPath.emptyPath(), |
| | | new ServerManagedObject<>(ManagedObjectPath.emptyPath(), |
| | | RootCfgDefn.getInstance(), Collections.<PropertyDefinition<?>, |
| | | SortedSet<?>> emptyMap(), null, this); |
| | | } |
| | |
| | | } catch (ConfigException e) { |
| | | return new String[0]; |
| | | } |
| | | List<String> names = new ArrayList<String>(children.size()); |
| | | List<String> names = new ArrayList<>(children.size()); |
| | | for (DN child : children) { |
| | | // Assume that RDNs are single-valued and can be trimmed. |
| | | String name = child.rdn().getFirstAVA().getAttributeValue().toString().trim(); |
| | |
| | | ManagedObjectDefinition<? extends C, ? extends S> mod = d.resolveManagedObjectDefinition(resolver); |
| | | |
| | | // Build the managed object's properties. |
| | | List<PropertyException> exceptions = new LinkedList<PropertyException>(); |
| | | Map<PropertyDefinition<?>, SortedSet<?>> properties = new HashMap<PropertyDefinition<?>, SortedSet<?>>(); |
| | | List<PropertyException> exceptions = new LinkedList<>(); |
| | | Map<PropertyDefinition<?>, SortedSet<?>> properties = new HashMap<>(); |
| | | for (PropertyDefinition<?> propertyDef : mod.getAllPropertyDefinitions()) { |
| | | List<String> attributeValues = getAttributeValues(mod, propertyDef, configEntry); |
| | | try { |
| | |
| | | ManagedObjectPath<? super C, ? super S> path, ManagedObjectDefinition<C, S> d, |
| | | Map<PropertyDefinition<?>, SortedSet<?>> properties, DN configDN) { |
| | | ManagedObjectPath<C, S> newPath = path.asSubType(d); |
| | | return new ServerManagedObject<S>(newPath, d, properties, configDN, this); |
| | | return new ServerManagedObject<>(newPath, d, properties, configDN, this); |
| | | } |
| | | |
| | | /** Decode a property using the provided attribute values. */ |
| | | private <T> SortedSet<T> decodeProperty(ManagedObjectPath<?, ?> path, PropertyDefinition<T> propertyDef, |
| | | List<String> attributeValues, Entry newConfigEntry) { |
| | | PropertyException exception = null; |
| | | SortedSet<T> pvalues = new TreeSet<T>(propertyDef); |
| | | SortedSet<T> pvalues = new TreeSet<>(propertyDef); |
| | | |
| | | if (attributeValues.size() > 0) { |
| | | // The property has values defined for it. |
| | |
| | | String attrID = LDAPProfile.getInstance().getAttributeName(d, pd); |
| | | AttributeType type = Schema.getDefaultSchema().getAttributeType(attrID); |
| | | Iterable<Attribute> attributes = configEntry.getAllAttributes(AttributeDescription.create(type)); |
| | | List<String> values = new ArrayList<String>(); |
| | | List<String> values = new ArrayList<>(); |
| | | for (Attribute attribute : attributes) { |
| | | for (ByteString byteValue : attribute) { |
| | | values.add(byteValue.toString()); |
| | |
| | | /** Get the default values for the specified property. */ |
| | | private <T> Collection<T> getDefaultValues(ManagedObjectPath<?, ?> p, PropertyDefinition<T> pd, |
| | | Entry newConfigEntry) { |
| | | DefaultValueFinder<T> v = new DefaultValueFinder<T>(newConfigEntry); |
| | | DefaultValueFinder<T> v = new DefaultValueFinder<>(newConfigEntry); |
| | | return v.find(p, pd); |
| | | } |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013-2014 ForgeRock AS. |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | PropertyDefinition<T> propertyDefinition = (PropertyDefinition<T>) getPropertyDefMethod.invoke(definition); |
| | | DefaultBehaviorProvider<T> defaultBehaviorProvider = (DefaultBehaviorProvider<T>) propertyDefinition |
| | | .getClass().getMethod("getDefaultBehaviorProvider").invoke(propertyDefinition); |
| | | MockProviderVisitor<T> visitor = new MockProviderVisitor<T>(propertyDefinition); |
| | | MockProviderVisitor<T> visitor = new MockProviderVisitor<>(propertyDefinition); |
| | | Collection<T> values = defaultBehaviorProvider.accept(visitor, null); |
| | | |
| | | if (values == null) { |
| | |
| | | */ |
| | | @Override |
| | | public Collection<T> visitDefined(DefinedDefaultBehaviorProvider<T> provider, Void p) { |
| | | SortedSet<T> values = new TreeSet<T>(); |
| | | SortedSet<T> values = new TreeSet<>(); |
| | | for (String stringValue : provider.getDefaultValues()) { |
| | | values.add(propertyDef.decodeValue(stringValue)); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | @BeforeClass |
| | | public void setUp() { |
| | | parentDefinition = TestParentCfgDefn.getInstance(); |
| | | this.defaultBehaviorProvider = new RelativeInheritedDefaultBehaviorProvider<Boolean>( |
| | | this.defaultBehaviorProvider = new RelativeInheritedDefaultBehaviorProvider<>( |
| | | parentDefinition, |
| | | parentDefinition.getMandatoryBooleanPropertyPropertyDefinition().getName(), |
| | | OFFSET); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | /** Create a one-to-many relation for test-parent components. */ |
| | | static { |
| | | InstantiableRelationDefinition.Builder<TestParentCfgClient, TestParentCfg> builder = |
| | | new InstantiableRelationDefinition.Builder<TestParentCfgClient, TestParentCfg>( |
| | | new InstantiableRelationDefinition.Builder<>( |
| | | RootCfgDefn.getInstance(), "test-one-to-many-parent", "test-one-to-many-parents", |
| | | TestParentCfgDefn.getInstance()); |
| | | RD_TEST_ONE_TO_MANY_PARENT = builder.getInstance(); |
| | |
| | | /** Create a one-to-many relation for test-parent components. */ |
| | | static { |
| | | OptionalRelationDefinition.Builder<TestParentCfgClient, TestParentCfg> builder = |
| | | new OptionalRelationDefinition.Builder<TestParentCfgClient, TestParentCfg>( |
| | | new OptionalRelationDefinition.Builder<>( |
| | | RootCfgDefn.getInstance(), "test-one-to-zero-or-one-parent", TestParentCfgDefn.getInstance()); |
| | | RD_TEST_ONE_TO_ZERO_OR_ONE_PARENT = builder.getInstance(); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | builder.setOption(PropertyOption.MANDATORY); |
| | | builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, |
| | | "mandatory-class-property")); |
| | | DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>( |
| | | DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<>( |
| | | "org.opends.server.extensions.UserDefinedVirtualAttributeProvider"); |
| | | builder.setDefaultBehaviorProvider(provider); |
| | | builder.addInstanceOf("org.opends.server.api.VirtualAttributeProvider"); |
| | |
| | | builder.setOption(PropertyOption.MULTI_VALUED); |
| | | builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, |
| | | "optional-multi-valued-dn-property1")); |
| | | DefaultBehaviorProvider<DN> provider = new RelativeInheritedDefaultBehaviorProvider<DN>( |
| | | DefaultBehaviorProvider<DN> provider = new RelativeInheritedDefaultBehaviorProvider<>( |
| | | TestParentCfgDefn.getInstance(), "optional-multi-valued-dn-property", 1); |
| | | builder.setDefaultBehaviorProvider(provider); |
| | | PROPDEF_OPTIONAL_MULTI_VALUED_DN_PROPERTY1 = builder.getInstance(); |
| | |
| | | builder.setOption(PropertyOption.MULTI_VALUED); |
| | | builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, |
| | | "optional-multi-valued-dn-property2")); |
| | | DefaultBehaviorProvider<DN> provider = new RelativeInheritedDefaultBehaviorProvider<DN>( |
| | | DefaultBehaviorProvider<DN> provider = new RelativeInheritedDefaultBehaviorProvider<>( |
| | | TestChildCfgDefn.getInstance(), "optional-multi-valued-dn-property1", 0); |
| | | builder.setDefaultBehaviorProvider(provider); |
| | | PROPDEF_OPTIONAL_MULTI_VALUED_DN_PROPERTY2 = builder.getInstance(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | builder.setOption(PropertyOption.MANDATORY); |
| | | builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, |
| | | "mandatory-class-property")); |
| | | DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>( |
| | | DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<>( |
| | | "org.opends.server.extensions.SomeVirtualAttributeProvider"); |
| | | builder.setDefaultBehaviorProvider(provider); |
| | | builder.addInstanceOf("org.opends.server.api.VirtualAttributeProvider"); |
| | |
| | | builder.setOption(PropertyOption.MULTI_VALUED); |
| | | builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, |
| | | "optional-multi-valued-dn-property")); |
| | | DefaultBehaviorProvider<DN> provider = new DefinedDefaultBehaviorProvider<DN>("dc=domain1,dc=com", |
| | | DefaultBehaviorProvider<DN> provider = new DefinedDefaultBehaviorProvider<>("dc=domain1,dc=com", |
| | | "dc=domain2,dc=com", "dc=domain3,dc=com"); |
| | | builder.setDefaultBehaviorProvider(provider); |
| | | PD_OPTIONAL_MULTI_VALUED_DN_PROPERTY = builder.getInstance(); |
| | |
| | | /** Build the "test-children" relation definition. */ |
| | | static { |
| | | InstantiableRelationDefinition.Builder<TestChildCfgClient, TestChildCfg> builder = |
| | | new InstantiableRelationDefinition.Builder<TestChildCfgClient, TestChildCfg>( |
| | | new InstantiableRelationDefinition.Builder<>( |
| | | INSTANCE, "multiple-children", "test-children", TestChildCfgDefn.getInstance()); |
| | | RD_TEST_CHILDREN = builder.getInstance(); |
| | | INSTANCE.registerRelationDefinition(RD_TEST_CHILDREN); |
| | |
| | | /** Build the "optional-test-child" relation definition. */ |
| | | static { |
| | | OptionalRelationDefinition.Builder<TestChildCfgClient, TestChildCfg> builder = |
| | | new OptionalRelationDefinition.Builder<TestChildCfgClient, TestChildCfg>( |
| | | new OptionalRelationDefinition.Builder<>( |
| | | INSTANCE, "optional-test-child", TestChildCfgDefn.getInstance()); |
| | | RD_OPTIONAL_TEST_CHILD = builder.getInstance(); |
| | | INSTANCE.registerRelationDefinition(RD_OPTIONAL_TEST_CHILD); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS |
| | | * Portions copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | @DataProvider |
| | | Object[][] enumerateManageObjectDefns() throws Exception { |
| | | TopCfgDefn topCfgDefn = TopCfgDefn.getInstance(); |
| | | List<AbstractManagedObjectDefinition<?, ?>> allCfgDefns = |
| | | new ArrayList<AbstractManagedObjectDefinition<?, ?>>(topCfgDefn.getAllChildren()); |
| | | List<AbstractManagedObjectDefinition<?, ?>> allCfgDefns = new ArrayList<>(topCfgDefn.getAllChildren()); |
| | | |
| | | Object[][] params = new Object[allCfgDefns.size()][]; |
| | | for (int i = 0; i < params.length; i++) { |
| | |
| | | + " is declared as mandatory in the schema.").append(EOL + EOL); |
| | | } |
| | | |
| | | Set<AttributeType> allowedAttributes = new HashSet<AttributeType>(mandatoryAttributes); |
| | | Set<AttributeType> allowedAttributes = new HashSet<>(mandatoryAttributes); |
| | | allowedAttributes.addAll(configObjectClass.getOptionalAttributes()); |
| | | if (!allowedAttributes.contains(attrType)) { |
| | | errors.append( |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.client.ldap; |
| | | |
| | |
| | | |
| | | /** Asserts that the actual set of DNs contains the expected values. */ |
| | | private void assertSetEquals(SortedSet<String> actual, String... expected) { |
| | | SortedSet<String> values = |
| | | new TreeSet<String>(TestChildCfgDefn.getInstance() |
| | | .getAggregationPropertyPropertyDefinition()); |
| | | SortedSet<String> values = new TreeSet<>( |
| | | TestChildCfgDefn.getInstance().getAggregationPropertyPropertyDefinition()); |
| | | if (expected != null) { |
| | | for (String value : expected) { |
| | | values.add(value); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | isProfileRegistered = true; |
| | | } |
| | | SingletonRelationDefinition.Builder<C, S> builder = |
| | | new SingletonRelationDefinition.Builder<C, S>(RootCfgDefn.getInstance(), DUMMY_TEST_RELATION, d); |
| | | new SingletonRelationDefinition.Builder<>(RootCfgDefn.getInstance(), DUMMY_TEST_RELATION, d); |
| | | ManagedObjectPath<?, ?> root = ManagedObjectPath.emptyPath(); |
| | | return root.child(builder.getInstance()); |
| | | } |
| | |
| | | /** Asserts that the actual set of DNs contains the expected values. */ |
| | | private void assertSetEquals(SortedSet<String> actual, String... expected) { |
| | | SortedSet<String> values = |
| | | new TreeSet<String>(TestChildCfgDefn.getInstance().getAggregationPropertyPropertyDefinition()); |
| | | new TreeSet<>(TestChildCfgDefn.getInstance().getAggregationPropertyPropertyDefinition()); |
| | | if (expected != null) { |
| | | for (String value : expected) { |
| | | values.add(value); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | @Test |
| | | public void createWithSingletonRelationDefinition() throws Exception { |
| | | SingletonRelationDefinition.Builder<TestChildCfgClient, TestChildCfg> builder = |
| | | new SingletonRelationDefinition.Builder<TestChildCfgClient, TestChildCfg>( |
| | | new SingletonRelationDefinition.Builder<>( |
| | | TestParentCfgDefn.getInstance(), "singleton-test-child", TestChildCfgDefn.getInstance()); |
| | | final SingletonRelationDefinition<TestChildCfgClient, TestChildCfg> relationDef = builder.getInstance(); |
| | | |
| | |
| | | |
| | | /** Make an entry by combining two lists. */ |
| | | static Entry makeEntryFrom(List<String> base, List<String> attrs) { |
| | | List<String> ldif = new ArrayList<String>(base); |
| | | List<String> ldif = new ArrayList<>(base); |
| | | ldif.addAll(attrs); |
| | | return makeEntry(ldif.toArray(new String[0])); |
| | | } |