コード例 #1
0
  private void addExternalItem(final FcpPersistentPut uploadRequest) {
    final FrostUploadItem ulItem = new FrostUploadItem();
    ulItem.setGqIdentifier(uploadRequest.getIdentifier());
    ulItem.setExternal(true);
    // direct uploads maybe have no filename, use identifier
    String fileName = uploadRequest.getFilename();
    if (fileName == null) {
      fileName = uploadRequest.getIdentifier();
    } else if (fileName.indexOf('/') > -1 || fileName.indexOf('\\') > -1) {
      // filename contains directories, use only filename
      final String stmp = new File(fileName).getName();
      if (stmp.length() > 0) {
        fileName = stmp; // use plain filename
      }
    }
    ulItem.setFile(new File(fileName));
    ulItem.setFileName(fileName);
    ulItem.setFileSize(uploadRequest.getFileSize());
    ulItem.setPriority(uploadRequest.getPriority());

    ulItem.setState(FrostUploadItem.STATE_PROGRESS);
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            uploadModel.addExternalItem(ulItem);
          }
        });
    applyState(ulItem, uploadRequest);
  }