You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Martin Mayr <ma...@cosy.sbg.ac.at> on 2008/08/25 19:19:45 UTC

problem when adding custom node type

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

Re: problem when adding custom node type

Posted by Martin Mayr <ma...@cosy.sbg.ac.at>.
kk, i looked into the repository folder now to the custom node types and
there was a wrong definition of this new nodetype present from a former
tryout

deleted it and now it works fine
sry for the bothering
> oh, sry ... changed the whole thing for presenting here to locked (used
> isLocked first)
> but i checked it twice - it has the same names in my code (so only
> locked is used)
>
> Julian Reschke schrieb:
>   
>> Martin Mayr wrote:
>>     
>>> ...
>>>         cnd += "- isLocked (BOOLEAN) mandatory ignore\n";
>>> ...
>>> node.setProperty("locked", true);
>>> ...
>>> ...
>>> i get a ConstraintViolationException: no matching property definition
>>> found for {}locked
>>> ...
>>>       
>> "isLocked" or "locked"?
>>
>> BR, Julian
>>     


Re: problem when adding custom node type

Posted by Martin Mayr <ma...@cosy.sbg.ac.at>.
oh, sry ... changed the whole thing for presenting here to locked (used
isLocked first)
but i checked it twice - it has the same names in my code (so only
locked is used)

Julian Reschke schrieb:
> Martin Mayr wrote:
>> ...
>>         cnd += "- isLocked (BOOLEAN) mandatory ignore\n";
>> ...
>> node.setProperty("locked", true);
>> ...
>> ...
>> i get a ConstraintViolationException: no matching property definition
>> found for {}locked
>> ...
>
> "isLocked" or "locked"?
>
> BR, Julian


Re: problem when adding custom node type

Posted by Julian Reschke <ju...@gmx.de>.
Martin Mayr wrote:
> ...
>         cnd += "- isLocked (BOOLEAN) mandatory ignore\n";
> ...
> node.setProperty("locked", true);
> ...
> ...
> i get a ConstraintViolationException: no matching property definition
> found for {}locked
> ...

"isLocked" or "locked"?

BR, Julian