hi bob
On 10/9/07, BobHitchins <[EMAIL PROTECTED]> wrote:
>
> Hi All - Need some help plz (JCR newbie)
>
> I have the following CND file (exerpt from ConopsJCR.cnd) that works just
> fine:
> <?xml version "1.0" encoding="UTF-8"?>
> <nodeTypes
> xmlns:fn.......
> xmlns:jcr.........
> xmlns:nt.........
> xmlns:sv........
> xmlns:xs.........
> xmlns:xml........
> <nodeType
> hasOrderableChildNodes="false"
> isMixin="true"
> name="nt:PermissionTemplate"
> primaryItemName="nt:templateName">
> <supertypes>
> <supertype>mix:versionable</supertype>
> </supertypes?
> <propertyDefinition
> autoCreated="false"
> mandatory="true"
> multiple="false"
> name="nt:description"
> onParentVersion="VERSION"
> protected="false"
> requiredType="String"/>
> <propertyDefinition
> autoCreated="false"
> mandatory="true"
> multiple="false"
> name="nt:templateName"
> onParentVersion="VERSION"
> protected="false"
> requiredType="String"/>
> </nodeType>
> </nodeTypes>
>
> When I execute the following code (logging code removed), I always get a "no
> definition found in parent node's node type for new node" error in the log
> and a Constraint Violation exception. I've looked for some simple
> implementing code to show me what I should be doing, but haven't been able
> to find it. Please let me what I'm doing wrong :-)
you defined nt:PermissionTemplate as being a mixin type rather than a
primary type,
> isMixin="true"
that's the problem. if you change that to a primary type, your sample
should work.
cheers
stefan
>
> import javax.jcr.Node;
> import javax.jcr.Repository;
> import javax.jcr.Session;
> import javax.jcr.SimpleCredentials;
> import javax.jcr.Workspace;
>
> import org.apache.jackrabbit.core.TransientRepository;
>
> public class JCRTest {
> public static void main(String[] args) throws Exception {
> String user = "bob";
>
> SimpleCredentials myCredentials = new SimpleCredentials(user,
> user.toCharArray());
> Repository repository = new TransientRepository();
> Session session = repository.login(myCredentials);
>
> try {
> Workspace ws = session.getWorkspace();
> CustomNodeType.RegisterCustomNodeTypes(ws,
> "ConopsJCR.cnd");
> Node root = session.getRootNode();
> root.addNode("PermissionTemplate",
> "nt:PermissionTemplate");
> session.save();
> }
> finally {
> session.logout();
> }
> }
> }
>
> Thanks in advance!
> Bob
> --
> View this message in context:
> http://www.nabble.com/Can%27t-add-Nodes-to-CND-constrained-Repository-tf4596634.html#a13123797
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>