Revision 3083
Added by Matt Jones about 18 years ago
lib/configure-restart.jsp | ||
---|---|---|
29 | 29 |
<head> |
30 | 30 |
<title>Metacat Configuration Succeeded</title> |
31 | 31 |
<style language="Javascript"> |
32 |
<!-- |
|
32 |
body { |
|
33 |
font-family: Arial, sans-serif; |
|
34 |
font-size: 12pt; |
|
35 |
margin-left: 30px; |
|
36 |
margin-right: 30px; |
|
37 |
width: 700px; |
|
38 |
} |
|
33 | 39 |
.section { |
34 | 40 |
font-size: 16pt; |
35 | 41 |
font-weight: bold; |
36 | 42 |
border-bottom: solid #dddddd 1px; |
37 | 43 |
} |
38 |
--> |
|
39 | 44 |
</style> |
40 | 45 |
</head> |
41 | 46 |
<body> |
42 |
<p><img src="metacat-logo.png" width="75px" align="right"/>
|
|
47 |
<p><img src="metacat-logo.png" width="100px" align="right"/>
|
|
43 | 48 |
<h2>Metacat Configuration Succeeded</h2> |
44 | 49 |
</p> |
45 | 50 |
|
lib/configure.jsp | ||
---|---|---|
1 |
<%@ page language="java" %> |
|
1 |
<%@ page language="java" import="java.util.Enumeration" %>
|
|
2 | 2 |
<% |
3 | 3 |
/** |
4 | 4 |
* '$RCSfile$' |
... | ... | |
29 | 29 |
<head> |
30 | 30 |
<title>Metacat Configuration</title> |
31 | 31 |
<style language="Javascript"> |
32 |
<!-- |
|
32 |
body { |
|
33 |
font-family: Arial, sans-serif; |
|
34 |
font-size: 12pt; |
|
35 |
margin-left: 30px; |
|
36 |
margin-right: 30px; |
|
37 |
width: 700px; |
|
38 |
} |
|
39 |
|
|
33 | 40 |
.section { |
34 | 41 |
font-size: 16pt; |
35 | 42 |
font-weight: bold; |
36 | 43 |
border-bottom: solid #dddddd 1px; |
37 | 44 |
} |
38 |
--> |
|
45 |
label,input { |
|
46 |
display: block; |
|
47 |
width: 400px; |
|
48 |
float: left; |
|
49 |
margin-bottom: 10px; |
|
50 |
} |
|
51 |
|
|
52 |
label { |
|
53 |
text-align: right; |
|
54 |
width: 250px; |
|
55 |
padding-right: 20px; |
|
56 |
} |
|
57 |
|
|
58 |
br { |
|
59 |
clear: left; |
|
60 |
} |
|
61 |
|
|
62 |
input[type="submit"] { |
|
63 |
width: 50px; |
|
64 |
} |
|
39 | 65 |
</style> |
40 | 66 |
</head> |
41 | 67 |
<body> |
42 |
<p><img src="metacat-logo.png" width="75px" align="right"/>
|
|
68 |
<p><img src="metacat-logo.png" width="100px" align="right"/>
|
|
43 | 69 |
<h2>Metacat Configuration</h2> |
44 | 70 |
</p> |
45 | 71 |
|
... | ... | |
49 | 75 |
up and running. |
50 | 76 |
</p> |
51 | 77 |
<br clear="right"/> |
52 |
<p class="section">Database connection</p> |
|
78 |
|
|
53 | 79 |
<form method="POST" action="/knb/metacat"> |
54 |
<p>Database Username: |
|
55 |
<input type="text" name="user" value="<%= request.getAttribute("user") %>"/></p> |
|
56 |
<p>Database Password: <input type="password" name="password" value="<%= request.getAttribute("password") %>"/></p> |
|
57 |
<p><input type="hidden" name="action" value="configure"/> |
|
80 |
|
|
81 |
<p class="section">All properties (unsorted, need to fix)</p> |
|
82 |
|
|
83 |
<% |
|
84 |
Enumeration optionsList = (Enumeration)request.getAttribute("optionslist"); |
|
85 |
while (optionsList.hasMoreElements()) { |
|
86 |
String name = (String)optionsList.nextElement(); |
|
87 |
if (!name.equals("configured")) { |
|
88 |
%> |
|
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/> |
|
98 |
<% |
|
99 |
} |
|
100 |
} |
|
101 |
%> |
|
102 |
|
|
103 |
<input type="hidden" name="action" value="configure"/> |
|
58 | 104 |
<p><input type="submit" value="Save"/></p> |
105 |
|
|
59 | 106 |
</form> |
60 | 107 |
|
61 |
<p class="section">Access controls</p> |
|
62 |
<p>More options go here.</p> |
|
63 |
|
|
64 | 108 |
</body> |
65 | 109 |
</html> |
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
3235 | 3235 |
*/ |
3236 | 3236 |
private void configureMetacat(HttpServletRequest request, |
3237 | 3237 |
HttpServletResponse response) { |
3238 |
Options options = (Options)Options.getInstance(); |
|
3238 | 3239 |
String action = request.getParameter("action"); |
3239 | 3240 |
if (action == null || !action.equals("configure")) { |
3240 | 3241 |
// The servlet configuration parameters have not been set, so |
3241 | 3242 |
// redirect to a web form for configuring metacat |
3242 | 3243 |
|
3243 |
// First add attributes to the request for all configuration options |
|
3244 |
// TODO: MBJ should not hard code these, but get them from the config |
|
3245 |
// Then the list of attributes can be passed to the form so that the |
|
3246 |
// form can autogenerate the right number of fields. Still need |
|
3247 |
// to determine a way to get some metadata about each attribute to |
|
3248 |
// the form jsp, such as a description and possibly a widget type |
|
3249 |
// to use and possibly a controlled values list |
|
3250 |
request.setAttribute( "user", MetaCatUtil.getOption("user")); |
|
3251 |
request.setAttribute( "password", MetaCatUtil.getOption("password")); |
|
3244 |
// Add attributes to the request for all configuration options so |
|
3245 |
// that the configuration form can display the names and values of |
|
3246 |
// all configuration options. |
|
3247 |
// TODO: Still need to determine a way to get some metadata about |
|
3248 |
// each attribute to the form jsp, such as a description and |
|
3249 |
// possibly a label and widget type to use and possibly a |
|
3250 |
// controlled values list |
|
3251 |
Enumeration properties = options.propertyNames(); |
|
3252 |
while (properties.hasMoreElements()) { |
|
3253 |
String name = (String)properties.nextElement(); |
|
3254 |
request.setAttribute( name, MetaCatUtil.getOption(name)); |
|
3255 |
} |
|
3256 |
properties = options.propertyNames(); |
|
3257 |
request.setAttribute("optionslist", properties); |
|
3252 | 3258 |
|
3253 | 3259 |
// Forward the request |
3254 | 3260 |
forwardRequest(request, response, |
... | ... | |
3262 | 3268 |
// legitimate, and possibly even test them (for example, use |
3263 | 3269 |
// the database connection info to connect to the database) |
3264 | 3270 |
|
3265 |
// TODO: MBJ should not hard code these, but get them from the config |
|
3266 |
checkAndSetOption(request, response, "user"); |
|
3267 |
checkAndSetOption(request, response, "password"); |
|
3271 |
// For each property, check if it is changed and save it |
|
3272 |
Enumeration properties = options.propertyNames(); |
|
3273 |
while (properties.hasMoreElements()) { |
|
3274 |
String name = (String)properties.nextElement(); |
|
3275 |
checkAndSetOption(request, name); |
|
3276 |
} |
|
3268 | 3277 |
|
3269 | 3278 |
// Now that the options have been set, change the 'configured' |
3270 | 3279 |
// option to 'true' so that normal metacat requests will go through |
... | ... | |
3288 | 3297 |
* @param optionName the name of the option to be checked and set |
3289 | 3298 |
*/ |
3290 | 3299 |
private void checkAndSetOption(HttpServletRequest request, |
3291 |
HttpServletResponse response, String optionName) {
|
|
3300 |
String optionName) { |
|
3292 | 3301 |
String value = MetaCatUtil.getOption(optionName); |
3293 | 3302 |
String newValue = request.getParameter(optionName); |
3294 |
if (!newValue.equals(value)) { |
|
3303 |
if (newValue != null && !newValue.equals(value)) {
|
|
3295 | 3304 |
MetaCatUtil.setOption(optionName, newValue); |
3296 | 3305 |
} |
3297 | 3306 |
} |
Also available in: Unified diff
Modified the configuration classes to allow configuration through the web interface of all of the properties set in the metacat.properties file. The layout of this form still needs work, in particular because java.util.Properties does not maintain any order for the properties, nor does it allow for metadata about each property to be set and saved in the file. We can probably overcome this by creating a shadow file that lists all of the options and their metadata (such as grouping, controlled values, etc).