* param is the upload control id and second will be the current
* progress of the upload.
*/
public org.w3c.dom.Element fetchProgress(String id, String filename, String sessionKey) {
String progress;
UploadInfo uploadInfo;
if (session.getAttribute(XFormsSession.ADAPTER_PREFIX + sessionKey + "-uploadInfo") != null) {
uploadInfo = (UploadInfo) session.getAttribute(XFormsSession.ADAPTER_PREFIX + sessionKey + "-uploadInfo");
if (uploadInfo.isInProgress()) {
double p = uploadInfo.getBytesRead() / uploadInfo.getTotalSize();
progress = p + "";
float total = uploadInfo.getTotalSize();
float read = uploadInfo.getBytesRead();
int iProgress = (int) Math.ceil((read / total) * 100);
if (iProgress < 100) {
progress = Integer.toString(iProgress);
}
else {
progress = "99";
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Bytes total: " + uploadInfo.getTotalSize());
LOGGER.debug("Bytes read: " + uploadInfo.getBytesRead());
LOGGER.debug("elapsed time: " + uploadInfo.getElapsedTime());
LOGGER.debug("status: " + uploadInfo.getStatus());
LOGGER.debug("Percent completed: " + Math.ceil((read / total) * 100));
}
} else {
progress = "100";
}