Examples of ValidationResult


Examples of org.apache.sling.validation.api.ValidationResult

            ValidationModel vm = validationService.getValidationModel("sling/validation/test", "/apps/validation/1/resource");
            HashMap<String, Object> hashMap = new HashMap<String, Object>() {{
                put("field1", "1");
            }};
            ValueMap map = new ValueMapDecorator(hashMap);
            ValidationResult vr = validationService.validate(map, vm);
        } finally {
            if (model1 != null) {
                rr.delete(model1);
            }
            if (rr != null) {
View Full Code Here

Examples of org.apache.sling.validation.api.ValidationResult

            HashMap<String, Object> hashMap = new HashMap<String, Object>() {{
                put("field1", "HelloWorld");
                put("field2", "HelloWorld");
            }};
            ValueMap map = new ValueMapDecorator(hashMap);
            ValidationResult vr = validationService.validate(map, vm);
            assertFalse(vr.isValid());
            // check for correct error message
            Map<String, List<String>> expectedFailureMessages = new HashMap<String, List<String>>();
            expectedFailureMessages.put("field2", Arrays.asList("Property does not match the pattern " + TEST_REGEX));
            Assert.assertThat(vr.getFailureMessages().entrySet(), Matchers.equalTo(expectedFailureMessages.entrySet()));
            if (model1 != null) {
                rr.delete(model1);
            }
        } finally {
            if (rr != null) {
View Full Code Here

Examples of org.apache.sling.validation.api.ValidationResult

                    put(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED);
                }});
                rr.commit();
            }
            ValidationModel vm = validationService.getValidationModel("sling/validation/test", "/apps/validation/1/resource");
            ValidationResult vr = validationService.validate(testResource, vm);
            assertFalse(vr.isValid());
            assertTrue(vr.getFailureMessages().containsKey("child1/hello"));
        } finally {
            if (rr != null) {
                if (model1 != null) {
                    rr.delete(model1);
                }
View Full Code Here

Examples of org.apache.sling.validation.api.ValidationResult

            }
            if (resourceType != null && !"".equals(resourceType)) {
                String resourcePath = request.getRequestPathInfo().getResourcePath();
                ValidationModel vm = validationService.getValidationModel(resourceType, resourcePath);
                if (vm != null) {
                    ValidationResult vr = validationService.validate(requestParameters, vm);
                    vpr.setValidationResult(vr);
                } else {
                    LOG.error("No validation model for resourceType {} and resourcePath {} ", resourceType, resourcePath);
                }
            }
View Full Code Here

Examples of org.apache.sling.validation.api.ValidationResult

    @PostConstruct
    protected void validate() {
        ValidationModel model = validationService.getValidationModel(resource);
        if (model != null) {
            ValidationResult result = validationService.validate(resource, model);
            if (!result.isValid()) {
                errors = result.getFailureMessages();
            }
        }
    }
View Full Code Here

Examples of org.apache.sling.validation.api.ValidationResult

        }
        if (resourceType != null && !"".equals(resourceType)) {
            String resourcePath = request.getRequestPathInfo().getResourcePath();
            ValidationModel vm = validationService.getValidationModel(resourceType, resourcePath);
            if (vm != null) {
                ValidationResult vr = validationService.validate(requestParameters, vm);
                if (vr.isValid()) {
                    RequestDispatcherOptions options = new RequestDispatcherOptions();
                    options.setReplaceSelectors(" ");
                    request.getRequestDispatcher(request.getResource(), options).forward(request, response);
                } else {
                    response.setContentType("application/json");
                    JSONObject json = new JSONObject();
                    try {
                        json.put("success", false);
                        JSONObject messages = new JSONObject();
                        for (Map.Entry<String, List<String>> entry : vr.getFailureMessages().entrySet()) {
                            String key = entry.getKey();
                            JSONArray errors = new JSONArray();
                            for (String message : entry.getValue()) {
                                errors.put(message);
                            }
View Full Code Here

Examples of org.candlepin.policy.ValidationResult

    public List<PoolQuantity> getBestPoolsForHost(Consumer guest,
        Consumer host, Date entitleDate, Owner owner,
        String serviceLevelOverride, Collection<String> fromPools)
        throws EntitlementRefusedException {

        ValidationResult failedResult = null;

        Date activePoolDate = entitleDate;
        if (entitleDate == null) {
            activePoolDate = new Date();
        }
        PoolFilterBuilder poolFilter = new PoolFilterBuilder();
        poolFilter.addIdFilters(fromPools);
        List<Pool> allOwnerPools = this.listAvailableEntitlementPools(
            host, null, owner, (String) null, activePoolDate, true, false,
            poolFilter, null).getPageData();
        List<Pool> allOwnerPoolsForGuest = this.listAvailableEntitlementPools(
            guest, null, owner, (String) null, activePoolDate,
            true, false, poolFilter,
            null).getPageData();
        for (Entitlement ent : host.getEntitlements()) {
            //filter out pools that are attached, there is no need to
            //complete partial stacks, as they are already granting
            //virtual pools
            allOwnerPools.remove(ent.getPool());
        }
        List<Pool> filteredPools = new LinkedList<Pool>();

        ComplianceStatus guestCompliance = complianceRules.getStatus(guest, entitleDate, false);
        Set<String> tmpSet = new HashSet<String>();
        //we only want to heal red products, not yellow
        tmpSet.addAll(guestCompliance.getNonCompliantProducts());

        /*Do not attempt to create subscriptions for products that
          already have virt_only pools available to the guest */
        Set<String> productsToRemove = new HashSet<String>();
        for (Pool pool : allOwnerPoolsForGuest) {
            if (pool.hasProductAttribute("virt_only") || pool.hasAttribute("virt_only")) {
                for (String prodId : tmpSet) {
                    if (pool.provides(prodId)) {
                        productsToRemove.add(prodId);
                    }
                }
            }
        }
        tmpSet.removeAll(productsToRemove);
        String[] productIds = tmpSet.toArray(new String [] {});

        if (log.isDebugEnabled()) {
            log.debug("Attempting for products on date: " + entitleDate);
            for (String productId : productIds) {
                log.debug("  " + productId);
            }
        }

        for (Pool pool : allOwnerPools) {
            boolean providesProduct = false;
            // Would parse the int here, but it can be 'unlimited'
            // and we only need to check that it's non-zero
            if (pool.hasProductAttribute("virt_limit") &&
                    !pool.getProductAttribute("virt_limit").getValue().equals("0")) {
                for (String productId : productIds) {
                    // If this is a derived pool, we need to see if the derived product
                    // provides anything for the guest, otherwise we use the parent.
                    if (pool.providesDerived(productId)) {
                        providesProduct = true;
                        break;
                    }
                }
            }
            if (providesProduct) {
                ValidationResult result = enforcer.preEntitlement(host,
                    pool, 1, CallerType.BEST_POOLS);

                if (result.hasErrors() || result.hasWarnings()) {
                    // Just keep the last one around, if we need it
                    failedResult = result;
                    if (log.isDebugEnabled()) {
                        log.debug("Pool filtered from candidates due to rules " +
                            "failure: " +
View Full Code Here

Examples of org.codehaus.enunciate.contract.validation.ValidationResult

  protected GenericTypeDefinition(ClassDeclaration delegate) {
    super(delegate);
  }

  public ValidationResult accept(BaseValidator validator) {
    return new ValidationResult();
  }
View Full Code Here

Examples of org.codehaus.spice.configkit.ValidationResult

                throw new IllegalStateException( message );
            }

            final ConfigValidator validator =
                ConfigValidatorFactory.create( inputSource, c_resolver );
            final ValidationResult result = validator.validate( input,
                                                                (ContentHandler)handler );
            processValidationResults( result, logger );
        }
        return handler.getConfiguration();
    }
View Full Code Here

Examples of org.dcm4che3.data.ValidationResult

        DicomInputStream dis = null;
        try {
            System.out.print("Validate: " + file + " ... ");
            dis = new DicomInputStream(file);
            Attributes attrs = dis.readDataset(-1, -1);
            ValidationResult result = attrs.validate(iod);
            if (result.isValid())
                System.out.println("OK");
            else {
                System.out.println("FAILED:");
                System.out.println(result.asText(attrs));
            }
        } catch (IOException e) {
            System.out.println("FAILED: " + e.getMessage());
        } finally {
            SafeClose.close(dis);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.