Example #1
0
  /**
   * Find a file with its name matching last path part
   *
   * @param securityContext
   * @param request
   * @param path
   * @return
   * @throws FrameworkException
   */
  private File findFile(
      final SecurityContext securityContext, HttpServletRequest request, final String path)
      throws FrameworkException {

    List<Linkable> entryPoints = findPossibleEntryPoints(securityContext, request, path);

    // If no results were found, try to replace whitespace by '+' or '%20'
    if (entryPoints.isEmpty()) {
      entryPoints =
          findPossibleEntryPoints(
              securityContext, request, PathHelper.replaceWhitespaceByPlus(path));
    }

    if (entryPoints.isEmpty()) {
      entryPoints =
          findPossibleEntryPoints(
              securityContext, request, PathHelper.replaceWhitespaceByPercentTwenty(path));
    }

    for (Linkable node : entryPoints) {
      if (node instanceof File
          && (path.equals(node.getPath()) || node.getUuid().equals(PathHelper.getName(path)))) {
        return (File) node;
      }
    }

    return null;
  }