Example #1
0
  /** {@inheritDoc} */
  @Override
  public List<Violation> getViolations(ViolationQuery violationQuery) {
    Resource resource = violationQuery.getResource();
    if (resource == null) {
      throw new IllegalArgumentException(
          "A resource must be set on the ViolationQuery in order to search for violations.");
    }

    if (!Scopes.isHigherThanOrEquals(resource, Scopes.FILE)) {
      return Collections.emptyList();
    }

    Bucket bucket = buckets.get(resource);
    if (bucket == null) {
      return Collections.emptyList();
    }

    List<Violation> violations = deprecatedViolations.get(bucket.getResource().getEffectiveKey());
    if (violationQuery.getSwitchMode() == ViolationQuery.SwitchMode.BOTH) {
      return violations;
    }

    List<Violation> filteredViolations = Lists.newArrayList();
    for (Violation violation : violations) {
      if (isFiltered(violation, violationQuery.getSwitchMode())) {
        filteredViolations.add(violation);
      }
    }
    return filteredViolations;
  }
Example #2
0
 public List<Resource> getChildren(Resource resource, boolean acceptExcluded) {
   List<Resource> children = Lists.newLinkedList();
   Bucket bucket = getBucket(resource, acceptExcluded);
   if (bucket != null) {
     for (Bucket childBucket : bucket.getChildren()) {
       if (acceptExcluded || !childBucket.isExcluded()) {
         children.add(childBucket.getResource());
       }
     }
   }
   return children;
 }