1
by tony mancill
Import upstream version 7.0.14 |
1 |
/*
|
2 |
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
3 |
* contributor license agreements. See the NOTICE file distributed with
|
|
4 |
* this work for additional information regarding copyright ownership.
|
|
5 |
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
6 |
* (the "License"); you may not use this file except in compliance with
|
|
7 |
* the License. You may obtain a copy of the License at
|
|
8 |
*
|
|
9 |
* 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 |
||
20 |
import java.io.PrintWriter; |
|
21 |
import java.util.Collection; |
|
22 |
import java.util.Iterator; |
|
23 |
/**
|
|
24 |
* Implements the Server-side #printenv command
|
|
25 |
*
|
|
26 |
* @author Dan Sandberg
|
|
27 |
* @author David Becker
|
|
1.1.2
by tony mancill
Import upstream version 7.0.19 |
28 |
* @version $Id: SSIPrintenv.java 1138121 2011-06-21 18:32:41Z markt $
|
1
by tony mancill
Import upstream version 7.0.14 |
29 |
*/
|
30 |
public class SSIPrintenv implements SSICommand { |
|
31 |
/**
|
|
32 |
* @see SSICommand
|
|
33 |
*/
|
|
1.1.2
by tony mancill
Import upstream version 7.0.19 |
34 |
@Override
|
1
by tony mancill
Import upstream version 7.0.14 |
35 |
public long process(SSIMediator ssiMediator, String commandName, |
36 |
String[] paramNames, String[] paramValues, PrintWriter writer) { |
|
37 |
long lastModified = 0; |
|
38 |
//any arguments should produce an error
|
|
39 |
if (paramNames.length > 0) { |
|
40 |
String errorMessage = ssiMediator.getConfigErrMsg(); |
|
41 |
writer.write(errorMessage); |
|
42 |
} else { |
|
43 |
Collection<String> variableNames = ssiMediator.getVariableNames(); |
|
44 |
Iterator<String> iter = variableNames.iterator(); |
|
45 |
while (iter.hasNext()) { |
|
46 |
String variableName = iter.next(); |
|
47 |
String variableValue = ssiMediator |
|
48 |
.getVariableValue(variableName); |
|
49 |
//This shouldn't happen, since all the variable names must
|
|
50 |
// have values
|
|
51 |
if (variableValue == null) { |
|
52 |
variableValue = "(none)"; |
|
53 |
}
|
|
54 |
writer.write(variableName); |
|
55 |
writer.write('='); |
|
56 |
writer.write(variableValue); |
|
57 |
writer.write('\n'); |
|
58 |
lastModified = System.currentTimeMillis(); |
|
59 |
}
|
|
60 |
}
|
|
61 |
return lastModified; |
|
62 |
}
|
|
63 |
}
|