jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nandana Mihindukulasooriya" <nandana....@gmail.com>
Subject Re: How to start thinking in JCR
Date Sun, 08 Apr 2007 07:35:16 GMT
Hi,
   Thank you very much Brian and Jukka for the comments. This is the code I
used earlier (without error handling),

Workspace workSpace = session.getWorkspace();
String CNDFile = "…";
FileReader fileReader = *new* FileReader(cndFileName);
CompactNodeTypeDefReader cndReader =
*new*CompactNodeTypeDefReader(fileReader, cndFileName);
List ntdList = cndReader.getNodeTypeDefs();
NodeTypeManagerImpl  ntmgr = (NodeTypeManagerImpl)ws.getNodeTypeManager()
NodeTypeRegistry ntreg = ntmgr.getNodeTypeRegistry();
NodeTypeDef ntd = (NodeTypeDef)ntdList.next()
ntreg.registerNodeType(ntd);

But now I'm using Jackrabbit 1.2.3 , with JSR - 349, I can simply use

file = *new* File("CNDFile");
FileInputStream inputStream = *new* FileInputStream(file);
Workspace workSpace = session.getWorkspace();
NodeTypeManagerImpl ntTypeMgr = (NodeTypeManagerImpl) workSpace
.getNodeTypeManager();
ntTypeMgr.registerNodeTypes(inputStream,JackrabbitNodeTypeManager.*
TEXT_X_JCR_CND*,*false*);


But when I tried to use it with the registerExisting flag true, it gave me
an exception at line,

*return* (NodeType[]) nodeTypes.toArray(*new* NodeTypeDef[nodeTypes.size
()]);

Exception in thread "main" *java.lang.ArrayStoreException*
    at java.lang.System.arraycopy(*Native Method*)
    at java.util.ArrayList.toArray(*ArrayList.java:304*)
    at
org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl.registerNodeTypes(*
NodeTypeManagerImpl.java:295*)
    at nandana.jackrabbit.example1.NodeStructuteNew.main(*
NodeStructuteNew.java:34*)


I was able to fix type conflict by changing that line to

*return* (NodeType[]) nodeTypes.toArray(*new* NodeType[nodeTypes.size()])

I will go through content structure again and do the modifications. Thanks.

BR,
Nandana

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message