[Fedora-directory-commits] directoryconsole/src/com/netscape/admin/dirserv DSAdmin.java, 1.3, 1.4 DSUtil.java, 1.1.1.1, 1.2 dirserv.properties, 1.5, 1.6

Nathan Kinder (nkinder) fedora-directory-commits at redhat.com
Mon Jul 2 19:44:10 UTC 2007


Author: nkinder

Update of /cvs/dirsec/directoryconsole/src/com/netscape/admin/dirserv
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv5440/src/com/netscape/admin/dirserv

Modified Files:
	DSAdmin.java DSUtil.java dirserv.properties 
Log Message:
Resolves: 246513
Summary: Removed server root concept from Directory Console.



Index: DSAdmin.java
===================================================================
RCS file: /cvs/dirsec/directoryconsole/src/com/netscape/admin/dirserv/DSAdmin.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DSAdmin.java	28 Oct 2005 22:18:17 -0000	1.3
+++ DSAdmin.java	2 Jul 2007 19:44:08 -0000	1.4
@@ -208,7 +208,6 @@
 		int securePort = 0;
 		String baseDN = null;
 		String	sServerID = null;			  // Instance of DS server
-		String installPath = null;            // Path where server is installed
 		try {
 			LDAPConnection ldc = _info.getLDAPConnection();
 			if ( ldc == null ) {
@@ -225,7 +224,6 @@
 			baseDN = getAttrVal( entry, "nsBaseDN" );
 			_bindDN = getAttrVal( entry, "nsBindDN" );
 			sServerID = getAttrVal( entry, "nsServerID" );
-			installPath = getAttrVal ( entry, "serverroot");
 
 			if ( (host == null) || (sPort == null) ||
 				 (baseDN == null) || (sServerID == null) ) {
@@ -347,9 +345,6 @@
 		/* For the key and cert wizard */
 		_serverInfo.put( "SIE", sServerID );
 
-		/* Save the install path */
-		_serverInfo.put( "InstallPath", installPath);
-
 		Debug.println(9,  "DSAdmin.getInfo: OS = " + _info.getAdminOS() );
 
 /*
@@ -749,9 +744,6 @@
 		   things statically across server instances */
 		DSUtil.initialize( ldc, _serverInfo.getAuthenticationDN() );
 
-		// set the server root for other directory console classes to use
-		readServerRoot();
-
 		// create new frame
 		_serverInfo.frame = null;
 		_pagefeeder = new DSPageFeeder( this, _info, _serverInfo );
@@ -824,10 +816,6 @@
 		}
 	}
 
-    private void readServerRoot() {
-		DSUtil.readServerRoot(_info, _serverInfo, null);
-	}
-
 
     private void startUpdater() {
 		_animate = true;
@@ -1231,7 +1219,7 @@
 	private boolean checkVersion(ConsoleInfo info) {
 		String version = null;
 		JFrame frame = UtilConsoleGlobals.getActivatedFrame();
-		version = VersionInfo.getVersionNumber();
+		version = VersionInfo.getMajorVersionNumber();
 
 		try {
 			Float f = new Float(version);


Index: DSUtil.java
===================================================================
RCS file: /cvs/dirsec/directoryconsole/src/com/netscape/admin/dirserv/DSUtil.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- DSUtil.java	18 Jul 2005 00:55:42 -0000	1.1.1.1
+++ DSUtil.java	2 Jul 2007 19:44:08 -0000	1.2
@@ -23,6 +23,7 @@
 import java.awt.*;
 import java.awt.image.*;
 import java.util.*;
+import java.util.regex.*;
 import java.io.*;
 import java.net.*;
 import java.text.SimpleDateFormat;
@@ -236,74 +237,6 @@
 	return (result == AUTH_SUCCESS);
     }
 
-    /**
-     * Reads server root and writes it to the serverInfo provided with the key
-	 * "serverroot".  
-     *
-     * @param consoleInfo ConsoleInfo; the ConsoleInfo of the admin console
-     * @param frame Parent frame for error dialogs
-     * @param serverInfo ConsoleInfo; the ConsoleInfo of the server we are connected to
-     *     
-     */
-    static public void readServerRoot(ConsoleInfo consoleInfo,
-				      ConsoleInfo serverInfo,
-				      JFrame frame) {
-	String root = null;
-	String authName = null;
-	/* Get the server root */
-	if (serverInfo != null) {
-	    LDAPConnection ldc = serverInfo.getLDAPConnection();
-	    authName = ldc.getAuthenticationDN();
-	    LDAPEntry entry = null;
-	    Debug.println(9, "DSUtil.readServerRoot ldc=" + format(ldc));
-	    try {
-		String[] attrs = { INSTANCE_ATTR, SECURITY_ATTR };
-		entry = ldc.read( "cn=config", attrs );
-		Debug.println(9, "DSUtil.readServerRoot entry=" + entry);
-		root = getAttrValue(entry, INSTANCE_ATTR);
-		String secValue = getAttrValue(entry, SECURITY_ATTR);
-	    } catch ( LDAPException e ) {
-		Debug.println("DSUtil.readServerRoot(): exception " + e);
-		Debug.println( "DSUtil.readServerRoot: cannot read " +
-			       "cn=config ldc " +
-			       (ldc.isConnected() ? "is" : "is not") +
-			       " connected, bind DN = " +
-			       ldc.getAuthenticationDN());
-	    }
-	}
-
-	/* Get the server root from the SIE */
-        if (root == null && consoleInfo != null) {
-	    LDAPConnection ldc = consoleInfo.getLDAPConnection();
-	    authName = ldc.getAuthenticationDN();
-	    LDAPEntry entry = null;
-	    Debug.println(9, "DSUtil.readServerRoot console ldc=" +
-			  format(ldc));
-	    try {
-		String[] attrs = { "serverroot" };
-		entry = ldc.read( consoleInfo.getCurrentDN(), attrs );
-		Debug.println(9, "DSUtil.readServerRoot entry=" + entry);
-		root = getAttrValue(entry, "serverroot");
-	    } catch ( LDAPException e ) {
-		Debug.println("DSUtil.readServerRoot(): exception " + e);
-		Debug.println( "DSUtil.readServerRoot: cannot read " +
-			       consoleInfo.getCurrentDN() +
-			       " ldc " +
-			       (ldc.isConnected() ? "is" : "is not") +
-			       " connected, bind DN = " +
-			       ldc.getAuthenticationDN());
-	    }
-	}
-			
-        if (root == null && frame != null) {
-            showErrorDialog( frame, "config-privilege", authName );    
-        } else if (root != null && serverInfo != null) {
-	    serverInfo.put("serverroot", root);
-	}
-
-	return;
-    }
-
 
     /**
      * Returns the name of the server instance corresponding to the server connection.
@@ -2344,7 +2277,7 @@
 	}
 	LDAPSearchResults res = null;
 	try {
-	    res = ldc.search(LDBM_CONFIG_BASE_DN, ldc.SCOPE_SUB,
+	    res = ldc.search(LDBM_BASE_DN, ldc.SCOPE_SUB,
 			     filter, null, false);
 	    while (res.hasMoreElements()) {
 		LDAPEntry entry = (LDAPEntry)res.nextElement();
@@ -2821,49 +2754,98 @@
 	}
 
     /**
+     * Returns the default path used for backups.
+     *
+     * @param info serverInfo, information for the current server
+     *
+     * @return the default backup path
+     */
+    public static String getDefaultBackupPath(ConsoleInfo serverInfo) {
+        return getDefaultDSPath( serverInfo, CONFIG_BASE_DN, BAKDIR_ATTR );
+    }
+
+    /**
+     * Returns the default path used to store the changelog database.
+     *
+     * @param info serverInfo, information for the current server
+     *
+     * @return the default changelog database path
+     */
+    public static String getDefaultChangelogPath(ConsoleInfo serverInfo) {
+        String path = getDefaultDBPath( serverInfo );
+
+        // We want the changelog path to be at the same level as the db directory.
+        Matcher matcher = Pattern.compile("/db$").matcher( path );
+        return matcher.replaceAll("/" + CHANGELOG_DIR);
+    }
+
+    /**
+     * Returns the default path used to store database files.
+     *
+     * @param info serverInfo, information for the current server
+     *
+     * @return the default database path
+     */
+    public static String getDefaultDBPath(ConsoleInfo serverInfo) {
+        return getDefaultDSPath( serverInfo, LDBM_CONFIG_BASE_DN, DBDIR_ATTR );
+    }
+
+    /**
      * Returns the default path used to store the LDIF files.
-	 * Returns a path of type /usr/fedora/servers/slapd-host/ldif/.
-	 * If something is wrong returns the parent path (../)
      *
      * @param info serverInfo, information for the current server
      *
-     * @return the name of the instance
+     * @return the default LDIF path
      */
-	public static String getDefaultLDIFPath(ConsoleInfo serverInfo) {
-		String defaultPath = "";
-		if (serverInfo != null) {
-			String installPath = (String) serverInfo.get("InstallPath");
-			
-			if (installPath != null) {
-				/* We get the OS of the server we are working with from the admin */
-				String separator = "\\";
-				if (!isNT(serverInfo)) {
-					separator = "/";
-				}
-				String slapd = (String)serverInfo.get("ServerInstance");
-				if (slapd != null) {										
-					/* The slapd variable contains now the 'slapd-<instance name>' */					
-					defaultPath = installPath + separator + 
-						slapd + separator + 
-						"ldif" + separator;
-				}			
-			}
-		}	
-	
-		File defaultPathFile = new File(defaultPath);
-		if (!defaultPathFile.exists()  &&
-			isLocal(serverInfo.getHost())) {
-			Debug.println("DSUtil.getDefaultLDIFPath() : "+defaultPath+" does not exist");
-			String separator = "\\";
-			if (serverInfo != null) {
-				if (!isNT(serverInfo)) {
-					separator = "/";
-				}
-			}
-			defaultPath = ".."+separator;
-		}
-		return defaultPath;		
-	}
+    public static String getDefaultLDIFPath(ConsoleInfo serverInfo) {
+        return getDefaultDSPath( serverInfo, CONFIG_BASE_DN, LDIFDIR_ATTR );
+    }
+
+    /**
+     * Returns the default path used to store the server log files.
+     *
+     * @param info serverInfo, information for the current server
+     *
+     * @return the default server logfile path
+     */
+    public static String getDefaultLogPath(ConsoleInfo serverInfo) {
+        String path = getDefaultDSPath( serverInfo, CONFIG_BASE_DN, LOGDIR_ATTR );
+
+        // There is no logdir attribute, so we get the errorlog location and
+        // trim off the logfile name to get the default path.
+        Matcher matcher = Pattern.compile("/errors$").matcher( path );
+        return matcher.replaceAll("");
+    }
+
+    private static String getDefaultDSPath(ConsoleInfo serverInfo,
+                                          String entry,
+                                          String pathAttr) {
+        String defaultPath = "";
+
+        if (serverInfo != null) {
+            LDAPConnection ldc = serverInfo.getLDAPConnection();
+            if ( reconnect( ldc ) ) {
+                try {
+                    /* Lookup the path from the server config */
+                    String[] attrs = { pathAttr };
+                    LDAPEntry lde = ldc.read(entry, attrs);
+                    defaultPath = getAttrValue(lde, pathAttr);
+                } catch ( LDAPException e ) {
+                    Debug.println("DSUtil.getDefaultDSPath() : Caught ldap exception + e");
+                }
+            }
+        } else {
+            Debug.println("DSUtil.getDefaultDSPath() : serverInfo is null");
+        }
+
+        File defaultPathFile = new File(defaultPath);
+        if (!defaultPathFile.exists()  &&
+            isLocal(serverInfo.getHost())) {
+            Debug.println("DSUtil.getDefaultDSPath() : " + defaultPath + " does not exist");
+        }
+
+        return defaultPath;
+    }
 
 	/**
 	 * Gets a boolean valued attribute from a properties file.  Values meaning
@@ -2927,6 +2909,11 @@
     public static final String AUTH_CHANGE_LISTENERS = "AuthChangeListeners";
     private static final String INSTANCE_ATTR = "nsslapd-instancedir";
     private static final String SECURITY_ATTR = "nsslapd-security";
+    private static final String BAKDIR_ATTR = "nsslapd-bakdir";
+    private static final String DBDIR_ATTR = "nsslapd-directory";
+    private static final String LDIFDIR_ATTR = "nsslapd-ldifdir";
+    private static final String LOGDIR_ATTR = "nsslapd-errorlog";
+    private static final String CHANGELOG_DIR = "changelogdb";
     private static final ResourceSet _helpResource =
 	new ResourceSet("com.netscape.admin.dirserv.dirserv-help");
     static public ResourceSet _resource = 
@@ -2937,8 +2924,10 @@
 
 	private static int _local = -1;
 
+    static public final String CONFIG_BASE_DN = "cn=config";
     static public final String PLUGIN_CONFIG_BASE_DN = "cn=plugins,cn=config";
-    static public final String LDBM_CONFIG_BASE_DN = "cn=ldbm database,cn=plugins,cn=config";
+    static public final String LDBM_BASE_DN = "cn=ldbm database,cn=plugins,cn=config";
+    static public final String LDBM_CONFIG_BASE_DN = "cn=config,cn=ldbm database,cn=plugins,cn=config";
     static public final String CHAINING_CONFIG_BASE_DN = "cn=chaining database,cn=plugins,cn=config";
     static public final String DEFAULT_DB_INSTANCE_FILTER = "objectclass=nsBackendInstance";
     static public final String MAPPING_TREE_BASE_DN = "cn=mapping tree,cn=config";


Index: dirserv.properties
===================================================================
RCS file: /cvs/dirsec/directoryconsole/src/com/netscape/admin/dirserv/dirserv.properties,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- dirserv.properties	29 Sep 2006 17:17:26 -0000	1.5
+++ dirserv.properties	2 Jul 2007 19:44:08 -0000	1.6
@@ -2657,9 +2657,13 @@
 mappingtree-backend-bdelete-ttip=Remove a database from the list
 mappingtree-backend-bck-list-label=Databases containing entries for this suffix:
 mappingtree-backend-bck-list-ttip=Select the database(s) managed by this suffix from the list.
-mappingtree-backend-error-no-funct-label=The function name is missing
-mappingtree-backend-error-no-lib-label=The library path is missing
-mappingtree-backend-update-error-title=Failed to Update Databases Info
+mappingtree-backend-error-no-funct-msg=The distribution library function name is missing.
+mappingtree-backend-error-no-funct-title=Distribution Plugin Error
+mappingtree-backend-error-no-lib-msg=The distribution library path is missing.
+mappingtree-backend-error-no-lib-title=Distribution Plugin Error
+mappingtree-backend-error-not-local-msg=You must be local to the server to browse for distribution libraries.
+mappingtree-backend-error-not-local-title=Browsing Error
+mappingtree-backend-update-error-title=Failed to Update Databases Info.
 mappingtree-backend-update-error-msg=Error updating :%1 \n %2
 mappingtree-backend-add-backend-description=Use this dialog to choose a database to add to this suffix
 




More information about the Fedora-directory-commits mailing list