コード例 #1
0
 public void testSequence() {
   List<Integer> lst = Iterators.sequence(1, 4);
   assertEquals(1, (int) lst.get(0));
   assertEquals(2, (int) lst.get(1));
   assertEquals(3, (int) lst.get(2));
   assertEquals(3, lst.size());
 }
コード例 #2
0
 /** Gets the last successful {@link Promotion}. */
 public Promotion getLastFailed() {
   PromotionProcess p = getProcess();
   for (Integer n : Iterators.reverse(promotionAttempts)) {
     Promotion b = p.getBuildByNumber(n);
     if (b != null && b.getResult() != Result.SUCCESS) return b;
   }
   return null;
 }
コード例 #3
0
ファイル: ExtensionList.java プロジェクト: neevor/hudson
 @Override
 public Iterator<T> iterator() {
   // we need to intercept mutation, so for now don't allow Iterator.remove
   return new AdaptedIterator<ExtensionComponent<T>, T>(
       Iterators.readOnly(ensureLoaded().iterator())) {
     protected T adapt(ExtensionComponent<T> item) {
       return item.getInstance();
     }
   };
 }
コード例 #4
0
 /** Gets all the promotion builds. */
 public List<Promotion> getPromotionBuilds() {
   PromotionProcess p = getProcess();
   List<Promotion> builds = new ArrayList<Promotion>();
   for (Integer n : Iterators.reverse(promotionAttempts)) {
     Promotion b = p.getBuildByNumber(n);
     if (b != null) {
       builds.add(b);
     }
   }
   return builds;
 }
コード例 #5
0
ファイル: Functions.java プロジェクト: stevenzyk/hudson
 /**
  * This version is so that the 'hasPermission' can degrade gracefully if "it" is not an {@link
  * AccessControlled} object.
  */
 public static boolean hasPermission(Object object, Permission permission)
     throws IOException, ServletException {
   if (permission == null) return true;
   if (object instanceof AccessControlled)
     return ((AccessControlled) object).hasPermission(permission);
   else {
     List<Ancestor> ancs = Stapler.getCurrentRequest().getAncestors();
     for (Ancestor anc : Iterators.reverse(ancs)) {
       Object o = anc.getObject();
       if (o instanceof AccessControlled) {
         return ((AccessControlled) o).hasPermission(permission);
       }
     }
     return Hudson.getInstance().hasPermission(permission);
   }
 }
コード例 #6
0
ファイル: Functions.java プロジェクト: stevenzyk/hudson
  /**
   * This version is so that the 'checkPermission' on <tt>layout.jelly</tt> degrades gracefully if
   * "it" is not an {@link AccessControlled} object. Otherwise it will perform no check and that
   * problem is hard to notice.
   */
  public static void checkPermission(Object object, Permission permission)
      throws IOException, ServletException {
    if (permission == null) return;

    if (object instanceof AccessControlled) checkPermission((AccessControlled) object, permission);
    else {
      List<Ancestor> ancs = Stapler.getCurrentRequest().getAncestors();
      for (Ancestor anc : Iterators.reverse(ancs)) {
        Object o = anc.getObject();
        if (o instanceof AccessControlled) {
          checkPermission((AccessControlled) o, permission);
          return;
        }
      }
      checkPermission(Hudson.getInstance(), permission);
    }
  }