From 9ea7b3f8b3730a5be6c441ed1a6e52b00eb1233f Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 10 Feb 2014 09:49:48 +0000
Subject: [PATCH] OPENDJ-1337 Remove all code related to dsframework
---
opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java | 31 +-
opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java | 3
opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java | 40 ++--
opendj3-server-dev/src/main/docbkx/admin-guide/index.xml | 1
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java | 32 ++-
opendj3-server-dev/src/messages/messages/quicksetup_fr.properties | 2
opendj3-server-dev/src/messages/messages/quicksetup_ja.properties | 2
opendj3-server-dev/src/quicksetup/org/opends/quicksetup/UserData.java | 4
/dev/null | 291 --------------------------------
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigLdapConnectionTestCase.java | 15 -
opendj3-server-dev/src/messages/messages/quicksetup_es.properties | 2
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java | 2
opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java | 3
opendj3-server-dev/src/messages/messages/quicksetup_de.properties | 2
opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliParser.java | 16
opendj3-server-dev/src/messages/messages/quicksetup.properties | 3
opendj3-server-dev/src/main/docbkx/admin-guide/chap-admin-tools.xml | 12 -
opendj3-server-dev/src/main/docbkx/release-notes/chap-compatibility.xml | 7
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigOptionsTestCase.java | 4
opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java | 23 +-
opendj3-server-dev/src/messages/messages/quicksetup_zh_CN.properties | 2
21 files changed, 98 insertions(+), 399 deletions(-)
diff --git a/opendj3-server-dev/resource/bin/dsframework b/opendj3-server-dev/resource/bin/dsframework
deleted file mode 100755
index 051a3fb..0000000
--- a/opendj3-server-dev/resource/bin/dsframework
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
-# or http://forgerock.org/license/CDDLv1.0.html.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at legal-notices/CDDLv1_0.txt.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information:
-# Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2006-2008 Sun Microsystems, Inc.
-# Portions Copyright 2011 ForgeRock AS
-
-
-# This script may be used to perform operations with the global administration
-# framework
-OPENDJ_INVOKE_CLASS="org.opends.server.admin.client.cli.DsFrameworkCliMain"
-export OPENDJ_INVOKE_CLASS
-
-SCRIPT_NAME="dsframework"
-export SCRIPT_NAME
-
-SCRIPT_DIR=`dirname "${0}"`
-"${SCRIPT_DIR}/../lib/_client-script.sh" "${@}"
diff --git a/opendj3-server-dev/resource/bin/dsframework.bat b/opendj3-server-dev/resource/bin/dsframework.bat
deleted file mode 100644
index 304e4f6..0000000
--- a/opendj3-server-dev/resource/bin/dsframework.bat
+++ /dev/null
@@ -1,33 +0,0 @@
-
-@echo off
-rem CDDL HEADER START
-rem
-rem The contents of this file are subject to the terms of the
-rem Common Development and Distribution License, Version 1.0 only
-rem (the "License"). You may not use this file except in compliance
-rem with the License.
-rem
-rem You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
-rem or http://forgerock.org/license/CDDLv1.0.html.
-rem See the License for the specific language governing permissions
-rem and limitations under the License.
-rem
-rem When distributing Covered Code, include this CDDL HEADER in each
-rem file and include the License file at legal-notices/CDDLv1_0.txt.
-rem If applicable, add the following below this CDDL HEADER, with the
-rem fields enclosed by brackets "[]" replaced with your own identifying
-rem information:
-rem Portions Copyright [yyyy] [name of copyright owner]
-rem
-rem CDDL HEADER END
-rem
-rem
-rem Copyright 2006-2008 Sun Microsystems, Inc.
-rem Portions Copyright 2011 ForgeRock AS
-
-setlocal
-
-set OPENDJ_INVOKE_CLASS="org.opends.server.admin.client.cli.DsFrameworkCliMain"
-set SCRIPT_NAME=dsframework
-for %%i in (%~sf0) do call "%%~dPsi\..\lib\_client-script.bat" %*
-
diff --git a/opendj3-server-dev/resource/man/man1/dsframework.1 b/opendj3-server-dev/resource/man/man1/dsframework.1
deleted file mode 100644
index 9344bfb..0000000
--- a/opendj3-server-dev/resource/man/man1/dsframework.1
+++ /dev/null
@@ -1,243 +0,0 @@
-'\" t
-.\" Title: dsframework
-.\" Author:
-.\" Generator: DocBook XSL-NS Stylesheets v1.76.1 <http://docbook.sf.net/>
-.\" Date: 05/16/2013
-.\" Manual: Tools Reference
-.\" Source: OpenDJ 2.6.0
-.\" Language: English
-.\"
-.TH "DSFRAMEWORK" "1" "05/16/2013" "OpenDJ 2\&.6\&.0" "Tools Reference"
-.\" -----------------------------------------------------------------
-.\" * Define some portability stuff
-.\" -----------------------------------------------------------------
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" http://bugs.debian.org/507673
-.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.ie \n(.g .ds Aq \(aq
-.el .ds Aq '
-.\" -----------------------------------------------------------------
-.\" * set default formatting
-.\" -----------------------------------------------------------------
-.\" disable hyphenation
-.nh
-.\" disable justification (adjust text to left margin only)
-.ad l
-.\" -----------------------------------------------------------------
-.\" * MAIN CONTENT STARTS HERE *
-.\" -----------------------------------------------------------------
-.SH "NAME"
-dsframework \- manage OpenDJ administration framework
-.SH "SYNOPSIS"
-.HP \w'\fBdsframework\fR\fB\fIsubcommand\fR\fR\ 'u
-\fBdsframework\fR\fB\fIsubcommand\fR\fR {options}
-.SH "DESCRIPTION"
-.PP
-This utility can be used to perform operations in the directory server administration framework\&.
-.PP
-This utility has no interactive mode\&. Consider using
-\fB\-X\fR
-if you authenticate over a secure connection protected with a self\-signed certificate\&.
-.SH "SUBCOMMANDS"
-.PP
-The
-\fBdsconfig\fR
-command provides many subcommands\&. Use the following options to view help for subcommands\&.
-.PP
-\fB\-\-help\-all\fR
-.RS 4
-Display all subcommands
-.RE
-.PP
-\fB\-\-help\-admin\-user\fR
-.RS 4
-Display subcommands relating to admin\-user
-.RE
-.PP
-\fB\-\-help\-server\fR
-.RS 4
-Display subcommands relating to server
-.RE
-.PP
-\fB\-\-help\-server\-group\fR
-.RS 4
-Display subcommands relating to server\-group
-.RE
-.PP
-For help with individual subcommands, use
-\fBdsframework \fR\fB\fIsubcommand\fR\fR\fB \-\-help\fR\&.
-.SH "OPTIONS"
-.PP
-The following options are supported\&.
-.SS "LDAP Connection Options"
-.PP
-\fB\-\-connectTimeout {timeout}\fR
-.RS 4
-Maximum length of time (in milliseconds) that can be taken to establish a connection\&. Use \*(Aq0\*(Aq to specify no time out\&.
-.sp
-Default value: 30000
-.RE
-.PP
-\fB\-h, \-\-hostname {host}\fR
-.RS 4
-Directory server hostname or IP address
-.sp
-Default value: localhost\&.localdomain
-.RE
-.PP
-\fB\-I, \-\-adminUID {adminUID}\fR
-.RS 4
-User ID of the global administrator to use to bind to the server\&. For the
-\fBenable\fR
-subcommand, if no global administrator was defined previously for any servers, the global administrator will be created using the UID provided\&.
-.sp
-Default value: admin
-.RE
-.PP
-\fB\-j, \-\-adminPasswordFile {bindPasswordFile}\fR
-.RS 4
-Global administrator password file
-.RE
-.PP
-\fB\-K, \-\-keyStorePath {keyStorePath}\fR
-.RS 4
-Certificate key store path
-.RE
-.PP
-\fB\-N, \-\-certNickname {nickname}\fR
-.RS 4
-Nickname of certificate for SSL client authentication
-.RE
-.PP
-\fB\-o, \-\-saslOption {name=value}\fR
-.RS 4
-SASL bind options
-.RE
-.PP
-\fB\-p, \-\-port {port}\fR
-.RS 4
-Directory server administration port number
-.sp
-Default value: 4444
-.RE
-.PP
-\fB\-P, \-\-trustStorePath {trustStorePath}\fR
-.RS 4
-Certificate trust store path
-.sp
-Default value: /path/to/opendj/config/admin\-truststore
-.RE
-.PP
-\fB\-T, \-\-trustStorePassword {trustStorePassword}\fR
-.RS 4
-Certificate trust store PIN
-.RE
-.PP
-\fB\-u, \-\-keyStorePasswordFile {keyStorePasswordFile}\fR
-.RS 4
-Certificate key store PIN file
-.RE
-.PP
-\fB\-U, \-\-trustStorePasswordFile {path}\fR
-.RS 4
-Certificate trust store PIN file
-.RE
-.PP
-\fB\-w, \-\-adminPassword {bindPassword}\fR
-.RS 4
-Password for the global administrator
-.RE
-.PP
-\fB\-W, \-\-keyStorePassword {keyStorePassword}\fR
-.RS 4
-Certificate key store PIN
-.RE
-.PP
-\fB\-X, \-\-trustAll\fR
-.RS 4
-Trust all server SSL certificates
-.RE
-.SS "Utility Input/Output Options"
-.PP
-\fB\-\-noPropertiesFile\fR
-.RS 4
-No properties file will be used to get default command line argument values
-.RE
-.PP
-\fB\-\-propertiesFilePath {propertiesFilePath}\fR
-.RS 4
-Path to the file containing default property values used for command line arguments
-.RE
-.PP
-\fB\-v, \-\-verbose\fR
-.RS 4
-Use verbose mode
-.RE
-.SS "General Options"
-.PP
-\fB\-V, \-\-version\fR
-.RS 4
-Display version information
-.RE
-.PP
-\fB\-?, \-H, \-\-help\fR
-.RS 4
-Display usage information
-.RE
-.SH "EXIT CODES"
-.PP
-0
-.RS 4
-The command completed successfully\&.
-.RE
-.PP
-> 0
-.RS 4
-An error occurred\&.
-.RE
-.SH "EXAMPLES"
-.PP
-This example lists server properties\&.
-.sp
-.if n \{\
-.RS 4
-.\}
-.nf
-$ dsframework \-p 4444 \-h opendj\&.example\&.com \-D "cn=Directory Manager"
- \-w password \-X list\-server\-properties
-Option Types:
-
- r \-\- Property value(s) are readable
- w \-\- Property value(s) are writable
- m \-\- The property is mandatory
- s \-\- The property is single\-valued
-
-Property Options Syntax Default value
-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
-ldapsport rw\-\- INTEGER \-
-certificate rw\-s STRING \-
-hostname r\-ms STRING localhost
-ldapport rwm\- INTEGER 389
-jmxsEnabled rw\-s BOOLEAN false
-instancepath rw\-s STRING \-
-ldapsEnabled rw\-s BOOLEAN false
-jmxsport rw\-\- INTEGER \-
-os rw\-s STRING \-
-ds\-cfg\-key\-id rw\-s STRING \-
-jmxport rw\-\- INTEGER \-
-description rw\-s STRING \-
-id rw\-s STRING \-
-startTLSEnabled rw\-s BOOLEAN false
-jmxEnabled rw\-s BOOLEAN false
-ds\-cfg\-public\-key\-certificate rw\-s CERTIFICATE_BINARY \-
-location rw\-s STRING \-
-ldapEnabled rw\-s BOOLEAN false
-.fi
-.if n \{\
-.RE
-.\}
-.SH "COPYRIGHT"
-.br
-Copyright \(co 2011-2013 ForgeRock AS
-.br
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java
index 63e934d..a86cb8a 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java
@@ -120,7 +120,7 @@
String[] names =
{
"start-ds", "import-ldif.offline", "backup.online", "base64",
- "create-rc-script", "dsconfig", "dsreplication", "dsframework",
+ "create-rc-script", "dsconfig", "dsreplication",
"export-ldif.online", "import-ldif.online", "ldapcompare",
"ldapdelete", "ldapmodify", "ldappasswordmodify", "ldapsearch",
"list-backends", "manage-account", "manage-tasks", "restore.online",
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java b/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
index 3adb808..e535115 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -26,14 +26,23 @@
*/
package org.opends.guitools.uninstaller;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
+import javax.net.ssl.TrustManager;
+
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.i18n.slf4j.LocalizedLogger;
-
-import static org.forgerock.util.Utils.*;
-import static org.opends.messages.AdminToolMessages.*;
-import static org.opends.messages.QuickSetupMessages.*;
-
import org.opends.admin.ads.ADSContext;
import org.opends.admin.ads.ServerDescriptor;
import org.opends.admin.ads.TopologyCache;
@@ -47,9 +56,9 @@
import org.opends.quicksetup.util.PlainTextProgressMessageFormatter;
import org.opends.quicksetup.util.ServerController;
import org.opends.quicksetup.util.Utils;
-import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode;
import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
import org.opends.server.tools.ClientException;
+import org.opends.server.tools.JavaPropertiesTool.ErrorReturnCode;
import org.opends.server.tools.ToolConstants;
import org.opends.server.tools.dsconfig.LDAPManagementContextFactory;
import org.opends.server.util.StaticUtils;
@@ -58,20 +67,9 @@
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.CLIException;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.Collections;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.URI;
-
-import javax.naming.NamingException;
-import javax.naming.ldap.InitialLdapContext;
-import javax.net.ssl.TrustManager;
+import static org.forgerock.util.Utils.*;
+import static org.opends.messages.AdminToolMessages.*;
+import static org.opends.messages.QuickSetupMessages.*;
/**
* The class used to provide some CLI interface in the uninstall.
@@ -157,7 +155,7 @@
*/
LocalizableMessageBuilder buf = new LocalizableMessageBuilder();
int v = args.validateGlobalOptions(buf);
- if (v != DsFrameworkCliReturnCode.SUCCESSFUL_NOP.getReturnCode())
+ if (v != ErrorReturnCode.SUCCESSFUL_NOP.getReturnCode())
{
throw new UserDataException(null, buf.toMessage());
}
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java b/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java
index ae770fe..b5053a3 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java
@@ -27,11 +27,6 @@
package org.opends.guitools.uninstaller;
-import static org.opends.messages.ToolMessages.*;
-import static org.opends.messages.AdminToolMessages.*;
-import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
-import static org.opends.server.tools.ToolConstants.*;
-
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.LinkedHashSet;
@@ -41,12 +36,18 @@
import org.opends.quicksetup.UserData;
import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
import org.opends.server.admin.client.cli.SecureConnectionCliParser;
+import org.opends.server.tools.JavaPropertiesTool.ErrorReturnCode;
import org.opends.server.tools.ToolConstants;
+
import com.forgerock.opendj.cli.Argument;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.StringArgument;
+import static org.opends.messages.AdminToolMessages.*;
+import static org.opends.messages.ToolMessages.*;
+import static org.opends.server.tools.ToolConstants.*;
+
/**
* Class used to parse and populate the arguments of the Uninstaller.
*
@@ -249,6 +250,7 @@
* @return <CODE>true</CODE> if the user specified to have a verbose
* uninstall and <CODE>false</CODE> otherwise.
*/
+ @Override
public boolean isVerbose()
{
return verboseArg.isPresent();
@@ -373,6 +375,7 @@
* @param buf the LocalizableMessageBuilder to write the error messages.
* @return return code.
*/
+ @Override
public int validateGlobalOptions(LocalizableMessageBuilder buf)
{
int returnValue;
@@ -397,13 +400,13 @@
removeBackupFilesArg,
removeLDIFFilesArg
};
- for (int i=0; i<removeArgs.length; i++)
+ for (BooleanArgument removeArg : removeArgs)
{
- if (removeArgs[i].isPresent())
+ if (removeArg.isPresent())
{
LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
removeAllArg.getLongIdentifier(),
- removeArgs[i].getLongIdentifier());
+ removeArg.getLongIdentifier());
if (buf.length() > 0)
{
buf.append(EOL);
@@ -415,11 +418,11 @@
super.validateGlobalOptions(buf);
if (buf.length() > 0)
{
- returnValue = CONFLICTING_ARGS.getReturnCode();
+ returnValue = ErrorReturnCode.CONFLICTING_ARGS.getReturnCode();
}
else
{
- returnValue = SUCCESSFUL_NOP.getReturnCode();
+ returnValue = ErrorReturnCode.SUCCESSFUL_NOP.getReturnCode();
}
return returnValue;
}
diff --git a/opendj3-server-dev/src/main/docbkx/admin-guide/chap-admin-tools.xml b/opendj3-server-dev/src/main/docbkx/admin-guide/chap-admin-tools.xml
index ad01a7f..6af46be 100644
--- a/opendj3-server-dev/src/main/docbkx/admin-guide/chap-admin-tools.xml
+++ b/opendj3-server-dev/src/main/docbkx/admin-guide/chap-admin-tools.xml
@@ -20,7 +20,7 @@
!
! CCPL HEADER END
!
- ! Copyright 2011-2013 ForgeRock AS
+ ! Copyright 2011-2014 ForgeRock AS
!
-->
<chapter xml:id='chap-admin-tools'
@@ -280,16 +280,6 @@
command.</para>
</listitem>
</varlistentry>
-<!--
- <varlistentry>
- <term><link xlink:href="admin-guide#dsframework-1"
- xlink:role="http://docbook.org/xlink/role/olink">dsframework</link></term>
- <listitem>
- <para>Manage server registration, server groups, and administrative
- users.</para>
- </listitem>
- </varlistentry>
--->
<varlistentry>
<term><link xlink:href="admin-guide#dsjavaproperties-1"
xlink:role="http://docbook.org/xlink/role/olink">dsjavaproperties</link></term>
diff --git a/opendj3-server-dev/src/main/docbkx/admin-guide/index.xml b/opendj3-server-dev/src/main/docbkx/admin-guide/index.xml
index c42b810..bde8323 100644
--- a/opendj3-server-dev/src/main/docbkx/admin-guide/index.xml
+++ b/opendj3-server-dev/src/main/docbkx/admin-guide/index.xml
@@ -110,7 +110,6 @@
<xinclude:include href='man-create-rc-script.xml' />
<xinclude:include href='man-dbtest.xml' />
<xinclude:include href='man-dsconfig.xml' />
- <xinclude:include href='man-dsframework.xml' />
<xinclude:include href='man-dsjavaproperties.xml' />
<xinclude:include href='man-dsreplication.xml' />
<xinclude:include href='man-encode-password.xml' />
diff --git a/opendj3-server-dev/src/main/docbkx/admin-guide/man-dsframework.xml b/opendj3-server-dev/src/main/docbkx/admin-guide/man-dsframework.xml
deleted file mode 100644
index 131cb09..0000000
--- a/opendj3-server-dev/src/main/docbkx/admin-guide/man-dsframework.xml
+++ /dev/null
@@ -1,295 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ! CCPL HEADER START
- !
- ! This work is licensed under the Creative Commons
- ! Attribution-NonCommercial-NoDerivs 3.0 Unported License.
- ! To view a copy of this license, visit
- ! http://creativecommons.org/licenses/by-nc-nd/3.0/
- ! or send a letter to Creative Commons, 444 Castro Street,
- ! Suite 900, Mountain View, California, 94041, USA.
- !
- ! You can also obtain a copy of the license at
- ! trunk/opendj3/legal-notices/CC-BY-NC-ND.txt.
- ! See the License for the specific language governing permissions
- ! and limitations under the License.
- !
- ! If applicable, add the following below this CCPL HEADER, with the fields
- ! enclosed by brackets "[]" replaced with your own identifying information:
- ! Portions Copyright [yyyy] [name of copyright owner]
- !
- ! CCPL HEADER END
- !
- ! Copyright 2011-2013 ForgeRock AS
- !
--->
-<refentry xml:id='dsframework-1'
- xmlns='http://docbook.org/ns/docbook'
- version='5.0' xml:lang='en'
- xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
- xsi:schemaLocation='http://docbook.org/ns/docbook http://docbook.org/xml/5.0/xsd/docbook.xsd'
- xmlns:xlink='http://www.w3.org/1999/xlink'
- xmlns:xinclude='http://www.w3.org/2001/XInclude'>
- <info><copyright><year>2011-2013</year><holder>ForgeRock AS</holder></copyright></info>
- <refmeta>
- <refentrytitle>dsframework</refentrytitle><manvolnum>1</manvolnum>
- <refmiscinfo class="software">OpenDJ</refmiscinfo>
- <refmiscinfo class="version"><?eval ${docTargetVersion}?></refmiscinfo>
- </refmeta>
- <refnamediv>
- <refname>dsframework</refname>
- <refpurpose>manage OpenDJ administration framework</refpurpose>
- </refnamediv>
- <refsynopsisdiv>
- <cmdsynopsis>
- <command>dsframework</command>
- <command><replaceable>subcommand</replaceable></command>
- <arg choice="req">options</arg>
- </cmdsynopsis>
- </refsynopsisdiv>
- <refsect1>
- <title>Description</title>
- <para>This utility can be used to perform operations in the directory server
- administration framework.</para>
- <para>This utility has no interactive mode. Consider using <option>-X</option>
- if you authenticate over a secure connection protected with a self-signed
- certificate.</para>
- </refsect1>
- <refsect1>
- <title>Subcommands</title>
-
- <para>The <command>dsconfig</command> command provides many subcommands.
- Use the following options to view help for subcommands.</para>
-
- <variablelist>
- <varlistentry>
- <term><option>--help-all</option></term>
- <listitem>
- <para>Display all subcommands</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>--help-admin-user</option></term>
- <listitem>
- <para>Display subcommands relating to admin-user</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>--help-server</option></term>
- <listitem>
- <para>Display subcommands relating to server</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>--help-server-group</option></term>
- <listitem>
- <para>Display subcommands relating to server-group</para>
- </listitem>
- </varlistentry>
- </variablelist>
-
- <para>For help with individual subcommands, use <command>dsframework
- <replaceable>subcommand</replaceable> --help</command>.</para>
- </refsect1>
- <refsect1>
- <title>Options</title>
- <para>The following options are supported.</para>
- <refsect2>
- <title>LDAP Connection Options</title>
- <variablelist>
- <varlistentry>
- <term><option>--connectTimeout {timeout}</option></term>
- <listitem>
- <para>Maximum length of time (in milliseconds) that can be taken to
- establish a connection. Use '0' to specify no time out.</para>
- <para>Default value: 30000</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-h, --hostname {host}</option></term>
- <listitem>
- <para>Directory server hostname or IP address</para>
- <para>Default value: localhost.localdomain</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-I, --adminUID {adminUID}</option></term>
- <listitem>
- <para>User ID of the global administrator to use to bind to the server.
- For the <command>enable</command> subcommand, if no global administrator
- was defined previously for any servers, the global administrator will be
- created using the UID provided.</para>
- <para>Default value: admin</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-j, --adminPasswordFile {bindPasswordFile}</option></term>
- <listitem>
- <para>Global administrator password file</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-K, --keyStorePath {keyStorePath}</option></term>
- <listitem>
- <para> Certificate key store path</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-N, --certNickname {nickname}</option></term>
- <listitem>
- <para>Nickname of certificate for SSL client authentication</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-o, --saslOption {name=value}</option></term>
- <listitem>
- <para>SASL bind options</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-p, --port {port}</option></term>
- <listitem>
- <para>Directory server administration port number</para>
- <para>Default value: 4444</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-P, --trustStorePath {trustStorePath}</option></term>
- <listitem>
- <para>Certificate trust store path</para>
- <para>Default value: /path/to/opendj/config/admin-truststore</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-T, --trustStorePassword {trustStorePassword}</option></term>
- <listitem>
- <para>Certificate trust store PIN</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-u, --keyStorePasswordFile {keyStorePasswordFile}</option></term>
- <listitem>
- <para>Certificate key store PIN file</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-U, --trustStorePasswordFile {path}</option></term>
- <listitem>
- <para>Certificate trust store PIN file</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-w, --adminPassword {bindPassword}</option></term>
- <listitem>
- <para>Password for the global administrator</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-W, --keyStorePassword {keyStorePassword}</option></term>
- <listitem>
- <para>Certificate key store PIN</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-X, --trustAll</option></term>
- <listitem>
- <para>Trust all server SSL certificates</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect2>
- <refsect2>
- <title>Utility Input/Output Options</title>
- <variablelist>
- <varlistentry>
- <term><option>--noPropertiesFile</option></term>
- <listitem>
- <para>No properties file will be used to get default command line
- argument values</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>--propertiesFilePath {propertiesFilePath}</option></term>
- <listitem>
- <para>Path to the file containing default property values used for
- command line arguments</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-v, --verbose</option></term>
- <listitem>
- <para>Use verbose mode</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect2>
- <refsect2>
- <title>General Options</title>
- <variablelist>
- <varlistentry>
- <term><option>-V, --version</option></term>
- <listitem>
- <para>Display version information</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-?, -H, --help</option></term>
- <listitem>
- <para>Display usage information</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect2>
- </refsect1>
- <refsect1>
- <title>Exit Codes</title>
- <variablelist>
- <varlistentry>
- <term>0</term>
- <listitem>
- <para>The command completed successfully.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>> 0</term>
- <listitem>
- <para>An error occurred.</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
- <refsect1>
- <title>Examples</title>
- <para>This example lists server properties.</para>
- <screen>
-$ dsframework -p 4444 -h opendj.example.com -D "cn=Directory Manager"
- -w password -X list-server-properties
-Option Types:
-
- r -- Property value(s) are readable
- w -- Property value(s) are writable
- m -- The property is mandatory
- s -- The property is single-valued
-
-Property Options Syntax Default value
--------------------------------------------------------------------------
-ldapsport rw-- INTEGER -
-certificate rw-s STRING -
-hostname r-ms STRING localhost
-ldapport rwm- INTEGER 389
-jmxsEnabled rw-s BOOLEAN false
-instancepath rw-s STRING -
-ldapsEnabled rw-s BOOLEAN false
-jmxsport rw-- INTEGER -
-os rw-s STRING -
-ds-cfg-key-id rw-s STRING -
-jmxport rw-- INTEGER -
-description rw-s STRING -
-id rw-s STRING -
-startTLSEnabled rw-s BOOLEAN false
-jmxEnabled rw-s BOOLEAN false
-ds-cfg-public-key-certificate rw-s CERTIFICATE_BINARY -
-location rw-s STRING -
-ldapEnabled rw-s BOOLEAN false</screen>
- </refsect1>
-</refentry>
diff --git a/opendj3-server-dev/src/main/docbkx/release-notes/chap-compatibility.xml b/opendj3-server-dev/src/main/docbkx/release-notes/chap-compatibility.xml
index 8e29640..6f658e8 100644
--- a/opendj3-server-dev/src/main/docbkx/release-notes/chap-compatibility.xml
+++ b/opendj3-server-dev/src/main/docbkx/release-notes/chap-compatibility.xml
@@ -20,7 +20,7 @@
!
! CCPL HEADER END
!
- ! Copyright 2011-2013 ForgeRock AS
+ ! Copyright 2011-2014 ForgeRock AS
!
-->
<chapter xml:id='chap-compatibility'
@@ -149,9 +149,6 @@
Use of the old variables is Deprecated. The old variables are likely to be
removed in a future release.</para>
- <para>The <command>dsframework</command> command is Deprecated and likely
- to be removed in a future release.</para>
-
<itemizedlist>
<para>The following OpenDJ LDAP SDK methods are Deprecated and likely to be
removed in a future release.</para>
@@ -167,5 +164,7 @@
<para>Native packages in SVR4 format for Solaris are not provided at this
time.</para>
+
+ <para>The <command>dsframework</command> command has been removed.</para>
</section>
</chapter>
diff --git a/opendj3-server-dev/src/messages/messages/quicksetup.properties b/opendj3-server-dev/src/messages/messages/quicksetup.properties
index 5c9a974..0e11139 100644
--- a/opendj3-server-dev/src/messages/messages/quicksetup.properties
+++ b/opendj3-server-dev/src/messages/messages/quicksetup.properties
@@ -895,8 +895,7 @@
and server %s could not be merged. Reasons:%n%s
FATAL_ERR_ADS_ADMINISTRATOR_MERGE=The following administrators are defined in \
server %s but not in server %s:%n%s%nThe merge can only be performed if these \
- administrators are defined in server %s. Use the command-line dsframework \
- to do so.
+ administrators are defined in server %s.
INFO_INITIAL_MEMORY_LABEL=Initial Memory:
INFO_INITIAL_MEMORY_TOOLTIP=Provide the initial memory in megabytes that \
the Java process will use.
diff --git a/opendj3-server-dev/src/messages/messages/quicksetup_de.properties b/opendj3-server-dev/src/messages/messages/quicksetup_de.properties
index 33bc6e4..c197d97 100644
--- a/opendj3-server-dev/src/messages/messages/quicksetup_de.properties
+++ b/opendj3-server-dev/src/messages/messages/quicksetup_de.properties
@@ -617,7 +617,7 @@
INFO_ADS_CONTEXT_EXCEPTION_MSG=Fehler bei den Registrierungsinformationen. Fehlertyp: '%s'.
INFO_ADS_CONTEXT_EXCEPTION_WITH_DETAILS_MSG=Fehler bei den Registrierungsinformationen. Fehlertyp: '%s'. Details: %s
FATAL_ERR_ADS_MERGE=Die Registrierungsinformationen von Server %s und Server %s konnten nicht zusammengef\u00fchrt werden. Ursachen:%n%s
-FATAL_ERR_ADS_ADMINISTRATOR_MERGE=Die folgenden Administratoren sind in Server %s aber nicht in Server %s definiert:%n%s%nDie Zusammenf\u00fchrung ist nur m\u00f6glich, wenn diese Administratoren in Server %s definiert sind. Verwenden Sie hierzu die Befehlszeile dsframework.
+FATAL_ERR_ADS_ADMINISTRATOR_MERGE=Die folgenden Administratoren sind in Server %s aber nicht in Server %s definiert:%n%s%nDie Zusammenf\u00fchrung ist nur m\u00f6glich, wenn diese Administratoren in Server %s definiert sind.
INFO_INITIAL_MEMORY_LABEL=Anf\u00e4nglicher Arbeitsspeicher:
INFO_INITIAL_MEMORY_TOOLTIP=Geben Sie den anf\u00e4nglichen Speicher, den der Java-Prozess verwendet, in Megabyte an.
INFO_MAX_MEMORY_LABEL=Maximaler Arbeitsspeicher:
diff --git a/opendj3-server-dev/src/messages/messages/quicksetup_es.properties b/opendj3-server-dev/src/messages/messages/quicksetup_es.properties
index fd75d8a..9536cae 100644
--- a/opendj3-server-dev/src/messages/messages/quicksetup_es.properties
+++ b/opendj3-server-dev/src/messages/messages/quicksetup_es.properties
@@ -617,7 +617,7 @@
INFO_ADS_CONTEXT_EXCEPTION_MSG=Error de informaci\u00f3n de registro. Tipo de error: '%s'.
INFO_ADS_CONTEXT_EXCEPTION_WITH_DETAILS_MSG=Error de informaci\u00f3n de registro. Tipo de error: '%s'. Detalles: %s
FATAL_ERR_ADS_MERGE=No pudo combinarse la informaci\u00f3n de registro del servidor %s y del servidor %s. Razones:%n%s
-FATAL_ERR_ADS_ADMINISTRATOR_MERGE=Se han definido los siguientes administradores en el servidor %s, pero no en el servidor %s:%n%s%nS\u00f3lo puede realizarse la combinaci\u00f3n si se definen dichos administradores en el servidor %s. Para ello, use la l\u00ednea se comandos dsframework.
+FATAL_ERR_ADS_ADMINISTRATOR_MERGE=Se han definido los siguientes administradores en el servidor %s, pero no en el servidor %s:%n%s%nS\u00f3lo puede realizarse la combinaci\u00f3n si se definen dichos administradores en el servidor %s.
INFO_INITIAL_MEMORY_LABEL=Memoria inicial:
INFO_INITIAL_MEMORY_TOOLTIP=Proporcione la memoria inicial en megabytes que emplear\u00e1 el proceso Java.
INFO_MAX_MEMORY_LABEL=Memoria m\u00e1xima:
diff --git a/opendj3-server-dev/src/messages/messages/quicksetup_fr.properties b/opendj3-server-dev/src/messages/messages/quicksetup_fr.properties
index 1ade251..01ad335 100644
--- a/opendj3-server-dev/src/messages/messages/quicksetup_fr.properties
+++ b/opendj3-server-dev/src/messages/messages/quicksetup_fr.properties
@@ -618,7 +618,7 @@
INFO_ADS_CONTEXT_EXCEPTION_MSG=Erreur sur les informations d'enregistrement. Type d'erreur : '%s'.
INFO_ADS_CONTEXT_EXCEPTION_WITH_DETAILS_MSG=Erreur sur les informations d'enregistrement. Type d'erreur : '%s'. D\u00e9tails\u00a0: %s
FATAL_ERR_ADS_MERGE=Impossible de fusionner les informations d'enregistrement des serveurs %s et %s. Raisons\u00a0:%n%s
-FATAL_ERR_ADS_ADMINISTRATOR_MERGE=Les administrateurs suivants sont d\u00e9finis sur le serveur %s mais pas sur le serveur %s\u00a0:%n%s%nLa fusion ne fonctionne que si ces administrateurs sont d\u00e9finis sur le serveur %s. Utilisez la ligne de commande dsframework pour effectuer l'op\u00e9ration.
+FATAL_ERR_ADS_ADMINISTRATOR_MERGE=Les administrateurs suivants sont d\u00e9finis sur le serveur %s mais pas sur le serveur %s\u00a0:%n%s%nLa fusion ne fonctionne que si ces administrateurs sont d\u00e9finis sur le serveur %s.
INFO_INITIAL_MEMORY_LABEL=M\u00e9moire initiale\u00a0:
INFO_INITIAL_MEMORY_TOOLTIP=Indiquez la quantit\u00e9 de m\u00e9moire initiale (en m\u00e9ga-octets) que le processus Java va utiliser.
INFO_MAX_MEMORY_LABEL=M\u00e9moire maximale\u00a0:
diff --git a/opendj3-server-dev/src/messages/messages/quicksetup_ja.properties b/opendj3-server-dev/src/messages/messages/quicksetup_ja.properties
index cde539b..a39a6c3 100644
--- a/opendj3-server-dev/src/messages/messages/quicksetup_ja.properties
+++ b/opendj3-server-dev/src/messages/messages/quicksetup_ja.properties
@@ -617,7 +617,7 @@
INFO_ADS_CONTEXT_EXCEPTION_MSG=\u767b\u9332\u60c5\u5831\u30a8\u30e9\u30fc\u3002\u30a8\u30e9\u30fc\u306e\u30bf\u30a4\u30d7: '%s'\u3002
INFO_ADS_CONTEXT_EXCEPTION_WITH_DETAILS_MSG=\u767b\u9332\u60c5\u5831\u30a8\u30e9\u30fc\u3002\u30a8\u30e9\u30fc\u306e\u30bf\u30a4\u30d7: '%s'\u3002\u8a73\u7d30: %s
FATAL_ERR_ADS_MERGE=\u30b5\u30fc\u30d0\u30fc %s \u3068\u30b5\u30fc\u30d0\u30fc %s \u306e\u767b\u9332\u60c5\u5831\u3092\u30de\u30fc\u30b8\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u7406\u7531:%n%s
-FATAL_ERR_ADS_ADMINISTRATOR_MERGE=\u6b21\u306e\u7ba1\u7406\u8005\u306f\u3001\u30b5\u30fc\u30d0\u30fc %s \u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u30b5\u30fc\u30d0\u30fc %s \u306b\u306f\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u305b\u3093:%n%s%n\u30de\u30fc\u30b8\u3092\u5b9f\u884c\u3059\u308b\u306b\u306f\u3001\u3053\u308c\u3089\u306e\u7ba1\u7406\u8005\u3092\u30b5\u30fc\u30d0\u30fc %s \u306b\u5b9a\u7fa9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u5b9a\u7fa9\u3059\u308b\u306b\u306f\u3001\u30b3\u30de\u30f3\u30c9\u884c dsframework \u3092\u4f7f\u7528\u3057\u307e\u3059\u3002
+FATAL_ERR_ADS_ADMINISTRATOR_MERGE=\u6b21\u306e\u7ba1\u7406\u8005\u306f\u3001\u30b5\u30fc\u30d0\u30fc %s \u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u30b5\u30fc\u30d0\u30fc %s \u306b\u306f\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u305b\u3093:%n%s%n\u30de\u30fc\u30b8\u3092\u5b9f\u884c\u3059\u308b\u306b\u306f\u3001\u3053\u308c\u3089\u306e\u7ba1\u7406\u8005\u3092\u30b5\u30fc\u30d0\u30fc %s \u306b\u5b9a\u7fa9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002
INFO_INITIAL_MEMORY_LABEL=\u521d\u671f\u30e1\u30e2\u30ea\u30fc:
INFO_INITIAL_MEMORY_TOOLTIP=Java \u30d7\u30ed\u30bb\u30b9\u304c\u4f7f\u7528\u3059\u308b\u521d\u671f\u30e1\u30e2\u30ea\u30fc\u3092 MB \u5358\u4f4d\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002
INFO_MAX_MEMORY_LABEL=\u6700\u5927\u30e1\u30e2\u30ea\u30fc:
diff --git a/opendj3-server-dev/src/messages/messages/quicksetup_zh_CN.properties b/opendj3-server-dev/src/messages/messages/quicksetup_zh_CN.properties
index a54b844..4eca7ed 100644
--- a/opendj3-server-dev/src/messages/messages/quicksetup_zh_CN.properties
+++ b/opendj3-server-dev/src/messages/messages/quicksetup_zh_CN.properties
@@ -617,7 +617,7 @@
INFO_ADS_CONTEXT_EXCEPTION_MSG=\u6ce8\u518c\u4fe1\u606f\u9519\u8bef\u3002\u9519\u8bef\u7c7b\u578b: '%s'\u3002
INFO_ADS_CONTEXT_EXCEPTION_WITH_DETAILS_MSG=\u6ce8\u518c\u4fe1\u606f\u9519\u8bef\u3002\u9519\u8bef\u7c7b\u578b: '%s'\u3002\u8be6\u7ec6\u4fe1\u606f: %s
FATAL_ERR_ADS_MERGE=\u4e0d\u80fd\u5408\u5e76\u670d\u52a1\u5668 %s \u4e0e\u670d\u52a1\u5668 %s \u7684\u6ce8\u518c\u4fe1\u606f\u3002\u539f\u56e0:%n%s
-FATAL_ERR_ADS_ADMINISTRATOR_MERGE=\u4ee5\u4e0b\u7ba1\u7406\u5458\u53ea\u5728\u670d\u52a1\u5668 %s \u4e2d\u5b9a\u4e49\uff0c\u800c\u672a\u5728\u670d\u52a1\u5668 %s:%n%s \u4e2d\u5b9a\u4e49\u3002%n\u53ea\u6709\u5728\u670d\u52a1\u5668 %s \u4e2d\u5b9a\u4e49\u8fd9\u4e9b\u7ba1\u7406\u5458\u65f6\u624d\u80fd\u6267\u884c\u5408\u5e76\u3002\u4f7f\u7528\u547d\u4ee4\u884c dsframework \u5b8c\u6210\u6b64\u64cd\u4f5c\u3002
+FATAL_ERR_ADS_ADMINISTRATOR_MERGE=\u4ee5\u4e0b\u7ba1\u7406\u5458\u53ea\u5728\u670d\u52a1\u5668 %s \u4e2d\u5b9a\u4e49\uff0c\u800c\u672a\u5728\u670d\u52a1\u5668 %s:%n%s \u4e2d\u5b9a\u4e49\u3002%n\u53ea\u6709\u5728\u670d\u52a1\u5668 %s \u4e2d\u5b9a\u4e49\u8fd9\u4e9b\u7ba1\u7406\u5458\u65f6\u624d\u80fd\u6267\u884c\u5408\u5e76\u3002
INFO_INITIAL_MEMORY_LABEL=\u521d\u59cb\u5185\u5b58:
INFO_INITIAL_MEMORY_TOOLTIP=\u63d0\u4f9b Java \u8fdb\u7a0b\u4f7f\u7528\u7684\u521d\u59cb\u5185\u5b58\uff08\u4ee5\u5146\u5b57\u8282\u4e3a\u5355\u4f4d\uff09\u3002
INFO_MAX_MEMORY_LABEL=\u6700\u5927\u5185\u5b58:
diff --git a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/UserData.java b/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/UserData.java
index 4688bc7..18977f4 100644
--- a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/UserData.java
+++ b/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/UserData.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
- * Portions copyright 2011-2013 ForgeRock AS.
+ * Portions copyright 2011-2014 ForgeRock AS.
*/
package org.opends.quicksetup;
@@ -902,7 +902,7 @@
{
return new String[] {
"backup.online", "base64", "create-rc-script", "dsconfig",
- "dsreplication", "dsframework", "export-ldif.online",
+ "dsreplication", "export-ldif.online",
"import-ldif.online", "ldapcompare", "ldapdelete",
"ldapmodify", "ldappasswordmodify", "ldapsearch", "list-backends",
"manage-account", "manage-tasks", "restore.online", "stop-ds",
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliAds.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliAds.java
deleted file mode 100644
index c02c974..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliAds.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.admin.client.cli;
-
-import static org.opends.messages.AdminMessages.*;
-import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.tools.ToolConstants.*;
-
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.naming.ldap.InitialLdapContext;
-
-import org.opends.admin.ads.ADSContext;
-import org.opends.admin.ads.ADSContextException;
-import org.opends.admin.ads.ADSContextHelper;
-import com.forgerock.opendj.cli.ArgumentException;
-import com.forgerock.opendj.cli.BooleanArgument;
-import com.forgerock.opendj.cli.StringArgument;
-import com.forgerock.opendj.cli.SubCommand;
-
-import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
-import static org.opends.server.util.StaticUtils.*;
-
-/**
- * This class is handling server group CLI.
- */
-public class DsFrameworkCliAds implements DsFrameworkCliSubCommandGroup
-{
- /**
- * The subcommand Parser.
- */
- private DsFrameworkCliParser argParser;
-
- /**
- * The enumeration containing the different subCommand names.
- */
- private enum SubCommandNameEnum
- {
- /**
- * The create-ads subcommand.
- */
- CREATE_ADS("create-ads"),
-
- /**
- * The delete-ads subcommand.
- */
- DELETE_ADS("delete-ads");
-
- /** String representation of the value. */
- private final String name;
-
- /** Private constructor. */
- private SubCommandNameEnum(String name)
- {
- this.name = name;
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString()
- {
- return name;
- }
-
- /** A lookup table for resolving a unit from its name. */
- private static final List<String> nameToSubCmdName ;
- static
- {
- nameToSubCmdName = new ArrayList<String>();
-
- for (SubCommandNameEnum subCmd : SubCommandNameEnum.values())
- {
- nameToSubCmdName.add(subCmd.toString());
- }
- }
- public static boolean isSubCommand(String name)
- {
- return nameToSubCmdName.contains(name);
- }
- }
-
- /**
- * The 'create-ads' subcommand.
- */
- public SubCommand createAdsSubCmd;
-
- /**
- * The 'backend-name' argument of the 'create-ads' subcommand.
- */
- private StringArgument createAdsBackendNameArg;
-
- /**
- * The 'delete-ads' subcommand.
- */
- private SubCommand deleteAdsSubCmd;
-
- /**
- * The 'backend-name' argument of the 'delete-ads' subcommand.
- */
- private StringArgument deleteAdsBackendNameArg;
-
- /**
- * The subcommand list.
- */
- private HashSet<SubCommand> subCommands = new HashSet<SubCommand>();
-
- /**
- * Indicates whether this subCommand should be hidden in the usage
- * information.
- */
- private boolean isHidden;
-
- /**
- * The subcommand group name.
- */
- private String groupName;
-
- /** {@inheritDoc} */
- @Override
- public Set<SubCommand> getSubCommands()
- {
- return subCommands;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isHidden()
- {
- return isHidden;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getGroupName()
- {
- return groupName;
- }
-
- /** {@inheritDoc} */
- @Override
- public void initializeCliGroup(DsFrameworkCliParser argParser,
- BooleanArgument verboseArg)
- throws ArgumentException
- {
-
- isHidden = true;
- groupName = "ads";
- this.argParser = argParser;
-
- // Create-ads subcommand
- createAdsSubCmd = new SubCommand(argParser, SubCommandNameEnum.CREATE_ADS
- .toString(), INFO_ADMIN_SUBCMD_CREATE_ADS_DESCRIPTION.get());
- createAdsSubCmd.setHidden(true);
- subCommands.add(createAdsSubCmd);
-
- createAdsBackendNameArg = new StringArgument("backendName",
- OPTION_SHORT_BACKENDNAME, OPTION_LONG_BACKENDNAME, false, true,
- INFO_BACKENDNAME_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_BACKENDNAME_DESCRIPTION.get());
- createAdsSubCmd.addArgument(createAdsBackendNameArg);
-
- // delete-ads
- deleteAdsSubCmd = new SubCommand(argParser,SubCommandNameEnum.DELETE_ADS
- .toString(), INFO_ADMIN_SUBCMD_DELETE_ADS_DESCRIPTION.get());
- deleteAdsSubCmd.setHidden(true);
- subCommands.add(deleteAdsSubCmd);
-
- deleteAdsBackendNameArg = new StringArgument("backendName",
- OPTION_SHORT_BACKENDNAME, OPTION_LONG_BACKENDNAME, true, true,
- INFO_BACKENDNAME_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_BACKENDNAME_DESCRIPTION.get());
- deleteAdsSubCmd.addArgument(deleteAdsBackendNameArg);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isSubCommand(SubCommand subCmd)
- {
- return SubCommandNameEnum.isSubCommand(subCmd.getName());
- }
-
-
- /** {@inheritDoc} */
- @Override
- public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd,
- OutputStream outStream, OutputStream errStream)
- throws ADSContextException, ArgumentException
- {
- ADSContext adsCtx = null ;
- InitialLdapContext ctx = null ;
-
- DsFrameworkCliReturnCode returnCode = ERROR_UNEXPECTED;
-
- try
- {
- // create-ads subcommand
- if (subCmd.getName().equals(createAdsSubCmd.getName()))
- {
- String backendName = null;
- if (createAdsBackendNameArg.isPresent())
- {
- backendName = createAdsBackendNameArg.getValue();
- }
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx);
- adsCtx.createAdminData(backendName);
- returnCode = SUCCESSFUL;
- }
- else if (subCmd.getName().equals(deleteAdsSubCmd.getName()))
- {
- String backendName = deleteAdsBackendNameArg.getValue();
- ADSContextHelper helper = new ADSContextHelper();
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx);
- helper
- .removeAdministrationSuffix(adsCtx.getDirContext(), backendName);
- returnCode = SUCCESSFUL;
- }
- else
- {
- // Should never occurs: If we are here, it means that the code to
- // handle to subcommand is not yet written.
- returnCode = ERROR_UNEXPECTED;
- }
- }
- catch (ADSContextException e)
- {
- throw e;
- }
- finally
- {
- close(ctx);
- }
-
- // return part
- return returnCode;
- }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliGlobalAdmin.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliGlobalAdmin.java
deleted file mode 100644
index a17f29b..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliGlobalAdmin.java
+++ /dev/null
@@ -1,832 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2007-2009 Sun Microsystems, Inc.
- * Portions Copyright 2011-2014 ForgeRock AS
- */
-package org.opends.server.admin.client.cli;
-
-import static org.opends.messages.AdminMessages.*;
-import static org.opends.messages.DSConfigMessages.*;
-import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
-import static org.opends.server.tools.ToolConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.naming.ldap.InitialLdapContext;
-
-import org.opends.admin.ads.ADSContext;
-import org.opends.admin.ads.ADSContextException;
-import org.opends.admin.ads.ADSContext.AdministratorProperty;
-import org.opends.admin.ads.ADSContextException.ErrorType;
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.opends.server.tools.dsconfig.ArgumentExceptionFactory;
-import org.opends.server.types.Privilege;
-import com.forgerock.opendj.cli.Argument;
-import com.forgerock.opendj.cli.ArgumentException;
-import com.forgerock.opendj.cli.BooleanArgument;
-import com.forgerock.opendj.cli.StringArgument;
-import com.forgerock.opendj.cli.SubCommand;
-import org.opends.server.util.table.TableBuilder;
-import org.opends.server.util.table.TextTablePrinter;
-
-/**
- * This class is handling user Admin CLI.
- */
-public class DsFrameworkCliGlobalAdmin implements DsFrameworkCliSubCommandGroup
-{
- // Strings used in property help.
- private static final LocalizableMessage DESCRIPTION_OPTIONS_TITLE =
- INFO_DSCFG_HELP_DESCRIPTION_OPTION.get();
-
- private static final LocalizableMessage DESCRIPTION_OPTIONS_READ =
- INFO_DSCFG_HELP_DESCRIPTION_READ.get();
-
- private static final LocalizableMessage DESCRIPTION_OPTIONS_WRITE =
- INFO_DSCFG_HELP_DESCRIPTION_WRITE.get();
-
- private static final LocalizableMessage DESCRIPTION_OPTIONS_MANDATORY =
- INFO_DSCFG_HELP_DESCRIPTION_MANDATORY.get();
-
- private static final LocalizableMessage DESCRIPTION_OPTIONS_SINGLE =
- INFO_DSCFG_HELP_DESCRIPTION_SINGLE_VALUED.get();
-
- /**
- * The subcommand Parser.
- */
- private DsFrameworkCliParser argParser;
-
- /**
- * The enumeration containing the different subCommand names.
- */
- private enum SubCommandNameEnum
- {
- /**
- * The create-admin-user subcommand.
- */
- CREATE_ADMIN_USER("create-admin-user"),
-
- /**
- * The delete-admin-user subcommand.
- */
- DELETE_ADMIN_USER("delete-admin-user"),
-
- /**
- * The list-admin-user subcommand.
- */
- LIST_ADMIN_USER("list-admin-user"),
-
- /**
- * The list-admin-user-properties subcommand.
- */
- LIST_ADMIN_USER_PROPERTIES("list-admin-user-properties"),
-
- /**
- * The get-admin-user-properties subcommand.
- */
- GET_ADMIN_USER_PROPERTIES("get-admin-user-properties"),
-
- /**
- * The set-admin-user-properties subcommand.
- */
- SET_ADMIN_USER_PROPERTIES("set-admin-user-properties");
-
-
- /** String representation of the value. */
- private final String name;
-
- /** Private constructor. */
- private SubCommandNameEnum(String name)
- {
- this.name = name;
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString()
- {
- return name;
- }
-
- /** A lookup table for resolving a unit from its name. */
- private static final List<String> nameToSubCmdName;
- static
- {
- nameToSubCmdName = new ArrayList<String>();
-
- for (SubCommandNameEnum subCmd : SubCommandNameEnum.values())
- {
- nameToSubCmdName.add(subCmd.toString());
- }
- }
-
- public static boolean isSubCommand(String name)
- {
- return nameToSubCmdName.contains(name);
- }
- }
-
- /**
- * The create-admin-user subcommand.
- */
- private SubCommand createAdminUserSubCmd;
-
- /**
- * The 'userID' argument of the 'create-admin-user' subcommand.
- */
- private StringArgument createAdminUserUserIdArg;
-
- /**
- * The 'set' argument of the 'create-admin-user' subcommand.
- */
- private StringArgument createAdminUserSetArg ;
-
- /**
- * The delete-admin-user subcommand.
- */
- private SubCommand deleteAdminUserSubCmd;
-
- /**
- * The 'userID' argument of the 'delete-admin-user' subcommand.
- */
- private StringArgument deleteAdminUserUserIdArg;
-
- /**
- * The list-admin-user subcommand.
- */
- private SubCommand listAdminUserSubCmd;
-
- /**
- * The get-admin-user-properties subcommand.
- */
- private SubCommand getAdminUserPropertiesSubCmd;
-
- /**
- * The 'userID' argument of the 'get-admin-user-properties' subcommand.
- */
- private StringArgument getAdminUserPropertiesUserIdArg;
-
- /**
- * The set-admin-user-properties subcommand.
- */
- private SubCommand setAdminUserPropertiesSubCmd;
-
- /**
- * The 'userID' argument of the 'set-admin-user-properties' subcommand.
- */
- private StringArgument setAdminUserPropertiesUserIdArg;
-
- /**
- * The 'set' argument of the 'set-admin-user-properties' subcommand.
- */
- private StringArgument setAdminUserPropertiesSetArg;
-
-
- /**
- * The list-admin-user-properties subcommand.
- */
- private SubCommand listAdminUserPropertiesSubCmd;
-
- /**
- * Association between ADSContext enum and properties.
- */
- private HashMap<AdministratorProperty, Argument> userAdminProperties;
-
- /**
- * List of read-only server properties.
- */
- private HashSet<AdministratorProperty> readonlyadminUserProperties;
-
-
- /**
- * The subcommand list.
- */
- private final HashSet<SubCommand> subCommands = new HashSet<SubCommand>();
-
- /**
- * Indicates whether this subCommand should be hidden in the usage
- * information.
- */
- private boolean isHidden;
-
- /**
- * The subcommand group name.
- */
- private String groupName;
-
- /** {@inheritDoc} */
- @Override
- public Set<SubCommand> getSubCommands()
- {
- return subCommands;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isHidden()
- {
- return isHidden;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getGroupName()
- {
- return groupName;
- }
-
- /** {@inheritDoc} */
- @Override
- public void initializeCliGroup(DsFrameworkCliParser argParser,
- BooleanArgument verboseArg) throws ArgumentException
- {
- isHidden = false;
- groupName = "admin-user";
- this.argParser = argParser;
-
- // create-admin-user subcommand.
- createAdminUserSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.CREATE_ADMIN_USER.toString(),
- INFO_ADMIN_SUBCMD_CREATE_ADMIN_USER_DESCRIPTION.get());
- subCommands.add(createAdminUserSubCmd);
-
- createAdminUserUserIdArg = new StringArgument("userID", null,
- OPTION_LONG_USERID, false, true, INFO_USERID_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_USERID_DESCRIPTION.get());
- createAdminUserSubCmd.addArgument(createAdminUserUserIdArg);
-
- createAdminUserSetArg = new StringArgument(OPTION_LONG_SET,
- OPTION_SHORT_SET, OPTION_LONG_SET, false, true, true,
- INFO_VALUE_SET_PLACEHOLDER.get(), null, null,
- INFO_DSCFG_DESCRIPTION_PROP_VAL.get());
- createAdminUserSubCmd.addArgument(createAdminUserSetArg);
-
- // delete-admin-user subcommand.
- deleteAdminUserSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.DELETE_ADMIN_USER.toString(),
- INFO_ADMIN_SUBCMD_DELETE_ADMIN_USER_DESCRIPTION.get());
- subCommands.add(deleteAdminUserSubCmd);
-
- deleteAdminUserUserIdArg = new StringArgument("userID", null,
- OPTION_LONG_USERID, false, true, INFO_USERID_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_USERID_DESCRIPTION.get());
- deleteAdminUserSubCmd.addArgument(deleteAdminUserUserIdArg);
-
- // list-admin-user subcommand.
- listAdminUserSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.LIST_ADMIN_USER.toString(),
- INFO_ADMIN_SUBCMD_LIST_ADMIN_USER_DESCRIPTION.get());
- subCommands.add(listAdminUserSubCmd);
-
- // get-admin-user-properties subcommand.
- getAdminUserPropertiesSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.GET_ADMIN_USER_PROPERTIES.toString(),
- INFO_ADMIN_SUBCMD_GET_ADMIN_USER_PROPERTIES_DESCRIPTION.get());
- subCommands.add(getAdminUserPropertiesSubCmd);
-
- getAdminUserPropertiesUserIdArg = new StringArgument("userID", null,
- OPTION_LONG_USERID, false, true, INFO_USERID_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_USERID_DESCRIPTION.get());
- getAdminUserPropertiesUserIdArg.setMultiValued(true);
- getAdminUserPropertiesSubCmd.addArgument(getAdminUserPropertiesUserIdArg);
-
- // set-admin-user-properties subcommand.
- setAdminUserPropertiesSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.SET_ADMIN_USER_PROPERTIES.toString(),
- INFO_ADMIN_SUBCMD_SET_ADMIN_USER_PROPERTIES_DESCRIPTION.get());
- subCommands.add(setAdminUserPropertiesSubCmd);
-
- setAdminUserPropertiesUserIdArg = new StringArgument("userID", null,
- OPTION_LONG_USERID, false, true, INFO_USERID_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_USERID_DESCRIPTION.get());
- setAdminUserPropertiesSubCmd.addArgument(setAdminUserPropertiesUserIdArg);
-
- setAdminUserPropertiesSetArg = new StringArgument(OPTION_LONG_SET,
- OPTION_SHORT_SET, OPTION_LONG_SET, false, true, true,
- INFO_VALUE_SET_PLACEHOLDER.get(), null, null,
- INFO_DSCFG_DESCRIPTION_PROP_VAL.get());
- setAdminUserPropertiesSubCmd.addArgument(setAdminUserPropertiesSetArg);
-
- // list-admin-user-properties subcommand.
- listAdminUserPropertiesSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.LIST_ADMIN_USER_PROPERTIES.toString(),
- INFO_ADMIN_SUBCMD_LIST_ADMIN_USER_PROPERTIES_DESCRIPTION.get());
- subCommands.add(listAdminUserPropertiesSubCmd);
-
- // Create association between ADSContext enum and server
- // properties
- // Server properties are mapped to Argument.
- userAdminProperties = new HashMap<AdministratorProperty, Argument>();
- readonlyadminUserProperties = new HashSet<AdministratorProperty>();
-
- /**
- * The ID used to identify the user.
- */
- {
- AdministratorProperty prop = AdministratorProperty.UID;
- String attName = prop.getAttributeName();
- StringArgument arg = new StringArgument(attName, null,
- attName, false, false, true, LocalizableMessage.raw(""), null, null, null);
- userAdminProperties.put(prop, arg);
- }
-
- /**
- * The PASSWORD used to identify the user.
- */
- {
- // TODO : Allow file based password
- AdministratorProperty prop = AdministratorProperty.PASSWORD;
- String attName = prop.getAttributeName();
- StringArgument arg = new StringArgument(attName, null,
- attName, false, false, true, LocalizableMessage.raw(""), null, null, null);
- userAdminProperties.put(prop, arg);
- }
-
- /**
- * The DESCRIPTION used to identify the user.
- */
- {
- AdministratorProperty prop = AdministratorProperty.DESCRIPTION;
- String attName = prop.getAttributeName();
- StringArgument arg = new StringArgument(attName, null,
- attName, false, false, true, LocalizableMessage.raw(""), null, null, null);
- userAdminProperties.put(prop, arg);
- }
-
- /**
- * The ADMINISTRATOR_DN used to identify the user.
- */
- {
- AdministratorProperty prop = AdministratorProperty.ADMINISTRATOR_DN;
- String attName = prop.getAttributeName();
- StringArgument arg = new StringArgument(attName, null,
- attName, false, false, true, LocalizableMessage.raw(""), null, null, null);
- userAdminProperties.put(prop, arg);
- readonlyadminUserProperties.add(prop);
- }
-
- /**
- * The PRIVILEGE associated to the user.
- */
- {
- AdministratorProperty prop = AdministratorProperty.PRIVILEGE;
- String attName = prop.getAttributeName();
- StringArgument arg = new StringArgument(attName, null,
- attName, true, true, true, LocalizableMessage.raw(""), "root", null, null);
- userAdminProperties.put(prop, arg);
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isSubCommand(SubCommand subCmd)
- {
- return SubCommandNameEnum.isSubCommand(subCmd.getName());
- }
-
- /** {@inheritDoc} */
- @Override
- public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd,
- OutputStream outStream, OutputStream errStream)
- throws ADSContextException, ArgumentException
- {
-
- ADSContext adsCtx = null;
- InitialLdapContext ctx = null;
- DsFrameworkCliReturnCode returnCode = ERROR_UNEXPECTED;
-
- try
- {
- // -----------------------
- // create-admin-user subcommand.
- // -----------------------
- if (subCmd.getName().equals(createAdminUserSubCmd.getName()))
- {
- String userId = createAdminUserUserIdArg.getValue();
- Map<AdministratorProperty, Object> map =
- mapSetOptionsToMap(createAdminUserSetArg,true);
- map.put(AdministratorProperty.UID, userId);
-
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx);
- adsCtx.createAdministrator(map);
-
- returnCode = SUCCESSFUL;
- }
- else
- // -----------------------
- // delete-admin-user subcommand.
- // -----------------------
- if (subCmd.getName().equals(deleteAdminUserSubCmd.getName()))
- {
- String userId = deleteAdminUserUserIdArg.getValue();
- Map<AdministratorProperty, Object> map =
- new HashMap<AdministratorProperty, Object>();
- map.put(AdministratorProperty.UID, userId);
-
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx);
- adsCtx.deleteAdministrator(map);
-
- returnCode = SUCCESSFUL;
- }
- else
- // -----------------------
- // list-admin-user subcommand.
- // -----------------------
- if (subCmd.getName().equals(listAdminUserSubCmd.getName()))
- {
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx);
- Set<Map<AdministratorProperty, Object>> adminUserList = adsCtx
- .readAdministratorRegistry();
-
- PrintStream out = new PrintStream(outStream);
- for (Map<AdministratorProperty, Object> user : adminUserList)
- {
- // print out server ID
- out.println(AdministratorProperty.UID.getAttributeName() + ": "
- + user.get(AdministratorProperty.UID));
- }
- returnCode = SUCCESSFUL;
- }
- else
- // -----------------------
- // get-admin-user-properties subcommand.
- // -----------------------
- if (subCmd.getName().equals(getAdminUserPropertiesSubCmd.getName()))
- {
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx);
- Set<Map<AdministratorProperty, Object>> adsAdminUserList = adsCtx
- .readAdministratorRegistry();
-
- LinkedList<String> userAdminUserList = getAdminUserPropertiesUserIdArg
- .getValues();
- PrintStream out = new PrintStream(outStream);
- for (Map<AdministratorProperty, Object> adminUser : adsAdminUserList)
- {
- String adminUserID = (String) adminUser
- .get(AdministratorProperty.UID);
- if (!userAdminUserList.contains(adminUserID))
- {
- continue;
- }
- // print out the Admin User ID
- out.println(AdministratorProperty.UID.getAttributeName() + ": "
- + adminUser.get(AdministratorProperty.UID));
- for (AdministratorProperty ap : adminUser.keySet())
- {
- if (ap.equals(AdministratorProperty.UID))
- {
- continue;
- }
- out.println(ap.getAttributeName() + ": " + adminUser.get(ap));
- }
- out.println();
- }
- returnCode = SUCCESSFUL;
- }
- else
- // -----------------------
- // set-admin-user-properties subcommand.
- // -----------------------
- if (subCmd.getName().equals(setAdminUserPropertiesSubCmd.getName()))
- {
- Map<AdministratorProperty, Object> map =
- mapSetOptionsToMap(setAdminUserPropertiesSetArg,false);
-
- // if the ID is specify in the --set list, it may mean that
- // the user wants to rename the serverID
- String newServerId = (String) map.get(AdministratorProperty.UID) ;
-
- // replace the serverID in the map
- map.put(AdministratorProperty.UID, setAdminUserPropertiesUserIdArg
- .getValue());
-
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx);
- adsCtx.updateAdministrator(map, newServerId);
- returnCode = SUCCESSFUL;
- }
- else
- // -----------------------
- // list-admin-user-properties subcommand.
- // -----------------------
- if (subCmd.getName().equals(listAdminUserPropertiesSubCmd.getName()))
- {
- PrintStream out = new PrintStream(outStream);
- out.println(DESCRIPTION_OPTIONS_TITLE);
- out.println();
- out.print(" r -- ");
- out.println(DESCRIPTION_OPTIONS_READ);
- out.print(" w -- ");
- out.println(DESCRIPTION_OPTIONS_WRITE);
- out.print(" m -- ");
- out.println(DESCRIPTION_OPTIONS_MANDATORY);
- out.print(" s -- ");
- out.println(DESCRIPTION_OPTIONS_SINGLE);
- out.println();
-
- TableBuilder table = new TableBuilder();
- table.appendHeading(INFO_DSCFG_HEADING_PROPERTY_NAME.get());
- table.appendHeading(INFO_DSCFG_HEADING_PROPERTY_OPTIONS.get());
- table.appendHeading(INFO_DSCFG_HEADING_PROPERTY_SYNTAX.get());
- table.appendHeading(INFO_CLI_HEADING_PROPERTY_DEFAULT_VALUE.get());
- for (AdministratorProperty adminUserProp : userAdminProperties.keySet())
- {
- if (userAdminProperties.get(adminUserProp).isHidden())
- {
- continue;
- }
- table.startRow();
- table.appendCell(adminUserProp.getAttributeName());
- table.appendCell(getPropertyOptionSummary(adminUserProp));
- table.appendCell(adminUserProp.getAttributeSyntax());
- if (userAdminProperties.get(adminUserProp).getDefaultValue() != null)
- {
- table.appendCell(userAdminProperties.get(adminUserProp)
- .getDefaultValue());
- }
- else
- {
- table.appendCell("-");
- }
- }
- TextTablePrinter printer = new TextTablePrinter(outStream);
- table.print(printer);
- returnCode = SUCCESSFUL;
- }
- // -----------------------
- // ERROR
- // -----------------------
- else
- {
- // Should never occurs: If we are here, it means that the code
- // to handle to subcommand is not yet written.
- throw new ADSContextException(ErrorType.ERROR_UNEXPECTED);
- }
- }
- catch (ADSContextException e)
- {
- throw e;
- }
- finally
- {
- close(ctx);
- }
-
- // return part
- return returnCode;
- }
-
- /**
- * Translate a Set properties a to a MAP.
- *
- * @param propertySetArgument
- * The input set argument.
- * @param createCall
- * Indicates if we should check the presence of mandatory
- * properties and add root privileges.
- * @return The created map.
- * @throws ArgumentException
- * If error error occurs during set parsing.
- */
- private Map<AdministratorProperty, Object> mapSetOptionsToMap(
- StringArgument propertySetArgument, boolean createCall)
- throws ArgumentException
- {
- HashMap<AdministratorProperty, Object> map =
- new HashMap<AdministratorProperty, Object>();
- boolean rootPrivileges = false ;
- for (String m : propertySetArgument.getValues())
- {
- // Parse the property "property:value".
- int sep = m.indexOf(':');
-
- if (sep < 0)
- {
- throw ArgumentExceptionFactory.missingSeparatorInPropertyArgument(m);
- }
-
- if (sep == 0)
- {
- throw ArgumentExceptionFactory.missingNameInPropertyArgument(m);
- }
-
- String propertyName = m.substring(0, sep);
- String value = m.substring(sep + 1, m.length());
- if (value.length() == 0)
- {
- throw ArgumentExceptionFactory.missingValueInPropertyArgument(m);
- }
-
- // Check that propName is a known prop.
- AdministratorProperty adminUserProperty = ADSContext
- .getAdminUserPropFromName(propertyName);
- if (adminUserProperty == null)
- {
- LocalizableMessage message = ERR_CLI_ERROR_PROPERTY_UNRECOGNIZED.get(propertyName);
- throw new ArgumentException(message);
- }
-
- // Check that propName is not hidden.
- if (userAdminProperties.get(adminUserProperty).isHidden())
- {
- LocalizableMessage message = ERR_CLI_ERROR_PROPERTY_UNRECOGNIZED.get(propertyName);
- throw new ArgumentException(message);
- }
-
- // Check the property Syntax.
- LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
- Argument arg = userAdminProperties.get(adminUserProperty) ;
- if ( ! arg.valueIsAcceptable(value, invalidReason))
- {
- LocalizableMessage message =
- ERR_CLI_ERROR_INVALID_PROPERTY_VALUE.get(propertyName, value);
- throw new ArgumentException(message);
- }
- if (adminUserProperty.equals(AdministratorProperty.PRIVILEGE))
- {
- // Check if 'root' privilege is requested, or
- // if it's a valid privilege
- if (value.equals(arg.getDefaultValue()))
- {
- rootPrivileges = true ;
- }
- else
- {
- String valueToCheck = value ;
- if (value.startsWith("-"))
- {
- valueToCheck = value.substring(1);
- }
- if (Privilege.privilegeForName(valueToCheck) == null)
- {
- LocalizableMessage message = ERR_CLI_ERROR_INVALID_PROPERTY_VALUE.get(
- AdministratorProperty.PRIVILEGE.getAttributeName(),
- valueToCheck);
- throw new ArgumentException(message);
- }
- }
- }
-
- // Add the value to the argument.
- arg.addValue(value);
-
- // add to the map.
- if (arg.isMultiValued())
- {
- map.put(adminUserProperty, arg.getValues());
- }
- else
- {
- map.put(adminUserProperty, value);
- }
- }
-
- // If we are not in the create admin user, just return the
- // provided atributes.
- if (! createCall)
- {
- return map ;
- }
-
- // Here, we are in the create case.
- // If privileges was not provided by the user, set the default value
- if (! map.containsKey(AdministratorProperty.PRIVILEGE))
- {
- rootPrivileges = true ;
- }
-
- // If we have root privilege, translate it to the corresponding
- // list of privileges associated to 'root' user.
- if (rootPrivileges)
- {
- LinkedList<String> privilegesList = new LinkedList<String>();
- for (Privilege p : Privilege.getDefaultRootPrivileges())
- {
- privilegesList.add(p.getName());
- }
- map.put(AdministratorProperty.PRIVILEGE,privilegesList);
- }
-
- for (AdministratorProperty s : AdministratorProperty.values())
- {
- Argument arg = userAdminProperties.get(s);
- if (arg.isHidden())
- {
- continue;
- }
- if (map.containsKey(s))
- {
- continue ;
- }
- if ( ! arg.isRequired())
- {
- continue ;
- }
-
- // If we are here, it means that the argument is required
- // but not yet is the map. Check if we have a default value.
- if (arg.getDefaultValue() == null)
- {
- LocalizableMessage message =
- ERR_CLI_ERROR_MISSING_PROPERTY.get(s.getAttributeName());
- throw new ArgumentException(message);
- }
- else
- {
- map.put(s, arg.getDefaultValue());
- }
- }
- return map;
- }
-
- /** Compute the options field. */
- private String getPropertyOptionSummary(AdministratorProperty adminUserProp)
- {
- Argument arg = userAdminProperties.get(adminUserProp);
- StringBuilder b = new StringBuilder();
-
- if (readonlyadminUserProperties.contains(adminUserProp))
- {
- b.append("r-"); //$NON-NLS-1$
- }
- else
- {
- b.append("rw"); //$NON-NLS-1$
- }
-
- if (arg.isRequired())
- {
- b.append('m');
- }
- else
- {
- b.append('-');
- }
-
- if (arg.isMultiValued())
- {
- b.append('-');
- }
- else
- {
- b.append('s');
- }
- return b.toString();
- }
-
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliMain.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliMain.java
deleted file mode 100644
index 716769d..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliMain.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2013-2014 ForgeRock AS
- */
-package org.opends.server.admin.client.cli;
-import org.forgerock.i18n.LocalizableMessage;
-
-import java.io.OutputStream;
-import java.io.PrintStream;
-
-import org.opends.admin.ads.ADSContextException;
-import org.opends.server.admin.ClassLoaderProvider;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.InitializationException;
-import org.opends.server.types.NullOutputStream;
-import org.opends.server.util.BuildVersion;
-import org.opends.server.util.StaticUtils;
-import com.forgerock.opendj.cli.ArgumentException;
-
-import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
-import static org.opends.messages.AdminMessages.*;
-import static org.opends.messages.DSConfigMessages.*;
-import static org.opends.messages.ToolMessages.*;
-
-import org.forgerock.i18n.LocalizableMessageBuilder;
-
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
-
-/**
- * This class provides a tool that can be used to Directory Server framework
- * services.
- */
-public class DsFrameworkCliMain
-{
- /**
- * The fully-qualified name of this class.
- */
- private static final String CLASS_NAME =
- "org.opends.server.admin.client.cli.DsFrameworkCliMain";
-
- // The print stream to use for standard error.
- private PrintStream err;
-
- // The print stream to use for standard output.
- private PrintStream out;
-
-
-
- /**
- * Constructor for the DsFrameworkCLI object.
- *
- * @param out The print stream to use for standard output.
- * @param err The print stream to use for standard error.
- */
- public DsFrameworkCliMain(PrintStream out, PrintStream err)
- {
- this.out = out;
- this.err = err;
- }
-
- /**
- * The main method for dsframework tool.
- *
- * @param args The command-line arguments provided to this program.
- */
-
- public static void main(String[] args)
- {
- int retCode = mainCLI(args, true, System.out, System.err);
-
- if(retCode != 0)
- {
- System.exit(retCode);
- }
- }
-
- /**
- * Parses the provided command-line arguments and uses that information to
- * run the dsframework tool.
- *
- * @param args The command-line arguments provided to this program.
- *
- * @return The error code.
- */
-
- public static int mainCLI(String[] args)
- {
- return mainCLI(args, true, System.out, System.err);
- }
-
- /**
- * Parses the provided command-line arguments and uses that information to
- * run the dsframework tool.
- *
- * @param args The command-line arguments provided to this
- * program.
- * @param initializeServer Indicates whether to initialize the server.
- * @param outStream The output stream to use for standard output, or
- * <CODE>null</CODE> if standard output is not
- * needed.
- * @param errStream The output stream to use for standard error, or
- * <CODE>null</CODE> if standard error is not
- * needed.
- * @return The error code.
- */
-
- public static int mainCLI(String[] args, boolean initializeServer,
- OutputStream outStream, OutputStream errStream)
- {
- PrintStream out = NullOutputStream.wrapOrNullStream(outStream);
- PrintStream err = NullOutputStream.wrapOrNullStream(errStream);
-
- DsFrameworkCliMain dsFrameworkCli = new DsFrameworkCliMain(out, err);
- return dsFrameworkCli.execute(args,initializeServer);
- }
-
- /**
- * Parses the provided command-line arguments and uses that information to
- * run the dsframework tool.
- *
- * @param args The command-line arguments provided to this
- * program.
- * @param initializeServer Indicates whether to initialize the server.
- *
- * @return The error code.
- */
- public int execute(String[] args, boolean initializeServer)
- {
- // Create the command-line argument parser for use with this
- // program.
- DsFrameworkCliParser argParser ;
- try
- {
- LocalizableMessage toolDescription = INFO_ADMIN_TOOL_DESCRIPTION.get();
- argParser = new DsFrameworkCliParser(CLASS_NAME,
- toolDescription, false);
- argParser.initializeParser(out);
- }
- catch (ArgumentException ae)
- {
- LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
-
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return CANNOT_INITIALIZE_ARGS.getReturnCode();
- }
-
- // Parse the command-line arguments provided to this program.
- try
- {
- argParser.parseArguments(args);
- }
- catch (ArgumentException ae)
- {
- LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
-
- err.println(wrapText(message, MAX_LINE_WIDTH));
- err.println(argParser.getUsage());
- return ERROR_PARSING_ARGS.getReturnCode();
- }
-
- // If we should just display usage information, then print it and exit.
- if (argParser.usageOrVersionDisplayed())
- {
- return SUCCESSFUL.getReturnCode();
- }
-
- // Checks the version - if upgrade required, the tool is unusable
- try
- {
- BuildVersion.checkVersionMismatch();
- }
- catch (InitializationException e)
- {
- err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
- return 1;
- }
-
- if (argParser.getSubCommand() == null)
- {
- LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(
- ERR_DSCFG_ERROR_MISSING_SUBCOMMAND.get());
- err.println(wrapText(message, MAX_LINE_WIDTH));
- err.println();
- err.println(argParser.getHelpUsageReference());
- return ERROR_PARSING_ARGS.getReturnCode();
- }
-
- // Validate args
- int ret = argParser.validateGlobalOptions(err);
- if (ret != SUCCESSFUL_NOP.getReturnCode())
- {
- return ret;
- }
-
- // Check if we need a connection
-
- DsFrameworkCliReturnCode returnCode = SUCCESSFUL;
-
-
- // Should we initialize the server in client mode?
- if (initializeServer)
- {
- // Bootstrap and initialize directory data structures.
- DirectoryServer.bootstrapClient();
-
- // Bootstrap definition classes.
- try
- {
- ClassLoaderProvider.getInstance().enable();
- }
- catch (InitializationException e)
- {
- err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
- return ERROR_UNEXPECTED.getReturnCode();
- }
- catch (IllegalStateException e)
- {
- err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
- return ERROR_UNEXPECTED.getReturnCode();
- }
- }
-
- // perform the subCommand
- ADSContextException adsException = null;
- try
- {
- returnCode = argParser.performSubCommand(out, err);
- }
- catch (ADSContextException e)
- {
- adsException = e;
- returnCode = DsFrameworkCliReturnCode.getReturncodeFromAdsError(e
- .getError());
- if (returnCode == null)
- {
- returnCode = ERROR_UNEXPECTED;
- }
- }
- catch (ArgumentException ae)
- {
- LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
-
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return CANNOT_INITIALIZE_ARGS.getReturnCode();
- }
-
- LocalizableMessage msg = returnCode.getMessage();
- if ( (returnCode == SUCCESSFUL)
- ||
- (returnCode == SUCCESSFUL_NOP))
- {
- if (argParser.isVerbose())
- {
- out.println(wrapText(msg.toString(), MAX_LINE_WIDTH));
- }
- }
- else
- if (msg != null && StaticUtils.hasDescriptor(msg, ERR_ADMIN_NO_MESSAGE))
- {
- LocalizableMessageBuilder mb = new LocalizableMessageBuilder(INFO_ADMIN_ERROR.get());
- mb.append(msg);
- err.println(wrapText(mb.toString(), MAX_LINE_WIDTH));
- if (argParser.isVerbose() && (adsException != null))
- {
- adsException.printStackTrace();
- }
- }
- return returnCode.getReturnCode();
- }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliParser.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliParser.java
deleted file mode 100644
index ae6b489..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliParser.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2009 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.admin.client.cli;
-
-import static org.opends.messages.AdminMessages.*;
-import static org.opends.messages.DSConfigMessages.*;
-import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
-import static org.opends.server.tools.ToolConstants.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import javax.naming.NamingException;
-import javax.naming.ldap.InitialLdapContext;
-
-import org.opends.admin.ads.ADSContextException;
-import org.opends.admin.ads.util.ConnectionUtils;
-import org.forgerock.i18n.LocalizableMessage;
-import com.forgerock.opendj.cli.ArgumentException;
-import com.forgerock.opendj.cli.BooleanArgument;
-import com.forgerock.opendj.cli.SubCommand;
-
-/**
- * This class will parse CLI arguments for the dsframework command lines.
- */
-public class DsFrameworkCliParser extends SecureConnectionCliParser
-{
- /**
- * The different CLI group.
- */
- public HashSet<DsFrameworkCliSubCommandGroup> cliGroup;
-
-
- // This CLI is always using the administration connector with SSL
- private final boolean alwaysSSL = true;
-
-
- /**
- * Creates a new instance of this subcommand argument parser with no
- * arguments.
- *
- * @param mainClassName
- * The fully-qualified name of the Java class that should
- * be invoked to launch the program with which this
- * argument parser is associated.
- * @param toolDescription
- * A human-readable description for the tool, which will be
- * included when displaying usage information.
- * @param longArgumentsCaseSensitive
- * Indicates whether subcommand and long argument names
- * should be treated in a case-sensitive manner.
- */
- public DsFrameworkCliParser(String mainClassName, LocalizableMessage toolDescription,
- boolean longArgumentsCaseSensitive)
- {
- super(mainClassName, toolDescription, longArgumentsCaseSensitive);
- cliGroup = new HashSet<DsFrameworkCliSubCommandGroup>();
- }
-
- /**
- * Initialize the parser with the Global options and subcommands.
- *
- * @param outStream
- * The output stream to use for standard output, or <CODE>null</CODE>
- * if standard output is not needed.
- * @throws ArgumentException
- * If there is a problem with any of the parameters used
- * to create this argument.
- */
- public void initializeParser(OutputStream outStream)
- throws ArgumentException
- {
- // Global parameters
- initializeGlobalArguments(createGlobalArguments(outStream, alwaysSSL));
-
- // ads Group cli
- cliGroup.add(new DsFrameworkCliAds());
-
- // Server-group Group cli
- cliGroup.add(new DsFrameworkCliServerGroup());
-
- // Server Group cli
- cliGroup.add(new DsFrameworkCliServer());
-
- // User Admin cli
- cliGroup.add(new DsFrameworkCliGlobalAdmin());
-
- // Initialization
- Comparator<SubCommand> c = new Comparator<SubCommand>() {
-
- public int compare(SubCommand o1, SubCommand o2) {
- return o1.getName().compareTo(o2.getName());
- }
- };
-
- SortedSet<SubCommand> allSubCommands = new TreeSet<SubCommand>(c);
-
- for (DsFrameworkCliSubCommandGroup oneCli : cliGroup)
- {
- oneCli.initializeCliGroup(this, verboseArg);
- Set<SubCommand> oneCliSubCmds = oneCli.getSubCommands() ;
- allSubCommands.addAll(oneCliSubCmds);
-
- // register group help
- String grpName = oneCli.getGroupName();
- String option = OPTION_LONG_HELP + "-" + grpName;
- BooleanArgument arg = new BooleanArgument(option, null, option,
- INFO_DSCFG_DESCRIPTION_SHOW_GROUP_USAGE.get(grpName));
- addGlobalArgument(arg);
- arg.setHidden(oneCli.isHidden());
- TreeSet<SubCommand> subCmds = new TreeSet<SubCommand>(c);
- subCmds.addAll(oneCliSubCmds);
- setUsageGroupArgument(arg, subCmds);
- }
-
- // Register the --help-all argument.
- String option = OPTION_LONG_HELP + "-all";
- BooleanArgument arg = new BooleanArgument(option, null, option,
- INFO_DSCFG_DESCRIPTION_SHOW_GROUP_USAGE_ALL.get());
-
- addGlobalArgument(arg);
- setUsageGroupArgument(arg, allSubCommands);
-
- }
-
-
-
- /**
- * Handle the subcommand.
- * @param outStream The output stream to use for standard output.
- * @param errStream The output stream to use for standard error.
- *
- * @return the return code
- * @throws ADSContextException
- * If there is a problem with when trying to perform the
- * operation.
- * @throws ArgumentException
- * If there is a problem with any of the parameters used
- * to execute this subcommand.
- */
- public DsFrameworkCliReturnCode performSubCommand(OutputStream outStream,
- OutputStream errStream)
- throws ADSContextException, ArgumentException
- {
- SubCommand subCmd = getSubCommand();
-
- for (DsFrameworkCliSubCommandGroup oneCli : cliGroup)
- {
- if (oneCli.isSubCommand(subCmd))
- {
- return oneCli.performSubCommand( subCmd, outStream, errStream);
- }
- }
-
- // Should never occurs: If we are here, it means that the code to
- // handle to subcommand is not yet written.
- return ERROR_UNEXPECTED;
- }
-
-
- /**
- * Get the InitialLdapContext that has to be used for the ADS.
- * @param out The output stream to use for standard output.
- * @param err The output stream to use for standard error.
- *
- * @return The InitialLdapContext that has to be used for the ADS.
- */
- public InitialLdapContext getContext(OutputStream out, OutputStream err)
- {
- // Get connection parameters
- String host = null ;
- String port = null;
- String dn = null ;
- String pwd = null;
- InitialLdapContext ctx = null;
-
- // Get connection parameters
- host = ConnectionUtils.getHostNameForLdapUrl(getHostName());
- port = getPort();
- dn = getBindDN();
- pwd = getBindPassword(dn, out, err);
-
- // Try to connect
- if (useSSL())
- {
- String ldapsUrl = "ldaps://" + host + ":" + port;
- try
- {
- ctx = ConnectionUtils.createLdapsContext(ldapsUrl, dn, pwd,
- ConnectionUtils.getDefaultLDAPTimeout(), null,getTrustManager(),
- getKeyManager());
- }
- catch (NamingException e)
- {
- LocalizableMessage message = ERR_ADMIN_CANNOT_CONNECT_TO_ADS.get(host);
- try
- {
- err.write(wrapText(message, MAX_LINE_WIDTH).getBytes());
- err.write(EOL.getBytes());
- }
- catch (IOException e1)
- {
- }
- return null;
- }
- }
- else if (useStartTLS())
- {
- String ldapUrl = "ldap://" + host + ":" + port;
- try
- {
- ctx = ConnectionUtils.createStartTLSContext(ldapUrl, dn, pwd,
- ConnectionUtils.getDefaultLDAPTimeout(), null, getTrustManager(),
- getKeyManager(), null);
- }
- catch (NamingException e)
- {
- LocalizableMessage message = ERR_ADMIN_CANNOT_CONNECT_TO_ADS.get(host);
- try
- {
- err.write(wrapText(message, MAX_LINE_WIDTH).getBytes());
- err.write(EOL.getBytes());
- }
- catch (IOException e1)
- {
- }
- return null;
- }
- }
- else
- {
- String ldapUrl = "ldap://" + host + ":" + port;
- try
- {
- ctx = ConnectionUtils.createLdapContext(ldapUrl, dn, pwd,
- ConnectionUtils.getDefaultLDAPTimeout(), null);
- }
- catch (NamingException e)
- {
- LocalizableMessage message = ERR_ADMIN_CANNOT_CONNECT_TO_ADS.get(host);
- try
- {
- err.write(wrapText(message, MAX_LINE_WIDTH).getBytes());
- err.write(EOL.getBytes());
- }
- catch (IOException e1)
- {
- }
- return null;
- }
- }
- return ctx;
- }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliReturnCode.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliReturnCode.java
deleted file mode 100644
index 6805c99..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliReturnCode.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2006-2009 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.admin.client.cli;
-import org.forgerock.i18n.LocalizableMessage;
-
-import static org.opends.messages.AdminMessages.*;
-
-
-import java.util.HashMap;
-
-import org.opends.admin.ads.ADSContextException.ErrorType;
-
- /**
- *
- * The enumeration which defines the return code.
- *
- */
- public enum DsFrameworkCliReturnCode
- {
- /**
- * successful.
- */
- SUCCESSFUL(0, INFO_ADMIN_SUCCESSFUL.get()),
-
- /**
- * successful but no operation was performed.
- */
- SUCCESSFUL_NOP(SUCCESSFUL.getReturnCode(), INFO_ADMIN_SUCCESSFUL_NOP.get()),
-
- /**
- * Unable to initialize arguments.
- */
- CANNOT_INITIALIZE_ARGS(1, ERR_ADMIN_NO_MESSAGE.get()),
-
- /**
- * Cannot parse arguments.
- */
- ERROR_PARSING_ARGS(2, ERR_ADMIN_NO_MESSAGE.get()),
- /**
- * Return code: Cannot get the connection to the ADS.
- */
- CANNOT_CONNECT_TO_ADS(3, ERR_ADMIN_NO_MESSAGE.get()),
-
- /**
- * The host name is missing.
- */
- MISSING_HOSTNAME(4, ERR_ADMIN_MISSING_HOSTNAME.get()),
-
- /**
- * The host name is not valid.
- */
- NOVALID_HOSTNAME(5, ERR_ADMIN_NOVALID_HOSTNAME.get()),
-
- /**
- * The installation path is missing.
- */
- MISSING_IPATH(6, ERR_ADMIN_MISSING_IPATH.get()),
-
- /**
- * The installation path is not valid.
- */
- NOVALID_IPATH(7, ERR_ADMIN_NOVALID_IPATH.get()),
-
- /**
- * An access permission error.
- */
- ACCESS_PERMISSION(8, ERR_ADMIN_ACCESS_PERMISSION.get()),
-
- /**
- * The entity is already registered.
- */
- ALREADY_REGISTERED(9, ERR_ADMIN_ALREADY_REGISTERED.get()),
-
- /**
- * The installation is broken.
- */
- BROKEN_INSTALL(10, ERR_ADMIN_BROKEN_INSTALL.get()),
-
- /**
- * The entity is not yet registered.
- */
- NOT_YET_REGISTERED(11, ERR_ADMIN_NOT_YET_REGISTERED.get()),
-
- /**
- * The port is missing.
- */
- MISSING_PORT(12, ERR_ADMIN_MISSING_PORT.get()),
-
- /**
- * The port is not valid.
- */
- NOVALID_PORT(13, ERR_ADMIN_NOVALID_PORT.get()),
-
- /**
- * The name is missing.
- */
- MISSING_NAME(14, ERR_ADMIN_MISSING_NAME.get()),
-
- /**
- * The administration UID is missing.
- */
- MISSING_ADMIN_UID(15, ERR_ADMIN_MISSING_ADMIN_UID.get()),
-
- /**
- * The administrator password is missing.
- */
- MISSING_ADMIN_PASSWORD(16, ERR_ADMIN_MISSING_ADMIN_PASSWORD.get()),
-
- /**
- * Unexpected error (potential bug).
- */
- ERROR_UNEXPECTED(17, ERR_ADMIN_ERROR_UNEXPECTED.get()),
-
- /**
- * Unexpected error (potential bug).
- */
- CONFLICTING_ARGS(18, ERR_ADMIN_NO_MESSAGE.get()),
-
- /**
- * The server entity is not yet registered.
- */
- SERVER_NOT_REGISTERED(19, ERR_ADMIN_SERVER_NOT_REGISTERED.get()),
-
- /**
- * The merge of the ADS cannot be performed.
- */
- ERROR_MERGING(20, ERR_ADMIN_MERGING.get());
-
- // The retunCodevalue of the value.
- private final int returnCode;
-
- // The message id to be used of the value.
- private final LocalizableMessage message;
-
- // Private constructor.
- private DsFrameworkCliReturnCode(int returnCode, LocalizableMessage message)
- {
- this.returnCode = returnCode;
- this.message = message;
- }
-
- /**
- * Get the corresponding message.
- *
- * @return The corresponding message.
- */
- public LocalizableMessage getMessage()
- {
- return message;
- }
-
- /**
- * Get the corresponding return code value.
- *
- * @return The corresponding return code value.
- */
- public int getReturnCode()
- {
- return returnCode;
- }
-
- /**
- * Indicate whenever the association between ADS errors and return
- * has been done.
- */
- private static boolean initialized = false ;
-
- /**
- * The association map between ADS Error and Return code.
- */
- private static HashMap<ErrorType, DsFrameworkCliReturnCode>
- adsErrorToReturnCode = new HashMap<ErrorType, DsFrameworkCliReturnCode>();
-
- /**
- * Associates a set of ADS errors to return code.
- */
- private static void registerAdsError()
- {
- adsErrorToReturnCode.put(ErrorType.MISSING_HOSTNAME,
- MISSING_HOSTNAME);
- adsErrorToReturnCode.put(ErrorType.NOVALID_HOSTNAME,
- NOVALID_HOSTNAME);
- adsErrorToReturnCode.put(ErrorType.MISSING_IPATH,
- MISSING_IPATH);
- adsErrorToReturnCode.put(ErrorType.NOVALID_IPATH,
- NOVALID_IPATH);
- adsErrorToReturnCode.put(ErrorType.ACCESS_PERMISSION,
- ACCESS_PERMISSION);
- adsErrorToReturnCode.put(ErrorType.ALREADY_REGISTERED,
- ALREADY_REGISTERED);
- adsErrorToReturnCode.put(ErrorType.BROKEN_INSTALL,
- BROKEN_INSTALL);
- adsErrorToReturnCode.put(ErrorType.UNEXPECTED_ADS_BACKEND_TYPE,
- BROKEN_INSTALL);
- adsErrorToReturnCode.put(ErrorType.NOT_YET_REGISTERED,
- NOT_YET_REGISTERED);
- adsErrorToReturnCode.put(ErrorType.MISSING_PORT,
- MISSING_PORT);
- adsErrorToReturnCode.put(ErrorType.NOVALID_PORT,
- NOVALID_PORT);
- adsErrorToReturnCode.put(ErrorType.MISSING_NAME,
- MISSING_NAME);
- adsErrorToReturnCode.put(ErrorType.MISSING_ADMIN_UID,
- MISSING_ADMIN_UID);
- adsErrorToReturnCode.put(ErrorType.MISSING_ADMIN_PASSWORD,
- MISSING_ADMIN_PASSWORD);
- adsErrorToReturnCode.put(ErrorType.ERROR_UNEXPECTED,
- ERROR_UNEXPECTED);
- adsErrorToReturnCode.put(ErrorType.ERROR_MERGING,
- ERROR_MERGING);
- }
-
- /**
- * Get ReturnCode from an ADS error.
- * @param error The ADS error
- * @return the ReturnCode associated to the ADS error.
- */
- public static DsFrameworkCliReturnCode
- getReturncodeFromAdsError(ErrorType error)
- {
- if (! initialized)
- {
- registerAdsError();
- initialized = true ;
- }
- return adsErrorToReturnCode.get(error);
- }
- }
-
-
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java
deleted file mode 100644
index 80285cd..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java
+++ /dev/null
@@ -1,956 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2006-2009 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.admin.client.cli;
-
-import static org.opends.messages.AdminMessages.*;
-import static org.opends.messages.DSConfigMessages.*;
-import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
-import static org.opends.server.tools.ToolConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.naming.ldap.InitialLdapContext;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.opends.admin.ads.ADSContext;
-import org.opends.admin.ads.ADSContextException;
-import org.opends.admin.ads.ADSContext.ServerProperty;
-import org.opends.admin.ads.ADSContextException.ErrorType;
-import org.opends.server.tools.dsconfig.ArgumentExceptionFactory;
-import com.forgerock.opendj.cli.Argument;
-import com.forgerock.opendj.cli.ArgumentException;
-import com.forgerock.opendj.cli.BooleanArgument;
-import com.forgerock.opendj.cli.IntegerArgument;
-import com.forgerock.opendj.cli.StringArgument;
-import com.forgerock.opendj.cli.SubCommand;
-import org.opends.server.util.table.TableBuilder;
-import org.opends.server.util.table.TextTablePrinter;
-
-/**
- * This class is handling server group CLI.
- */
-public class DsFrameworkCliServer implements DsFrameworkCliSubCommandGroup
-{
- // Strings used in property help.
- private static final LocalizableMessage DESCRIPTION_OPTIONS_TITLE =
- INFO_DSCFG_HELP_DESCRIPTION_OPTION.get();
-
- private static final LocalizableMessage DESCRIPTION_OPTIONS_READ =
- INFO_DSCFG_HELP_DESCRIPTION_READ.get();
-
- private static final LocalizableMessage DESCRIPTION_OPTIONS_WRITE =
- INFO_DSCFG_HELP_DESCRIPTION_WRITE.get();
-
- private static final LocalizableMessage DESCRIPTION_OPTIONS_MANDATORY =
- INFO_DSCFG_HELP_DESCRIPTION_MANDATORY.get();
-
- private static final LocalizableMessage DESCRIPTION_OPTIONS_SINGLE =
- INFO_DSCFG_HELP_DESCRIPTION_SINGLE_VALUED.get();
-
- /**
- * The subcommand Parser.
- */
- private DsFrameworkCliParser argParser;
-
- /**
- * The enumeration containing the different subCommand names.
- */
- private enum SubCommandNameEnum
- {
- /**
- * The register-server subcommand.
- */
- REGISTER_SERVER("register-server"),
-
- /**
- * The unregister-server subcommand.
- */
- UNREGISTER_SERVER("unregister-server"),
-
- /**
- * The list-servers subcommand.
- */
- LIST_SERVERS("list-servers"),
-
- /**
- * The get-server-properties subcommand.
- */
- GET_SERVER_PROPERTIES("get-server-properties"),
-
- /**
- * The set-server-properties subcommand.
- */
- SET_SERVER_PROPERTIES("set-server-properties"),
-
- /**
- * The list-servers subcommand.
- */
- LIST_SERVER_PROPERTIES("list-server-properties");
-
- /** String representation of the value. */
- private final String name;
-
- /** Private constructor. */
- private SubCommandNameEnum(String name)
- {
- this.name = name;
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString()
- {
- return name;
- }
-
- /** A lookup table for resolving a unit from its name. */
- private static final List<String> nameToSubCmdName;
- static
- {
- nameToSubCmdName = new ArrayList<String>();
-
- for (SubCommandNameEnum subCmd : SubCommandNameEnum.values())
- {
- nameToSubCmdName.add(subCmd.toString());
- }
- }
-
- public static boolean isSubCommand(String name)
- {
- return nameToSubCmdName.contains(name);
- }
- }
-
- /**
- * The 'register-server' subcommand.
- */
- private SubCommand registerServerSubCmd;
-
- /**
- * The 'serverID' argument of the 'register-server' subcommand.
- */
- private StringArgument registerServerServerIdArg;
-
- /**
- * The 'serverName' argument of the 'register-server' subcommand.
- */
- private StringArgument registerServerSetArg;
-
- /**
- * The 'unregister-server' subcommand.
- */
- private SubCommand unregisterServerSubCmd;
-
- /**
- * The 'serverHost' argument of the 'unregister-server' subcommand.
- */
- private StringArgument unregisterServerServerIDArg;
-
- /**
- * The 'list-server-properties' subcommand.
- */
- private SubCommand listServerPropertiesSubCmd;
-
- /**
- * The 'list-servers' subcommand.
- */
- private SubCommand listServersSubCmd;
-
- /**
- * The 'get-server-properties' subcommand.
- */
- private SubCommand getServerPropertiesSubCmd;
-
- /**
- * The 'serverID' argument of the 'get-server-properties' subcommand.
- */
- private StringArgument getServerPropertiesServerIdArg;
-
- /**
- * The 'set-server-properties' subcommand.
- */
- private SubCommand setServerPropertiesSubCmd;
-
- /**
- * The 'serverID' argument of the 'set-server-properties' subcommand.
- */
- private StringArgument setServerPropertiesServerIdArg;
-
- /**
- * The 'serverName' argument of the 'set-server-properties' subcommand.
- */
- private StringArgument setServerPropertiesSetArg;
-
- /**
- * Association between ADSContext enum and properties.
- */
- private HashMap<ServerProperty, Argument> serverProperties;
-
- /**
- * List of read-only server properties.
- */
- private HashSet<ServerProperty> readonlyServerProperties;
-
- /**
- * The subcommand list.
- */
- private final HashSet<SubCommand> subCommands = new HashSet<SubCommand>();
-
- /**
- * Indicates whether this subCommand should be hidden in the usage
- * information.
- */
- private boolean isHidden;
-
- /**
- * The subcommand group name.
- */
- private String groupName;
-
- /** {@inheritDoc} */
- @Override
- public Set<SubCommand> getSubCommands()
- {
- return subCommands;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isHidden()
- {
- return isHidden;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getGroupName()
- {
- return groupName;
- }
-
- /** {@inheritDoc} */
- @Override
- public void initializeCliGroup(DsFrameworkCliParser argParser,
- BooleanArgument verboseArg) throws ArgumentException
- {
- isHidden = false;
- groupName = "server";
- this.argParser = argParser;
-
- // list-server-properties subcommand
- listServerPropertiesSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.LIST_SERVER_PROPERTIES.toString(),
- INFO_ADMIN_SUBCMD_LIST_SERVER_PROPS_DESCRIPTION.get());
- subCommands.add(listServerPropertiesSubCmd);
-
- // register-server subcommand
- registerServerSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.REGISTER_SERVER.toString(),
- INFO_ADMIN_SUBCMD_REGISTER_SERVER_DESCRIPTION.get());
- subCommands.add(registerServerSubCmd);
-
- registerServerServerIdArg = new StringArgument("serverID", null,
- OPTION_LONG_SERVERID, false, true, INFO_SERVERID_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_SERVERID_DESCRIPTION.get());
- registerServerSubCmd.addArgument(registerServerServerIdArg);
-
- registerServerSetArg = new StringArgument(OPTION_LONG_SET,
- OPTION_SHORT_SET, OPTION_LONG_SET, false, true, true,
- INFO_VALUE_SET_PLACEHOLDER.get(), null, null,
- INFO_DSCFG_DESCRIPTION_PROP_VAL.get());
- registerServerSubCmd.addArgument(registerServerSetArg);
-
- // unregister-server subcommand
- unregisterServerSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.UNREGISTER_SERVER.toString(),
- INFO_ADMIN_SUBCMD_UNREGISTER_SERVER_DESCRIPTION.get());
- subCommands.add(unregisterServerSubCmd);
-
- unregisterServerServerIDArg = new StringArgument("serverID", null,
- OPTION_LONG_SERVERID, false, true, INFO_SERVERID_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_SERVERID_DESCRIPTION.get());
- unregisterServerSubCmd.addArgument(unregisterServerServerIDArg);
-
- // list-servers subcommand
- listServersSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.LIST_SERVERS.toString(),
- INFO_ADMIN_SUBCMD_LIST_SERVERS_DESCRIPTION.get());
- subCommands.add(listServersSubCmd);
-
- // get-server-properties subcommand
- getServerPropertiesSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.GET_SERVER_PROPERTIES.toString(),
- INFO_ADMIN_SUBCMD_GET_SERVER_PROPERTIES_DESCRIPTION.get());
- subCommands.add(getServerPropertiesSubCmd);
-
- getServerPropertiesServerIdArg = new StringArgument("serverID", null,
- OPTION_LONG_SERVERID, false, true, INFO_SERVERID_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_SERVERID_DESCRIPTION.get());
- getServerPropertiesServerIdArg.setMultiValued(true);
- getServerPropertiesSubCmd.addArgument(getServerPropertiesServerIdArg);
-
-
- // set-server-properties subcommand
- setServerPropertiesSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.SET_SERVER_PROPERTIES.toString(),
- INFO_ADMIN_SUBCMD_SET_SERVER_PROPERTIES_DESCRIPTION.get());
- subCommands.add(setServerPropertiesSubCmd);
-
- setServerPropertiesServerIdArg = new StringArgument("serverID", null,
- OPTION_LONG_SERVERID, true, true, INFO_SERVERID_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_SERVERID_DESCRIPTION.get());
- setServerPropertiesSubCmd.addArgument(setServerPropertiesServerIdArg);
-
- setServerPropertiesSetArg = new StringArgument(OPTION_LONG_SET,
- OPTION_SHORT_SET, OPTION_LONG_SET, false, true, true,
- INFO_VALUE_SET_PLACEHOLDER.get(), null, null,
- INFO_DSCFG_DESCRIPTION_PROP_VAL.get());
- setServerPropertiesSubCmd.addArgument(setServerPropertiesSetArg);
-
-
- // Create association between ADSContext enum and server
- // properties
- // Server properties are mapped to Argument.
- serverProperties = new HashMap<ServerProperty, Argument>();
- readonlyServerProperties = new HashSet<ServerProperty>();
-
- /**
- * The ID used to identify the server.
- */
- {
- ServerProperty prop = ServerProperty.ID;
- String attName = prop.getAttributeName();
- StringArgument arg = new StringArgument(attName, null,
- prop.getAttributeName(), false, false, true, LocalizableMessage.raw(""), null,
- null, null);
- serverProperties.put(prop, arg);
- }
-
- /**
- * The host name of the server.
- */
- {
- ServerProperty prop = ServerProperty.HOST_NAME;
- String attName = prop.getAttributeName();
- readonlyServerProperties.add(prop);
- StringArgument arg = new StringArgument(attName, null, attName, true,
- false, true, LocalizableMessage.raw(""), "localhost", null, null);
- serverProperties.put(prop, arg);
- }
-
- /**
- * The LDAP port of the server.
- */
- {
- ServerProperty prop = ServerProperty.LDAP_PORT;
- String attName = prop.getAttributeName();
- IntegerArgument arg = new IntegerArgument(attName, null, attName, true,
- true, true, LocalizableMessage.raw(attName), 389, null, null);
- serverProperties.put(prop, arg);
- }
-
- /**
- * The JMX port of the server.
- */
- {
- ServerProperty prop = ServerProperty.JMX_PORT;
- String attName = prop.getAttributeName();
- IntegerArgument arg = new IntegerArgument(attName, null, attName,
- false, true, LocalizableMessage.raw(attName), null);
- arg.setMultiValued(true);
- serverProperties.put(prop, arg);
- }
-
- /**
- * The JMX secure port of the server.
- */
- {
- ServerProperty prop = ServerProperty.JMXS_PORT;
- String attName = prop.getAttributeName();
- IntegerArgument arg = new IntegerArgument(attName, null, attName,
- false, true, LocalizableMessage.raw(attName), null);
- arg.setMultiValued(true);
- serverProperties.put(prop, arg);
- }
-
- /**
- * The LDAPS port of the server.
- */
- {
- ServerProperty prop = ServerProperty.LDAPS_PORT;
- String attName = prop.getAttributeName();
- IntegerArgument arg = new IntegerArgument(attName, null, attName,
- false, true, LocalizableMessage.raw(attName), null);
- arg.setMultiValued(true);
- serverProperties.put(prop, arg);
- }
-
- /**
- * The certificate used by the server.
- */
- {
- ServerProperty prop = ServerProperty.CERTIFICATE;
- String attName = prop.getAttributeName();
- StringArgument arg = new StringArgument(attName, null, attName, false,
- false, true, LocalizableMessage.raw(attName), null, null, null);
- serverProperties.put(prop, arg);
- }
-
- /**
- * The path where the server is installed.
- */
- {
- ServerProperty prop = ServerProperty.INSTANCE_PATH;
- String attName = prop.getAttributeName();
- StringArgument arg = new StringArgument(attName, null, attName, false,
- false, true, LocalizableMessage.raw(attName), null, null, null);
- serverProperties.put(prop, arg);
- }
-
- /**
- * The description of the server.
- */
- {
- ServerProperty prop = ServerProperty.DESCRIPTION;
- String attName = prop.getAttributeName();
- StringArgument arg = new StringArgument(attName, null, attName, false,
- false, true, LocalizableMessage.raw(attName), null, null, null);
- serverProperties.put(prop, arg);
- }
-
- /**
- * The OS of the machine where the server is installed.
- */
- {
- ServerProperty prop = ServerProperty.HOST_OS;
- String attName = prop.getAttributeName();
- StringArgument arg = new StringArgument(attName, null, attName, false,
- false, true, LocalizableMessage.raw(attName), null, null, null);
- serverProperties.put(prop, arg);
- }
-
- /**
- * Whether LDAP is enabled or not.
- */
- {
- ServerProperty prop = ServerProperty.LDAP_ENABLED;
- String attName = prop.getAttributeName();
- BooleanArgument arg = new BooleanArgument(attName, null, attName, null);
- arg.setDefaultValue("false");
- serverProperties.put(prop, arg);
- }
-
- /**
- * Whether LDAPS is enabled or not.
- */
- {
- ServerProperty prop = ServerProperty.LDAPS_ENABLED;
- String attName = prop.getAttributeName();
- BooleanArgument arg = new BooleanArgument(attName, null, attName, null);
- arg.setDefaultValue("false");
- serverProperties.put(prop, arg);
- }
-
- /**
- * Whether StartTLS is enabled or not.
- */
- {
- ServerProperty prop = ServerProperty.STARTTLS_ENABLED;
- String attName = prop.getAttributeName();
- BooleanArgument arg = new BooleanArgument(attName, null, attName, null);
- arg.setDefaultValue("false");
- serverProperties.put(prop, arg);
- }
-
- /**
- * Whether JMX is enabled or not.
- */
- {
- ServerProperty prop = ServerProperty.JMX_ENABLED;
- String attName = prop.getAttributeName();
- BooleanArgument arg = new BooleanArgument(attName, null, attName, null);
- arg.setDefaultValue("false");
- serverProperties.put(prop, arg);
- }
-
- /**
- * Whether JMXS is enabled or not.
- */
- {
- ServerProperty prop = ServerProperty.JMXS_ENABLED;
- String attName = prop.getAttributeName();
- BooleanArgument arg = new BooleanArgument(attName, null, attName, null);
- arg.setDefaultValue("false");
- serverProperties.put(prop, arg);
- }
-
- /**
- * The location of the server.
- */
- {
- ServerProperty prop = ServerProperty.LOCATION;
- String attName = prop.getAttributeName();
- StringArgument arg = new StringArgument(attName, null, attName, false,
- false, true, LocalizableMessage.raw(attName), null, null, null);
- serverProperties.put(prop, arg);
- }
-
- /**
- * The list of groups in which the server is registered.
- */
- {
- ServerProperty prop = ServerProperty.GROUPS;
- String attName = prop.getAttributeName();
- StringArgument arg = new StringArgument(attName, null, attName, false,
- true, true, LocalizableMessage.raw(attName), null, null, null);
- arg.setHidden(true);
- serverProperties.put(prop, arg);
- }
-
- /**
- * The INSTANCE_KEY_ID used to identify the server key ID.
- */
- {
- ServerProperty prop = ServerProperty.INSTANCE_KEY_ID;
- String attName = prop.getAttributeName();
- StringArgument arg = new StringArgument(attName, null, prop
- .getAttributeName(), false, false, true, LocalizableMessage.raw(""), null, null,
- null);
- serverProperties.put(prop, arg);
- }
-
- /**
- * The INSTANCE_PUBLIC_KEY_CERTIFICATE associated to the server.
- */
- {
- ServerProperty prop = ServerProperty.INSTANCE_PUBLIC_KEY_CERTIFICATE;
- String attName = prop.getAttributeName();
- StringArgument arg = new StringArgument(attName, null, prop
- .getAttributeName(), false, false, true, LocalizableMessage.raw(""), null, null,
- null);
- serverProperties.put(prop, arg);
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isSubCommand(SubCommand subCmd)
- {
- return SubCommandNameEnum.isSubCommand(subCmd.getName());
- }
-
- /** {@inheritDoc} */
- @Override
- public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd,
- OutputStream outStream, OutputStream errStream)
- throws ADSContextException, ArgumentException
- {
-
- ADSContext adsCtx = null;
- InitialLdapContext ctx = null;
- DsFrameworkCliReturnCode returnCode = ERROR_UNEXPECTED;
-
- try
- {
- // -----------------------
- // register-server subcommand
- // -----------------------
- if (subCmd.getName().equals(registerServerSubCmd.getName()))
- {
- String serverId ;
- Map<ServerProperty, Object> map =
- mapSetOptionsToMap(registerServerSetArg);
- if (registerServerServerIdArg.isPresent())
- {
- serverId = registerServerServerIdArg.getValue();
- }
- else
- {
- serverId = ADSContext.getServerIdFromServerProperties(map);
- }
- map.put(ServerProperty.ID, serverId);
-
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx);
- adsCtx.registerServer(map);
-
- returnCode = SUCCESSFUL;
- }
- else
- // -----------------------
- // unregister-server subcommand
- // -----------------------
- if (subCmd.getName().equals(unregisterServerSubCmd.getName()))
- {
- returnCode = SUCCESSFUL;
-
- Map<ServerProperty, Object> map = new HashMap<ServerProperty, Object>();
- String serverId = null;
- if (unregisterServerServerIDArg.isPresent())
- {
- serverId = unregisterServerServerIDArg.getValue();
- }
- else
- {
- serverId = ADSContext.getServerIdFromServerProperties(map);
- }
- map.put(ServerProperty.ID,serverId);
-
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx);
-
- // update groups in which server was registered
- Set<Map<ServerProperty, Object>> serverList =
- adsCtx.readServerRegistry();
- boolean found = false;
- for (Map<ServerProperty,Object> elm : serverList)
- {
- if (serverId.equals(elm.get(ServerProperty.ID)))
- {
- found = true ;
- break ;
- }
- }
- if ( ! found )
- {
- throw new ADSContextException (ErrorType.NOT_YET_REGISTERED) ;
- }
-
- // unregister the server
- adsCtx.unregisterServer(map);
- }
- else
- // -----------------------
- // list-servers subcommand
- // -----------------------
- if (subCmd.getName().equals(listServersSubCmd.getName()))
- {
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx);
- Set<Map<ServerProperty, Object>> serverList = adsCtx
- .readServerRegistry();
-
- PrintStream out = new PrintStream(outStream);
- for (Map<ServerProperty, Object> server : serverList)
- {
- // print out server ID
- out.println(ServerProperty.ID.getAttributeName() + ": "
- + server.get(ServerProperty.ID));
- }
- returnCode = SUCCESSFUL;
- }
- else
- // -----------------------
- // get-server-properties subcommand
- // -----------------------
- if (subCmd.getName().equals(getServerPropertiesSubCmd.getName()))
- {
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx);
- Set<Map<ServerProperty, Object>> adsServerList = adsCtx
- .readServerRegistry();
-
- LinkedList<String> userServerList = getServerPropertiesServerIdArg
- .getValues();
- PrintStream out = new PrintStream(outStream);
- for (Map<ServerProperty, Object> server : adsServerList)
- {
- String serverID = (String) server.get(ServerProperty.ID);
- if (!userServerList.contains(serverID))
- {
- continue;
- }
- // print out server ID
- out.println(ServerProperty.ID.getAttributeName() + ": "
- + server.get(ServerProperty.ID));
- for (ServerProperty sp : server.keySet())
- {
- if (sp.equals(ServerProperty.ID))
- {
- continue;
- }
- out.println(sp.getAttributeName() + ": " + server.get(sp));
- }
- out.println();
- }
- returnCode = SUCCESSFUL;
- }
- else
- // -----------------------
- // set-server-properties subcommand
- // -----------------------
- if (subCmd.getName().equals(setServerPropertiesSubCmd.getName()))
- {
- Map<ServerProperty, Object> map =
- mapSetOptionsToMap(setServerPropertiesSetArg);
-
- // if the ID is specify in the --set list, it may mean that
- // the user wants to rename the serverID
- String newServerId = (String) map.get(ServerProperty.ID) ;
-
- // replace the serverID in the map
- map.put(ServerProperty.ID, setServerPropertiesServerIdArg.getValue());
-
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx);
- adsCtx.updateServer(map, newServerId);
- returnCode = SUCCESSFUL;
- }
- else
- // -----------------------
- // list-server-properties subcommand
- // -----------------------
- if (subCmd.getName().equals(listServerPropertiesSubCmd.getName()))
- {
- PrintStream out = new PrintStream(outStream);
- out.println(DESCRIPTION_OPTIONS_TITLE);
- out.println();
- out.print(" r -- ");
- out.println(DESCRIPTION_OPTIONS_READ);
- out.print(" w -- ");
- out.println(DESCRIPTION_OPTIONS_WRITE);
- out.print(" m -- ");
- out.println(DESCRIPTION_OPTIONS_MANDATORY);
- out.print(" s -- ");
- out.println(DESCRIPTION_OPTIONS_SINGLE);
- out.println();
-
- TableBuilder table = new TableBuilder();
- table.appendHeading(INFO_DSCFG_HEADING_PROPERTY_NAME.get());
- table.appendHeading(INFO_DSCFG_HEADING_PROPERTY_OPTIONS.get());
- table.appendHeading(INFO_DSCFG_HEADING_PROPERTY_SYNTAX.get());
- table.appendHeading(INFO_CLI_HEADING_PROPERTY_DEFAULT_VALUE.get());
- for (ServerProperty serverProp : serverProperties.keySet())
- {
- if (serverProperties.get(serverProp).isHidden())
- {
- continue;
- }
- table.startRow();
- table.appendCell(serverProp.getAttributeName());
- table.appendCell(getPropertyOptionSummary(serverProperties
- .get(serverProp)));
- table.appendCell(serverProp.getAttributeSyntax());
- if (serverProperties.get(serverProp).getDefaultValue() != null)
- {
- table.appendCell(serverProperties.get(serverProp)
- .getDefaultValue());
- }
- else
- {
- table.appendCell("-");
- }
- }
- TextTablePrinter printer = new TextTablePrinter(outStream);
- table.print(printer);
- returnCode = SUCCESSFUL;
- }
- else
- {
- // Should never occurs: If we are here, it means that the code to
- // handle to subcommand is not yet written.
- returnCode = ERROR_UNEXPECTED;
- }
- }
- catch (ADSContextException e)
- {
- throw e;
- }
- finally
- {
- close(ctx);
- }
-
- // return part
- return returnCode;
- }
-
- /** Compute the options field. */
- private String getPropertyOptionSummary(Argument arg)
- {
- StringBuilder b = new StringBuilder();
-
- if (readonlyServerProperties.contains(
- ADSContext.getServerPropFromName(arg.getName())))
- {
- b.append("r-"); //$NON-NLS-1$
- }
- else
- {
- b.append("rw"); //$NON-NLS-1$
- }
-
- if (arg.isRequired())
- {
- b.append('m');
- }
- else
- {
- b.append('-');
- }
-
- if (arg.isMultiValued())
- {
- b.append('-');
- }
- else
- {
- b.append('s');
- }
- return b.toString();
- }
-
- /**
- * Translate a Set properties a to a MAP.
- *
- * @param propertySetArgument
- * The input set argument.
- * @return The created map.
- * @throws ArgumentException
- * If error error occurs during set parsing.
- */
- private Map<ServerProperty, Object> mapSetOptionsToMap(
- StringArgument propertySetArgument) throws ArgumentException
- {
- HashMap<ServerProperty, Object> map = new HashMap<ServerProperty, Object>();
- for (String m : propertySetArgument.getValues())
- {
- // Parse the property "property:value".
- int sep = m.indexOf(':');
-
- if (sep < 0)
- {
- throw ArgumentExceptionFactory.missingSeparatorInPropertyArgument(m);
- }
-
- if (sep == 0)
- {
- throw ArgumentExceptionFactory.missingNameInPropertyArgument(m);
- }
-
- String propertyName = m.substring(0, sep);
- String value = m.substring(sep + 1, m.length());
- if (value.length() == 0)
- {
- throw ArgumentExceptionFactory.missingValueInPropertyArgument(m);
- }
-
- // Check that propName is a known prop.
- ServerProperty serverProperty = ADSContext
- .getServerPropFromName(propertyName);
- if (serverProperty == null)
- {
- LocalizableMessage message = ERR_CLI_ERROR_PROPERTY_UNRECOGNIZED.get(propertyName);
- throw new ArgumentException(message);
- }
-
- // Check that propName is not hidden.
- if (serverProperties.get(serverProperty).isHidden())
- {
- LocalizableMessage message = ERR_CLI_ERROR_PROPERTY_UNRECOGNIZED.get(propertyName);
- throw new ArgumentException(message);
- }
-
- // Check the property Syntax.
- LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
- Argument arg = serverProperties.get(serverProperty) ;
- if ( ! arg.valueIsAcceptable(value, invalidReason))
- {
- LocalizableMessage message =
- ERR_CLI_ERROR_INVALID_PROPERTY_VALUE.get(propertyName, value);
- throw new ArgumentException(message);
- }
- serverProperties.get(serverProperty).addValue(value);
-
- // add to the map.
- map.put(serverProperty, value);
- }
-
- // Check that all mandatory props are set.
- for (ServerProperty s : ServerProperty.values())
- {
- Argument arg = serverProperties.get(s);
- if (arg.isHidden())
- {
- continue;
- }
- if (map.containsKey(s))
- {
- continue ;
- }
- if ( ! arg.isRequired())
- {
- continue ;
- }
-
- // If we are here, it means that the argument is required
- // but not yet is the map. Check if we have a default value.
- if (arg.getDefaultValue() == null)
- {
- LocalizableMessage message =
- ERR_CLI_ERROR_MISSING_PROPERTY.get(s.getAttributeName());
- throw new ArgumentException(message);
- }
- else
- {
- map.put(s, arg.getDefaultValue());
- }
- }
- return map;
- }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServerGroup.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServerGroup.java
deleted file mode 100644
index 696efc7..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServerGroup.java
+++ /dev/null
@@ -1,1021 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.admin.client.cli;
-
-import static org.opends.messages.AdminMessages.*;
-import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.tools.ToolConstants.*;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.naming.ldap.InitialLdapContext;
-import javax.naming.ldap.Rdn;
-
-import org.opends.admin.ads.ADSContext;
-import org.opends.admin.ads.ADSContextException;
-import org.opends.admin.ads.ADSContext.ServerGroupProperty;
-import org.opends.admin.ads.ADSContext.ServerProperty;
-import org.opends.admin.ads.ADSContextException.ErrorType;
-import com.forgerock.opendj.cli.ArgumentException;
-import com.forgerock.opendj.cli.BooleanArgument;
-import com.forgerock.opendj.cli.StringArgument;
-import com.forgerock.opendj.cli.SubCommand;
-
-import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
-import static org.opends.server.util.StaticUtils.*;
-
-/**
- * This class is handling server group CLI.
- */
-public class DsFrameworkCliServerGroup implements DsFrameworkCliSubCommandGroup
-{
-
- /**
- * End Of Line.
- */
- private String EOL = System.getProperty("line.separator");
-
- /**
- * The subcommand Parser.
- */
- private DsFrameworkCliParser argParser ;
-
- /**
- * The verbose argument.
- */
- private BooleanArgument verboseArg ;
-
- /**
- * The enumeration containing the different subCommand names.
- */
- private enum SubCommandNameEnum
- {
- /**
- * The create-group subcommand.
- */
- CREATE_GROUP("create-group"),
-
- /**
- * The delete-group subcommand.
- */
- DELETE_GROUP("delete-group"),
-
- /**
- * The modify-group subcommand.
- */
- MODIFY_GROUP("modify-group"),
-
- /**
- * The list-groups subcommand.
- */
- LIST_GROUPS("list-groups"),
-
- /**
- * The list-members subcommand.
- */
- LIST_MEMBERS("list-members"),
-
- /**
- * The list-membership subcommand.
- */
- LIST_MEMBERSHIP("list-membership"),
-
- /**
- * The add-to-group subcommand.
- */
- ADD_TO_GROUP("add-to-group"),
-
- /**
- * The remove-from-group subcommand.
- */
- REMOVE_FROM_GROUP("remove-from-group");
-
- /** String representation of the value. */
- private final String name;
-
- /** Private constructor. */
- private SubCommandNameEnum(String name)
- {
- this.name = name;
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString()
- {
- return name;
- }
-
- /** A lookup table for resolving a unit from its name. */
- private static final List<String> nameToSubCmdName ;
- static
- {
- nameToSubCmdName = new ArrayList<String>();
-
- for (SubCommandNameEnum subCmd : SubCommandNameEnum.values())
- {
- nameToSubCmdName.add(subCmd.toString());
- }
- }
- public static boolean isSubCommand(String name)
- {
- return nameToSubCmdName.contains(name);
- }
- }
-
- /**
- * The 'create-group' subcommand.
- */
- public SubCommand createGroupSubCmd;
-
- /**
- * The 'description' argument of the 'create-group' subcommand.
- */
- private StringArgument createGroupDescriptionArg;
-
- /**
- * The 'group-name' argument of the 'create-group' subcommand.
- */
- private StringArgument createGroupGroupNameArg;
-
- /**
- * The 'modify-group' subcommand.
- */
- private SubCommand modifyGroupSubCmd;
-
- /**
- * The 'description' argument of the 'modify-group' subcommand.
- */
- private StringArgument modifyGroupDescriptionArg;
-
- /**
- * The 'group-id' argument of the 'modify-group' subcommand.
- */
- private StringArgument modifyGroupGroupIdArg;
-
- /**
- * The 'group-name' argument of the 'modify-group' subcommand.
- */
- private StringArgument modifyGroupGroupNameArg;
-
- /**
- * The 'delete-group' subcommand.
- */
- private SubCommand deleteGroupSubCmd;
-
- /**
- * The 'group-name' argument of the 'delete-group' subcommand.
- */
- private StringArgument deleteGroupGroupNameArg;
-
- /**
- * The 'list-group' subcommand.
- */
- private SubCommand listGroupSubCmd;
-
- /**
- * The 'add-to-group' subcommand.
- */
- private SubCommand addToGroupSubCmd;
-
- /**
- * The 'group-name' argument of the 'add-to-group' subcommand.
- */
- private StringArgument addToGroupGroupNameArg;
-
- /**
- * The 'member-id' argument of the 'add-to-group' subcommand.
- */
- private StringArgument addToGoupMemberNameArg;
-
- /**
- * The 'remove-from-group' subcommand.
- */
- private SubCommand removeFromGroupSubCmd;
-
- /**
- * The 'group-name' argument of the 'remove-from-group' subcommand.
- */
- private StringArgument removeFromGroupGroupNameArg;
-
- /**
- * The 'member-id' argument of the 'remove-from-group' subcommand.
- */
- private StringArgument removeFromGoupMemberNameArg;
-
- /**
- * The 'list-members' subcommand.
- */
- private SubCommand listMembersSubCmd;
-
- /**
- * The 'group-name' argument of the 'list-members' subcommand.
- */
- private StringArgument listMembersGroupNameArg;
-
- /**
- * The 'list-membership' subcommand.
- */
- private SubCommand listMembershipSubCmd;
-
- /**
- * The 'member-name' argument of the 'list-membership' subcommand.
- */
- private StringArgument listMembershipMemberNameArg;
-
-
- /**
- * Association between ADSContext enum and display field.
- */
- private HashMap<ServerGroupProperty, String> attributeDisplayName;
-
- /**
- * The subcommand list.
- */
- private HashSet<SubCommand> subCommands = new HashSet<SubCommand>();
-
- /**
- * Indicates whether this subCommand should be hidden in the usage
- * information.
- */
- private boolean isHidden;
-
- /**
- * The subcommand group name.
- */
- private String groupName;
-
- /**
- * Get the display attribute name for a given attribute.
- * @param prop The server property
- * @return the display attribute name for a given attribute
- */
- public String getAttributeDisplayName(ServerGroupProperty prop)
- {
- return attributeDisplayName.get(prop);
- }
-
- /** {@inheritDoc} */
- @Override
- public Set<SubCommand> getSubCommands()
- {
- return subCommands;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isHidden()
- {
- return isHidden;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getGroupName()
- {
- return groupName ;
- }
-
- /** {@inheritDoc} */
- @Override
- public void initializeCliGroup(DsFrameworkCliParser argParser,
- BooleanArgument verboseArg)
- throws ArgumentException
- {
- this.verboseArg = verboseArg ;
- isHidden = false ;
- groupName = "server-group";
- this.argParser = argParser;
-
-
- // Create-group subcommand
- createGroupSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.CREATE_GROUP.toString(),
- INFO_ADMIN_SUBCMD_CREATE_GROUP_DESCRIPTION.get());
- subCommands.add(createGroupSubCmd);
-
- createGroupDescriptionArg = new StringArgument("description",
- OPTION_SHORT_DESCRIPTION, OPTION_LONG_DESCRIPTION, false, false,
- true, INFO_DESCRIPTION_PLACEHOLDER.get(), "", null,
- INFO_ADMIN_ARG_DESCRIPTION_DESCRIPTION.get());
- createGroupSubCmd.addArgument(createGroupDescriptionArg);
-
- createGroupGroupNameArg = new StringArgument("groupName",
- OPTION_SHORT_GROUPNAME, OPTION_LONG_GROUPNAME, true, true,
- INFO_GROUPNAME_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_CREATE_GROUP_GROUPNAME_DESCRIPTION.get());
- createGroupSubCmd.addArgument(createGroupGroupNameArg);
-
- // modify-group
- modifyGroupSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.MODIFY_GROUP.toString(),
- INFO_ADMIN_SUBCMD_MODIFY_GROUP_DESCRIPTION.get());
- subCommands.add(modifyGroupSubCmd);
-
- modifyGroupDescriptionArg = new StringArgument("new-description",
- OPTION_SHORT_DESCRIPTION, OPTION_LONG_DESCRIPTION, false, false,
- true, INFO_DESCRIPTION_PLACEHOLDER.get(), "", null,
- INFO_ADMIN_ARG_NEW_DESCRIPTION_DESCRIPTION.get());
- modifyGroupSubCmd.addArgument(modifyGroupDescriptionArg);
-
- modifyGroupGroupIdArg = new StringArgument("new-groupName",
- OPTION_SHORT_NEWGROUPNAME, OPTION_LONG_NEWGROUPNAME, false, false, true,
- INFO_GROUPNAME_PLACEHOLDER.get(), "", null,
- INFO_ADMIN_ARG_NEW_GROUPNAME_DESCRIPTION.get());
- modifyGroupSubCmd.addArgument(modifyGroupGroupIdArg);
-
- modifyGroupGroupNameArg = new StringArgument("groupName",
- OPTION_SHORT_GROUPNAME, OPTION_LONG_GROUPNAME, true, true,
- INFO_GROUPNAME_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_GROUPNAME_DESCRIPTION.get());
- modifyGroupSubCmd.addArgument(modifyGroupGroupNameArg);
-
- // delete-group
- deleteGroupSubCmd = new SubCommand(argParser,SubCommandNameEnum.DELETE_GROUP
- .toString(), INFO_ADMIN_SUBCMD_DELETE_GROUP_DESCRIPTION.get());
- subCommands.add(deleteGroupSubCmd);
-
- deleteGroupGroupNameArg = new StringArgument("groupName",
- OPTION_SHORT_GROUPNAME, OPTION_LONG_GROUPNAME, true, true,
- INFO_GROUPNAME_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_GROUPNAME_DESCRIPTION.get());
- deleteGroupSubCmd.addArgument(deleteGroupGroupNameArg);
-
- // list-groups
- listGroupSubCmd = new SubCommand(argParser, "list-groups",
- INFO_ADMIN_SUBCMD_LIST_GROUPS_DESCRIPTION.get());
- subCommands.add(listGroupSubCmd);
-
- // add-to-group
- addToGroupSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.ADD_TO_GROUP.toString(),
- INFO_ADMIN_SUBCMD_ADD_TO_GROUP_DESCRIPTION.get());
- subCommands.add(addToGroupSubCmd);
-
- addToGoupMemberNameArg = new StringArgument("memberName",
- OPTION_SHORT_MEMBERNAME, OPTION_LONG_MEMBERNAME, true, true,
- INFO_MEMBERNAME_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_ADD_MEMBERNAME_DESCRIPTION.get());
- addToGroupSubCmd.addArgument(addToGoupMemberNameArg);
-
- addToGroupGroupNameArg = new StringArgument("groupName",
- OPTION_SHORT_GROUPNAME, OPTION_LONG_GROUPNAME, true, true,
- INFO_GROUPNAME_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_GROUPNAME_DESCRIPTION.get());
- addToGroupSubCmd.addArgument(addToGroupGroupNameArg);
-
- // remove-from-group
- removeFromGroupSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.REMOVE_FROM_GROUP.toString(),
- INFO_ADMIN_SUBCMD_REMOVE_FROM_GROUP_DESCRIPTION.get());
- subCommands.add(removeFromGroupSubCmd);
-
- removeFromGoupMemberNameArg = new StringArgument("memberName",
- OPTION_SHORT_MEMBERNAME, OPTION_LONG_MEMBERNAME, true, true,
- INFO_MEMBERNAME_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_REMOVE_MEMBERNAME_DESCRIPTION.get());
- removeFromGroupSubCmd.addArgument(removeFromGoupMemberNameArg);
-
- removeFromGroupGroupNameArg = new StringArgument("groupName",
- OPTION_SHORT_GROUPNAME, OPTION_LONG_GROUPNAME, true, true,
- INFO_GROUPNAME_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_GROUPNAME_DESCRIPTION.get());
- removeFromGroupSubCmd.addArgument(removeFromGroupGroupNameArg);
-
-
- // list-members
- listMembersSubCmd = new SubCommand(argParser,SubCommandNameEnum.LIST_MEMBERS
- .toString(), INFO_ADMIN_SUBCMD_LIST_MEMBERS_DESCRIPTION.get());
- subCommands.add(listMembersSubCmd);
-
- listMembersGroupNameArg = new StringArgument("groupName",
- OPTION_SHORT_GROUPNAME, OPTION_LONG_GROUPNAME, true, true,
- INFO_GROUPNAME_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_GROUPNAME_DESCRIPTION.get());
- listMembersSubCmd.addArgument(listMembersGroupNameArg);
-
- // list-membership
- listMembershipSubCmd = new SubCommand(argParser,
- SubCommandNameEnum.LIST_MEMBERSHIP.toString(),
- INFO_ADMIN_SUBCMD_LIST_MEMBERSHIP_DESCRIPTION.get());
- subCommands.add(listMembershipSubCmd);
-
- listMembershipMemberNameArg = new StringArgument("memberName",
- OPTION_SHORT_MEMBERNAME, OPTION_LONG_MEMBERNAME, true, true,
- INFO_MEMBERNAME_PLACEHOLDER.get(),
- INFO_ADMIN_ARG_MEMBERNAME_DESCRIPTION.get());
- listMembershipSubCmd.addArgument(listMembershipMemberNameArg);
-
- // Create association between ADSContext enum and display field
- attributeDisplayName = new HashMap<ServerGroupProperty, String>();
- attributeDisplayName.put(ServerGroupProperty.UID, OPTION_LONG_GROUPNAME);
- attributeDisplayName.put(ServerGroupProperty.DESCRIPTION,
- OPTION_LONG_DESCRIPTION);
- attributeDisplayName.put(ServerGroupProperty.MEMBERS,
- OPTION_LONG_MEMBERNAME);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isSubCommand(SubCommand subCmd)
- {
- return SubCommandNameEnum.isSubCommand(subCmd.getName());
- }
-
-
- /** {@inheritDoc} */
- @Override
- public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd,
- OutputStream outStream, OutputStream errStream)
- throws ADSContextException, ArgumentException
- {
- ADSContext adsCtx = null ;
- InitialLdapContext ctx = null ;
-
- DsFrameworkCliReturnCode returnCode = ERROR_UNEXPECTED;
- try
- {
- // -----------------------
- // create-group subcommand
- // -----------------------
- if (subCmd.getName().equals(createGroupSubCmd.getName()))
- {
- String groupId = createGroupGroupNameArg.getValue();
- HashMap<ServerGroupProperty, Object> serverGroupProperties =
- new HashMap<ServerGroupProperty, Object>();
-
- // get the GROUP_NAME
- serverGroupProperties.put(ServerGroupProperty.UID, groupId);
-
- // get the Description
- if (createGroupDescriptionArg.isPresent())
- {
- serverGroupProperties.put(ServerGroupProperty.DESCRIPTION,
- createGroupDescriptionArg.getValue());
- }
-
- // Create the group
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx) ;
- adsCtx.createServerGroup(serverGroupProperties);
- returnCode = SUCCESSFUL;
- }
- // -----------------------
- // delete-group subcommand
- // -----------------------
- else if (subCmd.getName().equals(deleteGroupSubCmd.getName()))
- {
- returnCode = SUCCESSFUL;
- String groupId = deleteGroupGroupNameArg.getValue();
- if (groupId.equals(ADSContext.ALL_SERVERGROUP_NAME))
- {
- return ACCESS_PERMISSION ;
- }
- HashMap<ServerGroupProperty, Object> serverGroupProperties =
- new HashMap<ServerGroupProperty, Object>();
-
- // Get ADS context
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx) ;
-
- // update server Property "GROUPS"
- Set<String> serverList = adsCtx.getServerGroupMemberList(groupId);
- for (String serverId : serverList)
- {
- // serverId contains "cn=" string, just remove it.
- removeServerFromGroup(adsCtx, groupId,serverId.substring(3));
- }
-
- // Delete the group
- serverGroupProperties.put(ServerGroupProperty.UID, groupId);
- adsCtx.deleteServerGroup(serverGroupProperties);
- }
- // -----------------------
- // list-groups subcommand
- // -----------------------
- else if (subCmd.getName().equals(listGroupSubCmd.getName()))
- {
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx) ;
-
- Set<Map<ServerGroupProperty, Object>> result = adsCtx
- .readServerGroupRegistry();
- StringBuilder buffer = new StringBuilder();
-
- // if not verbose mode, print group name (1 per line)
- if (! verboseArg.isPresent())
- {
- for (Map<ServerGroupProperty, Object> groupProps : result)
- {
- // Get the group name
- buffer.append(groupProps.get(ServerGroupProperty.UID));
- buffer.append(EOL);
- }
- }
- else
- {
- // Look for the max group identifier length
- int uidLength = 0 ;
- for (ServerGroupProperty sgp : ServerGroupProperty.values())
- {
- int cur = attributeDisplayName.get(sgp).length();
- if (cur > uidLength)
- {
- uidLength = cur;
- }
- }
- uidLength++;
-
- for (Map<ServerGroupProperty, Object> groupProps : result)
- {
- // Get the group name
- buffer.append(attributeDisplayName.get(ServerGroupProperty.UID));
- // add space
- int curLen = attributeDisplayName.get(ServerGroupProperty.UID)
- .length();
- for (int i = curLen; i < uidLength; i++)
- {
- buffer.append(" ");
- }
- buffer.append(": ");
- buffer.append(groupProps.get(ServerGroupProperty.UID));
- buffer.append(EOL);
-
- // Write other props
- for (ServerGroupProperty propName : ServerGroupProperty.values())
- {
- if (propName.compareTo(ServerGroupProperty.UID) == 0)
- {
- // We have already displayed the group Id
- continue;
- }
- buffer.append(attributeDisplayName.get(propName));
- // add space
- curLen = attributeDisplayName.get(propName).length();
- for (int i = curLen; i < uidLength; i++)
- {
- buffer.append(" ");
- }
- buffer.append(": ");
-
- if (propName.compareTo(ServerGroupProperty.MEMBERS) == 0)
- {
- Set atts = (Set) groupProps.get(propName);
- if (atts != null)
- {
- boolean indent = false;
- for (Object att : atts)
- {
- if (indent)
- {
- buffer.append(EOL);
- for (int i = 0; i < uidLength + 2; i++)
- {
- buffer.append(" ");
- }
- }
- else
- {
- indent = true;
- }
- buffer.append(att.toString().substring(3));
- }
- }
- }
- else
- {
- if (groupProps.get(propName) != null)
- {
- buffer.append(groupProps.get(propName));
- }
- }
- buffer.append(EOL);
- }
- buffer.append(EOL);
- }
- }
- try
- {
- outStream.write(buffer.toString().getBytes());
- }
- catch (IOException e)
- {
- }
- returnCode = SUCCESSFUL;
- }
- // -----------------------
- // modify-group subcommand
- // -----------------------
- else if (subCmd.getName().equals(modifyGroupSubCmd.getName()))
- {
- String groupId = modifyGroupGroupNameArg.getValue();
- HashMap<ServerGroupProperty, Object> serverGroupProperties =
- new HashMap<ServerGroupProperty, Object>();
- HashSet<ServerGroupProperty> serverGroupPropertiesToRemove =
- new HashSet<ServerGroupProperty>();
-
- Boolean updateRequired = false;
- Boolean removeRequired = false;
- // get the GROUP_ID
- if (modifyGroupGroupIdArg.isPresent())
- {
- // rename the entry !
- serverGroupProperties.put(ServerGroupProperty.UID,
- modifyGroupGroupIdArg.getValue());
- updateRequired = true;
- }
- else
- {
- serverGroupProperties.put(ServerGroupProperty.UID, groupId) ;
- }
-
-
- // get the Description
- if (modifyGroupDescriptionArg.isPresent())
- {
- String newDesc = modifyGroupDescriptionArg.getValue();
- if (newDesc.length() == 0)
- {
- serverGroupPropertiesToRemove.add(ServerGroupProperty.DESCRIPTION);
- removeRequired = true;
- }
- else
- {
- serverGroupProperties.put(ServerGroupProperty.DESCRIPTION,
- modifyGroupDescriptionArg.getValue());
- updateRequired = true;
- }
- }
-
-
- // Update the server group
- if ( ! (updateRequired || removeRequired ) )
- {
- returnCode = SUCCESSFUL_NOP;
- }
-
- // We need to perform an update
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx) ;
-
- if (updateRequired)
- {
- adsCtx.updateServerGroup(groupId, serverGroupProperties);
- }
- if (removeRequired)
- {
- adsCtx.removeServerGroupProp(groupId,
- serverGroupPropertiesToRemove);
- }
-
- returnCode = SUCCESSFUL;
- }
- // -----------------------
- // add-to-group subcommand
- // -----------------------
- else if (subCmd.getName().equals(addToGroupSubCmd.getName()))
- {
- String groupId = addToGroupGroupNameArg.getValue();
-
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx) ;
-
- // Check if the server is registered inside to ADS
- Set<Map<ServerProperty, Object>> serverList = adsCtx
- .readServerRegistry();
- boolean found = false ;
- Map<ServerProperty, Object> foundServerProperties = null ;
- for (Map<ServerProperty, Object> serverProperties : serverList)
- {
- String serverId = ADSContext
- .getServerIdFromServerProperties(serverProperties);
- if (addToGoupMemberNameArg.getValue().equals(serverId))
- {
- found = true;
- foundServerProperties = serverProperties ;
- break;
- }
- }
- if ( !found )
- {
- throw new ADSContextException (ErrorType.NOT_YET_REGISTERED) ;
- }
-
- // Add the server inside the group
- returnCode = addServerTogroup(adsCtx, groupId, foundServerProperties);
- }
- // -----------------------
- // remove-from-group subcommand
- // -----------------------
- else if (subCmd.getName().equals(removeFromGroupSubCmd.getName()))
- {
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx) ;
-
- returnCode = removeServerFromGroup(adsCtx,
- removeFromGroupGroupNameArg.getValue(),
- removeFromGoupMemberNameArg.getValue());
- }
- // -----------------------
- // list-members subcommand
- // -----------------------
- else if (subCmd.getName().equals(listMembersSubCmd.getName()))
- {
- String groupId = listMembersGroupNameArg.getValue();
-
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx) ;
-
- // get the current member list
- Set<String> memberList = adsCtx.getServerGroupMemberList(groupId);
- if (memberList == null)
- {
- returnCode = SUCCESSFUL;
- }
- StringBuilder buffer = new StringBuilder();
- for (String member : memberList)
- {
- // We shouldn't print out the "cn="
- buffer.append(member.substring(3));
- buffer.append(EOL);
- }
- try
- {
- outStream.write(buffer.toString().getBytes());
- }
- catch (IOException e)
- {
- }
-
- returnCode = SUCCESSFUL;
- }
- // -----------------------
- // list-membership subcommand
- // -----------------------
- else if (subCmd.getName().equals(listMembershipSubCmd.getName()))
- {
- ctx = argParser.getContext(outStream, errStream);
- if (ctx == null)
- {
- return CANNOT_CONNECT_TO_ADS;
- }
- adsCtx = new ADSContext(ctx) ;
-
- Set<Map<ServerGroupProperty, Object>> result = adsCtx
- .readServerGroupRegistry();
- String MemberId = listMembershipMemberNameArg.getValue();
-
- StringBuilder buffer = new StringBuilder();
- for (Map<ServerGroupProperty, Object> groupProps : result)
- {
- // Get the group name;
- String groupId = groupProps.get(ServerGroupProperty.UID).toString();
-
- // look for member list attribute
- for (ServerGroupProperty propName : groupProps.keySet())
- {
- if (propName.compareTo(ServerGroupProperty.MEMBERS) != 0)
- {
- continue;
- }
- // Check if the member list contains the member-id
- Set atts = (Set) groupProps.get(propName);
- for (Object att : atts)
- {
- if (att.toString().substring(3).toLowerCase().equals(
- MemberId.toLowerCase()))
- {
- buffer.append(groupId);
- buffer.append(EOL);
- break;
- }
- }
- break;
- }
- }
- try
- {
- outStream.write(buffer.toString().getBytes());
- }
- catch (IOException e)
- {
- }
- returnCode = SUCCESSFUL;
- }
- else
- {
- // Should never occurs: If we are here, it means that the code to
- // handle to subcommand is not yet written.
- returnCode = ERROR_UNEXPECTED;
- }
- }
- catch (ADSContextException e)
- {
- throw e;
- }
- finally
- {
- close(ctx);
- }
-
- // return part
- return returnCode;
- }
-
- /**
- * Remove a server from a group.
- *
- * @param adsCtx
- * The ADS context to use.
- * @param groupId
- * The group identifier from which a server has to be
- * remove.
- * @param serverId
- * The server identifier to be removed.
- * @return The return code.
- * @throws ADSContextException
- * If there is a problem with any of the parameters used
- * to create this argument.
- */
- static DsFrameworkCliReturnCode removeServerFromGroup(ADSContext adsCtx,
- String groupId, String serverId)
- throws ADSContextException
- {
- DsFrameworkCliReturnCode returnCode = SUCCESSFUL;
-
- // get the current group member list
- Set<String> memberList = adsCtx.getServerGroupMemberList(groupId);
- if (memberList == null)
- {
- returnCode = NOT_YET_REGISTERED;
- }
- String memberToRemove = "cn="
- + Rdn.escapeValue(serverId);
- if (!memberList.contains(memberToRemove))
- {
- returnCode = NOT_YET_REGISTERED;
- }
-
- memberList.remove(memberToRemove);
- HashMap<ServerGroupProperty, Object> serverGroupProperties =
- new HashMap<ServerGroupProperty, Object>();
- serverGroupProperties.put(ServerGroupProperty.MEMBERS, memberList);
-
- // Update the server group
- adsCtx.updateServerGroup(groupId, serverGroupProperties);
-
- // Update the server property "GROUPS"
- Set<Map<ServerProperty,Object>> serverList = adsCtx.readServerRegistry() ;
- boolean found = false;
- Map<ServerProperty,Object> serverProperties = null ;
- for (Map<ServerProperty,Object> elm : serverList)
- {
- if (serverId.equals(elm.get(ServerProperty.ID)))
- {
- found = true ;
- serverProperties = elm ;
- break ;
- }
- }
- if ( ! found )
- {
- return SERVER_NOT_REGISTERED ;
- }
-
- Set rawGroupList = (Set) serverProperties.get(ServerProperty.GROUPS);
- Set<String> groupList = new HashSet<String>();
- if (rawGroupList != null)
- {
- for (Object elm :rawGroupList.toArray() )
- {
- if (groupId.equals(elm))
- {
- continue ;
- }
- groupList.add(elm.toString());
- }
- }
- serverProperties.put(ServerProperty.GROUPS, groupList);
- adsCtx.updateServer(serverProperties, null);
-
- return returnCode;
- }
-
- /**
- * Add a server inside a group.
- *
- * @param adsCtx
- * The ADS context to use.
- * @param groupId
- * The group identifier in which a server has to be added.
- * @param map
- * The properties of the server that have to be added to the
- * group.
- * @return the return code.
- * @throws ADSContextException
- * If there is a problem with any of the parameters used
- * to create this argument.
- */
- static DsFrameworkCliReturnCode addServerTogroup(ADSContext adsCtx,
- String groupId, Map<ServerProperty, Object> map)
- throws ADSContextException
- {
- DsFrameworkCliReturnCode returnCode = SUCCESSFUL;
- String serverId = (String) map.get(ServerProperty.ID);
-
- // Add the server inside the group
- HashMap<ServerGroupProperty, Object> serverGroupProperties =
- new HashMap<ServerGroupProperty, Object>();
- Set<String> memberList = adsCtx.getServerGroupMemberList(groupId);
- if (memberList == null)
- {
- memberList = new HashSet<String>();
- }
- String newMember = "cn="
- + Rdn.escapeValue(serverId);
- if (memberList.contains(newMember))
- {
- returnCode = ALREADY_REGISTERED;
- }
- memberList.add(newMember);
- serverGroupProperties.put(ServerGroupProperty.MEMBERS, memberList);
-
- adsCtx.updateServerGroup(groupId, serverGroupProperties);
-
-
- // Update the server property "GROUPS"
- Set rawGroupList = (Set) map.get(ServerProperty.GROUPS);
- Set<String> groupList = new HashSet<String>();
- if (rawGroupList != null)
- {
- for (Object elm :rawGroupList.toArray() )
- {
- groupList.add(elm.toString());
- }
- }
- groupList.add(groupId) ;
- map.put(ServerProperty.GROUPS, groupList);
- adsCtx.updateServer(map, null);
-
- return returnCode;
- }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliSubCommandGroup.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliSubCommandGroup.java
deleted file mode 100644
index 3132daa..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliSubCommandGroup.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
- */
- package org.opends.server.admin.client.cli;
-
-import java.io.OutputStream;
-import java.util.Set;
-
-import org.opends.admin.ads.ADSContextException;
-import com.forgerock.opendj.cli.ArgumentException;
-import com.forgerock.opendj.cli.BooleanArgument;
-import com.forgerock.opendj.cli.SubCommand;
-
-/**
- * This Interface defines method that a group of subcommand shoud implement.
- */
-public interface DsFrameworkCliSubCommandGroup
-{
-
- /**
- * Initialize subcommand related to server group management.
- *
- * @param argParser
- * The parser in which we should be registered.
- * @param verboseArg
- * The verbose Argument.
- * @throws ArgumentException
- * If there is a problem with any of the parameters used
- * to create this argument.
- */
- public void initializeCliGroup(DsFrameworkCliParser argParser,
- BooleanArgument verboseArg) throws ArgumentException;
-
- /**
- * Indicates if the provided suncommand is part of this group.
- *
- * @param subCmd
- * The actual subcommand with input parameter.
- * @return True if the provided suncommand is part of this group.
- */
- public boolean isSubCommand(SubCommand subCmd);
-
- /**
- * Handle the subcommand.
- * @param subCmd
- * The actual subcommand with input parameter
- * @param outStream The output stream to use for standard output.
- * @param errStream The output stream to use for standard error.
- * @return the return code
- * @throws ADSContextException
- * If there is a problem with when trying to perform the
- * operation.
- * @throws ArgumentException
- * If there is a problem with any of the parameters used
- * to execute this subcommand.
- */
- public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd,
- OutputStream outStream, OutputStream errStream)
- throws ADSContextException, ArgumentException;
-
- /**
- * Get the subcommands list.
- * @return the subcommand list.
- */
- public Set<SubCommand> getSubCommands();
-
- /**
- * Indicates whether this subcommand group should be hidden from the usage
- * information.
- *
- * @return <CODE>true</CODE> if this subcommand group should be hidden
- * from the usage information, or <CODE>false</CODE> if
- * not.
- */
- public boolean isHidden();
-
- /**
- * Indicates subcommand group name.
- *
- * @return the subcommand group name
- */
- public String getGroupName();
-
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java
index c600958..b30adde 100644
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java
+++ b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java
@@ -24,10 +24,9 @@
* Copyright 2007-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2014 ForgeRock AS
*/
-
package org.opends.server.admin.client.cli;
-import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
+import static org.opends.server.tools.JavaPropertiesTool.ErrorReturnCode.*;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.ToolMessages.*;
import org.forgerock.i18n.LocalizableMessage;
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliParser.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliParser.java
index 6af3818..a598f7c 100644
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliParser.java
+++ b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliParser.java
@@ -27,12 +27,6 @@
package org.opends.server.admin.client.cli;
-import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
-import static org.opends.server.tools.ToolConstants.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
@@ -41,13 +35,19 @@
import javax.net.ssl.KeyManager;
-import org.opends.admin.ads.util.ApplicationTrustManager;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.server.util.PasswordReader;
+
import com.forgerock.opendj.cli.*;
+import static org.opends.messages.ToolMessages.*;
+import static org.opends.server.tools.ToolConstants.*;
+import static org.opends.server.util.ServerConstants.*;
+import static org.opends.server.util.StaticUtils.*;
+
/**
* This is a commodity class that can be used to check the arguments required
* to establish a secure connection in the command line. It can be used
@@ -371,7 +371,7 @@
buf.append(EOL);
}
buf.append(message);
- ret = CONFLICTING_ARGS.getReturnCode();
+ ret = 1;
}
return ret;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java b/opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java
index e147e55..df6536c 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java
@@ -27,19 +27,7 @@
package org.opends.server.tools;
-import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.util.ServerConstants.EOL;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
+import java.io.*;
import java.util.Enumeration;
import java.util.Properties;
@@ -48,9 +36,13 @@
import org.opends.quicksetup.Constants;
import org.opends.quicksetup.util.Utils;
import org.opends.server.types.NullOutputStream;
-import com.forgerock.opendj.cli.ArgumentException;
import org.opends.server.util.cli.ConsoleApplication;
+import com.forgerock.opendj.cli.ArgumentException;
+
+import static org.opends.messages.ToolMessages.*;
+import static org.opends.server.util.ServerConstants.*;
+
/**
* This class is used to update the scripts that are used to launch the command
* lines. We read the contents of a given properties file and we update the
@@ -89,7 +81,11 @@
/**
* Error writing to destination file.
*/
- ERROR_WRITING_FILE(3);
+ ERROR_WRITING_FILE(3),
+ /**
+ * Conflicting command line arguments.
+ */
+ CONFLICTING_ARGS(18);
private int returnCode;
private ErrorReturnCode(int returnCode)
@@ -432,6 +428,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isQuiet()
{
return argParser.quietArg.isPresent();
@@ -440,6 +437,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isInteractive()
{
return false;
@@ -456,6 +454,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isScriptFriendly() {
return false;
}
@@ -463,6 +462,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isAdvancedMode() {
return false;
}
@@ -471,6 +471,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isVerbose() {
return true;
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
index c225cf0..6b752ec 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
@@ -26,18 +26,15 @@
*/
package org.opends.server.tools.dsconfig;
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.admin.ads.util.OpendsCertificateException;
-
-import static org.opends.messages.DSConfigMessages.*;
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.server.admin.client.AuthenticationException;
import org.opends.server.admin.client.AuthenticationNotSupportedException;
import org.opends.server.admin.client.CommunicationException;
import org.opends.server.admin.client.ManagementContext;
-import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode;
import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor;
import org.opends.server.admin.client.ldap.LDAPConnection;
@@ -45,21 +42,26 @@
import org.opends.server.config.ConfigException;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.tools.ClientException;
+import org.opends.server.tools.JavaPropertiesTool.ErrorReturnCode;
+import org.opends.server.tools.ToolConstants;
+import org.opends.server.util.cli.CommandBuilder;
+import org.opends.server.util.cli.ConsoleApplication;
+import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
+
import com.forgerock.opendj.cli.Argument;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.SubCommandArgumentParser;
-import org.opends.server.util.cli.CommandBuilder;
-import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
-import org.opends.server.util.cli.ConsoleApplication;
+
+import java.util.LinkedHashSet;
import javax.naming.NamingException;
import javax.naming.ldap.InitialLdapContext;
import javax.net.ssl.KeyManager;
-import javax.net.ssl.TrustManager;
-import java.util.LinkedHashSet;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
-import org.opends.server.tools.ToolConstants;
+import javax.net.ssl.TrustManager;
+
+import static org.opends.messages.DSConfigMessages.*;
/**
@@ -96,6 +98,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ManagementContext getManagementContext(ConsoleApplication app)
throws ArgumentException, ClientException
{
@@ -114,6 +117,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void close()
{
if (context != null)
@@ -125,6 +129,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public CommandBuilder getContextCommandBuilder()
{
return contextCommandBuilder;
@@ -327,6 +332,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void setRawArguments(String[] args) {
this.rawArgs = args;
@@ -335,6 +341,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void registerGlobalArguments(SubCommandArgumentParser parser)
throws ArgumentException {
// Create the global arguments.
@@ -376,12 +383,13 @@
/**
* {@inheritDoc}
*/
+ @Override
public void validateGlobalArguments() throws ArgumentException {
// Make sure that the user didn't specify any conflicting
// arguments.
LocalizableMessageBuilder buf = new LocalizableMessageBuilder();
int v = secureArgsList.validateGlobalOptions(buf);
- if (v != DsFrameworkCliReturnCode.SUCCESSFUL_NOP.getReturnCode())
+ if (v != ErrorReturnCode.SUCCESSFUL_NOP.getReturnCode())
{
throw new ArgumentException(buf.toMessage());
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java b/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java
index 37c0f9f..07e1c4c 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java
@@ -57,7 +57,6 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.admin.AdministrationConnector;
import org.opends.server.admin.client.ManagementContext;
-import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode;
import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
import org.opends.server.config.ConfigException;
import org.opends.server.tools.ClientException;
@@ -304,7 +303,7 @@
}
int v = argParser.validateGlobalOptions(getErrorStream());
- if (v != DsFrameworkCliReturnCode.SUCCESSFUL_NOP.getReturnCode()) {
+ if (v != ErrorReturnCode.SUCCESSFUL_NOP.getReturnCode()) {
println(LocalizableMessage.raw(argParser.getUsage()));
return v;
} else {
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/admin/client/cli/CliTest.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/admin/client/cli/CliTest.java
deleted file mode 100755
index 9754fa4..0000000
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/admin/client/cli/CliTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
- */
-
-package org.opends.server.admin.client.cli;
-
-import static org.testng.Assert.*;
-
-import org.testng.annotations.*;
-import org.opends.admin.ads.ADSContext.ServerGroupProperty;
-import org.opends.admin.ads.ADSContextException.ErrorType;
-import com.forgerock.opendj.cli.ArgumentException;
-import org.opends.server.DirectoryServerTestCase;
-
-import static org.opends.messages.AdminMessages.*;
-import org.forgerock.i18n.LocalizableMessage;
-
-
-/**
- * PropertySet Tester.
- */
-public class CliTest extends DirectoryServerTestCase {
-
-
- /**
- * Initialization
- */
- @BeforeClass
- public void setUp()
- {
- }
-
- /**
- * Verify that returncode are registered with declared MesssageId
- */
- @Test
- public void testReturnCodeMessageId()
- {
- String invalidMsg;
- String msg;
- LocalizableMessage message;
- for (DsFrameworkCliReturnCode returnCode : DsFrameworkCliReturnCode
- .values())
- {
- if ((message = returnCode.getMessage()).equals(ERR_ADMIN_NO_MESSAGE.get()))
- {
- continue;
- }
- invalidMsg = "Unknown message for message ID " + message;
- if (message.toString().equals(invalidMsg))
- {
- assertTrue(false, "ReturnCode \"" + returnCode
- + "\" is registered with a wrong message Id (" + message + ")");
- }
- }
- }
-
-
- /**
- * Test if ADS errors are all associated with returncode.
- */
- @Test
- public void testCheckRegisterAdsError()
- {
- for (ErrorType error: ErrorType.values())
- {
- assertNotNull(DsFrameworkCliReturnCode.getReturncodeFromAdsError(error),
- "ErrorType." + error + " is not associated with a return code");
- }
- }
-
- /**
- * Test if ADS errors are all associated with returncode.
- */
- @Test
- public void testServerGroupAttributeDisplayName()
- {
- DsFrameworkCliServerGroup cli = new DsFrameworkCliServerGroup();
-
- try
- {
- cli.initializeCliGroup(new DsFrameworkCliParser(null, null, false),
- null);
- }
- catch (ArgumentException e)
- {
- assertTrue(false, e.getMessage());
- }
- for (ServerGroupProperty prop : ServerGroupProperty.values())
- {
- assertNotNull(cli.getAttributeDisplayName(prop), "ServerGroupProperty."
- + prop.toString() + " has no display value");
- }
- }
-
-
-}
-
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/admin/client/cli/DsframeworkTestCase.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/admin/client/cli/DsframeworkTestCase.java
deleted file mode 100644
index 7a3fd4f..0000000
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/admin/client/cli/DsframeworkTestCase.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2006-2008 Sun Microsystems, Inc.
- */
-package org.opends.server.admin.client.cli;
-
-
-
-import java.io.File;
-import java.io.FileWriter;
-
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.opends.server.TestCaseUtils;
-import org.opends.server.DirectoryServerTestCase;
-import org.opends.server.core.DirectoryServer;
-
-import static org.testng.Assert.*;
-
-import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
-
-
-
-/**
- * A set of test cases for the dsservice tool.
- */
-public class DsframeworkTestCase extends DirectoryServerTestCase {
- // The path to a file containing an invalid bind password.
- private String invalidPasswordFile;
-
- // The path to a file containing a valid bind password.
- private String validPasswordFile;
-
-
-
- /**
- * Ensures that the Directory Server is running and performs other necessary
- * setup.
- *
- * @throws Exception If an unexpected problem occurs.
- */
- @BeforeClass()
- public void before()
- throws Exception
- {
- TestCaseUtils.startServer();
-
- File pwFile = File.createTempFile("valid-bind-password-", ".txt");
- pwFile.deleteOnExit();
- FileWriter fileWriter = new FileWriter(pwFile);
- fileWriter.write("password" + System.getProperty("line.separator"));
- fileWriter.close();
- validPasswordFile = pwFile.getAbsolutePath();
-
- pwFile = File.createTempFile("invalid-bind-password-", ".txt");
- pwFile.deleteOnExit();
- fileWriter = new FileWriter(pwFile);
- fileWriter.write("wrongPassword" + System.getProperty("line.separator"));
- fileWriter.close();
- invalidPasswordFile = pwFile.getAbsolutePath();
-
- String[] args =
- {
- "create-ads",
- "--noPropertiesFile",
- "-p", String.valueOf(TestCaseUtils.getServerAdminPort()),
- "-w", "password",
- "-X"
- };
-
- assertEquals(DsFrameworkCliMain.mainCLI(args, false, System.out,
- System.err), SUCCESSFUL.getReturnCode());
- }
-
- /**
- * Ensures ADS is removed.
- * @throws Exception If an unexpected problem occurs.
- */
- @AfterClass()
- public void afterClass()
- throws Exception
- {
-// String[] args =
-// {
-// "delete-ads",
-// "--noPropertiesFile",
-// "-p", String.valueOf(TestCaseUtils.getServerAdminPort()),
-// "-w", "password",
-// "--backendName", "admin"
-// };
-//
-// assertEquals(DsFrameworkCliMain.mainCLI(args, false, System.out,
-// System.err), SUCCESSFUL.getReturnCode());
- }
-
- /**
- * Tests list-groups with a malformed bind DN.
- */
- @Test()
- public void testMalformedBindDN()
- {
- String[] args =
- {
- "list-groups",
- "--noPropertiesFile",
- "-p", String.valueOf(TestCaseUtils.getServerAdminPort()),
- "-D", "malformed",
- "-w", "password",
- "-X"
- };
-
- assertFalse(DsFrameworkCliMain.mainCLI(args, false, null, null)
- == SUCCESSFUL.getReturnCode());
- }
-
- /**
- * Tests list-groups with a nonexistent bind DN.
- */
- @Test()
- public void testNonExistentBindDN()
- {
- String[] args =
- {
- "list-groups",
- "--noPropertiesFile",
- "-p", String.valueOf(TestCaseUtils.getServerAdminPort()),
- "-D", "cn=Does Not Exist",
- "-w", "password",
- "-X"
- };
-
- assertFalse(DsFrameworkCliMain.mainCLI(args, false, System.out, System.err)
- == SUCCESSFUL.getReturnCode());
- }
-
- /**
- * Tests list-groups with an invalid password.
- */
- @Test()
- public void testInvalidBindPassword()
- {
- String[] args =
- {
- "list-groups",
- "--noPropertiesFile",
- "-p", String.valueOf(TestCaseUtils.getServerAdminPort()),
- "-D", "cn=Directory Manager",
- "-w", "wrongPassword",
- "-X"
- };
-
- assertFalse(DsFrameworkCliMain.mainCLI(args, false, System.out, System.err)
- == SUCCESSFUL.getReturnCode());
- }
-
-
-
-
- /**
- * Tests list-groups with a valid password read from a file.
- *
- * @throws Exception If an unexpected problem occurs.
- */
- @Test()
- public void testValidPasswordFromFile()
- throws Exception
- {
- String[] args =
- {
- "list-groups",
- "--noPropertiesFile",
- "-p", String.valueOf(TestCaseUtils.getServerAdminPort()),
- "-D", "cn=Directory Manager",
- "-j", validPasswordFile,
- "-X"
- };
-
- assertEquals(DsFrameworkCliMain.mainCLI(args, false, System.out,
- System.err), SUCCESSFUL.getReturnCode());
- }
-
- /**
- * Tests list-groups with an invalid password read from a file.
- *
- * @throws Exception If an unexpected problem occurs.
- */
- @Test()
- public void testInvalidPasswordFromFile()
- throws Exception
- {
- String[] args =
- {
- "list-groups",
- "--noPropertiesFile",
- "-p", String.valueOf(TestCaseUtils.getServerAdminPort()),
- "-D", "cn=Directory Manager",
- "-j",invalidPasswordFile,
- "-X"
- };
-
- assertFalse(DsFrameworkCliMain.mainCLI(args, false, System.out, System.err)
- == SUCCESSFUL.getReturnCode());
- }
-
- /**
- * Tests a list-groups over SSL using blind trust.
- */
- @Test()
- public void testListGroupsSSLBlindTrust()
- {
- String[] args =
- {
- "list-groups",
- "--noPropertiesFile",
- "-p", String.valueOf(TestCaseUtils.getServerAdminPort()),
- "-w", "password",
- "-X"
- };
-
- assertEquals(DsFrameworkCliMain.mainCLI(args, false, System.out,
- System.err), SUCCESSFUL.getReturnCode());
- }
-
-
-
- /**
- * Tests a list-groups over SSL using a trust store.
- */
- @Test()
- public void testListGroupsSSLTrustStore()
- {
- String trustStorePath = DirectoryServer.getInstanceRoot() + File.separator +
- "config" + File.separator + "admin-truststore";
-
- String[] args =
- {
- "list-groups",
- "--noPropertiesFile",
- "-p", String.valueOf(TestCaseUtils.getServerAdminPort()),
- "-w", "password",
- "-P", trustStorePath
- };
-
- assertEquals(DsFrameworkCliMain.mainCLI(args, false, System.out,
- System.err), SUCCESSFUL.getReturnCode());
- }
-
-
- /**
- * Tests the dsservice with the "--help" option.
- */
- @Test()
- public void testHelp()
- {
- String[] args = {"--noPropertiesFile", "--help" };
- assertEquals(DsFrameworkCliMain.mainCLI(args, false, null, null),
- SUCCESSFUL.getReturnCode());
-
- args = new String[] {"--noPropertiesFile", "-H" };
- assertEquals(DsFrameworkCliMain.mainCLI(args, false, null, null),
- SUCCESSFUL.getReturnCode());
-
- args = new String[] {"--noPropertiesFile", "-?" };
- assertEquals(DsFrameworkCliMain.mainCLI(args, false, null, null),
- SUCCESSFUL.getReturnCode());
- }
-}
-
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigLdapConnectionTestCase.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigLdapConnectionTestCase.java
index bbf7651..e1e6f71 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigLdapConnectionTestCase.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigLdapConnectionTestCase.java
@@ -22,28 +22,23 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.tools.dsconfig;
-
-
import java.io.File;
import java.io.FileWriter;
+import org.opends.server.DirectoryServerTestCase;
+import org.opends.server.TestCaseUtils;
+import org.opends.server.core.DirectoryServer;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.opends.server.TestCaseUtils;
-import org.opends.server.DirectoryServerTestCase;
-import org.opends.server.core.DirectoryServer;
-
+import static org.opends.server.tools.JavaPropertiesTool.ErrorReturnCode.*;
import static org.testng.Assert.*;
-import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
-
-
-
/**
* A set of test cases for the dsservice tool.
*/
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigOptionsTestCase.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigOptionsTestCase.java
index 636622f..cd61fd1 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigOptionsTestCase.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/dsconfig/DsconfigOptionsTestCase.java
@@ -30,7 +30,7 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
+import static org.opends.server.tools.JavaPropertiesTool.ErrorReturnCode.*;
import static org.testng.Assert.*;
/**
@@ -110,7 +110,7 @@
};
try
{
- assertEquals(dsconfigMain(args), CANNOT_INITIALIZE_ARGS.getReturnCode());
+ assertEquals(dsconfigMain(args), 1);
}
finally
{
--
Gitblit v1.10.0