Fix potential problem

The capture url could be the same if it's generated in the same
second.
This commit is contained in:
Oscar Gonzalez Fernandez 2013-06-11 13:42:43 +02:00
parent 98bcf3decd
commit df0a6d1502

View file

@ -27,7 +27,6 @@ import java.io.IOException;
import java.lang.ProcessBuilder.Redirect; import java.lang.ProcessBuilder.Redirect;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@ -140,15 +139,6 @@ public class CutyPrint {
private static class CutyCaptParameters { private static class CutyCaptParameters {
private static String buildCaptureDestination(String extension) {
if (extension == null || extension.equals("")) {
extension = ".pdf";
}
return "/print/"
+ new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())
+ extension;
}
private static final AtomicLong counter = new AtomicLong(); private static final AtomicLong counter = new AtomicLong();
private final HttpServletRequest request = (HttpServletRequest) Executions private final HttpServletRequest request = (HttpServletRequest) Executions
@ -190,6 +180,15 @@ public class CutyPrint {
return generatedSnapshotServerPath; return generatedSnapshotServerPath;
} }
private String buildCaptureDestination(String extension) {
if (extension == null || extension.equals("")) {
extension = ".pdf";
}
return String.format("/print/%tY%<tm%<td%<tH%<tM%<tS-%s%s",
new Date(),
recentUniqueToken, extension);
}
/** /**
* An unique recent display number for Xvfb. It's not truly unique * An unique recent display number for Xvfb. It's not truly unique
* across all the life of a libreplan application, but it's in the last * across all the life of a libreplan application, but it's in the last