Package com.google.collide.dto.server.DtoServerImpls

Examples of com.google.collide.dto.server.DtoServerImpls.RecoverFromMissedDocOpsImpl


   * Replies with the DocOps that were missed by the requesting client.
   */
  class DocOpRecoverer implements Handler<Message<JsonObject>> {
    @Override
    public void handle(Message<JsonObject> event) {
      RecoverFromMissedDocOpsImpl req = RecoverFromMissedDocOpsImpl.fromJsonString(Dto.get(event));

      String resourceId = req.getFileEditSessionKey();
      FileEditSession editSession = editSessions.get(resourceId);

      if (editSession == null) {
        logger.error("No edit session for resourceId " + resourceId);

        // TODO: This is going to leave the reply handler hanging.
        return;
      }

      List<String> docOps = ((JsonArrayListAdapter<String>) req.getDocOps2()).asList();

      // If the client is re-sending any unacked doc ops, apply them first
      if (req.getDocOps2().size() > 0) {
        documentMutator.applyMutation(
            docOps, req.getClientId(), req.getCurrentCcRevision(), null, resourceId, editSession);
      }

      // Get all the applied doc ops the client doesn't know about
      SortedMap<Integer, VersionedDocument.AppliedDocOp> appliedDocOps =
          editSession.getDocument().getAppliedDocOps(req.getCurrentCcRevision() + 1);

      List<ServerToClientDocOpImpl> appliedDocOpsList = Lists.newArrayList();
      for (Entry<Integer, VersionedDocument.AppliedDocOp> entry : appliedDocOps.entrySet()) {
        DocOpImpl docOp = (DocOpImpl) entry.getValue().docOp;
        ServerToClientDocOpImpl wrappedBroadcastDocOp = ServerToClientDocOpImpl.make()
            .setClientId(req.getClientId()).setAppliedCcRevision(entry.getKey()).setDocOp2(docOp)
            .setFileEditSessionKey(resourceId)
            .setFilePath(editSession.getSavedPath());
        appliedDocOpsList.add(wrappedBroadcastDocOp);
      }

View Full Code Here

TOP

Related Classes of com.google.collide.dto.server.DtoServerImpls.RecoverFromMissedDocOpsImpl

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.