Пример #1
0
  @Override
  public void requestWasRemoved(ObjectContainer container, ClientContext context) {
    // if request is still running, send a GetFailed with code=cancelled
    if (!finished) {
      synchronized (this) {
        succeeded = false;
        finished = true;
        FetchException cancelled = new FetchException(FetchException.CANCELLED);
        getFailedMessage = new GetFailedMessage(cancelled, identifier, global);
      }
      trySendDataFoundOrGetFailed(null, container);
    }
    // notify client that request was removed
    FCPMessage msg = new PersistentRequestRemovedMessage(getIdentifier(), global);
    if (persistenceType != PERSIST_CONNECTION) {
      if (persistenceType == PERSIST_FOREVER) container.activate(client, 1);
      client.queueClientRequestMessage(msg, 0, container);
    }

    freeData(container);

    if (persistenceType == PERSIST_FOREVER) {
      container.activate(fctx, 1);
      if (fctx.allowedMIMETypes != null) {
        container.activate(fctx.allowedMIMETypes, 5);
        container.delete(fctx.allowedMIMETypes);
      }
      fctx.removeFrom(container);
      getter.removeFrom(container, context);
      if (targetFile != null) container.delete(targetFile);
      if (tempFile != null) container.delete(tempFile);
      if (getFailedMessage != null) {
        container.activate(getFailedMessage, 5);
        getFailedMessage.removeFrom(container);
      }
      if (postFetchProtocolErrorMessage != null) {
        container.activate(postFetchProtocolErrorMessage, 5);
        postFetchProtocolErrorMessage.removeFrom(container);
      }
      if (allDataPending != null) {
        container.activate(allDataPending, 5);
        allDataPending.removeFrom(container);
      }
      if (progressPending != null) {
        container.activate(progressPending, 5);
        progressPending.removeFrom(container);
      }
    }
    super.requestWasRemoved(container, context);
  }
Пример #2
0
 @Override
 public boolean restart(ObjectContainer container, ClientContext context) {
   if (!canRestart()) return false;
   FreenetURI redirect;
   synchronized (this) {
     finished = false;
     redirect = getFailedMessage == null ? null : getFailedMessage.redirectURI;
     if (persistenceType == PERSIST_FOREVER && getFailedMessage != null)
       getFailedMessage.removeFrom(container);
     this.getFailedMessage = null;
     if (persistenceType == PERSIST_FOREVER && allDataPending != null)
       allDataPending.removeFrom(container);
     this.allDataPending = null;
     if (persistenceType == PERSIST_FOREVER && postFetchProtocolErrorMessage != null)
       postFetchProtocolErrorMessage.removeFrom(container);
     this.postFetchProtocolErrorMessage = null;
     if (persistenceType == PERSIST_FOREVER && progressPending != null)
       progressPending.removeFrom(container);
     this.progressPending = null;
     started = false;
   }
   if (persistenceType == PERSIST_FOREVER) container.store(this);
   try {
     if (getter.restart(redirect, container, context)) {
       synchronized (this) {
         if (redirect != null) {
           if (persistenceType == PERSIST_FOREVER) uri.removeFrom(container);
           this.uri = redirect;
         }
         started = true;
       }
       if (persistenceType == PERSIST_FOREVER) container.store(this);
     }
     return true;
   } catch (FetchException e) {
     onFailure(e, null, container);
     return false;
   }
 }