summaryrefslogtreecommitdiffstats
path: root/idrop-lite
diff options
context:
space:
mode:
authorLISA STILLWELL <lisa@dhcp152-54-6-218.wireless.europa.renci.org>2011-12-20 16:33:52 (GMT)
committer LISA STILLWELL <lisa@dhcp152-54-6-218.wireless.europa.renci.org>2011-12-20 16:33:52 (GMT)
commitc2a3ea99dc1ce2719bad086f82f489462485c1ec (patch)
tree33406aafe5e1d35fb6d8379b393e623dcb348d3b /idrop-lite
parent8cf286ef765f78244886fd2c8a60c312731b6237 (diff)
downloadQCG-Data-c2a3ea99dc1ce2719bad086f82f489462485c1ec.zip
QCG-Data-c2a3ea99dc1ce2719bad086f82f489462485c1ec.tar.gz
QCG-Data-c2a3ea99dc1ce2719bad086f82f489462485c1ec.tar.bz2
[#427] moved creation of TransferControlBlock to Get/Put TransferRunners
Diffstat (limited to 'idrop-lite')
-rw-r--r--idrop-lite/src/main/java/org/irods/jargon/idrop/lite/GetTransferRunner.java28
-rw-r--r--idrop-lite/src/main/java/org/irods/jargon/idrop/lite/IRODSTreeTransferHandler.java10
-rw-r--r--idrop-lite/src/main/java/org/irods/jargon/idrop/lite/LocalTreeTransferHandler.java5
-rw-r--r--idrop-lite/src/main/java/org/irods/jargon/idrop/lite/PutTransferRunner.java29
-rw-r--r--idrop-lite/src/main/java/org/irods/jargon/idrop/lite/TransferProgressInfo.java8
-rw-r--r--idrop-lite/src/main/java/org/irods/jargon/idrop/lite/UploadTableProgressBar.java21
-rw-r--r--idrop-lite/src/main/java/org/irods/jargon/idrop/lite/iDropLiteApplet.java9
7 files changed, 80 insertions, 30 deletions
diff --git a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/GetTransferRunner.java b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/GetTransferRunner.java
index 781a66c..0b93b16 100644
--- a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/GetTransferRunner.java
+++ b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/GetTransferRunner.java
@@ -6,6 +6,7 @@ import java.util.List;
import org.irods.jargon.core.exception.JargonException;
import org.irods.jargon.core.pub.DataTransferOperations;
import org.irods.jargon.core.pub.io.IRODSFile;
+import org.irods.jargon.core.transfer.DefaultTransferControlBlock;
import org.irods.jargon.core.transfer.TransferControlBlock;
import org.slf4j.LoggerFactory;
@@ -15,12 +16,13 @@ public class GetTransferRunner implements Runnable {
private final List<File> sourceFiles;
private final String targetIrodsFileAbsolutePath;
private final iDropLiteApplet idropGui;
- private final TransferControlBlock transferControlBlock;
+ //private final TransferControlBlock transferControlBlock;
+ private TransferControlBlock transferControlBlock;
public GetTransferRunner(final iDropLiteApplet gui,
final String targetPath,
- final List<File> files,
- final TransferControlBlock transferControlBlock)
+ final List<File> files)
+ //final TransferControlBlock transferControlBlock)
throws JargonException {
if (files == null) {
@@ -35,14 +37,14 @@ public class GetTransferRunner implements Runnable {
throw new JargonException("null idrop gui");
}
- if (transferControlBlock == null) {
- throw new JargonException("null transferControlBlock");
- }
+// if (transferControlBlock == null) {
+// throw new JargonException("null transferControlBlock");
+// }
this.targetIrodsFileAbsolutePath = targetPath;
this.sourceFiles = files;
this.idropGui = gui;
- this.transferControlBlock = transferControlBlock;
+ //this.transferControlBlock = transferControlBlock;
}
@@ -51,6 +53,18 @@ public class GetTransferRunner implements Runnable {
for (File transferFile : sourceFiles) {
+ // need to create new Transfer Control Block for each transfer since it needs to be reset
+ // on how many files there are to transfer and how many have been transferred so far
+ TransferControlBlock tcb = null;
+ try {
+ tcb = DefaultTransferControlBlock.instance();
+ idropGui.getiDropCore().setTransferControlBlock(tcb);
+ this.transferControlBlock = tcb;
+ } catch (JargonException ex) {
+ java.util.logging.Logger.getLogger(LocalFileTree.class.getName()).log(
+ java.util.logging.Level.SEVERE, null, ex);
+ idropGui.showIdropException(ex);
+ }
if (transferFile instanceof IRODSFile) {
log.info("initiating a transfer of iRODS file:{}", transferFile.getAbsolutePath());
log.info("transfer to local file:{}", targetIrodsFileAbsolutePath);
diff --git a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/IRODSTreeTransferHandler.java b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/IRODSTreeTransferHandler.java
index f159533..dbb656e 100644
--- a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/IRODSTreeTransferHandler.java
+++ b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/IRODSTreeTransferHandler.java
@@ -289,8 +289,9 @@ public class IRODSTreeTransferHandler extends TransferHandler {
// process the drop as a put
try {
- currentTransferRunner = new PutTransferRunner(idropGui, targetIrodsFileAbsolutePath,
- sourceFiles, idropGui.getiDropCore().getTransferControlBlock());
+ //currentTransferRunner = new PutTransferRunner(idropGui, targetIrodsFileAbsolutePath,
+ //sourceFiles, idropGui.getiDropCore().getTransferControlBlock());
+ currentTransferRunner = new PutTransferRunner(idropGui, targetIrodsFileAbsolutePath, sourceFiles);
final Thread transferThread = new Thread(currentTransferRunner);
log.info("launching transfer thread");
transferThread.start();
@@ -411,8 +412,9 @@ public class IRODSTreeTransferHandler extends TransferHandler {
// process the drop as a put
try {
- currentTransferRunner = new PutTransferRunner(idropGui, targetIrodsFileAbsolutePath,
- sourceFiles, idropGui.getiDropCore().getTransferControlBlock());
+ //currentTransferRunner = new PutTransferRunner(idropGui, targetIrodsFileAbsolutePath,
+ //sourceFiles, idropGui.getiDropCore().getTransferControlBlock());
+ currentTransferRunner = new PutTransferRunner(idropGui, targetIrodsFileAbsolutePath, sourceFiles);
final Thread transferThread = new Thread(currentTransferRunner);
log.info("launching transfer thread");
transferThread.start();
diff --git a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/LocalTreeTransferHandler.java b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/LocalTreeTransferHandler.java
index 00b8db5..939c4d2 100644
--- a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/LocalTreeTransferHandler.java
+++ b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/LocalTreeTransferHandler.java
@@ -189,8 +189,9 @@ public class LocalTreeTransferHandler extends TransferHandler {
// process the drop as a get
try {
- currentTransferRunner = new GetTransferRunner(idropGui, tempTargetLocalFileAbsolutePath,
- sourceFiles, idropGui.getiDropCore().getTransferControlBlock());
+ //currentTransferRunner = new GetTransferRunner(idropGui, tempTargetLocalFileAbsolutePath,
+ //sourceFiles, idropGui.getiDropCore().getTransferControlBlock());
+ currentTransferRunner = new GetTransferRunner(idropGui, tempTargetLocalFileAbsolutePath, sourceFiles);
final Thread transferThread = new Thread(currentTransferRunner);
log.info("launching transfer thread");
transferThread.start();
diff --git a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/PutTransferRunner.java b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/PutTransferRunner.java
index 142161b..595cd1c 100644
--- a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/PutTransferRunner.java
+++ b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/PutTransferRunner.java
@@ -5,6 +5,7 @@ import java.util.List;
import org.irods.jargon.core.exception.JargonException;
import org.irods.jargon.core.pub.DataTransferOperations;
+import org.irods.jargon.core.transfer.DefaultTransferControlBlock;
import org.irods.jargon.core.transfer.TransferControlBlock;
import org.slf4j.LoggerFactory;
@@ -14,12 +15,13 @@ public class PutTransferRunner implements Runnable {
private final List<File> sourceFiles;
private final String targetIrodsFileAbsolutePath;
private final iDropLiteApplet idropGui;
- private final TransferControlBlock transferControlBlock;
+ //private final TransferControlBlock transferControlBlock;
+ private TransferControlBlock transferControlBlock;
public PutTransferRunner(final iDropLiteApplet gui,
final String targetPath,
- final List<File> files,
- final TransferControlBlock transferControlBlock)
+ final List<File> files)
+ //final TransferControlBlock transferControlBlock)
throws JargonException {
if (files == null) {
@@ -34,14 +36,14 @@ public class PutTransferRunner implements Runnable {
throw new JargonException("null idrop gui");
}
- if (transferControlBlock == null) {
- throw new JargonException("null transferControlBlock");
- }
+// if (transferControlBlock == null) {
+// throw new JargonException("null transferControlBlock");
+// }
this.targetIrodsFileAbsolutePath = targetPath;
this.sourceFiles = files;
this.idropGui = gui;
- this.transferControlBlock = transferControlBlock;
+ //this.transferControlBlock = transferControlBlock;
}
@@ -59,6 +61,19 @@ public class PutTransferRunner implements Runnable {
String localSourceAbsolutePath = transferFile.getAbsolutePath();
String sourceResource = idropGui.getIrodsAccount().getDefaultStorageResource();
+
+ // need to create new Transfer Control Block for each transfer since it needs to be reset
+ // on how many files there are to transfer and how many have been transferred so far
+ TransferControlBlock tcb = null;;
+ try {
+ tcb = DefaultTransferControlBlock.instance();
+ idropGui.getiDropCore().setTransferControlBlock(tcb);
+ this.transferControlBlock = tcb;
+ } catch (JargonException ex) {
+ java.util.logging.Logger.getLogger(LocalFileTree.class.getName()).log(
+ java.util.logging.Level.SEVERE, null, ex);
+ idropGui.showIdropException(ex);
+ }
log.info("initiating put transfer");
try {
idropGui.getiDropCore().getTransferManager().putOperation(localSourceAbsolutePath,
diff --git a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/TransferProgressInfo.java b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/TransferProgressInfo.java
index ea7ce11..49fb438 100644
--- a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/TransferProgressInfo.java
+++ b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/TransferProgressInfo.java
@@ -1,6 +1,7 @@
package org.irods.jargon.idrop.lite;
public class TransferProgressInfo {
+ Boolean isIntraFile = false;
int percentDone = 0;
int totalFilesToTransfer = 0;
int totalFilesTransferredSoFar = 0;
@@ -19,6 +20,13 @@ public class TransferProgressInfo {
this.totalFilesTransferredSoFar = soFar;
}
+ public TransferProgressInfo(long fileSize, long fileSoFar, int toTransfer, int soFar, Boolean isIntra) {
+ this.percentDone = this.calcPercentDone(fileSoFar, fileSize);
+ this.totalFilesToTransfer = toTransfer;
+ this.totalFilesTransferredSoFar = soFar;
+ this.isIntraFile = isIntra;
+ }
+
public int calcPercentDone(long bytesTransfered, long totalSize) {
float percent = 0;
diff --git a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/UploadTableProgressBar.java b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/UploadTableProgressBar.java
index 44a3a5d..ab4329e 100644
--- a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/UploadTableProgressBar.java
+++ b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/UploadTableProgressBar.java
@@ -53,6 +53,10 @@ public class UploadTableProgressBar extends JProgressBar implements TableCellRen
// setValue(0);
// setString("0%");
// }
+ Boolean transferInProgress = ((iDropLiteApplet)table.getTopLevelAncestor()).isTransferInProgress();
+
+ setFont(new java.awt.Font("Lucida Grande", 0, 12));
+
if((value != null) && (value instanceof TransferProgressInfo)) {
TransferProgressInfo tpInfo = (TransferProgressInfo)value;
Integer ival = tpInfo.getPercentDone();
@@ -62,18 +66,21 @@ public class UploadTableProgressBar extends JProgressBar implements TableCellRen
Boolean isFolder = (Boolean) table.getModel().getValueAt(row, 4);
int filesToTransfer = tpInfo.getTotalFilesToTransfer();
int soFar = tpInfo.getTotalFilesTransferredSoFar();
- if((isFolder) && (soFar > 0)) {
- String pbText = "File " + soFar + " of " + filesToTransfer + " complete";
- setString(pbText);
+ if((isFolder) && (ival > 0)) {
+ //if((transferInProgress) && (soFar > 0)) {
+ //if(!tpInfo.isIntraFile) {
+ String pbText = "File " + soFar + " of " + filesToTransfer + " complete";
+ setString(pbText);
+ //}
}
else {
setString(ival.toString().concat("%"));
}
}
- else {
- setValue(0);
- setString("0%");
- }
+// else {
+// setValue(0);
+// setString("0%");
+// }
return this;
}
diff --git a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/iDropLiteApplet.java b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/iDropLiteApplet.java
index 0bd68e8..5e19152 100644
--- a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/iDropLiteApplet.java
+++ b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/iDropLiteApplet.java
@@ -725,7 +725,7 @@ public class iDropLiteApplet extends javax.swing.JApplet implements TransferStat
float tot = ts.getTotalSize();
float percentDone = bt / tot;
//tblUploadTable1.getModel().setValueAt((int) percentDone, tableRow, 2);
- TransferProgressInfo tpi = new TransferProgressInfo(ts.getTotalSize(), ts.getBytesTransfered(), 0, 0);
+ TransferProgressInfo tpi = new TransferProgressInfo(ts.getTotalSize(), ts.getBytesTransfered(), 0, 0, true);
tblUploadTable1.getModel().setValueAt(tpi, tableRow, 2);
}
@@ -798,6 +798,7 @@ public class iDropLiteApplet extends javax.swing.JApplet implements TransferStat
final iDropLiteApplet idropGui = this;
idropGui.setTransferInProgress(true);
+ log.info("transfer OVERALL status callback to iDropLiteApplet:{}", ts);
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
@@ -2120,7 +2121,8 @@ public class iDropLiteApplet extends javax.swing.JApplet implements TransferStat
// set Upload button test to Cancel
try {
- currentTransferRunner = new PutTransferRunner(applet, targetPath, sourceFiles, iDropCore.getTransferControlBlock());
+ //currentTransferRunner = new PutTransferRunner(applet, targetPath, sourceFiles, iDropCore.getTransferControlBlock());
+ currentTransferRunner = new PutTransferRunner(applet, targetPath, sourceFiles);
final Thread transferThread = new Thread(currentTransferRunner);
log.info("launching transfer thread");
// close so that transfer thread can grab account
@@ -2194,7 +2196,8 @@ public class iDropLiteApplet extends javax.swing.JApplet implements TransferStat
}
try {
// process a get
- currentTransferRunner = new GetTransferRunner(applet, targetPath, sourceFiles, iDropCore.getTransferControlBlock());
+ //currentTransferRunner = new GetTransferRunner(applet, targetPath, sourceFiles, iDropCore.getTransferControlBlock());
+ currentTransferRunner = new GetTransferRunner(applet, targetPath, sourceFiles);
final Thread transferThread = new Thread(currentTransferRunner);
log.info("launching transfer thread");
// close so that transfer thread can grab account