private Map<TransferHandle, TransferProgress> convertTransfer(
      Map<GenericTransferHandle, GenericTransferProgress> transferMap) {

    Map<TransferHandle, TransferProgress> map = CommonUtils.createSerializableMap();

    TransferHandle handle = null;
    TransferProgress progress = null;
    GenericTransferHandle genericHandle = null;
    GenericTransferProgress genericProgress = null;

    for (Entry<GenericTransferHandle, GenericTransferProgress> entry : transferMap.entrySet()) {

      genericHandle = entry.getKey();
      genericProgress = entry.getValue();

      if (genericProgress.isOutgoing()) {
        OutgoingHandle outgoing = (OutgoingHandle) genericHandle;
        handle =
            new OutgoingTransferHandle(
                outgoing.getId(),
                outgoing.getLogicalFileName(),
                outgoing.getLocalFile(),
                outgoing.getDescription(),
                new DeploymentID(outgoing.getOppositeID()));
      } else {
        IncomingHandle incoming = (IncomingHandle) genericHandle;
        ContainerID senderID = ContainerID.parse(incoming.getSenderContainerID());

        handle =
            new IncomingTransferHandle(
                incoming.getId(),
                incoming.getLogicalFileName(),
                incoming.getDescription(),
                incoming.getFileSize(),
                senderID.getContainerID());
      }

      progress =
          new TransferProgress(
              handle,
              genericProgress.getFileName(),
              genericProgress.getFileSize(),
              getStatus(genericProgress.getNewStatus()),
              genericProgress.getAmountWritten(),
              genericProgress.getProgress(),
              genericProgress.getTransferRate(),
              genericProgress.isOutgoing());

      map.put(handle, progress);
    }

    return map;
  }
Пример #2
0
  public void fileTransferProgressUpdate(GenericTransferProgress fileTransferProgress) {

    transfersProgress.put(fileTransferProgress.getHandle(), fileTransferProgress);
  }