01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.test.web.framework.actions;
18:
19: import org.w3c.dom.Node;
20:
21: import edu.iu.uis.eden.test.web.framework.Script;
22: import edu.iu.uis.eden.test.web.framework.ScriptState;
23: import edu.iu.uis.eden.test.web.framework.Util;
24:
25: /**
26: * ScriptAction that sets or unsets the "USER" or "BACKDOORID" variable
27: * as a convenience.
28: * <pre>
29: * <user>...</user>
30: * <backdoorId>...</backdoorId>
31: * </pre>
32: * @author Aaron Hamid (arh14 at cornell dot edu)
33: */
34: public class UserAction extends BaseScriptAction {
35: private static final String[] NAMES = { "user", "backdoorId" };
36:
37: public String[] getNames() {
38: return NAMES;
39: }
40:
41: public void process(Script script, Node node) {
42: String key;
43: if ("user".equals(node.getNodeName())) {
44: key = ScriptState.USER;
45: } else {
46: key = ScriptState.BACKDOORID;
47: }
48: String user = Util.getContent(node);
49:
50: if (user == null) {
51: log.info("Unset " + node.getNodeName());
52: script.getState().setVariable(key, null);
53: } else {
54: log
55: .info("Set " + node.getNodeName() + " to '" + user
56: + "'");
57: script.getState().setVariable(key, user);
58: }
59: }
60: }
|