sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject svn commit: r1673435 - in /sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl: ./ util/
Date Tue, 14 Apr 2015 14:29:07 GMT
Author: kwin
Date: Tue Apr 14 14:29:07 2015
New Revision: 1673435

URL: http://svn.apache.org/r1673435
Log:
get rid of JCR in the name of classes, because they only depend on Sling API

Added:
    sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ResourceValidationModel.java
      - copied, changed from r1673430, sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/JCRValidationModel.java
    sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/util/ResourceValidationBuilder.java
      - copied, changed from r1673430, sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/util/JCRBuilder.java
Removed:
    sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/JCRValidationModel.java
    sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/util/JCRBuilder.java
Modified:
    sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ChildResourceImpl.java
    sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ValidationServiceImpl.java

Modified: sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ChildResourceImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ChildResourceImpl.java?rev=1673435&r1=1673434&r2=1673435&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ChildResourceImpl.java
(original)
+++ sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ChildResourceImpl.java
Tue Apr 14 14:29:07 2015
@@ -14,7 +14,7 @@ import org.apache.sling.commons.osgi.Pro
 import org.apache.sling.validation.api.ChildResource;
 import org.apache.sling.validation.api.ResourceProperty;
 import org.apache.sling.validation.api.Validator;
-import org.apache.sling.validation.impl.util.JCRBuilder;
+import org.apache.sling.validation.impl.util.ResourceValidationBuilder;
 
 /**
  * Implements a {@link ChildResource}
@@ -51,7 +51,7 @@ public class ChildResourceImpl implement
             namePattern = null;
         }
         isRequired = !PropertiesUtil.toBoolean(childrenProperties.get(Constants.OPTIONAL),
false);
-        properties = JCRBuilder.buildProperties(validatorsMap, childResource.getChild(Constants.PROPERTIES));
+        properties = ResourceValidationBuilder.buildProperties(validatorsMap, childResource.getChild(Constants.PROPERTIES));
         this.children = children;
     }
 

Copied: sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ResourceValidationModel.java
(from r1673430, sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/JCRValidationModel.java)
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ResourceValidationModel.java?p2=sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ResourceValidationModel.java&p1=sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/JCRValidationModel.java&r1=1673430&r2=1673435&rev=1673435&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/JCRValidationModel.java
(original)
+++ sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ResourceValidationModel.java
Tue Apr 14 14:29:07 2015
@@ -28,17 +28,22 @@ import org.apache.sling.validation.api.C
 import org.apache.sling.validation.api.ResourceProperty;
 import org.apache.sling.validation.api.ValidationModel;
 
-public class JCRValidationModel implements ValidationModel {
+/**
+ * 
+ * @author kwindszus
+ *
+ */
+public class ResourceValidationModel implements ValidationModel {
 
     private final @Nonnull Set<ResourceProperty> resourceProperties;
     private final @Nonnull String validatedResourceType;
     private final @Nonnull String[] applicablePaths;
-    private final String jcrPath;
+    private final String path;
     private final @Nonnull List<ChildResource> children;
 
-    public JCRValidationModel(String jcrPath, @Nonnull Set<ResourceProperty> resourceProperties,
@Nonnull String validatedResourceType,
+    public ResourceValidationModel(String path, @Nonnull Set<ResourceProperty> resourceProperties,
@Nonnull String validatedResourceType,
                               String[] applicablePaths, @Nonnull List<ChildResource>
children) {
-        this.jcrPath = jcrPath;
+        this.path = path;
         this.resourceProperties = resourceProperties;
         this.validatedResourceType = validatedResourceType;
         // if this property was not set
@@ -79,7 +84,7 @@ public class JCRValidationModel implemen
         return children;
     }
 
-    public String getJcrPath() {
-        return jcrPath;
+    public String getPath() {
+        return path;
     }
 }

Modified: sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ValidationServiceImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ValidationServiceImpl.java?rev=1673435&r1=1673434&r2=1673435&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ValidationServiceImpl.java
(original)
+++ sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/ValidationServiceImpl.java
Tue Apr 14 14:29:07 2015
@@ -55,7 +55,7 @@ import org.apache.sling.validation.api.V
 import org.apache.sling.validation.api.ValidationService;
 import org.apache.sling.validation.api.Validator;
 import org.apache.sling.validation.api.exceptions.SlingValidationException;
-import org.apache.sling.validation.impl.util.JCRBuilder;
+import org.apache.sling.validation.impl.util.ResourceValidationBuilder;
 import org.apache.sling.validation.impl.util.Trie;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.component.ComponentContext;
@@ -75,7 +75,7 @@ public class ValidationServiceImpl imple
     static final String[] TOPICS = {SlingConstants.TOPIC_RESOURCE_REMOVED, SlingConstants.TOPIC_RESOURCE_CHANGED,
             SlingConstants.TOPIC_RESOURCE_ADDED};
 
-    protected Map<String, Trie<JCRValidationModel>> validationModelsCache = new
ConcurrentHashMap<String, Trie<JCRValidationModel>>();
+    protected Map<String, Trie<ResourceValidationModel>> validationModelsCache
= new ConcurrentHashMap<String, Trie<ResourceValidationModel>>();
     private ThreadPool threadPool;
     private ServiceRegistration eventHandlerRegistration;
 
@@ -107,7 +107,7 @@ public class ValidationServiceImpl imple
         }
         validatedResourceType = getRelativeResourceType(validatedResourceType);
         ValidationModel model = null;
-        Trie<JCRValidationModel> modelsForResourceType = validationModelsCache.get(validatedResourceType);
+        Trie<ResourceValidationModel> modelsForResourceType = validationModelsCache.get(validatedResourceType);
         if (modelsForResourceType != null) {
             model = modelsForResourceType.getElementForLongestMatchingKey(resourcePath).getValue();
         }
@@ -372,10 +372,10 @@ public class ValidationServiceImpl imple
      * @param validatedResourceType the type of resource for which to scan the JCR repository
for validation models
      * @return a {@link Trie} with the validation models; an empty trie if no model is found
      */
-    private Trie<JCRValidationModel> searchAndStoreValidationModel(@Nonnull String
validatedResourceType) {
-        Trie<JCRValidationModel> modelsForResourceType = null;
+    private Trie<ResourceValidationModel> searchAndStoreValidationModel(@Nonnull String
validatedResourceType) {
+        Trie<ResourceValidationModel> modelsForResourceType = null;
         ResourceResolver rr = null;
-        JCRValidationModel vm;
+        ResourceValidationModel vm;
         if (StringUtils.isBlank(validatedResourceType)) {
             throw new IllegalArgumentException("validatedResourceType cannot be null or blank!");
         }
@@ -395,12 +395,12 @@ public class ValidationServiceImpl imple
                         String[] applicablePaths = PropertiesUtil.toStringArray(validationModelProperties.get(Constants.APPLICABLE_PATHS,
                                 String[].class));
                         Resource r = model.getChild(Constants.PROPERTIES);
-                        Set<ResourceProperty> resourceProperties = JCRBuilder.buildProperties(validators,
r);
-                        List<ChildResource> children = JCRBuilder.buildChildren(model,
model, validators);
+                        Set<ResourceProperty> resourceProperties = ResourceValidationBuilder.buildProperties(validators,
r);
+                        List<ChildResource> children = ResourceValidationBuilder.buildChildren(model,
model, validators);
                         if (resourceProperties.isEmpty() && children.isEmpty()) {
                             throw new IllegalArgumentException("Neither children nor properties
set.");
                         } else {
-                            vm = new JCRValidationModel(jcrPath, resourceProperties, validatedResourceType,
applicablePaths, children);
+                            vm = new ResourceValidationModel(jcrPath, resourceProperties,
validatedResourceType, applicablePaths, children);
                             modelsForResourceType = validationModelsCache.get(validatedResourceType);
                             /**
                              * if the modelsForResourceType is null the canAcceptModel will
return true: performance
@@ -409,7 +409,7 @@ public class ValidationServiceImpl imple
 
                             if (canAcceptModel(vm, searchPath, searchPaths, modelsForResourceType))
{
                                 if (modelsForResourceType == null) {
-                                    modelsForResourceType = new Trie<JCRValidationModel>();
+                                    modelsForResourceType = new Trie<ResourceValidationModel>();
                                     validationModelsCache.put(validatedResourceType, modelsForResourceType);
                                 }
                                 for (String applicablePath : vm.getApplicablePaths()) {
@@ -442,17 +442,17 @@ public class ValidationServiceImpl imple
      * @param validationModels  the existing validation models
      * @return {@code true} if the new model can be stored, {@code false} otherwise
      */
-    private boolean canAcceptModel(JCRValidationModel validationModel, String currentSearchPath,
String[] searchPaths,
-                                   Trie<JCRValidationModel> validationModels) {
+    private boolean canAcceptModel(ResourceValidationModel validationModel, String currentSearchPath,
String[] searchPaths,
+                                   Trie<ResourceValidationModel> validationModels)
{
         // perform null check to optimise performance in callee - no need to previously create
the Trie if we're not going to accept the model
         if (validationModels != null) {
-            String relativeModelPath = validationModel.getJcrPath().replaceFirst(currentSearchPath,
"");
+            String relativeModelPath = validationModel.getPath().replaceFirst(currentSearchPath,
"");
             for (String searchPath : searchPaths) {
                 if (!currentSearchPath.equals(searchPath)) {
                     for (String applicablePath : validationModel.getApplicablePaths()) {
-                        JCRValidationModel existingVM = validationModels.getElement(applicablePath).getValue();
+                        ResourceValidationModel existingVM = validationModels.getElement(applicablePath).getValue();
                         if (existingVM != null) {
-                            String existingModelRelativeModelPath = existingVM.getJcrPath().replaceFirst(searchPath,
"");
+                            String existingModelRelativeModelPath = existingVM.getPath().replaceFirst(searchPath,
"");
                             if (existingModelRelativeModelPath.equals(relativeModelPath))
{
                                 return false;
                             }

Copied: sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/util/ResourceValidationBuilder.java
(from r1673430, sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/util/JCRBuilder.java)
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/util/ResourceValidationBuilder.java?p2=sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/util/ResourceValidationBuilder.java&p1=sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/util/JCRBuilder.java&r1=1673430&r2=1673435&rev=1673435&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/util/JCRBuilder.java
(original)
+++ sling/trunk/bundles/extensions/validation/core/src/main/java/org/apache/sling/validation/impl/util/ResourceValidationBuilder.java
Tue Apr 14 14:29:07 2015
@@ -42,9 +42,9 @@ import org.apache.sling.validation.impl.
 import org.apache.sling.validation.impl.ResourcePropertyImpl;
 
 /**
- * Helps building validation related objects from JCR content trees.
+ * Helps building validation related objects from Sling resources.
  */
-public class JCRBuilder {
+public class ResourceValidationBuilder {
 
     /**
      * Creates a set of the properties that a resource is expected to have, together with
the associated validators.



Mime
View raw message