Process the SSI #set command. @param ssiMediator the SSI mediator @param commandName the command name @param paramNames the parameter names @param paramValues the parameter values @param writer the print writer for output @return the last modified timestamp @throws SSIStopProcessingExc
(SSIMediator ssiMediator, String commandName, String[] paramNames, String[] paramValues,
PrintWriter writer)
| 47 | * @throws SSIStopProcessingException if processing should stop |
| 48 | */ |
| 49 | @Override |
| 50 | public long process(SSIMediator ssiMediator, String commandName, String[] paramNames, String[] paramValues, |
| 51 | PrintWriter writer) throws SSIStopProcessingException { |
| 52 | long lastModified = 0; |
| 53 | String errorMessage = ssiMediator.getConfigErrMsg(); |
| 54 | String variableName = null; |
| 55 | for (int i = 0; i < paramNames.length; i++) { |
| 56 | String paramName = paramNames[i]; |
| 57 | String paramValue = paramValues[i]; |
| 58 | if (paramName.equalsIgnoreCase("var")) { |
| 59 | variableName = paramValue; |
| 60 | } else if (paramName.equalsIgnoreCase("value")) { |
| 61 | if (variableName != null) { |
| 62 | String substitutedValue = ssiMediator.substituteVariables(paramValue); |
| 63 | ssiMediator.setVariableValue(variableName, substitutedValue); |
| 64 | lastModified = System.currentTimeMillis(); |
| 65 | } else { |
| 66 | ssiMediator.log(sm.getString("ssiSet.noVariable")); |
| 67 | writer.write(errorMessage); |
| 68 | throw new SSIStopProcessingException(); |
| 69 | } |
| 70 | } else { |
| 71 | ssiMediator.log(sm.getString("ssiCommand.invalidAttribute", paramName)); |
| 72 | writer.write(errorMessage); |
| 73 | throw new SSIStopProcessingException(); |
| 74 | } |
| 75 | } |
| 76 | return lastModified; |
| 77 | } |
| 78 | } |
nothing calls this directly
no test coverage detected