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

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


   */
  class FileTreeGetter implements Handler<Message<JsonObject>> {
    @Override
    public void handle(Message<JsonObject> message) {
      GetDirectoryImpl request = GetDirectoryImpl.fromJsonString(Dto.get(message));
      final GetDirectoryResponseImpl response = GetDirectoryResponseImpl.make();
      synchronized (FileTree.this.lock) {
        response.setRootId(Long.toString(currentTreeVersion));
        PathUtils.walk(request.getPath(), "/", new PathVisitor() {
          @Override
          public void visit(String path, String name) {
            // Special case root.
            if ("/".equals(path)) {
              response.setBaseDirectory(root);
              response.setPath(path);
              return;
            }
            // Search for the next directory.
            DirInfo lastDir = response.getBaseDirectory();
            if (lastDir != null) {
              for (DirInfo dir : lastDir.getSubDirectories().asIterable()) {
                if (dir.getName().equals(name)) {
                  response.setBaseDirectory((DirInfoImpl) dir);
                  response.setPath(path + '/');
                  return;
                }
              }
            }
            // Didn't find it.
            response.setBaseDirectory(null);
          }
        });
      }
      message.reply(Dto.wrap(response));
    }
View Full Code Here

TOP

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

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.