01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
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 org.apache.catalina.ssi;
18:
19: import java.io.PrintWriter;
20:
21: /**
22: * Implements the Server-side #exec command
23: *
24: * @author Bip Thelin
25: * @author Paul Speed
26: * @author Dan Sandberg
27: * @author David Becker
28: * @version $Revision: 531303 $, $Date: 2007-04-23 02:24:01 +0200 (lun., 23 avr. 2007) $
29: */
30: public final class SSIConfig implements SSICommand {
31: /**
32: * @see SSICommand
33: */
34: public long process(SSIMediator ssiMediator, String commandName,
35: String[] paramNames, String[] paramValues,
36: PrintWriter writer) {
37: for (int i = 0; i < paramNames.length; i++) {
38: String paramName = paramNames[i];
39: String paramValue = paramValues[i];
40: String substitutedValue = ssiMediator
41: .substituteVariables(paramValue);
42: if (paramName.equalsIgnoreCase("errmsg")) {
43: ssiMediator.setConfigErrMsg(substitutedValue);
44: } else if (paramName.equalsIgnoreCase("sizefmt")) {
45: ssiMediator.setConfigSizeFmt(substitutedValue);
46: } else if (paramName.equalsIgnoreCase("timefmt")) {
47: ssiMediator.setConfigTimeFmt(substitutedValue);
48: } else {
49: ssiMediator.log("#config--Invalid attribute: "
50: + paramName);
51: //We need to fetch this value each time, since it may change
52: // during the
53: // loop
54: String configErrMsg = ssiMediator.getConfigErrMsg();
55: writer.write(configErrMsg);
56: }
57: }
58: // Setting config options doesn't really change the page
59: return 0;
60: }
61: }
|