jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Mayr <mam...@cosy.sbg.ac.at>
Subject problem when adding custom node type
Date Mon, 25 Aug 2008 17:19:45 GMT
hello everyone,

i want to extend the nodetype nt:file so i can save 2 more properties
with it
i'm working with jackrabbit 1.4

my code to get the session object looks like this:

  private Session getConectionToWorkspace(String workspaceName) throws
Exception
  {
    Session session = null;
    try
    {
      Repository repository = new URLRemoteRepository(sURL_TO_REPOSITORY);
      session = repository.login(loginData, workspaceName);
     
      Workspace wsp = session.getWorkspace();
      JackrabbitNodeTypeManager ntMgr = (JackrabbitNodeTypeManager)
wsp.getNodeTypeManager();

      // Register nodetypes
      if (!ntMgr.hasNodeType("ns:file"))
      {
        String cnd = "<ns = 'http://www.mycompany.com/jrc'>\n";
        cnd += "[ns:file] > nt:file\n";
        cnd += "- isLocked (BOOLEAN) mandatory ignore\n";
        cnd += "- layout (STRING) mandatory";
        byte cndArray[] = cnd.getBytes();
        ByteArrayInputStream byteArrayInputStream = new
ByteArrayInputStream(cndArray);

        ntMgr.registerNodeTypes(byteArrayInputStream,
JackrabbitNodeTypeManager.TEXT_X_JCR_CND);
        session.save();
      }
      return session;
    }
  ...
  }

so i want to add locked and layout properties, but everyhing else should
stay the same as a nt:file

i can create this new node
...
node = node.addNode("name", "ns:file");
node.addMixin("mix:versionable");
...
so i guess the nodetype adding works ... but when i now want to add such
a property
...
node.setProperty("locked", true);
node.setProperty("layout", "layout");
...
i get a ConstraintViolationException: no matching property definition
found for {}locked

---
so i guess i must do something wrong
i want to inherit from nt:file, because i also use a childnode
jcr:content and i store documents there
i need the layout for the name of the layout file (for pdf print later)
and locked for internal locked status of this document, so that it can't
be changed anymore
also i need the versioning


i hope anyone can help me
thanks in advance!
martin

Mime
View raw message