Hi,
+ actionMap.put("temp",
"view");
why "temp" and not "tmp"?
I thought temp would be more meaningful like existing actions "view" and
"edit", I could change it easily.
+ File
tempFile = getTempFile(uri);
Using File is not recommended IMO. Couldn't you use a URL instead?
Is it because using java.io.File in a server environment might pose security
restrictions etc. ? I don't know about it, can you explain?
+ private File getTempFile(String uri)
I'd prefer a more explicit name such as getTemporaryFile()
OK.
+ Matcher matcher =
URI_PATTERN.matcher(uri);
+ File result = null;
+ if (matcher.find()) {
+ String space = matcher.group(1);
+ String page = matcher.group(2);
+ String module = matcher.group(3);
+ String filePath = matcher.group(4);
+ String prefix = String.format("temp/%s/%s/%s/", module,
space, page);
+ String path = URI.create(prefix +
filePath).normalize().toString();
+ if (path.startsWith(prefix)) {
+ result = new
File(container.getApplicationContext().getTemporaryDirectory(), path);
+ result = result.exists() ?
result : null;
+ }
You should use the xwiki-url module to extract information from the URL
IMO. It's much more complicated than what is written above. See code in
xwiki-url for details.
Did you mean to say that it's more simpler to use xwiki-url module to
accomplish what is done above? I
Thanks.
- Asiri