You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2009/07/05 14:19:32 UTC

svn commit: r791234 - /sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceListener.java

Author: cziegeler
Date: Sun Jul  5 12:19:31 2009
New Revision: 791234

URL: http://svn.apache.org/viewvc?rev=791234&view=rev
Log:
SLING-1034 - Fix NPE in jcr resource listener.

Modified:
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceListener.java

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceListener.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceListener.java?rev=791234&r1=791233&r2=791234&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceListener.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceListener.java Sun Jul  5 12:19:31 2009
@@ -134,9 +134,15 @@
             final Resource resource = this.resolver.getResource(path);
             if ( resource != null ) {
                 final Dictionary<String, String> properties = new Hashtable<String, String>();
-                properties.put(SlingConstants.PROPERTY_PATH, resource.getPath());
-                properties.put(SlingConstants.PROPERTY_RESOURCE_TYPE, resource.getResourceType());
-                properties.put(SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE, resource.getResourceSuperType());
+                properties.put(SlingConstants.PROPERTY_PATH, path);
+                final String resourceType = resource.getResourceType();
+                final String resourceSuperType = resource.getResourceSuperType();
+                if ( resourceType != null ) {
+                    properties.put(SlingConstants.PROPERTY_RESOURCE_TYPE, resource.getResourceType());
+                }
+                if ( resourceSuperType != null ) {
+                    properties.put(SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE, resource.getResourceSuperType());
+                }
 
                 localEA.postEvent(new org.osgi.service.event.Event(SlingConstants.TOPIC_RESOURCE_ADDED, properties));
             }
@@ -145,9 +151,15 @@
             final Resource resource = this.resolver.getResource(path);
             if ( resource != null ) {
                 final Dictionary<String, String> properties = new Hashtable<String, String>();
-                properties.put(SlingConstants.PROPERTY_PATH, resource.getPath());
-                properties.put(SlingConstants.PROPERTY_RESOURCE_TYPE, resource.getResourceType());
-                properties.put(SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE, resource.getResourceSuperType());
+                properties.put(SlingConstants.PROPERTY_PATH, path);
+                final String resourceType = resource.getResourceType();
+                final String resourceSuperType = resource.getResourceSuperType();
+                if ( resourceType != null ) {
+                    properties.put(SlingConstants.PROPERTY_RESOURCE_TYPE, resource.getResourceType());
+                }
+                if ( resourceSuperType != null ) {
+                    properties.put(SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE, resource.getResourceSuperType());
+                }
 
                 localEA.postEvent(new org.osgi.service.event.Event(SlingConstants.TOPIC_RESOURCE_CHANGED, properties));
             }