Processes the flastmod directive to output the last modified date of a file.
(SSIMediator ssiMediator, String commandName, String[] paramNames, String[] paramValues,
PrintWriter writer)
| 40 | * Processes the flastmod directive to output the last modified date of a file. |
| 41 | */ |
| 42 | @Override |
| 43 | public long process(SSIMediator ssiMediator, String commandName, String[] paramNames, String[] paramValues, |
| 44 | PrintWriter writer) { |
| 45 | long lastModified = 0; |
| 46 | String configErrMsg = ssiMediator.getConfigErrMsg(); |
| 47 | for (int i = 0; i < paramNames.length; i++) { |
| 48 | String paramName = paramNames[i]; |
| 49 | String paramValue = paramValues[i]; |
| 50 | String substitutedValue = ssiMediator.substituteVariables(paramValue); |
| 51 | try { |
| 52 | if (paramName.equalsIgnoreCase("file") || paramName.equalsIgnoreCase("virtual")) { |
| 53 | boolean virtual = paramName.equalsIgnoreCase("virtual"); |
| 54 | lastModified = ssiMediator.getFileLastModified(substitutedValue, virtual); |
| 55 | Date date = new Date(lastModified); |
| 56 | String configTimeFmt = ssiMediator.getConfigTimeFmt(); |
| 57 | writer.write(formatDate(date, configTimeFmt)); |
| 58 | } else { |
| 59 | ssiMediator.log(sm.getString("ssiCommand.invalidAttribute", paramName)); |
| 60 | writer.write(configErrMsg); |
| 61 | } |
| 62 | } catch (IOException ioe) { |
| 63 | ssiMediator.log(sm.getString("ssiFlastmod.noLastModified", substitutedValue), ioe); |
| 64 | writer.write(configErrMsg); |
| 65 | } |
| 66 | } |
| 67 | return lastModified; |
| 68 | } |
| 69 | |
| 70 | |
| 71 | private String formatDate(Date date, String configTimeFmt) { |
nothing calls this directly
no test coverage detected