jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Guggisberg <stefan.guggisb...@gmail.com>
Subject Re: NodeType creation
Date Mon, 08 Mar 2010 16:39:38 GMT
On Mon, Mar 8, 2010 at 5:10 PM, Michael Dürig <michael.duerig@day.com> wrote:
> Sorry for popping in. JCR-2003 indicates that you access the repository via
> some kind of remoting (most likely DavEx) and that a method is involved
> which is not (yet) implemented in one of the involved remoting layers. See
> https://issues.apache.org/jira/browse/JCR-2003.

yes, you're right. i was under the assumption that JCR 2.0 is fully implemented
in jackrabbit 2.0.

but there's obviously still one related open issue with the spi2dav
remoting layer:
https://issues.apache.org/jira/browse/JCR-2454

cheers
stefan

>
> Michael
>
> On 3/8/10 4:59 PM, Birmingham, Steven wrote:
>>
>> Thanks again,  It compiles and runs now but I get the same result as when
>> I tried the cndImporter; java.lang.UnsupportedOperationException: JCR-2003.
>> Implementation missing.  I am still running the standalone jar and will
>> switch over to the war file when I get time and see if all is better.
>>
>> Steve
>>
>> -----Original Message-----
>> From: Stefan Guggisberg [mailto:stefan.guggisberg@gmail.com]
>> Sent: Monday, March 08, 2010 3:06 AM
>> To: users@jackrabbit.apache.org
>> Subject: Re: NodeType creation
>>
>> On Fri, Mar 5, 2010 at 9:20 PM, Birmingham, Steven
>> <Steven.Birmingham@itt.com>  wrote:
>>>
>>> Thanks Stefan,
>>>
>>> Yeah, I just looked through the message archives and saw the CndImporter
>>> example and gave it a try.  I tried using the CompactNodeTypeDefReader as
>>> you suggested.  It worked as far reading the cnd file, but the
>>> NodeTypeManager.registerNodeTypes() is expecting an array of
>>> NodeTypeDefinition not QNodeTypeDefinition[].  I saw a method to create
>>> QNodeTypeDefinitions out of NodeTypeDefinitions but have not found a way to
>>> do vice versa.
>>
>> sorry, i didn't notice it.
>>
>> o.a.jackrabbit.spi.commons.nodetyp.NodeTypeDefinitionFactory should do
>> the trick.
>>
>> http://jackrabbit.apache.org/api/2.0/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.html
>>
>> here's a sample i put together and which should help get you started:
>>
>>
>>
>> ////////////////////////////////////////////////////////////////////////////////
>> import org.apache.jackrabbit.commons.NamespaceHelper;
>> import org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader;
>> import org.apache.jackrabbit.commons.cnd.ParseException;
>> import org.apache.jackrabbit.spi.QNodeTypeDefinition;
>> import org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping;
>> import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
>> import
>> org.apache.jackrabbit.spi.commons.namespace.SessionNamespaceResolver;
>> import
>> org.apache.jackrabbit.spi.commons.nodetype.NodeTypeDefinitionFactory;
>> import
>> org.apache.jackrabbit.spi.commons.nodetype.QDefinitionBuilderFactory;
>>
>> import javax.jcr.RepositoryException;
>> import javax.jcr.Session;
>> import javax.jcr.nodetype.NodeTypeDefinition;
>> import javax.jcr.nodetype.NodeTypeIterator;
>> import java.io.IOException;
>> import java.io.InputStream;
>> import java.io.InputStreamReader;
>> import java.util.ArrayList;
>> import java.util.HashMap;
>> import java.util.List;
>> import java.util.Map;
>>
>> public class NodeTypeImporter {
>>
>>     public static NodeTypeIterator registerNodeTypesFromCND(Session
>> session,
>>                                                      
      InputStream
>> in,
>>                                                      
      boolean
>> allowUpdate)
>>             throws IOException, RepositoryException {
>>         Map<String, String>  namespaceMap = new HashMap<String, String>();
>>         List<QNodeTypeDefinition>  qNTDefs = new
>> ArrayList<QNodeTypeDefinition>();
>>         NamespaceResolver nsResolver = new
>> SessionNamespaceResolver(session);
>>         try {
>>             NamespaceMapping mapping = new NamespaceMapping(nsResolver);
>>
>>             CompactNodeTypeDefReader<QNodeTypeDefinition,
>> NamespaceMapping>  reader =
>>                 new CompactNodeTypeDefReader<QNodeTypeDefinition,
>> NamespaceMapping>(
>>                     new InputStreamReader(in), "cnd input stream",
>> mapping,
>>                     new QDefinitionBuilderFactory());
>>
>>             namespaceMap.putAll(mapping.getPrefixToURIMapping());
>>             for (QNodeTypeDefinition ntDef:
>> reader.getNodeTypeDefinitions()) {
>>                 qNTDefs.add(ntDef);
>>             }
>>         } catch (ParseException e) {
>>             IOException e2 = new IOException(e.getMessage());
>>             e2.initCause(e);
>>             throw e2;
>>         }
>>
>>         new NamespaceHelper(session).registerNamespaces(namespaceMap);
>>         List<NodeTypeDefinition>  ntDefs =
>>                 new NodeTypeDefinitionFactory(session).create(qNTDefs) ;
>>         return
>> session.getWorkspace().getNodeTypeManager().registerNodeTypes(
>>                 ntDefs.toArray(new NodeTypeDefinition[ntDefs.size()]),
>> allowUpdate);
>>     }
>> }
>>
>> ////////////////////////////////////////////////////////////////////////////////
>>
>>
>> cheers
>> stefan
>>
>>>
>>> Steve
>>>
>>> -----Original Message-----
>>> From: Stefan Guggisberg [mailto:stefan.guggisberg@gmail.com]
>>> Sent: Friday, March 05, 2010 2:39 AM
>>> To: users@jackrabbit.apache.org
>>> Subject: Re: NodeType creation
>>>
>>> On Thu, Mar 4, 2010 at 5:33 PM, Birmingham, Steven
>>> <Steven.Birmingham@itt.com>  wrote:
>>>>
>>>> Thanks for the input Stefan.  I looked up your suggestion and tried
>>>> using CndImporter
>>>
>>> erm, i don't think that i suggested using CndImporter...
>>>
>>> i suggested using CompactNodeTypeDefReader to generate
>>> NodeTypeDefinitions from your
>>> cnd-style definitions. those NodeTypeDefinition objects can then be
>>> passed on to the
>>> JCR 2.0 method NodeTypeManager.registerNodeTypes() which should be
>>> available
>>> on jcr-rmi and jcr2spi clients.
>>>
>>> you can find some code here, starting at line 232:
>>>
>>>
>>> http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeManagerImpl.java?revision=816551&view=markup
>>>
>>> cheers
>>> stefan
>>>
>>>> which threw the exception JCR-2003. Implementation missing.  So, are you
>>>> saying the implementation is missing from the StandAlone server but would
be
>>>> available from the embedded war file?
>>>>
>>>>                InputStream is =
>>>> getClass().getClassLoader().getResourceAsStream("test.cnd");
>>>>                Reader cnd = new InputStreamReader(is);
>>>>                NodeType[] nodeTypes = CndImporter.registerNodeTypes(cnd,
>>>> session);
>>>>
>>>> Steve
>>>>
>>>> -----Original Message-----
>>>> From: Stefan Guggisberg [mailto:stefan.guggisberg@gmail.com]
>>>> Sent: Thursday, March 04, 2010 3:46 AM
>>>> To: users@jackrabbit.apache.org
>>>> Subject: Re: NodeType creation
>>>>
>>>> On Thu, Mar 4, 2010 at 12:43 AM, Birmingham, Steven
>>>> <Steven.Birmingham@itt.com>  wrote:
>>>>>
>>>>> I built and added jackrabbit-core-2.0.0.jar to the build path, but
>>>>> JackRabbitNodeTypeManager is still unresolved.  Yes, I was trying to
do an
>>>>> evaluation on the standalone server.  So, are you saying NodeType management
>>>>> in 2.0 is not available in the standalone server?
>>>>
>>>> no, that's not what i am saying ;)
>>>>
>>>> i said that the method for registering node types defined in a CND or
>>>> XML format
>>>> might not be available on a remote client (such as jcr-rmi or jcr2spi).
>>>>
>>>> said method is specified in the jackrabbit-api, which is an extension
>>>> to the jcr api.
>>>> the jcr 2.0 api does not provide a method for registering node types
>>>> declared in CND
>>>> or XML format. it only allows to build and register node type
>>>> definitions programmatically, see e.g.
>>>>
>>>>
>>>> http://www.day.com/maven/javax.jcr/javadocs/jcr-2.0/javax/jcr/nodetype/NodeTypeManager.html#registerNodeTypes(javax.jcr.nodetype.NodeTypeDefinition[],%20boolean)
>>>>
>>>> you can use CompactNodeTypeDefReader (jcr-commons) to bridge the gap.
>>>> CompactNodeTypeDefReader allows you to parse a CND file returning
>>>> NodeTypeDefinitions
>>>> which can be registered using the jcr 2.0 api.
>>>>
>>>> cheers
>>>> stefan
>>>>
>>>>>
>>>>> I will download the 2.0 war file and see if things work differently on
>>>>> Tomcat.  I am a little confused as there is documentation on the 2.0
website
>>>>> for NodeType management but I guess it is incomplete?
>>>>>
>>>>> Thanks for your help,
>>>>> Steve
>>>>>
>>>>> -----Original Message-----
>>>>> From: Stefan Guggisberg [mailto:stefan.guggisberg@gmail.com]
>>>>> Sent: Wednesday, March 03, 2010 1:30 PM
>>>>> To: users@jackrabbit.apache.org
>>>>> Subject: Re: NodeType creation
>>>>>
>>>>>
>>>>>
>>>>> On 03.03.2010, at 19:01, "Birmingham, Steven"
>>>>> <Steven.Birmingham@itt.com>  wrote:
>>>>>
>>>>>> Thanks for the response.
>>>>>>
>>>>>> JackrabbitNodeTypeManager is not on the class path either.  I have
>>>>>> all the 2.0 jars on the class path.
>>>>>> For jackrabbitNodeTypeManagerImpl I get three implementations on
the
>>>>>> classpath:
>>>>>> //import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeManagerImpl;
>>>>>> //import
>>>>>>
>>>>>> org.apache.jackrabbit.ocm.nodemanagement.impl.jackrabbit.NodeTypeManagerImpl;
>>>>>> import
>>>>>>
>>>>>> org.apache.jackrabbit.ocm.nodemanagement.impl.jeceira.NodeTypeManagerImpl;
>>>>>>
>>>>>> Does NodeType registration work for you in 2.0?
>>>>>>
>>>>> yes
>>>>>
>>>>> JackrabbitNodeTypeManager is included in jackrabbit-core, which is
>>>>> missing from your dependencies list.
>>>>>
>>>>> are you accessing a stand-alone jackrabbit server? if yes, you might
>>>>> be out of luck since the said method is only available on a local,
>>>>> i.e. embedded instance.
>>>>>
>>>>> cheers
>>>>> stefan
>>>>>
>>>>>> Here are my dependencies.
>>>>>>
>>>>>>    <dependency org="org/apache" name="log4j" rev="1.2+"
>>>>>> conf="compile"/>
>>>>>>    <dependency org="javax.jcr" name="jcr" rev="2.0" conf="compile"/>
>>>>>>    <dependency org="org/apache/jackrabbit" name="jackrabbit-jcr-
>>>>>> commons" rev="2.0.0" conf="compile"/>
>>>>>>    <dependency org="org/apache/jackrabbit" name="jackrabbit-jcr2dav"
>>>>>> rev="2.0.0" conf="compile"/>
>>>>>>    <dependency org="org/apache/jackrabbit" name="jackrabbit-jcr2spi"
>>>>>> rev="2.0.0" conf="compile"/>
>>>>>>    <dependency org="org/apache/jackrabbit" name="jackrabbit-spi"
>>>>>> rev="2.0.0" conf="compile"/>
>>>>>>    <dependency org="org/apache/jackrabbit" name="jackrabbit-spi2dav"
>>>>>> rev="2.0.0" conf="compile"/>
>>>>>>    <dependency org="org/apache/jackrabbit" name="jackrabbit-spi-
>>>>>> commons" rev="2.0.0" conf="compile"/>
>>>>>>    <dependency org="org/apache/jackrabbit" name="jackrabbit-webdav"
>>>>>> rev="2.0.0" conf="compile"/>
>>>>>>    <dependency org="org/apache/jackrabbit" name="jackrabbit-jcr-
>>>>>> server" rev="2.0.0" conf="compile"/>
>>>>>>    <dependency org="org/apache" name="commons-httpclient"
>>>>>> rev="3.0.1" conf="compile"/>
>>>>>>    <dependency org="org/apache" name="commons-codec" rev="1.3"
>>>>>> conf="compile"/>
>>>>>>    <dependency org="org/apache" name="commons-logging" rev="1.1.1"
>>>>>> conf="compile"/>
>>>>>>    <dependency org="org/apache" name="commons-collections" rev="3.2"
>>>>>> conf="compile"/>
>>>>>>    <dependency org="org/slf4j" name="slf4j-api" rev="1.5.2"
>>>>>> conf="compile"/>
>>>>>>    <dependency org="org/slf4j" name="slf4j-log4j12" rev="1.5.2"
>>>>>> conf="compile"/>
>>>>>>
>>>>>> Steve
>>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Stefan Guggisberg [mailto:stefan.guggisberg@gmail.com]
>>>>>> Sent: Wednesday, March 03, 2010 10:44 AM
>>>>>> To: users@jackrabbit.apache.org
>>>>>> Subject: Re: NodeType creation
>>>>>>
>>>>>> On Wed, Mar 3, 2010 at 5:25 PM, Birmingham, Steven
>>>>>> <Steven.Birmingham@itt.com>  wrote:
>>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> I am trying to read a NodeType configuration from an xml file.
 The
>>>>>>> example I used was from the ocm test classes.
>>>>>>>
>>>>>>>
>>>>>>> jackrabbitNodeTypeManagerImpl.createNodeTypesFromConfiguration
>>>>>>> (session,
>>>>>>>                              new FileInputStream("./resources/
>>>>>>> Signal.xml"));
>>>>>>>
>>>>>>> Exception in thread "main" java.lang.NoClassDefFoundError: org/
>>>>>>> apache/jackrabbit/core/nodetype/xml/NodeTypeReader
>>>>>>>
>>>>>>> I have jcr-2.0.jar and all the other jackrabbit bundles on the
>>>>>>> class path.  Am I somehow missing a jar or is this method not
>>>>>>> supported anymore or changed?
>>>>>>
>>>>>> try this:
>>>>>>
>>>>>> http://jackrabbit.apache.org/api/2.0/org/apache/jackrabbit/api/JackrabbitNodeTypeManager.html#registerNodeTypes(java.io.InputStream,%20java.lang.String)
>>>>>>
>>>>>> e.g.
>>>>>>
>>>>>> ((JackrabbitNodeTypeManager)
>>>>>> session.getNodeTypeManager()).registerNodeTypes(new
>>>>>> FileInputStream("./resources/Signal.xml"),
>>>>>> JackrabbitNodeTypeManager.TEXT_XML);
>>>>>>
>>>>>> cheers
>>>>>> stefan
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Steve
>>>>>>>
>>>>>>> ________________________________
>>>>>>> This e-mail and any files transmitted with it may be proprietary
>>>>>>> and are intended solely for the use of the individual or entity
to
>>>>>>> whom they are addressed. If you have received this e-mail in
error
>>>>>>> please notify the sender.
>>>>>>> Please note that any views or opinions presented in this e-mail
are
>>>>>>> solely those of the author and do not necessarily represent those
>>>>>>> of ITT Corporation. The recipient should check this e-mail and
any
>>>>>>> attachments for the presence of viruses. ITT accepts no liability
>>>>>>> for any damage caused by any virus transmitted by this e-mail.
>>>>>>>
>>>>>
>>>>
>>>
>

Mime
View raw message