org.kohsuke.stapler.StaplerRequest.checkIfModified()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(76)

本文整理了Java中org.kohsuke.stapler.StaplerRequest.checkIfModified()方法的一些代码示例,展示了StaplerRequest.checkIfModified()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StaplerRequest.checkIfModified()方法的具体详情如下:
包路径:org.kohsuke.stapler.StaplerRequest
类名称:StaplerRequest
方法名:checkIfModified

StaplerRequest.checkIfModified介绍

[英]Checks "If-Modified-Since" header and returns false if the resource needs to be served.

This method can behave in three ways.

  1. If timestampOfResource is 0 or negative, this method just returns false.
  2. If "If-Modified-Since" header is sent and if it's bigger than timestampOfResource, then this method sets HttpServletResponse#SC_NOT_MODIFIED as the response code and returns true.
  3. Otherwise, "Last-Modified" header is added with timestampOfResource value, and this method returns false.

This method sends out the "Expires" header to force browser to re-validate all the time.
[中]检查“If Modified Since”标题,如果需要提供资源,则返回false。
这种方法有三种表现。
1.如果timestampOfResource为0或负值,则此方法只返回false。
1.如果发送了“If Modified Since”报头,并且该报头大于timestampOfResource,则该方法将HttpServletResponse#SC_NOT_Modified设置为响应代码,并返回true。
1.否则,“Last Modified”标头将添加timestampOfResource值,此方法返回false。
此方法发送“Expires”标题,强制浏览器始终重新验证。

代码示例

代码示例来源:origin: jenkinsci/jenkins

/**
   * Renders a clickable map.
   */
  public void doMap(StaplerRequest req, StaplerResponse rsp) throws IOException {
    if (req.checkIfModified(timestamp, rsp)) return;

    ChartRenderingInfo info = new ChartRenderingInfo();
    render(req,info);

    rsp.setContentType("text/plain;charset=UTF-8");
    rsp.getWriter().println(ChartUtilities.getImageMap( "map", info ));
  }
}

代码示例来源:origin: jenkinsci/jenkins

if (req.checkIfModified(timestamp, rsp)) return;

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-stapler

public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException {
    String path = req.getRestOfPath();
    if(path.length()>0) path=path.substring(1); // trim off the leading '/'
    
    Generator g = generators.get(path);
    if(g==null) {
      rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
      return;
    }

    if(req.checkIfModified(timestamp,rsp,expiration))
      return;

    g.doDynamic(req,rsp);
  }
}

代码示例来源:origin: org.jvnet.sorcerer/sorcerer-stapler

public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException {
    String path = req.getRestOfPath();
    if(path.length()>0) path=path.substring(1); // trim off the leading '/'
    
    Generator g = generators.get(path);
    if(g==null) {
      rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
      return;
    }

    if(req.checkIfModified(timestamp,rsp,expiration))
      return;

    g.doDynamic(req,rsp);
  }
}

代码示例来源:origin: jenkinsci/testng-plugin-plugin

/**
* If the last build is the same,
* no need to regenerate the graph. Browser should reuse it's cached image
*
* @param req request
* @param rsp response
* @return true, if new image does NOT need to be generated, false otherwise
*/
private boolean newGraphNotNeeded(final StaplerRequest req,
   StaplerResponse rsp) {
 Calendar t = getProject().getLastCompletedBuild().getTimestamp();
 return req.checkIfModified(t, rsp);
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
   * Renders a clickable map.
   */
  public void doMap(StaplerRequest req, StaplerResponse rsp) throws IOException {
    if (req.checkIfModified(timestamp, rsp)) return;

    ChartRenderingInfo info = new ChartRenderingInfo();
    render(req,info);

    rsp.setContentType("text/plain;charset=UTF-8");
    rsp.getWriter().println(ChartUtilities.getImageMap( "map", info ));
  }
}

代码示例来源:origin: org.hudsonci.plugins/jfreechart-plugin

/**
   * Renders a clickable map.
   */
  public void doMap(StaplerRequest req, StaplerResponse rsp) throws IOException {
    if (req.checkIfModified(timestamp, rsp)) return;

    String w = req.getParameter("width");
    if(w==null)     w=String.valueOf(defaultW);
    String h = req.getParameter("height");
    if(h==null)     h=String.valueOf(defaultH);

    ChartRenderingInfo info = new ChartRenderingInfo();
    render(req,info);

    rsp.setContentType("text/plain;charset=UTF-8");
    rsp.getWriter().println(ChartUtilities.getImageMap( "map", info ));
  }
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
   * Renders a clickable map.
   */
  public void doMap(StaplerRequest req, StaplerResponse rsp) throws IOException {
    if (req.checkIfModified(timestamp, rsp)) return;

    String w = req.getParameter("width");
    if(w==null)     w=String.valueOf(defaultW);
    String h = req.getParameter("height");
    if(h==null)     h=String.valueOf(defaultH);

    ChartRenderingInfo info = new ChartRenderingInfo();
    render(req,info);

    rsp.setContentType("text/plain;charset=UTF-8");
    rsp.getWriter().println(ChartUtilities.getImageMap( "map", info ));
  }
}

代码示例来源:origin: jenkinsci/junit-plugin

/**
 * Generates a clickable map HTML for {@link #doGraph(StaplerRequest, StaplerResponse)}.
 */
public void doGraphMap( StaplerRequest req, StaplerResponse rsp) throws IOException {
  if(req.checkIfModified(run.getTimestamp(),rsp))
    return;
  ChartUtil.generateClickableMap(req,rsp,createChart(req,buildDataSet(req)),calcDefaultSize());
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Generates a clickable map HTML for {@link #doGraph(StaplerRequest, StaplerResponse)}.
 */
public void doGraphMap( StaplerRequest req, StaplerResponse rsp) throws IOException {
  if(req.checkIfModified(owner.getTimestamp(),rsp))
    return;
  ChartUtil.generateClickableMap(req,rsp,createChart(req,buildDataSet(req)),calcDefaultSize());
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Generates a clickable map HTML for {@link #doGraph(StaplerRequest, StaplerResponse)}.
 */
public void doGraphMap( StaplerRequest req, StaplerResponse rsp) throws IOException {
  if(req.checkIfModified(owner.getTimestamp(),rsp))
    return;
  ChartUtil.generateClickableMap(req,rsp,createChart(req,buildDataSet(req)),calcDefaultSize());
}

代码示例来源:origin: jenkinsci/log-parser-plugin

public void doGraphMap(StaplerRequest req, StaplerResponse rsp)
    throws IOException {
  if (req.checkIfModified(this.getOwner().getTimestamp(), rsp))
    return;
  ChartUtil.generateClickableMap(req, rsp,
      createChart(req, buildDataSet()), calcDefaultSize());
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Generates a clickable map HTML for {@link #doGraph(StaplerRequest, StaplerResponse)}.
 */
public void doGraphMap( StaplerRequest req, StaplerResponse rsp) throws IOException {
  if(req.checkIfModified(owner.getTimestamp(),rsp))
    return;
  
  Area defSize = calcDefaultSize();
  Graph graph = new Graph(-1, defSize.width, defSize.height);
  graph.setYAxisLabel("count");
  graph.setData(getGraphDataSet(req));
  graph.doMap(req,rsp);
}

代码示例来源:origin: hudson/hudson-2.x

/**
 * Generates a PNG image for the test result trend.
 */
public void doGraph( StaplerRequest req, StaplerResponse rsp) throws IOException {
  if(ChartUtil.awtProblemCause!=null) {
    // not available. send out error message
    rsp.sendRedirect2(req.getContextPath()+"/images/headless.png");
    return;
  }
  if(req.checkIfModified(owner.getTimestamp(),rsp))
    return;
  ChartUtil.generateGraph(req,rsp,createChart(req,buildDataSet(req)),calcDefaultSize());
}

代码示例来源:origin: jenkinsci/junit-plugin

/**
 * Generates a PNG image for the test result trend.
 */
public void doGraph( StaplerRequest req, StaplerResponse rsp) throws IOException {
  if(ChartUtil.awtProblemCause!=null) {
    // not available. send out error message
    rsp.sendRedirect2(req.getContextPath()+"/images/headless.png");
    return;
  }
  if(req.checkIfModified(run.getTimestamp(),rsp))
    return;
  ChartUtil.generateGraph(req,rsp,createChart(req,buildDataSet(req)),calcDefaultSize());
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Generates a PNG image for the test result trend.
 */
public void doGraph( StaplerRequest req, StaplerResponse rsp) throws IOException {
  if(ChartUtil.awtProblemCause!=null) {
    // not available. send out error message
    rsp.sendRedirect2(req.getContextPath()+"/images/headless.png");
    return;
  }
  if(req.checkIfModified(owner.getTimestamp(),rsp))
    return;
  ChartUtil.generateGraph(req,rsp,createChart(req,buildDataSet(req)),calcDefaultSize());
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

/**
 * Generates a clickable map HTML for
 * {@link #doGraph(StaplerRequest, StaplerResponse)}.
 */
public void doGraphMap(StaplerRequest req, StaplerResponse rsp) throws IOException {
  if (req.checkIfModified(owner.getTimestamp(), rsp)) {
    return;
  }
  Area defSize = calcDefaultSize();
  Graph graph = new Graph(-1, defSize.width, defSize.height);
  graph.setYAxisLabel("count");
  graph.setData(getGraphDataSet(req));
  graph.doMap(req, rsp);
}

代码示例来源:origin: jenkinsci/log-parser-plugin

public void doGraph(StaplerRequest req, StaplerResponse rsp)
    throws IOException {
  if (ChartUtil.awtProblemCause != null) {
    // not available. send out error message
    rsp.sendRedirect2(req.getContextPath() + "/images/headless.png");
    return;
  }
  if (req.checkIfModified(getOwner().getTimestamp(), rsp))
    return;
  ChartUtil.generateGraph(req, rsp, createChart(req, buildDataSet()),
      calcDefaultSize());
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

/**
 * Generates a PNG image for the test result trend.
 */
public void doGraph( StaplerRequest req, StaplerResponse rsp) throws IOException {
  if(ChartUtil.awtProblemCause!=null) {
    // not available. send out error message
    rsp.sendRedirect2(req.getContextPath()+"/images/headless.png");
    return;
  }
  if(req.checkIfModified(owner.getTimestamp(),rsp))
    return;

  Area defSize = calcDefaultSize();
  Graph graph = new Graph(-1, defSize.width, defSize.height);
  graph.setYAxisLabel("count");
  graph.setData(getGraphDataSet(req));
  graph.doPng(req,rsp);
  
  //ChartUtil.generateGraph(req,rsp,createChart(req,buildDataSet(req)),calcDefaultSize());
}

代码示例来源:origin: org.jvnet.hudson.plugins/testng-plugin

public void doGraphMap(StaplerRequest req,
    StaplerResponse rsp) throws IOException {
 Calendar t = getProject().getLastCompletedBuild().getTimestamp();
 if (req.checkIfModified(t, rsp)) {
   return; // up to date
 }
 DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> dataSetBuilder =
  new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>();
 //TODO: optimize by using cache
 populateDataSetBuilder(dataSetBuilder);
 ChartUtil.generateClickableMap(req, rsp, GraphHelper.createChart(req, dataSetBuilder.build()),
      getGraphWidth(), getGraphHeight());
}

相关文章

微信公众号

最新文章

更多

StaplerRequest类方法