Return-Path: Delivered-To: apmail-sling-commits-archive@www.apache.org Received: (qmail 76353 invoked from network); 5 Jul 2009 12:19:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Jul 2009 12:19:44 -0000 Received: (qmail 54963 invoked by uid 500); 5 Jul 2009 12:19:54 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 54922 invoked by uid 500); 5 Jul 2009 12:19:54 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 54913 invoked by uid 99); 5 Jul 2009 12:19:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Jul 2009 12:19:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Jul 2009 12:19:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2CFC323888D9; Sun, 5 Jul 2009 12:19:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r791234 - /sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceListener.java Date: Sun, 05 Jul 2009 12:19:32 -0000 To: commits@sling.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090705121932.2CFC323888D9@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 properties = new Hashtable(); - 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 properties = new Hashtable(); - 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)); }