Package org.apache.sling.validation.api

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


    private ThreadPoolManager tpm = null;

    // ValidationService ###################################################################################################################
    @Override
    public ValidationModel getValidationModel(String validatedResourceType, String resourcePath) {
        ValidationModel model = null;
        Trie<JCRValidationModel> modelsForResourceType = validationModelsCache.get(validatedResourceType);
        if (modelsForResourceType != null) {
            model = modelsForResourceType.getElementForLongestMatchingKey(resourcePath).getValue();
        }
        if (model == null) {
View Full Code Here


                        new String[]{"/apps/validation/1",
                        "/apps/validation/2"}, properties);
            }

            // BEST MATCHING PATH = /apps/validation/1; assume the applicable paths contain /apps/validation/2
            ValidationModel vm = validationService.getValidationModel("sling/validation/test", "/apps/validation/1/resource");
            assertTrue(arrayContainsString(vm.getApplicablePaths(), "/apps/validation/2"));

            // BEST MATCHING PATH = /apps/validation; assume the applicable paths contain /apps/validation but not /apps/validation/1
            vm = validationService.getValidationModel("sling/validation/test", "/apps/validation/resource");
            assertTrue(arrayContainsString(vm.getApplicablePaths(), "/apps/validation"));
            assertTrue(!arrayContainsString(vm.getApplicablePaths(), "/apps/validation/1"));
            if (model1 != null) {
                rr.delete(model1);
            }
            if (model2 != null) {
                rr.delete(model2);
View Full Code Here

                model3 = createValidationModelResource(rr, libsValidatorsRoot.getPath(), "testValidationModel2", "sling/validation/test",
                        new String[]{"/apps/validation/3"}, fields);
            }

            // BEST MATCHING PATH = /apps/validation/1; assume the applicable paths contain /apps/validation/2
            ValidationModel vm = validationService.getValidationModel("sling/validation/test", "/apps/validation/1/resource");
            assertTrue(arrayContainsString(vm.getApplicablePaths(), "/apps/validation/2"));

            vm = validationService.getValidationModel("sling/validation/test", "/apps/validation/3/resource");
            assertTrue(arrayContainsString(vm.getApplicablePaths(), "/apps/validation/3"));

            if (model1 != null) {
                rr.delete(model1);
            }
            if (model2 != null) {
View Full Code Here

        try {
            if (rr != null) {
                model1 = createValidationModelResource(rr, libsValidatorsRoot.getPath(), "testValidationModel1", "sling/validation/test",
                        new String[]{"/apps/validation"}, properties);
            }
            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);
View Full Code Here

        try {
            if (rr != null) {
                model1 = createValidationModelResource(rr, libsValidatorsRoot.getPath(), "testValidationModel1", "sling/validation/test",
                        new String[]{"/apps/validation"}, fields);
            }
            ValidationModel vm = validationService.getValidationModel("sling/validation/test", "/apps/validation/1/resource");
            HashMap<String, Object> hashMap = new HashMap<String, Object>() {{
                put("field1", "HelloWorld");
                put("field2", "HelloWorld");
            }};
            ValueMap map = new ValueMapDecorator(hashMap);
View Full Code Here

                Resource resourceGrandChild = rr.create(resourceChild, "grandChild1", new HashMap<String, Object>(){{
                    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) {
View Full Code Here

            if (resourceTypeValues != null && resourceTypeValues.length > 0) {
                resourceType = resourceTypeValues[0];
            }
            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

        return errors;
    }

    @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

        if (resourceTypeValues != null && resourceTypeValues.length > 0) {
            resourceType = resourceTypeValues[0];
        }
        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(" ");
View Full Code Here

TOP

Related Classes of org.apache.sling.validation.api.ValidationModel

Copyright © 2018 www.massapicom. 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.