Exemplo n.º 1
0
 @Override
 public OutputStream getOutputStream() {
   if (file.getStreamVariable() == null) {
     return null;
   }
   return file.getStreamVariable().getOutputStream();
 }
Exemplo n.º 2
0
 @Override
 public void streamingStarted(StreamingStartEvent event) {
   listenProgressOfUploadedFile = file.getStreamVariable() != null;
   if (listenProgressOfUploadedFile) {
     file.getStreamVariable().streamingStarted(new ReceivingEventWrapper(event));
   }
   // no need tell to the client about this receiver on next paint
   receivers.remove(id);
   sentIds.remove(id);
   // let the terminal GC the streamvariable and not to accept other
   // file uploads to this variable
   event.disposeStreamVariable();
 }
Exemplo n.º 3
0
  @Override
  public void paintContent(PaintTarget target) throws PaintException {
    target.addAttribute(DragAndDropWrapperConstants.DRAG_START_MODE, dragStartMode.ordinal());
    if (getDropHandler() != null) {
      getDropHandler().getAcceptCriterion().paint(target);
    }
    if (receivers != null && receivers.size() > 0) {
      for (Iterator<Entry<String, ProxyReceiver>> it = receivers.entrySet().iterator();
          it.hasNext(); ) {
        Entry<String, ProxyReceiver> entry = it.next();
        String id = entry.getKey();
        ProxyReceiver proxyReceiver = entry.getValue();
        Html5File html5File = proxyReceiver.file;
        if (html5File.getStreamVariable() != null) {
          if (!sentIds.contains(id)) {
            target.addVariable(this, "rec-" + id, new ProxyReceiver(id, html5File));

            /*
             * if a new batch is requested to be uploaded before the
             * last one is done, any remaining ids will be replayed.
             * We want to avoid a new ProxyReceiver to be made since
             * it'll get a new URL, so we need to keep extra track
             * on what has been sent.
             *
             * See #12330.
             */
            sentIds.add(id);

            // these are cleaned from receivers once the upload has
            // started
          }
        } else {
          // instructs the client side not to send the file
          target.addVariable(this, "rec-" + id, (String) null);
          // forget the file from subsequent paints
          it.remove();
        }
      }
    }
    target.addAttribute(DragAndDropWrapperConstants.HTML5_DATA_FLAVORS, html5DataFlavors);
  }
Exemplo n.º 4
0
 @Override
 public boolean isInterrupted() {
   return file.getStreamVariable().isInterrupted();
 }
Exemplo n.º 5
0
 @Override
 public void streamingFailed(final StreamingErrorEvent event) {
   if (listenProgressOfUploadedFile) {
     file.getStreamVariable().streamingFailed(new ReceivingEventWrapper(event));
   }
 }
Exemplo n.º 6
0
 @Override
 public void streamingFinished(StreamingEndEvent event) {
   if (listenProgressOfUploadedFile) {
     file.getStreamVariable().streamingFinished(new ReceivingEventWrapper(event));
   }
 }
Exemplo n.º 7
0
 @Override
 public void onProgress(StreamingProgressEvent event) {
   file.getStreamVariable().onProgress(new ReceivingEventWrapper(event));
 }
Exemplo n.º 8
0
 @Override
 public boolean listenProgress() {
   return file.getStreamVariable().listenProgress();
 }