Project

General

Profile

« Previous | Next » 

Revision 3099

Updated MetaCatServlet so that it supports a web-based interface for configuring its own properties the first time it is run (determined by the property "configured" being set to false). Which properties are exposed in the web interface is determined by the list of properties in the 'metacat.properties.metadata' file. This file is managed by the new OptionsMetadata class in the utilities module, and provides information that allows metacat to build a human-readable configuration page for the properties. Still need to finish filling out the information in metacat.properties.metadata for the rest of the properties that we want to be editable. This autoconfiguration process is the first step towards building a turnkey installer for metacat.

Note: you need to remove the lib/utilities.jar file from your metacat workspace, update the utilities module, and then rebuild metacat clean in order to pickup the changes introduced here.

View differences:

configure.jsp
1
<%@ page    language="java" import="java.util.Enumeration" %>
1
<%@ page    language="java" import="java.util.Enumeration,java.util.Iterator,java.util.Set,java.util.Map,edu.ucsb.nceas.utilities.OptionsMetadata" %>
2 2
<% 
3 3
/**
4 4
 *  '$RCSfile$'
......
77 77
<br clear="right"/>
78 78

  
79 79
<form method="POST" action="<%= request.getContextPath() %>/metacat">
80

  
81
<p class="section">All properties (unsorted, need to fix)</p>
82

  
83 80
<% 
84
   Enumeration optionsList = (Enumeration)request.getAttribute("optionslist");
85
   while (optionsList.hasMoreElements()) {
86
       String name = (String)optionsList.nextElement();
87
       if (!name.equals("configured")) {
81
    OptionsMetadata metadata = (OptionsMetadata)request.getAttribute("metadata");
82
	if (metadata != null) {
83
        Set groups = metadata.getGroups();
84
        Iterator iter = groups.iterator();
85
   		while (iter.hasNext()) {
86
       		String groupName = (String)iter.next();
88 87
%>
89
        <label for="<%= name %>"><%= name %></label>
90
	    <input id="<%= name %>" name="<%= name %>" 
91
	           value="<%= request.getAttribute(name) %>"
92
	           <% if (name.equals("password")) { %>
93
	           type="password"
94
	           <% } else { %>
95
	           type="text" 
96
	           <% } %>
97
	           /><br/>
88
			<p class="section"><%= groupName  %></p>
98 89
<%
99
       }
100
   }
90
			Map keys = metadata.getKeysInGroup(groupName);
91
			Iterator optionsList = keys.values().iterator();
92
			while (optionsList.hasNext()) {
93
    			String name = (String)optionsList.next();
94
    			if (!name.equals("configured")) {
101 95
%>
96
     				<label for="<%= name %>" title="<%= metadata.getOptionDescription(name) %>"><%= metadata.getOptionLabel(name) %></label>
97
	    			<input id="<%= name %>" name="<%= name %>" 
98
	           			value="<%= request.getAttribute(name) %>"
99
	           			<% if (name.equals("password")) { %>
100
	           				type="password"
101
	           			<% } else { %>
102
	           				type="text" 
103
	           			<% } %>
104
	           			alt="<%= metadata.getOptionDescription(name) %>"
105
	           			/><br/>
106
<%
107
    			}
108
			}
109
   		}
110
   	}
111
%>
102 112

  
103
<input type="hidden" name="action" value="configure"/>
104
<p><input type="submit" value="Save"/></p>
113
			<input type="hidden" name="action" value="configure"/>
114
			<p><input type="submit" value="Save"/></p>
105 115

  
106 116
</form>
107 117

  

Also available in: Unified diff