title: JCR new Nodetype with custom Properties
body: <p>I am using this code to write files in my Modeshape JCR repository.</p>
  
  <pre><code>Session session = //some session
  Node folderNode = session.getRootNode();
  
  //init some calendar and a file from fileSystem
  Calendar lastModified = Calendar.getInstance();
  File myFile = new File("c://temp//pic.jpg");    
  
  //create nt:file node
  Node fileNode = folderNode.addNode(myFile.getName(), "nt:file");
  
  // create the mandatory child node - jcr:content
  Node resNode = fileNode.addNode("jcr:content", "nt:resource");
  resNode.setProperty("jcr:mimeType", "");
  resNode.setProperty("jcr:encoding", "");
  resNode.setProperty("jcr:lastModified", lastModified);
  
  // add some binary data                    
  InputStream stream = new BufferedInputStream(new FileInputStream(myFile));
  Binary binary = session.getValueFactory().createBinary(stream);
  lastModified.setTimeInMillis(myFile.lastModified());
  resNode.setProperty("jcr:data", binary);
  </code></pre>
  
  <p>I want to add some custom Property like this</p>
  
  <pre><code>resNode.setProperty("myCustomProperty", "some value", PropertyType.STRING)
  </code></pre>
  
  <p>But as described in all documentation, i get an <code>ConstraintViolationException</code> because of trying to add a custom property to native JCR nodeType.</p>
  
  <p>I have tried to generate a new NodeType which heritates from Native <code>nt:resource</code>, and then extending it with my custom property:</p>
  
  <pre><code>Session session = //some session
  Workspace workspace = session.getWorkspace();
  NodeTypeManager nodeTypeManager = workspace.getNodeTypeManager();
  NodeTypeTemplate ndt = nodeTypeManager.createNodeTypeTemplate();
  
  //i define my new custom propertie under the new nodeType
  PropertyDefinitionTemplate createPropertyDefinitionTemplate = nodeTypeManager.createPropertyDefinitionTemplate();
  createPropertyDefinitionTemplate.setName("myCustomProperty");
  createPropertyDefinitionTemplate.setRequiredType(PropertyType.STRING);
  ndt.getPropertyDefinitionTemplates().add(createPropertyDefinitionTemplate);
  
  String myNodeTypeName = "newCustimNodeType";
  ndt.setName(myNodeTypeName);
  //heritates from nt:resource
  String[] str = {"nt:resource"};
  ndt.setDeclaredSuperTypeNames(str);
  nodeTypeManager.registerNodeType(ndt, true);
  session.save();
  </code></pre>
  
  <p>Doing this we avoid <code>ConstraintViolationException</code> but now we get an <code>RepositoryException</code> because JCR is not able to save in fileSystem my new type of node with message:</p>
  
  <p>"Valid primary types are nt:file, nt:folder, nt:resource, and dna:resouce"</p>
  
  <p>So I guess I am not succesfully heritating new newNode from superClass <code>nt:resource</code>.</p>
  
  <p>Is this the proper approach to add custom properties to a node?
  Is this the proper way of defining a new nodeType heritating from a jcr native one?</p>