Violations violations = new Violations(); cenv.setExtent(extent); for (Mutation mutation : mutations) { Violations more = cc.check(cenv, mutation); if (more != null) { violations.add(more); if (violators == null) violators = new ArrayList<>(); if (!violations.isEmpty()) {
private void checkForFailures() throws MutationsRejectedException { if (somethingFailed) { List<ConstraintViolationSummary> cvsList = violations.asList(); HashMap<TabletId,Set<org.apache.accumulo.core.client.security.SecurityErrorCode>> af = new HashMap<>(); for (Entry<KeyExtent,Set<SecurityErrorCode>> entry : authorizationFailures.entrySet()) { HashSet<org.apache.accumulo.core.client.security.SecurityErrorCode> codes = new HashSet<>(); for (SecurityErrorCode sce : entry.getValue()) { codes.add(org.apache.accumulo.core.client.security.SecurityErrorCode.valueOf(sce.name())); } af.put(new TabletIdImpl(entry.getKey()), codes); } throw new MutationsRejectedException(context, cvsList, af, serverSideErrors, unknownErrors, lastUnknownError); } }
private static Violations addViolation(Violations violations, ConstraintViolationSummary cvs) { if (violations == null) { violations = new Violations(); } violations.add(cvs); return violations; }
/** * Adds a list of violations. * * @param cvsList * list of violation summaries */ public void add(List<ConstraintViolationSummary> cvsList) { for (ConstraintViolationSummary constraintViolationSummary : cvsList) { add(constraintViolationSummary); } }
public static void main(String[] args) { Violations violations = new Violations(); Integer age = AgeValidator.parse("0042", "age", violations); URL url = UrlValidator.parse("http://some.website.com", "url", violations); } // Validator defining all the rules for a valid age value public class AgeValidator { // Collection of validation rules for age values private static final Collection<Validator<String>> VALIDATORS = ...; // Pass in the value to validate, the name of the field // defining the value and the container to collect all // violations (could be a Map<String, ValidationException>) // // a return value of null indicates at least one rule violation public static Integer parse(String value, String name, Violations violations) { try { for (Validator<String> validator : VALIDATORS) validator.validate(value); } catch (ValidationException e) { violations.add(name, e); } return violations.existFor(name) ? null : Integer.parseInt(value); } }
public UpdateSession(TservConstraintEnv env, TCredentials credentials, Durability durability) { super(credentials); this.cenv = env; this.violations = new Violations(); this.durability = durability; } }
public Violations check(Environment env, Mutation m) { if (!env.getExtent().contains(new ComparableBytes(m.getRow()))) { Violations violations = new Violations(); violations.add(cvs);
private void updatedConstraintViolations(List<ConstraintViolationSummary> cvsList) { if (cvsList.size() > 0) { synchronized (this) { somethingFailed = true; violations.add(cvsList); this.notifyAll(); } } }
public UpdateSession(TservConstraintEnv env, TCredentials credentials, Durability durability) { super(credentials); this.cenv = env; this.violations = new Violations(); this.durability = durability; } }
Violations violations = new Violations(); cenv.setExtent(extent); for (Mutation mutation : mutations) { Violations more = cc.check(cenv, mutation); if (more != null) { violations.add(more); if (violators == null) violators = new ArrayList<Mutation>(); if (!violations.isEmpty()) {
private static Violations addViolation(Violations violations, ConstraintViolationSummary cvs) { if (violations == null) { violations = new Violations(); } violations.add(cvs); return violations; }
/** * Adds all violations from the given object to this one. * * @param violations * violations to add */ public void add(Violations violations) { Set<Entry<CVSKey,ConstraintViolationSummary>> es = violations.cvsmap.entrySet(); for (Entry<CVSKey,ConstraintViolationSummary> entry : es) { add(entry.getKey(), entry.getValue()); } }
us.failures.size(), first.getKey().toString(), first.getValue())); List<ConstraintViolationSummary> violations = us.violations.asList(); if (violations.size() > 0) { ConstraintViolationSummary first = us.violations.asList().iterator().next(); log.debug(String.format("Violations: %d, first %s occurs %d", violations.size(), first.violationDescription, first.numberOfViolatingMutations));
@Override public long startUpdate(TInfo tinfo, TCredentials credentials) throws ThriftSecurityException { // Make sure user is real security.authenticateUser(credentials, credentials); if (updateMetrics.isEnabled()) updateMetrics.add(TabletServerUpdateMetrics.permissionErrors, 0); UpdateSession us = new UpdateSession(); us.violations = new Violations(); us.credentials = credentials; us.cenv = new TservConstraintEnv(security, us.credentials); long sid = sessionManager.createSession(us, false); return sid; }
Violations violations = new Violations(); cenv.setExtent(extent); for (Mutation mutation : mutations) { Violations more = cc.check(cenv, mutation); if (more != null) { violations.add(more); if (violators == null) violators = new ArrayList<>(); if (!violations.isEmpty()) {
violations = new Violations(); violations.add(cvs); ConstraintViolationSummary cvs = new ConstraintViolationSummary(constraint.getClass().getName(), vcode, constraint.getViolationDescription(vcode), 1); if (violations == null) violations = new Violations(); violations.add(cvs); violations = new Violations(); violations.add(cvs);
/** * Adds a violation. If a matching violation was already added, then its count is increased. * * @param cvs * summary of violation */ public void add(ConstraintViolationSummary cvs) { CVSKey cvsk = new CVSKey(cvs); add(cvsk, cvs); }
Translator.translate(e.getViolations().asList(), Translators.CVST)); } finally { writeTracker.finishWrite(opid);
public Violations check(Environment env, Mutation m) { if (!env.getExtent().contains(new ComparableBytes(m.getRow()))) { Violations violations = new Violations(); violations.add(cvs);
us.violations.add(e.getViolations()); if (updateMetrics.isEnabled()) updateMetrics.add(TabletServerUpdateMetrics.CONSTRAINT_VIOLATIONS, 0);