local_runtime_shared_jetty9/src/main/java/com/google/apphosting/utils/servlet/DatastoreViewerServlet.java [283:351]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private void doGetDatastoreViewer(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    int start = getIntParam(req, START, 0);
    int numPerPage = getIntParam(req, NUM_PER_PAGE, 10);
    String requestedNamespace = req.getParameter(NAMESPACE);
    String selectedKind = req.getParameter(KIND);

    // Empty namespace parameter equals to no namespace specified
    String namespace = requestedNamespace != null ? requestedNamespace : "";

    String savedNamespace = NamespaceManager.get();
    List<EntityView> entities = new ArrayList<EntityView>();
    List<String> kinds = new ArrayList<String>();
    Set<String> props = new HashSet<String>();
    int countForKind = 0;

    // All code in the following try block will use specified namespace
    // if it is valid. Starting from the metadata queries and ending with
    // fetching entries from the datastore.
    try {
      NamespaceManager.set(namespace);
      kinds = getKinds();
      if (kinds.contains(selectedKind)) {
        props.addAll(getIndexedProperties(selectedKind));
        entities = getEntityViews(selectedKind, req.getParameter(ORDER), start, numPerPage);
        countForKind = countForKind(selectedKind);
      }
    } catch (IllegalArgumentException e) {
      req.setAttribute(ERROR_MESSAGE, "Error: " + e.getMessage());
      selectedKind = null;
    } finally {
      NamespaceManager.set(savedNamespace);
    }
    // Add all properties including unindexed.
    for (EntityView e : entities) {
      props.addAll(e.getProperties().keySet());
    }

    List<String> sortedProps = new ArrayList<String>(props);
    Collections.sort(sortedProps);
    // Limit the number of columns that we display.
    boolean propertyOverflow =
        sortedProps.size() > DEFAULT_MAX_DATASTORE_VIEWER_COLUMNS;
    if (propertyOverflow) {
      sortedProps = sortedProps.subList(
          0, DEFAULT_MAX_DATASTORE_VIEWER_COLUMNS);
    }
    req.setAttribute(PROPERTY_OVERFLOW, propertyOverflow);

    Collections.sort(kinds);
    int currentPage = start / numPerPage;
    int numPages = (int) ceil(countForKind * (1.0 / numPerPage));
    int pageStart = (int) max(floor(currentPage - (MAX_PAGER_LINKS / 2)), 0);
    int pageEnd = min(pageStart + MAX_PAGER_LINKS, numPages);
    List<Page> pages = new ArrayList<Page>();
    for (int i = pageStart + 1; i < pageEnd + 1; i++) {
      pages.add(new Page(i, (i - 1) * numPerPage));
    }

    setDatastoreViewerAttributes(
        req, kinds, sortedProps, entities, countForKind, pages, currentPage + 1, numPerPage,
        numPages, requestedNamespace);
    try {
      getServletContext().getRequestDispatcher(
          "/_ah/adminConsole?subsection=" + Subsection.datastoreViewer.name()).forward(req, resp);
    } catch (ServletException e) {
      throw new RuntimeException("Could not forward request", e);
    }
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



local_runtime_shared_jetty12/src/main/java/com/google/apphosting/utils/servlet/ee10/DatastoreViewerServlet.java [283:351]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private void doGetDatastoreViewer(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    int start = getIntParam(req, START, 0);
    int numPerPage = getIntParam(req, NUM_PER_PAGE, 10);
    String requestedNamespace = req.getParameter(NAMESPACE);
    String selectedKind = req.getParameter(KIND);

    // Empty namespace parameter equals to no namespace specified
    String namespace = requestedNamespace != null ? requestedNamespace : "";

    String savedNamespace = NamespaceManager.get();
    List<EntityView> entities = new ArrayList<EntityView>();
    List<String> kinds = new ArrayList<String>();
    Set<String> props = new HashSet<String>();
    int countForKind = 0;

    // All code in the following try block will use specified namespace
    // if it is valid. Starting from the metadata queries and ending with
    // fetching entries from the datastore.
    try {
      NamespaceManager.set(namespace);
      kinds = getKinds();
      if (kinds.contains(selectedKind)) {
        props.addAll(getIndexedProperties(selectedKind));
        entities = getEntityViews(selectedKind, req.getParameter(ORDER), start, numPerPage);
        countForKind = countForKind(selectedKind);
      }
    } catch (IllegalArgumentException e) {
      req.setAttribute(ERROR_MESSAGE, "Error: " + e.getMessage());
      selectedKind = null;
    } finally {
      NamespaceManager.set(savedNamespace);
    }
    // Add all properties including unindexed.
    for (EntityView e : entities) {
      props.addAll(e.getProperties().keySet());
    }

    List<String> sortedProps = new ArrayList<String>(props);
    Collections.sort(sortedProps);
    // Limit the number of columns that we display.
    boolean propertyOverflow =
        sortedProps.size() > DEFAULT_MAX_DATASTORE_VIEWER_COLUMNS;
    if (propertyOverflow) {
      sortedProps = sortedProps.subList(
          0, DEFAULT_MAX_DATASTORE_VIEWER_COLUMNS);
    }
    req.setAttribute(PROPERTY_OVERFLOW, propertyOverflow);

    Collections.sort(kinds);
    int currentPage = start / numPerPage;
    int numPages = (int) ceil(countForKind * (1.0 / numPerPage));
    int pageStart = (int) max(floor(currentPage - (MAX_PAGER_LINKS / 2)), 0);
    int pageEnd = min(pageStart + MAX_PAGER_LINKS, numPages);
    List<Page> pages = new ArrayList<Page>();
    for (int i = pageStart + 1; i < pageEnd + 1; i++) {
      pages.add(new Page(i, (i - 1) * numPerPage));
    }

    setDatastoreViewerAttributes(
        req, kinds, sortedProps, entities, countForKind, pages, currentPage + 1, numPerPage,
        numPages, requestedNamespace);
    try {
      getServletContext().getRequestDispatcher(
          "/_ah/adminConsole?subsection=" + Subsection.datastoreViewer.name()).forward(req, resp);
    } catch (ServletException e) {
      throw new RuntimeException("Could not forward request", e);
    }
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



local_runtime_shared_jetty12/src/main/java/com/google/apphosting/utils/servlet/DatastoreViewerServlet.java [283:351]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private void doGetDatastoreViewer(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    int start = getIntParam(req, START, 0);
    int numPerPage = getIntParam(req, NUM_PER_PAGE, 10);
    String requestedNamespace = req.getParameter(NAMESPACE);
    String selectedKind = req.getParameter(KIND);

    // Empty namespace parameter equals to no namespace specified
    String namespace = requestedNamespace != null ? requestedNamespace : "";

    String savedNamespace = NamespaceManager.get();
    List<EntityView> entities = new ArrayList<EntityView>();
    List<String> kinds = new ArrayList<String>();
    Set<String> props = new HashSet<String>();
    int countForKind = 0;

    // All code in the following try block will use specified namespace
    // if it is valid. Starting from the metadata queries and ending with
    // fetching entries from the datastore.
    try {
      NamespaceManager.set(namespace);
      kinds = getKinds();
      if (kinds.contains(selectedKind)) {
        props.addAll(getIndexedProperties(selectedKind));
        entities = getEntityViews(selectedKind, req.getParameter(ORDER), start, numPerPage);
        countForKind = countForKind(selectedKind);
      }
    } catch (IllegalArgumentException e) {
      req.setAttribute(ERROR_MESSAGE, "Error: " + e.getMessage());
      selectedKind = null;
    } finally {
      NamespaceManager.set(savedNamespace);
    }
    // Add all properties including unindexed.
    for (EntityView e : entities) {
      props.addAll(e.getProperties().keySet());
    }

    List<String> sortedProps = new ArrayList<String>(props);
    Collections.sort(sortedProps);
    // Limit the number of columns that we display.
    boolean propertyOverflow =
        sortedProps.size() > DEFAULT_MAX_DATASTORE_VIEWER_COLUMNS;
    if (propertyOverflow) {
      sortedProps = sortedProps.subList(
          0, DEFAULT_MAX_DATASTORE_VIEWER_COLUMNS);
    }
    req.setAttribute(PROPERTY_OVERFLOW, propertyOverflow);

    Collections.sort(kinds);
    int currentPage = start / numPerPage;
    int numPages = (int) ceil(countForKind * (1.0 / numPerPage));
    int pageStart = (int) max(floor(currentPage - (MAX_PAGER_LINKS / 2)), 0);
    int pageEnd = min(pageStart + MAX_PAGER_LINKS, numPages);
    List<Page> pages = new ArrayList<Page>();
    for (int i = pageStart + 1; i < pageEnd + 1; i++) {
      pages.add(new Page(i, (i - 1) * numPerPage));
    }

    setDatastoreViewerAttributes(
        req, kinds, sortedProps, entities, countForKind, pages, currentPage + 1, numPerPage,
        numPages, requestedNamespace);
    try {
      getServletContext().getRequestDispatcher(
          "/_ah/adminConsole?subsection=" + Subsection.datastoreViewer.name()).forward(req, resp);
    } catch (ServletException e) {
      throw new RuntimeException("Could not forward request", e);
    }
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



