Index: lib/admin/ldap-configuration.jsp
===================================================================
--- lib/admin/ldap-configuration.jsp	(revision 4158)
+++ lib/admin/ldap-configuration.jsp	(revision 4159)
@@ -27,15 +27,6 @@
  */
 %>
 
-<%
-	PropertiesMetaData propMetadata =
-		(PropertiesMetaData)request.getAttribute("metadata");
- 	Vector<String> ldapOrganizations = 
- 		(Vector<String>)request.getAttribute("orgList"); 
-	Map<Integer, MetaDataGroup> groupMap = 
-		(Map<Integer, MetaDataGroup>)request.getAttribute("groupMap"); 
-%>
-
 <html>
 <head>
 
@@ -57,106 +48,110 @@
 
 <form method="POST" name="configuration_form" action="<%= request.getContextPath() %>/admin" 
                                         onsubmit="return submitForm(this);">
-<%
-	Map<Integer, MetaDataProperty> globalPropertiesMap = propMetadata.getPropertiesInGroup(1);
-	MetaDataGroup globalGroup = groupMap.get(new Integer(1));
+<% 
+	// metadata holds all group and properties metadata
+    PropertiesMetaData metadata = (PropertiesMetaData)request.getAttribute("metadata");
+	if (metadata != null) {
+		// each group describes a section of properties
+		Map<Integer, MetaDataGroup> groupMap = metadata.getGroups();
+		Set<Integer> groupIdSet = groupMap.keySet();
+		for (Integer groupId : groupIdSet) {
+			// for this group, display the header (group name)
+			MetaDataGroup metaDataGroup = (MetaDataGroup)groupMap.get(groupId);
 %>
-  <h3><%=globalGroup.getName()%></h3> 
-  <hr class="config-line">
+		<h3><%= metaDataGroup.getName()  %></h3>
+		<hr class="config-line">
+		<table class="config-section">
 <%
- 	if (globalGroup.getComment() != null) {
-%>
-  <div class="heading-comment"><%=globalGroup.getComment()%></div><br>
+			// get all the properties in this group
+			Map<Integer, MetaDataProperty> propertyMap = 
+				metadata.getPropertiesInGroup(metaDataGroup.getIndex());
+			Set<Integer> propertyIndexes = propertyMap.keySet();
+			// iterate through each property and display appropriately
+			for (Integer propertyIndex : propertyIndexes) {
+				MetaDataProperty metaDataProperty = propertyMap.get(propertyIndex);
+    			String fieldType = metaDataProperty.getFieldType(); 
+    			if (fieldType.equals("select")) {
+%> 
+			<tr>
+				<td class="config-property-label">
+     				<label for="<%= metaDataProperty.getKey() %>" title="<%= metaDataProperty.getDescription() %>"><%= metaDataProperty.getLabel() %></label>   
+     			</td>	
+     			<td class="config-property-input" >		
+					<select name="<%= metaDataProperty.getKey() %>">
 <%
-	}
+					Vector<String> fieldOptionValues = metaDataProperty.getFieldOptionValues();
+					Vector<String> fieldOptionNames = metaDataProperty.getFieldOptionNames();
+					for (int i = 0; i < fieldOptionNames.size(); i++) {
 %>
-<br>
-<table class="config-section">
+					<option value="<%= fieldOptionValues.elementAt(i) %>"> <%= fieldOptionNames.elementAt(i) %>
 <%
-	Set<Integer> globalIdSet = globalPropertiesMap.keySet();
-	for (Integer globalId : globalIdSet) {
-		MetaDataProperty globalProperty = globalPropertiesMap.get(globalId);
+				}
 %>
-	<tr>
-		<td class="config-property-label">
-			<label for="<%= globalProperty.getKey() %>" title="<%= globalProperty.getDescription() %>"><%=globalProperty.getLabel()%></label>
-		</td>	
-		<td class="config-property-input" >	
-			<input id="<%= globalProperty.getKey() %>" name="<%= globalProperty.getKey() %>" 
-				value="<%= request.getAttribute(globalProperty.getKey()) %>"             		    	    	           		    	             			
-				type="text"           			
-				alt="LDAP server URL"/>	   
-		</td>
-		<td class="config-question-mark">        		    
-			<img src="style/images/question-mark.gif" onClick="helpWindow('<%= request.getContextPath() %>', '<%= globalProperty.getHelpFile() %>')"/><br/>
-		</td>
-	</tr>
-<%
-	}
-    Map<Integer, MetaDataProperty> orgPropertyMap = propMetadata.getPropertiesInGroup(2);
-    MetaDataGroup orgGroup = groupMap.get(new Integer(2));
-    Set<Integer> orgIdSet = orgPropertyMap.keySet();
+					</select>
+				</td>
+				<td class="config-question-mark">
+					<img src="style/images/question-mark.gif" 
+	           		       alt="<%= metaDataProperty.getDescription() %>" 
+	           		       title="<%= metaDataProperty.getDescription() %>"/>
+				</td>
+			</tr>
+
+<%		
+				} else if (fieldType.equals("password")) {
 %>
-	</table>
-	<h3><%=orgGroup.getName()%></h3> 
-    <hr class="config-line">
-<%
- 	if (orgGroup.getComment() != null) {
+			<tr>
+				<td class="config-property-label">
+					<label for="<%= metaDataProperty.getKey() %>" title="<%= metaDataProperty.getDescription() %>"><%= metaDataProperty.getLabel() %></label>
+     			</td>	
+     			<td class="config-property-input" >	
+					<input id="<%= metaDataProperty.getKey() %>" name="<%= metaDataProperty.getKey() %>" 	             		    	    	           		    	             			
+	           		    	value="<%= request.getAttribute(metaDataProperty.getKey()) %>"
+	           		    	type="<%= fieldType %>"
+	           		    	alt="<%= metaDataProperty.getDescription() %>"/> 
+				</td>
+				<td class="config-question-mark">
+					<img src="style/images/question-mark.gif" 
+	           		       alt="<%= metaDataProperty.getDescription() %>" 
+	           		       title="<%= metaDataProperty.getDescription() %>"/>
+				</td>
+			</tr>
+<%		
+				} else {
 %>
-  <div class="heading-comment"><%= orgGroup.getComment() %></div>
-<%
- 	}
+			<tr>
+				<td class="config-property-label">
+					<label for="<%= metaDataProperty.getKey() %>" title="<%= metaDataProperty.getDescription() %>"><%= metaDataProperty.getLabel() %></label>
+     			</td>	
+     			<td class="config-property-input" >							
+					<input id="<%= metaDataProperty.getKey() %>" name="<%= metaDataProperty.getKey() %>" 
+	    			        value="<%= request.getAttribute(metaDataProperty.getKey()) %>"	             		    	    	           		    	             			
+	           		    	type="<%= fieldType %>	"           			
+	           		    	alt="<%= metaDataProperty.getDescription() %>"/>	
+	           	</td>
+				<td class="config-question-mark">           		    
+					<img class=question-mark src="style/images/question-mark.gif" onClick="helpWindow('ldap_url_help.html')"/>
+				</td>
+ 			</tr>
+<%   			
+				}
+    			
+    			if (metaDataProperty.getDescription() != null) {
 %>
-<br>
+			<tr>
+    	        <td></td>
+    	        <td class="config-property-description" colspan="2" >
+					<%= metaDataProperty.getDescription() %>
+    	        </td>
+			</tr>
 <%
-	for (String orgName : ldapOrganizations) {
+    			}
+			}
 %>
-<table class="config-section">
-	<tr>
-		<td class="config-checkbox">
-	  		<input class="org" type="checkbox" name="<%= orgName %>.cb" onClick="toggleHiddenTable(this, 'hiding-section-<%= orgName %>')"/>
-	  	</td>
-	  	<td class="config-checkbox-label">	
-			<label for="<%= orgName %>.cb"><%=orgName%></label>
-		</td> 
-		<td class="config-question-mark">
-			<img src="style/images/question-mark.gif"
-					alt="blah"
-					title="blah"/>
-		</td>
-	</tr>
-</table>
-<table class="config-section-hiding" id="hiding-section-<%= orgName %>">  
+
+			</table>
 <%
-	  	for (Integer orgId : orgIdSet) {
-	  	MetaDataProperty orgProperty = orgPropertyMap.get(orgId);
-	  	String orgKeyName = orgProperty.getKey() + "." + orgName;
-%>		
-	<tr>
-		<td class="config-property-label" >	
-	    	<label for="<%= orgKeyName %>" title="<%= orgProperty.getDescription() %>"><%= orgProperty.getLabel() %></label>
-     	</td>	
-     	<td class="config-property-input" >
-			<input name="<%= orgKeyName %>" 
-				value="<%= request.getAttribute(orgKeyName) %>"	  
-<% 
-			if (orgProperty.getFieldType().equals("password")) { 
-%>           		    	    	           		    	             			
-	           	type="password"       
-<%
-	  		}
-%>    			
-	           alt="List of administrators for this installation in LDAP DN syntax (colon separated)"/>	           		    
-		</td>
-		<td class="config-question-mark">
-			<img src="style/images/question-mark.gif" onClick="helpWindow('<%= request.getContextPath() %>', '<%= orgProperty.getHelpFile() %>')"/>
-		</td>
-	</tr>	  
-<%
-	  	}
-%>
-      </table>
-<%
+		}
 	}
 %>
 
Index: lib/admin/organization-configuration.jsp
===================================================================
--- lib/admin/organization-configuration.jsp	(nonexistent)
+++ lib/admin/organization-configuration.jsp	(revision 4159)
@@ -0,0 +1,151 @@
+<%@ page language="java"%>
+<%@ page import="java.util.Set,java.util.Map,java.util.Vector,edu.ucsb.nceas.utilities.*" %>
+<%
+	/**
+ *  '$RCSfile$'
+ *    Copyright: 2008 Regents of the University of California and the
+ *               National Center for Ecological Analysis and Synthesis
+ *  For Details: http://www.nceas.ucsb.edu/
+ *
+ *   '$Author$'
+ *     '$Date$'
+ * '$Revision$'
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+%>
+
+<%
+	PropertiesMetaData metadata = (PropertiesMetaData)request.getAttribute("metadata");
+ 	Vector<String> ldapOrganizations = 
+ 		(Vector<String>)request.getAttribute("orgList"); 
+%>
+
+<html>
+<head>
+
+<title>Organization Configuration</title>
+<link rel="stylesheet" type="text/css" 
+        href="<%= request.getContextPath() %>/admin/admin.css"></link>
+<script language="JavaScript" type="text/JavaScript" src="<%= request.getContextPath() %>/admin/admin.js"></script>
+<script language="JavaScript" type="text/JavaScript" src="<%= request.getContextPath() %>/help/help.js"></script>
+
+</head>
+<body>
+<img src="<%= request.getContextPath() %>/metacat-logo.png" width="100px" align="right"/> 
+<h2>Organization Configuration</h2>
+Enter organization specific properties here. 
+<br class="ldap-header">
+
+<%@ include file="./page-message-section.jsp"%>
+
+
+<form method="POST" name="configuration_form" action="<%= request.getContextPath() %>/admin" 
+                                        onsubmit="return submitForm(this);">
+<%
+	if (metadata != null) {
+		// each group describes a section of properties
+		Map<Integer, MetaDataGroup> groupMap = metadata.getGroups();
+		Set<Integer> groupIdSet = groupMap.keySet();
+		for (Integer groupId : groupIdSet) {
+			// for this group, display the header (group name)
+			MetaDataGroup metaDataGroup = (MetaDataGroup)groupMap.get(groupId);
+%>
+			<h3><%= metaDataGroup.getName()  %></h3>
+			<hr class="config-line">
+<%
+ 			if (metaDataGroup.getComment() != null) {
+%>
+  				<div class="heading-comment"><%= metaDataGroup.getComment() %></div>
+<%
+ 			}
+%>
+			<br>
+<%
+			for (String orgName : ldapOrganizations) {
+%>
+			<table class="config-section">
+				<tr>
+				<td class="config-checkbox">
+	  				<input class="org" type="checkbox" name="<%= orgName %>.cb" onClick="toggleHiddenTable(this, 'hiding-section-<%= orgName %>')"/>
+	  			</td>
+	  			<td class="config-checkbox-label">	
+					<label for="<%= orgName %>.cb"><%=orgName%></label>
+				</td> 
+				<td class="config-question-mark">
+					<img src="style/images/question-mark.gif"
+							alt="blah"
+							title="blah"/>
+				</td>
+				</tr>
+			</table>
+			<table class="config-section-hiding" id="hiding-section-<%= orgName %>">  
+<%
+				// get all the properties in this group
+				Map<Integer, MetaDataProperty> propertyMap = 
+					metadata.getPropertiesInGroup(metaDataGroup.getIndex());
+				Set<Integer> orgIndexes = propertyMap.keySet();
+	  			for (Integer orgIndex : orgIndexes) {
+	  				MetaDataProperty orgProperty = propertyMap.get(orgIndex);
+	  				String orgKeyName = orgProperty.getKey() + "." + orgName;
+%>		
+				<tr>
+				<td class="config-property-label" >	
+	    			<label for="<%= orgKeyName %>" title="<%= orgProperty.getDescription() %>"><%= orgProperty.getLabel() %></label>
+     			</td>	
+     			<td class="config-property-input" >
+					<input name="<%= orgKeyName %>" 
+						value="<%= request.getAttribute(orgKeyName) %>"	  
+<% 
+					if (orgProperty.getFieldType().equals("password")) { 
+%>           		    	    	           		    	             			
+	           			type="password"       
+<%
+	  				}
+%>    			
+	           			alt="List of administrators for this installation in LDAP DN syntax (colon separated)"/>	           		    
+				</td>
+				<td class="config-question-mark">
+					<img src="style/images/question-mark.gif" onClick="helpWindow('<%= request.getContextPath() %>', '<%= orgProperty.getHelpFile() %>')"/>
+				</td>
+				</tr>	  
+<%
+				if (orgProperty.getDescription() != null) {
+%>
+	    	        <tr>
+	    	        <td></td>
+	    	        <td class="config-property-description" colspan="2" >
+						<%= orgProperty.getDescription() %>
+	    	        </td>
+<%
+	    			}
+	  			}
+%>
+      		</table>
+<%
+			}
+		}
+	}
+%>
+
+  <input type="hidden" name="configureType" value="organization"/>
+  <input type="hidden" name="processForm" value="true"/>
+  <input class="left-button" type="submit" value="Save"/>
+  <input class="button" type="button" value="Cancel" onClick="forward('./admin')"> 
+
+</form>
+
+</body>
+</html>

Property changes on: lib/admin/organization-configuration.jsp
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: lib/admin/admin-login.jsp
===================================================================
--- lib/admin/admin-login.jsp	(revision 4158)
+++ lib/admin/admin-login.jsp	(revision 4159)
@@ -1,5 +1,5 @@
 <%@ page language="java" %> 
-<%@ page import="java.util.Vector,edu.ucsb.nceas.metacat.util.LDAPUtil,edu.ucsb.nceas.metacat.service.PropertyService" %>
+<%@ page import="edu.ucsb.nceas.metacat.util.OrganizationUtil,edu.ucsb.nceas.metacat.service.PropertyService" %>
 <% 
 /**
  *  '$RCSfile$'
@@ -28,7 +28,7 @@
 %>
 
 <% 
-	Vector<String> organizationList = LDAPUtil.getOrganizations();
+	Vector<String> organizationList = OrganizationUtil.getOrganizations();
 %>
 
 <html>
@@ -85,7 +85,7 @@
 %>
 			<option value="<%= orgName %>"
 <%
-			if (PropertyService.getProperty("ldap.base." + orgName) == null || PropertyService.getProperty("ldap.base." + orgName).equals("")) {
+			if (PropertyService.getProperty("organization.base." + orgName) == null || PropertyService.getProperty("organization.base." + orgName).equals("")) {
 %>
 			disabled="disabled"
 <%
Index: lib/admin/metacat-configuration.jsp
===================================================================
--- lib/admin/metacat-configuration.jsp	(revision 4158)
+++ lib/admin/metacat-configuration.jsp	(revision 4159)
@@ -31,6 +31,7 @@
 	MetaCatVersion metacatVersion = (MetaCatVersion)request.getAttribute("metaCatVersion"); 	
 	DBVersion databaseVersion = (DBVersion)request.getAttribute("databaseVersion");		
     Boolean propsConfigured = (Boolean)request.getAttribute("propsConfigured");	
+    Boolean orgsConfigured = (Boolean)request.getAttribute("orgsConfigured");	
     Boolean ldapConfigured = (Boolean)request.getAttribute("ldapConfigured");	
     Boolean skinsConfigured = (Boolean)request.getAttribute("skinsConfigured");	
     Boolean dbConfigured = (Boolean)request.getAttribute("dbConfigured");
@@ -76,6 +77,26 @@
 %>
 
 <%
+	if (orgsConfigured != null && orgsConfigured) {
+%>
+        <tr>
+        <td class="configured-tag">[configured] </td>
+		<td class="property-title"> Organization Configuration </td> 
+		<td class="configure-link"> <a href="<%= request.getContextPath() %>/admin?configureType=organization">Reconfigure Now</a> </td>
+        </tr>
+<%
+	} else {
+%>    		
+        <tr>
+ 		<td class=unconfigured-tag>[unconfigured] </td>  
+ 		<td class=property-title> Organization Configuration </td>
+		<td class=configure-link> <a href="<%= request.getContextPath() %>/admin?configureType=organization">Configure Now</a> </td>			
+    	</tr>
+<%
+	}
+%>
+
+<%
 	if (propsConfigured != null && propsConfigured) {
 %>
         <tr>
Index: lib/ldap.properties.metadata.xml
===================================================================
--- lib/ldap.properties.metadata.xml	(nonexistent)
+++ lib/ldap.properties.metadata.xml	(revision 4159)
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+
+<metadataConfig>
+	<group>
+		<index>1</index>
+		<name>LDAP Configuration Values</name>
+		<comment>
+			LDAP Setup
+		</comment>
+		<description>LDAP Configuration Values.</description>
+	</group>
+	
+	<config>
+		<key>ldap.url</key>
+		<label>LDAP URL</label>
+		<group>1</group>
+		<index>1</index>
+		<description>LDAP Server URL.</description>
+		<helpFile>properties.html#ldap.url</helpFile>
+	</config>
+
+	<config>
+		<key>ldap.surl</key>
+		<label>LDAP Secure URL</label>
+		<group>1</group>
+		<index>2</index>
+		<description>LDAP Secure Server URL.</description>
+		<helpFile>properties.html#ldap.surl</helpFile>
+	</config>
+
+	<config>
+		<key>ldap.administrators</key>
+		<label>MetaCat Administrators</label>
+		<group>1</group>
+		<index>3</index>
+		<description>LDAP Administrators.</description>
+		<helpFile>properties.html#ldap.admin</helpFile>
+	</config>
+
+</metadataConfig>
\ No newline at end of file

Property changes on: lib/ldap.properties.metadata.xml
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: lib/org.properties.metadata.xml
===================================================================
--- lib/org.properties.metadata.xml	(revision 4158)
+++ lib/org.properties.metadata.xml	(revision 4159)
@@ -3,11 +3,6 @@
 <metadataConfig>
 	<group>
 		<index>1</index>
-		<name>Global Values</name>
-		<description>Database Configuration Values.</description>
-	</group>
-	<group>
-		<index>2</index>
 		<name>Organizational Level Values</name>
 		<comment>
 			Select the organizations for which you have admin rights, and update
@@ -17,83 +12,47 @@
 	</group>
 
 	<config>
-		<key>ldap.url</key>
-		<label>LDAP URL</label>
+		<key>organization.name</key>
+		<label>Organization Name</label>
 		<group>1</group>
 		<index>1</index>
-		<description>LDAP Server URL.</description>
-		<helpFile>properties.html#ldap.url</helpFile>
+		<description>The display name of organization</description>
+		<helpFile>properties.html#ldap.org</helpFile>
 	</config>
-
+	
 	<config>
-		<key>ldap.surl</key>
-		<label>LDAP Secure URL</label>
+		<key>organization.org</key>
+		<label>LDAP Organization</label>
 		<group>1</group>
 		<index>2</index>
-		<description>LDAP Secure Server URL.</description>
-		<helpFile>properties.html#ldap.surl</helpFile>
-	</config>
-
-	<config>
-		<key>ldap.administrators</key>
-		<label>MetaCat Administrators</label>
-		<group>1</group>
-		<index>3</index>
-		<description>LDAP Administrators.</description>
-		<helpFile>properties.html#ldap.admin</helpFile>
-	</config>
-	
-	<config>
-		<key>ldap.allowedSubmitters</key>
-		<label>Allowed Submitters</label>
-		<group>1</group>
-		<index>4</index>
-		<description>Allowed Submitters</description>
-		<helpFile>properties.html#ldap.allowed</helpFile>
-	</config>
-
-	<config>
-		<key>ldap.deniedSubmitters</key>
-		<label>Denied Submitters</label>
-		<group>1</group>
-		<index>5</index>
-		<description>Denied Submitters</description>
-		<helpFile>properties.html#ldap.denied</helpFile>
-	</config>
-	
-	<config>
-		<key>ldap.org</key>
-		<label>LDAP Organization</label>
-		<group>2</group>
-		<index>1</index>
 		<description>LDAP Organization</description>
 		<helpFile>properties.html#ldap.org</helpFile>
 	</config>
 	
 	<config>
-		<key>ldap.base</key>
+		<key>organization.base</key>
 		<label>LDAP Base</label>
-		<group>2</group>
-		<index>2</index>
+		<group>1</group>
+		<index>3</index>
 		<description>LDAP Base.</description>
-		<helpFile>properties.html#ldap.base</helpFile>
+		<helpFile>properties.html#organization.base</helpFile>
 	</config>
 	
 	<config>
-		<key>ldap.user</key>
+		<key>organization.user</key>
 		<label>LDAP User Name</label>
-		<group>2</group>
-		<index>3</index>
+		<group>1</group>
+		<index>4</index>
 		<description>LDAP User Name</description>
 		<helpFile>properties.html#ldap.user</helpFile>
 	</config>
 
 	<config>
-		<key>ldap.password</key>
+		<key>organization.password</key>
 		<label>LDAP Password</label>
-		<group>2</group>
+		<group>1</group>
 		<fieldType>password</fieldType>
-		<index>4</index>
+		<index>5</index>
 		<description>LDAP Password</description>
 		<helpFile>properties.html#ldap.passwd</helpFile>
 	</config>
Index: src/edu/ucsb/nceas/metacat/service/PropertyService.java
===================================================================
--- src/edu/ucsb/nceas/metacat/service/PropertyService.java	(revision 4158)
+++ src/edu/ucsb/nceas/metacat/service/PropertyService.java	(revision 4159)
@@ -38,7 +38,7 @@
 
 import org.apache.log4j.Logger;
 
-import edu.ucsb.nceas.metacat.util.LDAPUtil;
+import edu.ucsb.nceas.metacat.util.OrganizationUtil;
 import edu.ucsb.nceas.metacat.util.UtilException;
 import edu.ucsb.nceas.utilities.FileUtil;
 import edu.ucsb.nceas.utilities.GeneralPropertyException;
@@ -62,6 +62,7 @@
 	
 	private static final String MAIN_CONFIG_NAME = "metacat.properties";
 	private static final String ORG_CONFIG_NAME = "org.properties";
+	private static final String LDAP_CONFIG_NAME = "ldap.properties";
 	
 	private static boolean bypassAlreadyChecked = false;
 	
@@ -80,6 +81,13 @@
 	private static String orgMetaDataFilePath = null;
 	private static PropertiesMetaData orgMetaData = null;
 	
+	private static String ldapBackupPropertiesFilePath = null;
+	private static SortedProperties ldapBackupProperties = null;
+	
+	private static String ldapMetaDataFilePath = null;
+	private static PropertiesMetaData ldapMetaData = null;
+	
+	
 	private static Logger logMetacat = Logger.getLogger(PropertyService.class);
 
 	/**
@@ -139,14 +147,23 @@
 			}
 
 			// orgMetaData holds configuration information about organization level 
-			// properties.  these are mostly ldap information relative to an 
-			// organization. This is primarily used to display input fields on 
+			// properties.  This is primarily used to display input fields on 
 			// the organization configuration page. The information is retrieved 
-			// from an xml metadata file dedication just to organization properties.
+			// from an xml metadata file dedicated just to organization properties.
 			orgMetaDataFilePath = configDir + FileUtil.getFS() + ORG_CONFIG_NAME + ".metadata.xml";
 			if (orgMetaData == null) {
 				orgMetaData = new PropertiesMetaData(orgMetaDataFilePath);
 			}
+			
+
+			// ldapMetaData holds configuration information about organization level 
+			// properties.  This is primarily used to display input fields on 
+			// the ldap configuration page. The information is retrieved 
+			// from an xml metadata file dedicated just to ldap properties.
+			ldapMetaDataFilePath = configDir + FileUtil.getFS() + LDAP_CONFIG_NAME + ".metadata.xml";
+			if (ldapMetaData == null) {
+				ldapMetaData = new PropertiesMetaData(ldapMetaDataFilePath);
+			}
 		} catch (TransformerException te) {
 			throw new GeneralPropertyException(te.getMessage());
 		}
@@ -174,6 +191,17 @@
 				new SortedProperties(orgBackupPropertiesFilePath);
 			orgBackupProperties.load();
 		}
+		
+		// The ldapBackupProperties hold properties that were backed up the 
+		// last time the LDAP was configured.  On disk, the file will
+		// look like a smaller version of metacat.properties.  It is stored 
+		// in the data storage directory outside the application directories.
+		ldapBackupPropertiesFilePath = backupDirPath + FileUtil.getFS() +  LDAP_CONFIG_NAME + ".backup";
+		if (ldapBackupProperties == null) {
+			ldapBackupProperties = 
+				new SortedProperties(ldapBackupPropertiesFilePath);
+			ldapBackupProperties.load();
+		}
 	
 	}
 
@@ -284,6 +312,18 @@
 	}
 	
 	/**
+	 * Get the LDAP backup properties file. These are configurable 
+	 * properties that are stored outside the metacat install directories so 
+	 * the user does not need to re-enter all the configuration information 
+	 * every time they do an upgrade.
+	 * 
+	 * @return a SortedProperties object with the backup properties
+	 */
+	public static SortedProperties getLDAPBackupProperties() {
+		return ldapBackupProperties;
+	}
+	
+	/**
 	 * Get the main properties metadata. This is retrieved from an xml file that
 	 * describes the attributes of configurable properties.
 	 * 
@@ -305,6 +345,17 @@
 	}
 	
 	/**
+	 * Get the LDAP properties metadata. This is retrieved from an xml
+	 * file that describes the attributes of configurable properties.
+	 * 
+	 * @return a PropertiesMetaData object with the organization properties
+	 *         metadata
+	 */
+	public static PropertiesMetaData getLDAPMetaData() {
+		return ldapMetaData;
+	}
+	
+	/**
 	 * Writes out backup configurable properties to a file.
 	 */
 	public static void persistMainBackupProperties(ServletContext servletContext)
@@ -351,32 +402,17 @@
 			// the associated metadata file
 			PropertiesMetaData orgMetadata = new PropertiesMetaData(orgMetaDataFilePath);
 			
-			// Here we get the group definition for group 1 from the org
-			// metadata.  Group 1 should be global values across all 
-			// organizations.  We then get all properties metadata associated 
-			// with group 1, iterate through it and set it in the backup
-			// properties.
-			MetaDataGroup globalGroup = orgMetadata.getGroup(1);
-			SortedMap<Integer, MetaDataProperty> globalPropertyMap = 
-				orgMetadata.getPropertiesInGroup(globalGroup.getIndex());
-			for (MetaDataProperty property : globalPropertyMap.values()) {
-				String orgPropertyName = property.getKey();
-				backupProperties.addProperty(orgPropertyName, getProperty(orgPropertyName));
-			}
-			
 			// We do the same thing here for organization specific properies
 			// with the addition that we need to iterate through all available 
 			// organizations.  For instance, a metadata section that defines a 
-			// property as "ldap.base" will be entered into the metacat.properties
-			// file with a key of "ldap.base.NCEAS" for the NCEAS organization. 
+			// property as "organization.base" will be entered into the metacat.properties
+			// file with a key of "organization.base.NCEAS" for the NCEAS organization. 
 			// This will be repeated for all available organizations.
-			MetaDataGroup orgGroup = orgMetadata.getGroup(2);
-			SortedMap<Integer, MetaDataProperty> orgPropertyMap = orgMetadata
-					.getPropertiesInGroup(orgGroup.getIndex());
-			for (String orgName : LDAPUtil.getOrganizations()) {
-				for (MetaDataProperty property : orgPropertyMap.values()) {
-					String orgPropertyName = property.getKey() + "." + orgName;
-					backupProperties.addProperty(orgPropertyName, getProperty(orgPropertyName));
+			Set<String> orgKeySet = orgMetadata.getKeys();
+			for (String orgName : OrganizationUtil.getOrganizations()) {
+				for (String propertyKey : orgKeySet) {
+					String orgPropertyKey = propertyKey + "." + orgName;
+					backupProperties.addProperty(orgPropertyKey, getProperty(orgPropertyKey));
 				}
 			}
 			
@@ -393,7 +429,40 @@
 			throw new GeneralPropertyException("Could not get organizations: " + ue.getMessage());
 		}
 	}
+	
+	/**
+	 * Writes out backup configurable properties to a file.
+	 */
+	public static void persistLDAPBackupProperties(ServletContext servletContext)
+			throws GeneralPropertyException {
 
+		// Use the metadata to extract configurable properties from the 
+		// overall properties list, and store those properties.
+		try {
+			SortedProperties backupProperties = 
+				new SortedProperties(ldapBackupPropertiesFilePath);
+			
+			// Populate the backup properties for ldap properties using
+			// the associated metadata file
+			PropertiesMetaData ldapMetadata = new PropertiesMetaData(ldapMetaDataFilePath);
+
+			Set<String> ldapKeySet = ldapMetadata.getKeys();
+			for (String propertyKey : ldapKeySet) {
+				backupProperties.addProperty(propertyKey, getProperty(propertyKey));
+			}
+			
+			// store the properties to file
+			backupProperties.store();
+
+		} catch (TransformerException te) {
+			throw new GeneralPropertyException("Could not transform backup properties xml: "
+					+ te.getMessage());
+		} catch (IOException ioe) {
+			throw new GeneralPropertyException("Could not backup configurable properties: "
+					+ ioe.getMessage());
+		} 
+	}
+
 	/**
 	 * Gets the backup properties directory
 	 * 
@@ -473,8 +542,17 @@
 				setPropertyNoPersist(orgBackupPropertyName, value);
 			}
 			
+			SortedProperties ldapBackupProperties = getLDAPBackupProperties();
+			Vector<String> ldapBackupPropertyNames = 
+				ldapBackupProperties.getPropertyNames();
+			for (String ldapBackupPropertyName : ldapBackupPropertyNames) {
+				String value = ldapBackupProperties.getProperty(ldapBackupPropertyName);
+				setPropertyNoPersist(ldapBackupPropertyName, value);
+			}
+			
 			setPropertyNoPersist("configutil.propertiesConfigured", "true");
 			setPropertyNoPersist("configutil.ldapConfigured", "true");
+			setPropertyNoPersist("configutil.organizationsConfigured", "true");
 			setPropertyNoPersist("configutil.skinsConfigured", "true");
 			setPropertyNoPersist("configutil.databaseConfigured", "true");
 				
Index: src/edu/ucsb/nceas/metacat/util/OrganizationUtil.java
===================================================================
--- src/edu/ucsb/nceas/metacat/util/OrganizationUtil.java	(nonexistent)
+++ src/edu/ucsb/nceas/metacat/util/OrganizationUtil.java	(revision 4159)
@@ -0,0 +1,100 @@
+/**
+ *  '$RCSfile$'
+ *    Purpose: A Class that implements administrative methods 
+ *  Copyright: 2008 Regents of the University of California and the
+ *             National Center for Ecological Analysis and Synthesis
+ *    Authors: Michael Daigle
+ * 
+ *   '$Author$'
+ *     '$Date$'
+ * '$Revision$'
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+package edu.ucsb.nceas.metacat.util;
+
+import java.util.Vector;
+
+import edu.ucsb.nceas.metacat.service.PropertyService;
+import edu.ucsb.nceas.utilities.PropertyNotFoundException;
+import edu.ucsb.nceas.utilities.StringUtil;
+
+public class OrganizationUtil {
+
+	/**
+	 * private constructor - all methods are static so there is no no need to
+	 * instantiate.
+	 */
+	private OrganizationUtil() {}
+
+	/**
+	 * gets a list of organization names from metacat.properties. Parses the csv
+	 * string into a vector
+	 * 
+	 * @return a Vector of Strings that hold all available organizations
+	 * 
+	 * TODO MCD this should be retrieved from ldap instead of metacat.properties
+	 */
+	public static Vector<String> getOrganizations() throws UtilException {
+
+		Vector<String> shortOrgNames = new Vector<String>();
+		Vector<String> longOrgNames = null;
+		
+		longOrgNames = PropertyService.getPropertyNamesByGroup("organization.org");
+
+		for (String longName : longOrgNames) {
+			shortOrgNames.add(longName.substring(17));
+		}
+		return shortOrgNames;
+	}
+	
+	/**
+	 * gets a list of organization names from metacat.properties. Parses the csv
+	 * string into a vector
+	 * 
+	 * @return a Vector of Strings that hold all available organizations
+	 */
+	public static Vector<String> getOrgDNs(String orgName) throws UtilException {
+
+		String orgBaseList = null;
+		try {
+			orgBaseList = PropertyService.getProperty("organization.base." + orgName);
+		} catch (PropertyNotFoundException pnfe) {
+			throw new UtilException("Could not get metacat property: organization.base." 
+					+ orgName + " : " + pnfe.getMessage());
+		}
+		// this will always return a vector (maybe an empty one)
+		return StringUtil.toVector(orgBaseList, ',');
+	}
+	
+
+	/**
+	 * Reports whether LDAP is fully configured.
+	 * 
+	 * @return a boolean that is true if all sections are configured and false
+	 *         otherwise
+	 */
+	public static boolean areOrganizationsConfigured() throws UtilException {
+		String orgConfiguredString = PropertyService.UNCONFIGURED;
+		try {
+			orgConfiguredString = PropertyService.getProperty("configutil.organizationsConfigured");
+		} catch (PropertyNotFoundException pnfe) {
+			throw new UtilException("Could not determine if organizations are configured: "
+					+ pnfe.getMessage());
+		}
+		return !orgConfiguredString.equals(PropertyService.UNCONFIGURED);
+	}
+}

Property changes on: src/edu/ucsb/nceas/metacat/util/OrganizationUtil.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: src/edu/ucsb/nceas/metacat/util/MetaCatUtil.java
===================================================================
--- src/edu/ucsb/nceas/metacat/util/MetaCatUtil.java	(revision 4158)
+++ src/edu/ucsb/nceas/metacat/util/MetaCatUtil.java	(revision 4159)
@@ -993,7 +993,9 @@
 		boolean metacatConfigured = false;
 		try {
 			metacatConfigured = PropertyService.arePropertiesConfigured()
-					&& LDAPUtil.isLDAPConfigured() && SkinUtil.areSkinsConfigured()
+					&& OrganizationUtil.areOrganizationsConfigured() 
+					&& LDAPUtil.isLDAPConfigured()
+					&& SkinUtil.areSkinsConfigured()
 					&& DatabaseUtil.isDatabaseConfigured();
 		} catch (UtilException ue) {
 			logMetacat.error("Could not determine if metacat is configured: "
Index: src/edu/ucsb/nceas/metacat/util/LDAPUtil.java
===================================================================
--- src/edu/ucsb/nceas/metacat/util/LDAPUtil.java	(revision 4158)
+++ src/edu/ucsb/nceas/metacat/util/LDAPUtil.java	(revision 4159)
@@ -343,46 +343,6 @@
 	}
 
 	/**
-	 * gets a list of organization names from metacat.properties. Parses the csv
-	 * string into a vector
-	 * 
-	 * @return a Vector of Strings that hold all available organizations
-	 * 
-	 * TODO MCD this should be retrieved from ldap instead of metacat.properties
-	 */
-	public static Vector<String> getOrganizations() throws UtilException {
-
-		Vector<String> shortOrgNames = new Vector<String>();
-		Vector<String> longOrgNames = null;
-		
-		longOrgNames = PropertyService.getPropertyNamesByGroup("ldap.org");
-
-		for (String longName : longOrgNames) {
-			shortOrgNames.add(longName.substring(9));
-		}
-		return shortOrgNames;
-	}
-	
-	/**
-	 * gets a list of organization names from metacat.properties. Parses the csv
-	 * string into a vector
-	 * 
-	 * @return a Vector of Strings that hold all available organizations
-	 */
-	public static Vector<String> getOrgDNs(String orgName) throws UtilException {
-
-		String orgBaseList = null;
-		try {
-			orgBaseList = PropertyService.getProperty("ldap.base." + orgName);
-		} catch (PropertyNotFoundException pnfe) {
-			throw new UtilException("Could not get metacat property: ldap.base." 
-					+ orgName + " : " + pnfe.getMessage());
-		}
-		// this will always return a vector (maybe an empty one)
-		return StringUtil.toVector(orgBaseList, ',');
-	}
-
-	/**
 	 * Reports whether LDAP is fully configured.
 	 * 
 	 * @return a boolean that is true if all sections are configured and false
Index: src/edu/ucsb/nceas/metacat/AuthLdap.java
===================================================================
--- src/edu/ucsb/nceas/metacat/AuthLdap.java	(revision 4158)
+++ src/edu/ucsb/nceas/metacat/AuthLdap.java	(revision 4159)
@@ -96,7 +96,8 @@
 			this.ldapsUrl = PropertyService.getProperty("ldap.surl");
 			// use the NCEAS base as a fallback.  Normally, the base will be
 			// parsed from the user during authentication
-			this.ldapBase = PropertyService.getProperty("ldap.base.NCEAS");
+			// TODO MCD this may need to remain always at NCEAS value
+			this.ldapBase = PropertyService.getProperty("organization.base.NCEAS");
 			this.referral = PropertyService.getProperty("ldap.referral");
 			this.ldapConnectTimeLimit = PropertyService
 					.getProperty("ldap.connectTimeLimit");
Index: src/edu/ucsb/nceas/metacat/admin/LDAPAdmin.java
===================================================================
--- src/edu/ucsb/nceas/metacat/admin/LDAPAdmin.java	(revision 4158)
+++ src/edu/ucsb/nceas/metacat/admin/LDAPAdmin.java	(revision 4159)
@@ -95,13 +95,10 @@
 			
 			try {
 				// Load the properties metadata file so that the JSP page can
-				// use
-				// the metadata to construct the editing form
-				PropertiesMetaData metadata = PropertyService.getOrgMetaData();
+				// use the metadata to construct the editing form
+				PropertiesMetaData metadata = PropertyService.getLDAPMetaData();
 				request.setAttribute("metadata", metadata);
 				request.setAttribute("groupMap", metadata.getGroups());
-				
-				request.setAttribute("orgList", LDAPUtil.getOrganizations());
 
 				// add the list of ldap options and their values to the request
 				Vector<String> propertyNames = PropertyService.getPropertyNamesByGroup("ldap");
@@ -114,7 +111,7 @@
 				// the user from having to re-enter all values when upgrading.
 				// If this is a first time install, getBackupProperties will return
 				// null.
-				SortedProperties backupProperties = PropertyService.getOrgBackupProperties();
+				SortedProperties backupProperties = PropertyService.getLDAPBackupProperties();
 				if (backupProperties != null) {
 					Vector<String> backupKeys = backupProperties.getPropertyNames();
 					for (String key : backupKeys) {
@@ -130,9 +127,6 @@
 			} catch (PropertyNotFoundException pnfe) {
 				throw new AdminException("Problem getting property while initializing "
 						+ "LDAP properties page: " + pnfe.getMessage());
-			} catch (UtilException ue) {
-				throw new AdminException("Utility problem while " 
-						+ "initializing LDAP properties page: " + ue.getMessage());
 			} catch (IOException ioe) {
 				throw new AdminException("IO problem while initializing "
 						+ "LDAP properties page:" + ioe.getMessage());
@@ -149,11 +143,11 @@
 
 			try {
 				// For each property, check if it is changed and save it
-				PropertiesMetaData orgMetaData = PropertyService
-						.getOrgMetaData();
+				PropertiesMetaData ldapMetaData = PropertyService
+						.getLDAPMetaData();
 
 				// process the fields for the global options (group 1)
-				SortedMap<Integer, MetaDataProperty> globalPropertyMap = orgMetaData
+				SortedMap<Integer, MetaDataProperty> globalPropertyMap = ldapMetaData
 						.getPropertiesInGroup(1);
 				Set<Integer> globalPropertyIndexes = globalPropertyMap.keySet();
 				for (Integer globalPropertyIndex : globalPropertyIndexes) {
@@ -163,25 +157,6 @@
 							globalPropertyKey);
 				}
 
-				// process the fields for the organization options (group 2)
-				SortedMap<Integer, MetaDataProperty> orgPropertyMap = 
-						orgMetaData.getPropertiesInGroup(2);
-				Set<Integer> orgPropertyIndexes = orgPropertyMap.keySet();
-				for (String orgName : LDAPUtil.getOrganizations()) {
-					if (request.getParameter(orgName + ".cb") != null) {
-						for (Integer orgPropertyIndex : orgPropertyIndexes) {
-							String orgPropertyKey = orgPropertyMap.get(
-									orgPropertyIndex).getKey() + "." + orgName;
-							PropertyService.checkAndSetProperty(request, orgPropertyKey);
-						}
-						PropertyService.setPropertyNoPersist("ldap.configured." + orgName,
-								"true");
-					} else {
-						PropertyService.setPropertyNoPersist("ldap.configured." + orgName,
-								"false");
-					}
-				}
-
 				// we need to write the options from memory to the properties
 				// file
 				PropertyService.persistProperties();
@@ -205,7 +180,7 @@
 				// outside the install directory.  Note that we allow them to
 				// do this even if they have validation errors.  They will
 				// need to go back and fix the errors before they can run metacat.
-				PropertyService.persistOrgBackupProperties(request.getSession()
+				PropertyService.persistLDAPBackupProperties(request.getSession()
 						.getServletContext());
 			
 			} catch (GeneralPropertyException gpe) {
@@ -218,12 +193,7 @@
 						+ "properties page: " + ioe.getMessage();
 				logMetacat.error(errorMessage);
 				processingErrors.add(errorMessage);
-			} catch (UtilException ue) {
-				String errorMessage = "Error in utilities while: " 
-						+ "processing LDAP properties page: " + ue.getMessage();
-				logMetacat.error(errorMessage);
-				processingErrors.add(errorMessage);
-			}
+			} 
 			
 			try {
 				if (validationErrors.size() > 0 || processingErrors.size() > 0) {
@@ -269,13 +239,6 @@
 		Vector<String> errorVector = new Vector<String>();
 
 		//TODO MCD validate options.
-		
-//		// Test ldap connectivity
-//		String ldapError = LDAPUtil.validateLDAPConnectivity(
-//				request.getParameter("ldap.url"), request.getParameter("ldap.base"));
-//		if (ldapError != null) {
-//			errorVector.add(ldapError);
-//		}
 
 		return errorVector;
 	}
Index: src/edu/ucsb/nceas/metacat/admin/AuthAdmin.java
===================================================================
--- src/edu/ucsb/nceas/metacat/admin/AuthAdmin.java	(revision 4158)
+++ src/edu/ucsb/nceas/metacat/admin/AuthAdmin.java	(revision 4159)
@@ -36,6 +36,7 @@
 import org.apache.log4j.Logger;
 
 import edu.ucsb.nceas.metacat.util.LDAPUtil;
+import edu.ucsb.nceas.metacat.util.OrganizationUtil;
 import edu.ucsb.nceas.metacat.util.RequestUtil;
 import edu.ucsb.nceas.metacat.util.UtilException;
 
@@ -117,7 +118,7 @@
 				validationErrors.addAll(validateOptions(request));
 				
 				if (validationErrors.size() == 0) {
-					Vector<String> dnList = LDAPUtil.getOrgDNs(organization);
+					Vector<String> dnList = OrganizationUtil.getOrgDNs(organization);
 					isLoggedIn = LDAPUtil.logUserIn(request, userName, organization, dnList, password);
 					loginString = LDAPUtil.createLDAPString(userName, organization, dnList);
 				}
Index: src/edu/ucsb/nceas/metacat/admin/MetaCatAdminServlet.java
===================================================================
--- src/edu/ucsb/nceas/metacat/admin/MetaCatAdminServlet.java	(revision 4158)
+++ src/edu/ucsb/nceas/metacat/admin/MetaCatAdminServlet.java	(revision 4159)
@@ -42,6 +42,7 @@
 import edu.ucsb.nceas.metacat.service.SessionService;
 import edu.ucsb.nceas.metacat.util.LDAPUtil;
 import edu.ucsb.nceas.metacat.util.MetaCatUtil;
+import edu.ucsb.nceas.metacat.util.OrganizationUtil;
 import edu.ucsb.nceas.metacat.util.RequestUtil;
 import edu.ucsb.nceas.metacat.util.SkinUtil;
 import edu.ucsb.nceas.metacat.util.SystemUtil;
@@ -133,6 +134,7 @@
 							DBAdmin.getInstance().getDBVersion());
 				}
 			    request.setAttribute("ldapConfigured", new Boolean(LDAPUtil.isLDAPConfigured()));	
+			    request.setAttribute("orgsConfigured", new Boolean(OrganizationUtil.areOrganizationsConfigured()));
 			    request.setAttribute("skinsConfigured", new Boolean(SkinUtil.areSkinsConfigured()));
 			    request.setAttribute("metacatConfigured", new Boolean(MetaCatUtil.isMetacatConfigured()));	
 				RequestUtil.forwardRequest(request, response,
@@ -148,15 +150,19 @@
 				SkinsAdmin.getInstance().configureSkins(request, response);
 				return;
 			} else if (action.equals("database")) {
-				// process properties
+				// process database
 				DBAdmin.getInstance().configureDatabase(request, response);
 				return;
 			} else if (action.equals("ldap")) {
-				// process properties
+				// process ldap
 				LDAPAdmin.getInstance().configureLDAP(request, response);
 				return;
+			} else if (action.equals("organization")) {
+				// process organization
+				OrganizationAdmin.getInstance().configureOrganization(request, response);
+				return;
 			} else if (action.equals("login")) {
-				// process properties
+				// process login
 				AuthAdmin.getInstance().authenticateUser(request, response);
 				return;
 			} else {
Index: src/edu/ucsb/nceas/metacat/admin/OrganizationAdmin.java
===================================================================
--- src/edu/ucsb/nceas/metacat/admin/OrganizationAdmin.java	(nonexistent)
+++ src/edu/ucsb/nceas/metacat/admin/OrganizationAdmin.java	(revision 4159)
@@ -0,0 +1,253 @@
+/**
+ *  '$RCSfile$'
+ *    Purpose: A Class that implements organization configuration methods
+ *  Copyright: 2008 Regents of the University of California and the
+ *             National Center for Ecological Analysis and Synthesis
+ *    Authors: Michael Daigle
+ *
+ *   '$Author$'
+ *     '$Date$'
+ * '$Revision$'
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+package edu.ucsb.nceas.metacat.admin;
+
+import java.io.IOException;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.Vector;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+
+import edu.ucsb.nceas.metacat.service.PropertyService;
+import edu.ucsb.nceas.metacat.util.OrganizationUtil;
+import edu.ucsb.nceas.metacat.util.RequestUtil;
+import edu.ucsb.nceas.metacat.util.UtilException;
+import edu.ucsb.nceas.utilities.FileUtil;
+import edu.ucsb.nceas.utilities.GeneralPropertyException;
+import edu.ucsb.nceas.utilities.MetaDataProperty;
+import edu.ucsb.nceas.utilities.PropertiesMetaData;
+import edu.ucsb.nceas.utilities.PropertyNotFoundException;
+import edu.ucsb.nceas.utilities.SortedProperties;
+
+/**
+ * Control the display of the organization configuration page and the processing
+ * of the configuration values.
+ */
+public class OrganizationAdmin extends MetaCatAdmin {
+
+	private static OrganizationAdmin organizationAdmin = null;
+	private static Logger logMetacat = Logger.getLogger(OrganizationAdmin.class);
+
+	/**
+	 * private constructor since this is a singleton
+	 */
+	private OrganizationAdmin() {}
+
+	/**
+	 * Get the single instance of the MetaCatConfig.
+	 * 
+	 * @return the single instance of MetaCatConfig
+	 */
+	public static OrganizationAdmin getInstance() {
+		if (organizationAdmin == null) {
+			organizationAdmin = new OrganizationAdmin();
+		}
+		return organizationAdmin;
+	}
+	
+	/**
+	 * Handle configuration of the Organization properties
+	 * 
+	 * @param request
+	 *            the http request information
+	 * @param response
+	 *            the http response to be sent back to the client
+	 */
+	public void configureOrganization(HttpServletRequest request,
+			HttpServletResponse response) throws AdminException {
+
+		String processForm = request.getParameter("processForm");
+		String formErrors = (String) request.getAttribute("formErrors");
+
+		if (processForm == null || !processForm.equals("true") || formErrors != null) {
+			// The servlet configuration parameters have not been set, or there
+			// were form errors on the last attempt to configure, so redirect to
+			// the web form for configuring metacat
+			
+			try {
+				// Load the properties metadata file so that the JSP page can
+				// use
+				// the metadata to construct the editing form
+				PropertiesMetaData metadata = PropertyService.getOrgMetaData();
+				request.setAttribute("metadata", metadata);
+				request.setAttribute("groupMap", metadata.getGroups());
+				
+				request.setAttribute("orgList", OrganizationUtil.getOrganizations());
+
+				// add the list of organization options and their values to the request
+				Vector<String> propertyNames = 
+					PropertyService.getPropertyNamesByGroup("organization");
+				for (String name : propertyNames) {
+					request.setAttribute(name, PropertyService.getProperty(name));
+				} 
+
+				// Check for any backup properties and apply them to the request.
+				// These are properties from previous configurations. They keep
+				// the user from having to re-enter all values when upgrading.
+				// If this is a first time install, getBackupProperties will return
+				// null.
+				SortedProperties backupProperties = PropertyService.getOrgBackupProperties();
+				if (backupProperties != null) {
+					Vector<String> backupKeys = backupProperties.getPropertyNames();
+					for (String key : backupKeys) {
+						String value = backupProperties.getProperty(key);
+						if (value != null) {
+							request.setAttribute(key, value);
+						}
+					}
+				}
+				// Forward the request to the JSP page
+				RequestUtil.forwardRequest(request, response,
+						"/admin/organization-configuration.jsp");
+			} catch (PropertyNotFoundException pnfe) {
+				throw new AdminException("Problem getting property while initializing "
+						+ "organization properties page: " + pnfe.getMessage());
+			} catch (UtilException ue) {
+				throw new AdminException("Utility problem while " 
+						+ "initializing organization properties page: " + ue.getMessage());
+			} catch (IOException ioe) {
+				throw new AdminException("IO problem while initializing "
+						+ "organization properties page:" + ioe.getMessage());
+			} catch (ServletException se) {
+				throw new AdminException("problem forwarding request while " 
+						+ "initializing organization properties page: " + se.getMessage());
+			}
+		} else {
+			// The configuration form is being submitted and needs to be
+			// processed.
+			Vector<String> processingSuccess = new Vector<String>();
+			Vector<String> processingErrors = new Vector<String>();
+			Vector<String> validationErrors = new Vector<String>();
+
+			try {
+				// For each property, check if it is changed and save it
+				PropertiesMetaData orgMetaData = 
+					PropertyService.getOrgMetaData();
+
+				Set<String> orgKeys = orgMetaData.getKeys();
+				for (String orgName : OrganizationUtil.getOrganizations()) {
+					for (String key : orgKeys) {
+						PropertyService.checkAndSetProperty(request, key + "." + orgName);
+					}
+				}
+
+				// we need to write the options from memory to the properties
+				// file
+				PropertyService.persistProperties();
+
+				// Validate that the options provided are legitimate. Note that
+				// we've allowed them to persist their entries. As of this point
+				// there is no other easy way to go back to the configure form
+				// and preserve their entries.
+				validationErrors.addAll(validateOptions(request));
+
+				// Try to create data file and backup directories if
+				// necessary.
+				String backupDir = PropertyService.getBackupDir();
+				if (!FileUtil.createDirectory(backupDir)) {
+					String errorString = "Could not create directory: " + backupDir;
+					logMetacat.error(errorString);
+					validationErrors.add(errorString);
+				}
+
+				// Write out the configurable properties to a backup file
+				// outside the install directory.  Note that we allow them to
+				// do this even if they have validation errors.  They will
+				// need to go back and fix the errors before they can run metacat.
+				PropertyService.persistOrgBackupProperties(request.getSession()
+						.getServletContext());
+			
+			} catch (GeneralPropertyException gpe) {
+				String errorMessage = "Problem getting or setting property while "
+					+ "processing organization properties page: " + gpe.getMessage();
+				logMetacat.error(errorMessage);
+				processingErrors.add(errorMessage);
+			} catch (IOException ioe) {
+				String errorMessage = "IO problem while processing organization "
+						+ "properties page: " + ioe.getMessage();
+				logMetacat.error(errorMessage);
+				processingErrors.add(errorMessage);
+			} catch (UtilException ue) {
+				String errorMessage = "Error in utilities while: " 
+						+ "processing organization properties page: " + ue.getMessage();
+				logMetacat.error(errorMessage);
+				processingErrors.add(errorMessage);
+			}
+			
+			try {
+				if (validationErrors.size() > 0 || processingErrors.size() > 0) {
+					RequestUtil.clearRequestMessages(request);
+					RequestUtil.setRequestFormErrors(request, validationErrors);
+					RequestUtil.setRequestErrors(request, processingErrors);
+					RequestUtil.forwardRequest(request, response, "/admin");
+				} else {
+					// Now that the options have been set, change the
+					// 'organizationsConfigured' option to 'true'
+					PropertyService.setProperty("configutil.organizationsConfigured",
+							PropertyService.CONFIGURED);
+					
+					// Reload the main metacat configuration page
+					processingSuccess.add("Organizations successfully configured");
+					RequestUtil.clearRequestMessages(request);
+					RequestUtil.setRequestSuccess(request, processingSuccess);
+					RequestUtil.forwardRequest(request, response,
+							"/admin?configureType=configure&processForm=false");
+				}
+			} catch (ServletException se) {
+				throw new AdminException("problem forwarding request while "
+						+ "processing organization properties page: " + se.getMessage());
+			} catch (IOException ioe) {
+				throw new AdminException("IO problem while processing organization "
+						+ "properties page: " + ioe.getMessage());
+			} catch (GeneralPropertyException gpe) {
+				String errorMessage = "Problem getting or setting property while "
+					+ "processing organization properties page: " + gpe.getMessage();
+				logMetacat.error(errorMessage);
+				processingErrors.add(errorMessage);
+			}
+		}
+	}
+	
+	/**
+	 * Validate the most important configuration options submitted by the user.
+	 * 
+	 * @return a vector holding error message for any fields that fail
+	 *         validation.
+	 */
+	protected Vector<String> validateOptions(HttpServletRequest request) {
+		Vector<String> errorVector = new Vector<String>();
+
+		//TODO MCD validate options.
+
+		return errorVector;
+	}
+}
\ No newline at end of file

Property changes on: src/edu/ucsb/nceas/metacat/admin/OrganizationAdmin.java
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
