You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by st...@apache.org on 2014/06/04 15:54:15 UTC

svn commit: r1600214 - /sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/actions/JcrNewNodeAction.java

Author: stefanegli
Date: Wed Jun  4 13:54:14 2014
New Revision: 1600214

URL: http://svn.apache.org/r1600214
Log:
GRANITE-6293 : fixed a NPE when server is not started

Modified:
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/actions/JcrNewNodeAction.java

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/actions/JcrNewNodeAction.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/actions/JcrNewNodeAction.java?rev=1600214&r1=1600213&r2=1600214&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/actions/JcrNewNodeAction.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/actions/JcrNewNodeAction.java Wed Jun  4 13:54:14 2014
@@ -16,6 +16,8 @@
  */
 package org.apache.sling.ide.eclipse.ui.actions;
 
+import javax.jcr.nodetype.NodeType;
+
 import org.apache.sling.ide.eclipse.core.ServerUtil;
 import org.apache.sling.ide.eclipse.ui.internal.Activator;
 import org.apache.sling.ide.eclipse.ui.nav.model.JcrNode;
@@ -50,10 +52,6 @@ public class JcrNewNodeAction implements
             MessageDialog.openInformation(shell, "Cannot create node", "Node not in filter.xml");
             return;
         }
-        if (node.getNodeType().getName().equals("nt:file")) {
-            MessageDialog.openInformation(shell, "Cannot create node", "Node of type nt:file cannot have children");
-            return;
-        }
         Repository repository = ServerUtil.getDefaultRepository(node.getProject());
         if (repository == null) {
             MessageDialog.openWarning(null, "Unable to create a new node", "Unable to create a new node since project "
@@ -61,6 +59,11 @@ public class JcrNewNodeAction implements
             return;
         }
         NodeTypeRegistry ntManager = repository.getNodeTypeRegistry();
+        final NodeType nodeType = node.getNodeType();
+        if (nodeType!=null && nodeType.getName()!=null && nodeType.getName().equals("nt:file")) {
+            MessageDialog.openInformation(shell, "Cannot create node", "Node of type nt:file cannot have children");
+            return;
+        }
         
         try {
             final NewNodeDialog nnd = new NewNodeDialog(shell, node, ntManager);