Processes the fsize directive to output the size of a file.
(SSIMediator ssiMediator, String commandName, String[] paramNames, String[] paramValues,
PrintWriter writer)
| 49 | * Processes the fsize directive to output the size of a file. |
| 50 | */ |
| 51 | @Override |
| 52 | public long process(SSIMediator ssiMediator, String commandName, String[] paramNames, String[] paramValues, |
| 53 | PrintWriter writer) { |
| 54 | long lastModified = 0; |
| 55 | String configErrMsg = ssiMediator.getConfigErrMsg(); |
| 56 | for (int i = 0; i < paramNames.length; i++) { |
| 57 | String paramName = paramNames[i]; |
| 58 | String paramValue = paramValues[i]; |
| 59 | String substitutedValue = ssiMediator.substituteVariables(paramValue); |
| 60 | try { |
| 61 | if (paramName.equalsIgnoreCase("file") || paramName.equalsIgnoreCase("virtual")) { |
| 62 | boolean virtual = paramName.equalsIgnoreCase("virtual"); |
| 63 | lastModified = ssiMediator.getFileLastModified(substitutedValue, virtual); |
| 64 | long size = ssiMediator.getFileSize(substitutedValue, virtual); |
| 65 | String configSizeFmt = ssiMediator.getConfigSizeFmt(); |
| 66 | writer.write(formatSize(size, configSizeFmt)); |
| 67 | } else { |
| 68 | ssiMediator.log(sm.getString("ssiCommand.invalidAttribute", paramName)); |
| 69 | writer.write(configErrMsg); |
| 70 | } |
| 71 | } catch (IOException ioe) { |
| 72 | ssiMediator.log(sm.getString("ssiFsize.noSize", substitutedValue), ioe); |
| 73 | writer.write(configErrMsg); |
| 74 | } |
| 75 | } |
| 76 | return lastModified; |
| 77 | } |
| 78 | |
| 79 | |
| 80 | /** |
nothing calls this directly
no test coverage detected