Package com.google.walkaround.proto

Examples of com.google.walkaround.proto.ImportWaveletTask


    } else if ("importwavelet".equals(action)) {
      SourceInstance instance =
          sourceInstanceFactory.parseUnchecked(requireParameter(req, "instance"));
      WaveId waveId = WaveId.deserialise(requireParameter(req, "waveid"));
      WaveletId waveletId = WaveletId.deserialise(requireParameter(req, "waveletid"));
      ImportWaveletTask task = new ImportWaveletTaskGsonImpl();
      task.setInstance(instance.serialize());
      task.setWaveId(waveId.serialise());
      task.setWaveletId(waveletId.serialise());
      ImportSettings settings = new ImportSettingsGsonImpl();
      if ("private".equals(requireParameter(req, "sharingmode"))) {
        settings.setSharingMode(ImportSettings.ImportSharingMode.PRIVATE);
      } else if ("shared".equals(requireParameter(req, "sharingmode"))) {
        settings.setSharingMode(ImportSettings.ImportSharingMode.SHARED);
      } else {
        throw new BadRequestException("Unexpected import sharing mode");
      }
      settings.setSynthesizeHistory(!preserveHistory);
      task.setSettings(settings);
      @Nullable String existingSlobIdToIgnore = optionalParameter(req, "ignoreexisting", null);
      if (existingSlobIdToIgnore != null) {
        task.setExistingSlobIdToIgnore(existingSlobIdToIgnore);
      }
      final ImportTaskPayload payload = new ImportTaskPayloadGsonImpl();
      payload.setImportWaveletTask(task);
      log.info("Enqueueing import task for " + waveId
          + "; synthesizeHistory=" + task.getSettings().getSynthesizeHistory());
      enqueueTasks(ImmutableList.of(payload));
    } else if ("canceltasks".equals(action)) {
      log.info("Cancelling all tasks for " + userId);
      try {
        new RetryHelper().run(new RetryHelper.VoidBody() {
View Full Code Here


        return taskAgePrefix(task)
            + (t.hasAutoImportSettings() ? "Find and import" : "Find")
            + " wavelets in wave " + t.getWaveDigest().getWaveId() + " on "
            + sourceInstanceFactory.parseUnchecked(t.getInstance()).getShortName();
    } else if (task.getPayload().hasImportWaveletTask()) {
      ImportWaveletTask t = task.getPayload().getImportWaveletTask();
      String sharingMode;
      switch (t.getSettings().getSharingMode()) {
        case PRIVATE:
          sharingMode = "Private";
          break;
        case SHARED:
          sharingMode = "Shared";
          break;
        case PRIVATE_UNLESS_PARTICIPANT:
          sharingMode = "Shared (if participant)";
          break;
        default:
          throw new AssertionError("Unexpected SharingMode: " + t.getSettings().getSharingMode());
      }
      return taskAgePrefix(task)
          + sharingMode + " import of wavelet " + t.getWaveId() + " " + t.getWaveletId()
          + " from " + sourceInstanceFactory.parseUnchecked(t.getInstance()).getShortName();
    } else if (task.getPayload().hasFetchAttachmentsTask()) {
      FetchAttachmentsAndImportWaveletTask t = task.getPayload().getFetchAttachmentsTask();
      return taskAgePrefix(task)
          + " Fetch attachments for wavelet "
          + t.getOriginalImportTask().getWaveId() + " " + t.getOriginalImportTask().getWaveletId()
          + " from " + sourceInstanceFactory.parseUnchecked(
              t.getOriginalImportTask().getInstance()).getShortName()
          + " (" + t.getImportedSize() + "/" + (t.getImportedSize() + t.getToImportSize()) + ")";
    } else {
      throw new AssertionError("Unknown task payload type: " + task);
    }
  }
View Full Code Here

      if (task.getPayload().hasFindWavesTask()) {
        // nothing
      } else if (task.getPayload().hasFindWaveletsTask()) {
        // nothing
      } else {
        ImportWaveletTask t;
        if (task.getPayload().hasFetchAttachmentsTask()) {
          t = task.getPayload().getFetchAttachmentsTask().getOriginalImportTask();
        } else if (task.getPayload().hasImportWaveletTask()) {
          t = task.getPayload().getImportWaveletTask();
        } else {
          throw new AssertionError("Unknown task payload type: " + task);
        }
        out.put(
            Pair.of(sourceInstanceFactory.parseUnchecked(t.getInstance()),
                WaveletName.of(WaveId.deserialise(t.getWaveId()),
                    WaveletId.deserialise(t.getWaveletId()))),
            t.getSettings().getSharingMode());
      }
    }
    return out.build();
  }
View Full Code Here

          new RetryHelper.VoidBody() {
            @Override public void run() throws RetryableFailure, PermanentFailure {
              CheckedTransaction tx = datastore.beginTransaction();
              try {
                for (RemoteConvWavelet wavelet : partition) {
                  ImportWaveletTask task = new ImportWaveletTaskGsonImpl();
                  task.setInstance(wavelet.getSourceInstance().serialize());
                  task.setWaveId(wavelet.getDigest().getWaveId());
                  task.setWaveletId(wavelet.getWaveletId().serialise());
                  task.setSettings(autoImportSettings);
                  ImportTaskPayload payload = new ImportTaskPayloadGsonImpl();
                  payload.setImportWaveletTask(task);
                  perUserTable.addTask(tx, userId, payload);
                }
                tx.commit();
View Full Code Here

    }
  }

  public List<ImportTaskPayload> fetchAttachments(FetchAttachmentsAndImportWaveletTask task)
      throws PermanentFailure {
    ImportWaveletTask waveletTask = task.getOriginalImportTask();
    SourceInstance instance = sourceInstanceFactory.parseUnchecked(waveletTask.getInstance());
    WaveletName waveletName = WaveletName.of(
        WaveId.deserialise(waveletTask.getWaveId()),
        WaveletId.deserialise(waveletTask.getWaveletId()));
    LinkedList<RemoteAttachmentInfo> toImport = Lists.newLinkedList(task.getToImport());
    log.info("Need attachments for " + waveletName + ": " + toImport);
    int infosFetchedThisTask = 0;
    while (!toImport.isEmpty() && infosFetchedThisTask < MAX_FETCHES_PER_TASK) {
      RemoteAttachmentInfo info = toImport.removeFirst();
      AttachmentId localId = fetchAttachment(instance, info);
      log.info("Local id: " + localId);
      ImportedAttachmentInfo imported = new ImportedAttachmentInfoGsonImpl();
      imported.setRemoteInfo(info);
      if (localId != null) {
        imported.setLocalId(localId.getId());
      }
      infosFetchedThisTask++;
      task.addImported(imported);
    }
    if (toImport.isEmpty()) {
      log.info("All attachments imported, will import wavelet");
      for (ImportedAttachmentInfo info : task.getImported()) {
        ImportedAttachment attachment = new ImportedAttachmentGsonImpl();
        attachment.setRemoteId(info.getRemoteInfo().getRemoteId());
        if (info.hasLocalId()) {
          attachment.setLocalId(info.getLocalId());
        }
        waveletTask.addAttachment(attachment);
      }
      ImportTaskPayload payload = new ImportTaskPayloadGsonImpl();
      payload.setImportWaveletTask(waveletTask);
      return ImmutableList.of(payload);
    } else {
View Full Code Here

TOP

Related Classes of com.google.walkaround.proto.ImportWaveletTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.