Added readBytes and totalBytes to Bean

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@169896 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-07-23 13:00:20 +00:00
parent 0a9194ae1a
commit 92a814672d
3 changed files with 77 additions and 7 deletions

View File

@ -125,6 +125,8 @@ public abstract class AbstractUploadProgressListener implements ProgressListener
UploadProgressChangeEvent event = new UploadProgressChangeEvent(); UploadProgressChangeEvent event = new UploadProgressChangeEvent();
event.setReadPercentage(percentage); event.setReadPercentage(percentage);
event.setReadTime(System.currentTimeMillis()); event.setReadTime(System.currentTimeMillis());
event.setReadBytes(bytesRead);
event.setTotalBytes(totalBytes);
// logger.trace("Updating percentage.. "+percentage); // logger.trace("Updating percentage.. "+percentage);
synchronized (this.uploadProgress) { synchronized (this.uploadProgress) {
// logger.trace("Adding event: "+event); // logger.trace("Adding event: "+event);

View File

@ -1,3 +1,4 @@
package org.gcube.portlets.widgets.workspaceuploader.shared.event; package org.gcube.portlets.widgets.workspaceuploader.shared.event;
/** /**
@ -17,24 +18,38 @@ public interface UploadEvent {
/** /**
* Sets the read percentage. * Sets the read percentage.
* *
* @param percentage the new read percentage * @param percentage
* the new read percentage
*/ */
void setReadPercentage(int percentage); void setReadPercentage(int percentage);
/** /**
* Sets the read time. (in millisecond) * Sets the read time. (in millisecond) the difference, measured in
* milliseconds, between the current time and midnight, January 1, 1970 UTC.
* *
* the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC. * @param time
* * the new read time
* @param time the new read time
*/ */
void setReadTime(long time); void setReadTime(long time);
/** /**
* Gets the read time (in millisecond) * Gets the read time (in millisecond).
* *
* @return the read time * @return the read time
*/ */
long getReadTime(); long getReadTime();
/**
* Gets the read bytes.
*
* @return the read bytes
*/
public long getReadBytes();
/**
* Gets the total bytes.
*
* @return the total bytes
*/
public long getTotalBytes();
} }

View File

@ -16,6 +16,8 @@ public final class UploadProgressChangeEvent implements UploadEvent, Serializabl
private static final long serialVersionUID = -3445585716145899197L; private static final long serialVersionUID = -3445585716145899197L;
private int readPercentage = -1; private int readPercentage = -1;
private long readTime = 0L; private long readTime = 0L;
private long readBytes = 0L;
private long totalBytes = 0L;
/** /**
* Instantiates a new upload progress change event. * Instantiates a new upload progress change event.
@ -55,17 +57,68 @@ public final class UploadProgressChangeEvent implements UploadEvent, Serializabl
return readTime; return readTime;
} }
/**
* Sets the read bytes.
*
* @param readBytes the readBytes to set
*/
public void setReadBytes(long readBytes) {
this.readBytes = readBytes;
}
/**
* Sets the total bytes.
*
* @param totalBytes the totalBytes to set
*/
public void setTotalBytes(long totalBytes) {
this.totalBytes = totalBytes;
}
/**
* Gets the read bytes.
*
* @return the readBytes
*/
public long getReadBytes() {
return readBytes;
}
/**
* Gets the total bytes.
*
* @return the totalBytes
*/
public long getTotalBytes() {
return totalBytes;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("UploadProgressChangeEvent [readPercentage="); builder.append("UploadProgressChangeEvent [readPercentage=");
builder.append(readPercentage); builder.append(readPercentage);
builder.append(", readTime="); builder.append(", readTime=");
builder.append(readTime); builder.append(readTime);
builder.append(", readBytes=");
builder.append(readBytes);
builder.append(", totalBytes=");
builder.append(totalBytes);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }