/** @see SSICommand */ @Override public long process( SSIMediator ssiMediator, String commandName, String[] paramNames, String[] paramValues, PrintWriter writer) throws SSIStopProcessingException { long lastModified = 0; String errorMessage = ssiMediator.getConfigErrMsg(); String variableName = null; for (int i = 0; i < paramNames.length; i++) { String paramName = paramNames[i]; String paramValue = paramValues[i]; if (paramName.equalsIgnoreCase("var")) { variableName = paramValue; } else if (paramName.equalsIgnoreCase("value")) { if (variableName != null) { String substitutedValue = ssiMediator.substituteVariables(paramValue); ssiMediator.setVariableValue(variableName, substitutedValue); lastModified = System.currentTimeMillis(); } else { ssiMediator.log("#set--no variable specified"); writer.write(errorMessage); throw new SSIStopProcessingException(); } } else { ssiMediator.log("#set--Invalid attribute: " + paramName); writer.write(errorMessage); throw new SSIStopProcessingException(); } } return lastModified; }
protected void setDateVariables(boolean fromConstructor) { boolean alreadySet = ssiExternalResolver.getVariableValue(className + ".alreadyset") != null; // skip this if we are being called from the constructor, and this has // already // been set if (!(fromConstructor && alreadySet)) { ssiExternalResolver.setVariableValue(className + ".alreadyset", "true"); Date date = new Date(); TimeZone timeZone = TimeZone.getTimeZone("GMT"); String retVal = formatDate(date, timeZone); // If we are setting on of the date variables, we want to remove // them from the // user // defined list of variables, because this is what Apache does setVariableValue("DATE_GMT", null); ssiExternalResolver.setVariableValue(className + ".DATE_GMT", retVal); retVal = formatDate(date, null); setVariableValue("DATE_LOCAL", null); ssiExternalResolver.setVariableValue(className + ".DATE_LOCAL", retVal); retVal = formatDate(new Date(lastModifiedDate), null); setVariableValue("LAST_MODIFIED", null); ssiExternalResolver.setVariableValue(className + ".LAST_MODIFIED", retVal); } }