Finds the page, returns {@code null} when not able to find the page.
172236
private static Page findPage(
		ServletContext servletContext,
		HttpServletRequest req,
		HttpServletResponse resp,
		SemanticCMS semanticCMS
	) throws ServletException, IOException {
		// Path extra info not allowed
		if(req.getPathInfo() != null) {
			return null;
		}
		// Query string not allowed
		if(req.getQueryString() != null) {
			return null;
		}
		String basePath;
		{
			String servletPath = req.getServletPath();
			// Must end in expected extension
			if(!servletPath.endsWith(RssUtils.EXTENSION)) {
				return null;
			}
			basePath = servletPath.substring(0, servletPath.length() - RssUtils.EXTENSION.length());
		}
		// Try to find the page, jspx, then jsp, then direct URL without extension
		String pagePath = null;
		for (String extension : RssUtils.getResourceExtensions()) {
			pagePath = basePath + extension;
			try {
				if(
					!RssUtils.isProtectedExtension(pagePath)
					&& ServletContextCache.getResource(servletContext, pagePath) != null
				) {
					break;
				}
			} catch(MalformedURLException e) {
				// Assume does not exist
			}
		}
		assert pagePath != null : "The last extension should be the default if none matched";
		if(RssUtils.isProtectedExtension(pagePath)) {
			return null;
		}
		// Find book and path
		PageRef pageRef;
		{
			Book book = semanticCMS.getPublishedBook(pagePath);
			if(book == null || !book.isAccessible()) {
				return null;
			}
			BookRef bookRef = book.getBookRef();
			try {
				pageRef = new PageRef(
					bookRef,
					Path.valueOf(pagePath.substring(bookRef.getPrefix().length()))
				);
			} catch(ValidationException e) {
				return null;
			}
		}
		// Capture the page
		return CapturePage.capturePage(
			servletContext,
			req,
			resp,
			pageRef,
			CaptureLevel.META
		);
	}
230703
private static String getPageDoc(
            IAnnotationBinding[] annotations, AcceptableLocales locales) {
        Map<Locale, String> allPages = getAllPageDocs(annotations);
        if (allPages.isEmpty()) {
            return null; // no @Page found
        }

        for (Locale locale : locales.getLocales()) {
            String value = allPages.get(locale);
            if (value != null) {
                return value;
            }
        }
        // set empty string if no locale matched data is found
        return "";
    }
1049076
public static @Nullable Date get(@Nullable Page page) {
    if (page == null) {
      return null;
    }
    Calendar lastModified = page.getLastModified();
    if (lastModified != null) {
      return lastModified.getTime();
    }
    else {
      return null;
    }
  }
135035
private Boolean existsPage(String page) throws MalformedURLException {
        // Searching the page...
        LOGGER.debug("Searching page [{}]...", page);
        LOGGER.debug("Page's real path is [{}]", this.context.getRealPath(page));
        File file = new File(this.context.getRealPath(page));
        Boolean exists = file.exists();
        LOGGER.debug("Page [{}]{}found", page, (exists ? " " : " not "));
        return exists;
    }
965478
@Override
	public <S extends T> Optional<S> findOne(final Example<S> example) {
		final ArangoCursor cursor = findAllInternal((Pageable) null, example, new HashMap());
		return cursor.hasNext() ? Optional.ofNullable((S) cursor.next()) : Optional.empty();
	}
826212
public function getNextPage()
    {
        return ($this->record)
            ? $this->getManifest()->getNextPage(
                $this->record->getPath(),
                $this->getEntity()->getPath()
            )
            : null;
    }
755368
public LLIndexPage locatePageForKey(long key, long value, boolean allowCreate) {
		if (isLeaf) {
			return this;
		}
		if (nEntries == -1 && !allowCreate) {
			return null;
		}

		//The stored value[i] is the min-values of the according page[i+1} 
        int pos = binarySearch(0, nEntries, key, value);
        if (pos >= 0) {
            //pos of matching key
            pos++;
        } else {
            pos = -(pos+1);
        }
        //TODO use weak refs
        //read page before that value
        LLIndexPage page = (LLIndexPage) readOrCreatePage(pos, allowCreate);
        return page.locatePageForKey(key, value, allowCreate);
	}
332013
public String htmlSource() {
        try {
            return driver.getPageSource();
        } catch (Exception e) {
            log.warn(e);
            return null;
        }
    }
7631
public LazyList<T> getPage(int pageNumber) {

        if (pageNumber < 1) throw new IllegalArgumentException("minimum page index == 1");

        try {
            LazyList<T> list = find(query, params).offset((pageNumber - 1) * pageSize).limit(pageSize);
            if (orderBys != null) {
                list.orderBy(orderBys);
            }
            currentPageIndex = pageNumber;
            return list;
        } catch (Exception mustNeverHappen) {
            throw new InternalException(mustNeverHappen);
        }
    }
461874
public @Nullable String getLinkRootPath(@NotNull Page page, @NotNull String linkTypeId) {
    if (StringUtils.equals(linkTypeId, InternalLinkType.ID)) {
      // inside an experience fragment it does not make sense to use a site root path
      if (Path.isExperienceFragmentPath(page.getPath())) {
        return DEFAULT_ROOT_PATH_CONTENT;
      }
      return AdaptTo.notNull(page.getContentResource(), SiteRoot.class).getRootPath(page);
    }
    else if (StringUtils.equals(linkTypeId, InternalCrossContextLinkType.ID)) {
      return DEFAULT_ROOT_PATH_CONTENT;
    }
    else if (StringUtils.equals(linkTypeId, MediaLinkType.ID)) {
      return DEFAULT_ROOT_PATH_MEDIA;
    }
    return null;
  }
422857
public @NotNull List<Page> getPages(@Nullable final Predicate<Page> filter, @Nullable final Page basePage) {
    Resource baseResourceToUse = null;

    // detect pages page to use
    if (basePage == null) {
      PageManager pageManager = AdaptTo.notNull(request.getResourceResolver(), PageManager.class);
      Page currentPage = pageManager.getContainingPage(request.getResource());
      if (currentPage != null) {
        baseResourceToUse = currentPage.adaptTo(Resource.class);
      }
    }
    else {
      baseResourceToUse = basePage.adaptTo(Resource.class);
    }

    // filter pages (as resources)
    Predicate<Resource> resourceFilter = new Predicate<Resource>() {
      @Override
      public boolean test(Resource resource) {
        Page page = resource.adaptTo(Page.class);
        if (page == null) {
          return false;
        }
        if (filter == null) {
          return true;
        }
        return filter.test(page);
      }
    };
    List<Resource> resources = getResourcesWithBaseResource(resourceFilter, baseResourceToUse);

    // convert resources back to pages
    return Lists.transform(resources, new Function<Resource, Page>() {
      @Override
      @SuppressWarnings("null")
      public Page apply(@Nullable Resource resource) {
        return resource.adaptTo(Page.class);
      }
    });
  }
416487
public OptionalInt getLastPage() {
        if(total.isPresent()) {
            return of(calcLastPage(total.getAsInt(), pageSize));
        } else {
            return empty();
        }
    }
771291
public URL toURL() {
        if (StringUtils.isBlank(url)) {
            return null;
        }
        try {
            return new URL(url);
        } catch (MalformedURLException e) {
            logger.info("URL does not appear to be valid and cannot be parsed:"
                    + url, e);
            return null;
        }
    }
576177
@Override
  public <T> T findAndRemove(String jxQuery, String collectionName) {
    if (null == jxQuery) {
      throw new InvalidJsonDbApiUsageException("Query string cannot be null.");
    }
    CollectionMetaData cmd = cmdMap.get(collectionName);
    @SuppressWarnings("unchecked")
    Map<Object, T> collection = (Map<Object, T>) collectionsRef.get().get(collectionName);
    if((null == cmd) || (null == collection)) {
      throw new InvalidJsonDbApiUsageException("Collection by name '" + collectionName + "' not found. Create collection first.");
    }
    cmd.getCollectionLock().writeLock().lock();
    try {
      JXPathContext context = contextsRef.get().get(collectionName);
      @SuppressWarnings("unchecked")
      Iterator<T> resultItr = context.iterate(jxQuery);
      T objectToRemove = null;
      while (resultItr.hasNext()) {
        objectToRemove = resultItr.next();
        break; // Use only the first element we find.
      }
      if (null != objectToRemove) {
        Object idToRemove = Util.getIdForEntity(objectToRemove, cmd.getIdAnnotatedFieldGetterMethod());
        if (!collection.containsKey(idToRemove)) { //This will never happen since the object was located based of jxQuery
          throw new InvalidJsonDbApiUsageException(String.format("Objects with Id %s not found in collection %s", idToRemove, collectionName));
        }

        JsonWriter jw;
        try {
          jw = new JsonWriter(dbConfig, cmd, collectionName, fileObjectsRef.get().get(collectionName));
        } catch (IOException ioe) {
          logger.error("Failed to obtain writer for " + collectionName, ioe);
          throw new JsonDBException("Failed to save " + collectionName, ioe);
        }
        boolean substractResult = jw.removeFromJsonFile(collection, idToRemove);
        if (substractResult) {
          T objectRemoved = collection.remove(idToRemove);
          // Don't need to clone it, this object no more exists in the collection
          return objectRemoved;
        } else {
          logger.error("Unexpected, Failed to substract the object");
        }
      }
      return null; //Either the jxQuery found nothing or actual FileIO failed to substract it.
    } finally {
      cmd.getCollectionLock().writeLock().unlock();
    }
  }
399895
public CmsContainerPageBean getPage(Object page, Object locale) {

        CmsResource pageResource = null;
        CmsContainerPageBean result = null;
        if (m_cms != null) {
            try {
                pageResource = CmsJspElFunctions.convertRawResource(m_cms, page);
                Locale l = CmsJspElFunctions.convertLocale(locale);
                result = getPage(pageResource);
                if (result != null) {
                    CmsADEConfigData adeConfig = OpenCms.getADEManager().lookupConfiguration(
                        m_cms,
                        pageResource.getRootPath());
                    for (CmsContainerBean container : result.getContainers().values()) {
                        for (CmsContainerElementBean element : container.getElements()) {
                            boolean isGroupContainer = element.isGroupContainer(m_cms);
                            boolean isInheritedContainer = element.isInheritedContainer(m_cms);
                            I_CmsFormatterBean formatterConfig = null;
                            if (!isGroupContainer && !isInheritedContainer) {
                                element.initResource(m_cms);
                                // ensure that the formatter configuration id is added to the element settings, so it will be persisted on save
                                formatterConfig = CmsJspTagContainer.getFormatterConfigurationForElement(
                                    m_cms,
                                    element,
                                    adeConfig,
                                    container.getName(),
                                    "",
                                    0);
                                if (formatterConfig != null) {
                                    element.initSettings(m_cms, formatterConfig, l, m_request, null);
                                }
                            }
                        }
                    }
                }
            } catch (Exception e) {
                LOG.warn(e.getLocalizedMessage(), e);
            }

        }
        return result;
    }
1163053
public PageResult<Entity> page(Connection conn, Entity where, Page page) throws SQLException {
		return this.page(conn, null, where, page);
	}
858966
public static LocalDocument findLocalDocumentByParentAndUrlName(Folder parentFolder, String urlName) {
    ResourceDAO resourceDAO = new ResourceDAO();
    
    Resource resource = resourceDAO.findByUrlNameAndParentFolder(urlName, parentFolder);
    if (resource instanceof LocalDocument) {
      return (LocalDocument) resource;
    }
    
    return null;
  }