示例#1
0
    public List<List<Path>> invoke(File cur, VirtualChannel channel) throws IOException {
      List<List<Path>> r = new ArrayList<List<Path>>();

      File[] files = cur.listFiles();
      if (files != null) {
        Arrays.sort(files, new FileComparator());

        for (File f : files) {
          Path p =
              new Path(
                  Util.rawEncode(f.getName()),
                  f.getName(),
                  f.isDirectory(),
                  f.length(),
                  f.canRead());
          if (!f.isDirectory()) {
            r.add(Collections.singletonList(p));
          } else {
            // find all empty intermediate directory
            List<Path> l = new ArrayList<Path>();
            l.add(p);
            String relPath = Util.rawEncode(f.getName());
            while (true) {
              // files that don't start with '.' qualify for 'meaningful files', nor SCM related
              // files
              File[] sub =
                  f.listFiles(
                      new FilenameFilter() {
                        public boolean accept(File dir, String name) {
                          return !name.startsWith(".")
                              && !name.equals("CVS")
                              && !name.equals(".svn");
                        }
                      });
              if (sub == null || sub.length != 1 || !sub[0].isDirectory()) break;
              f = sub[0];
              relPath += '/' + Util.rawEncode(f.getName());
              l.add(new Path(relPath, f.getName(), true, 0, f.canRead()));
            }
            r.add(l);
          }
        }
      }

      return r;
    }
示例#2
0
  /**
   * When there are mutiple suggested items, this method can narrow down the resultset to the
   * SuggestedItem that has a url that contains the query. This is useful is one job has a display
   * name that matches another job's project name.
   *
   * @param r A list of Suggested items. It is assumed that there is at least one SuggestedItem in
   *     r.
   * @param query A query string
   * @return Returns the SuggestedItem which has a search url that contains the query. If no
   *     SuggestedItems have a search url which contains the query, then the first SuggestedItem in
   *     the List is returned.
   */
  static SuggestedItem findClosestSuggestedItem(List<SuggestedItem> r, String query) {
    for (SuggestedItem curItem : r) {
      if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.fine(
            String.format("item's searchUrl:%s;query=%s", curItem.item.getSearchUrl(), query));
      }
      if (curItem.item.getSearchUrl().contains(Util.rawEncode(query))) {
        return curItem;
      }
    }

    // couldn't find an item with the query in the url so just
    // return the first one
    return r.get(0);
  }
示例#3
0
  /**
   * Accepts submission from the configuration page.
   *
   * <p>Subtypes should override the {@link #submit(StaplerRequest)} method.
   */
  @RequirePOST
  public final synchronized void doConfigSubmit(StaplerRequest req, StaplerResponse rsp)
      throws IOException, ServletException, FormException {
    checkPermission(CONFIGURE);

    submit(req);

    description = Util.nullify(req.getParameter("description"));
    filterExecutors = req.getParameter("filterExecutors") != null;
    filterQueue = req.getParameter("filterQueue") != null;

    rename(req.getParameter("name"));

    getProperties().rebuild(req, req.getSubmittedForm(), getApplicablePropertyDescriptors());
    updateTransientActions();

    save();

    FormApply.success("../" + Util.rawEncode(name)).generateResponse(req, rsp, this);
  }
示例#4
0
    /** Builds the path list and href recursively top-down. */
    private void buildPathList(File baseDir, File filePath, List<Path> pathList, StringBuilder href)
        throws IOException {
      File parent = filePath.getParentFile();
      if (!baseDir.equals(parent)) {
        buildPathList(baseDir, parent, pathList, href);
      }

      href.append(Util.rawEncode(filePath.getName()));
      if (filePath.isDirectory()) {
        href.append("/");
      }

      Path path =
          new Path(
              href.toString(),
              filePath.getName(),
              filePath.isDirectory(),
              filePath.length(),
              filePath.canRead());
      pathList.add(path);
    }
示例#5
0
 /** Converts the original plot group name to a URL friendly group name. */
 public String originalGroupToUrlEncodedGroup(String originalGroup) {
   return Util.rawEncode(originalGroupToUrlGroup(originalGroup));
 }
示例#6
0
文件: User.java 项目: nahi/jenkins
 public String getSearchUrl() {
   return "/user/" + Util.rawEncode(id);
 }
示例#7
0
文件: User.java 项目: nahi/jenkins
 public String getUrl() {
   return "user/" + Util.rawEncode(id);
 }
示例#8
0
文件: View.java 项目: zlosch/jenkins
 /** Same as {@link #getUrl()} except this returns a view/{name} path even for the default view. */
 public String getViewUrl() {
   return (owner != null ? owner.getUrl() : "") + "view/" + Util.rawEncode(getViewName()) + '/';
 }
示例#9
0
 public String getShortUrl() {
     String prefix = getParent().getUrlChildPrefix();
     String subdir = Util.rawEncode(getName());
     return prefix.equals(".") ? subdir + '/' : prefix + '/' + subdir + '/';
 }