|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
Empty content from any versionHi, all
I have very big problem. Can somebody help me? I create node: Node rootNode = session.getRootNode(); Node documentNode = rootNode.addNode("test.txt", "nt:file"); Node resNode = contentNode.addNode("jcr:content", "nt:resource"); resNode.setProperty("jcr:mimeType", "text/plain"); resNode.setProperty("jcr:encoding", "UTF8"); resNode.setProperty("jcr:lastModified", System.currentTimeMillis()); resNode.setProperty("jcr:data", new ByteArrayInputStream(doc1.getInStream())); documentNode.addMixin("mix:versionable"); session.save(); documentNode.checkin(); Then i update node like this: Node documentNode = session.getRootNode().getNode("test.txt"); documentNode.checkout(); Node resNode = contentNode.getNode("jcr:content"); resNode.setProperty("jcr:data", new ByteArrayInputStream(doc2.getInStream())); session.save(); documentNode.checkin(); And then i try to get data from content node: Node node = session.getRootNode().getNode("test.txt"); VersionHistory hist = node.getVersionHistory(); Version vers = hist.getVersion(versionName); Node frozenNode= vers.getNode("jcr:frozenNode"); Node versionNode = frozenNode.getNode("jcr:content"); InputStream data = versionNode.getProperty("jcr:data").getStream(); And all properties are setting up, but property with key "jcr:data" is empty for all versions from versionhistory. Why?? What do i do wrong? Many thanks, Stas |
|
|
Re: Empty content from any versionThe JCR API access looks good. I think the problem lies in the usage
of the input stream. For example, ByteArrayInputStream does not take an InputStream as parameter in any of its constructors (it should be a byte[] parameter, but doc2.getInStream() sounds like it returns an InputStream): resNode.setProperty("jcr:data", new ByteArrayInputStream(doc2.getInStream())); Regards, Alex On Mon, Jun 9, 2008 at 4:11 PM, travmik <travmik@...> wrote: > > Hi, all > I have very big problem. Can somebody help me? > > I create node: > > > Node rootNode = session.getRootNode(); > Node documentNode = rootNode.addNode("test.txt", "nt:file"); > Node resNode = contentNode.addNode("jcr:content", "nt:resource"); > resNode.setProperty("jcr:mimeType", "text/plain"); > resNode.setProperty("jcr:encoding", "UTF8"); > resNode.setProperty("jcr:lastModified", System.currentTimeMillis()); > resNode.setProperty("jcr:data", new > ByteArrayInputStream(doc1.getInStream())); > documentNode.addMixin("mix:versionable"); > session.save(); > documentNode.checkin(); > > > Then i update node like this: > > > Node documentNode = session.getRootNode().getNode("test.txt"); > documentNode.checkout(); > Node resNode = contentNode.getNode("jcr:content"); > resNode.setProperty("jcr:data", new > ByteArrayInputStream(doc2.getInStream())); > session.save(); > documentNode.checkin(); > > > And then i try to get data from content node: > > > Node node = session.getRootNode().getNode("test.txt"); > VersionHistory hist = node.getVersionHistory(); > Version vers = hist.getVersion(versionName); > Node frozenNode= vers.getNode("jcr:frozenNode"); > Node versionNode = frozenNode.getNode("jcr:content"); > InputStream data = versionNode.getProperty("jcr:data").getStream(); > > And all properties are setting up, but property with key "jcr:data" is empty > for all versions from versionhistory. Why?? What do i do wrong? > Many thanks, > Stas > -- > View this message in context: http://www.nabble.com/Empty-content-from-any-version-tp17733642p17733642.html > Sent from the Jackrabbit - Dev mailing list archive at Nabble.com. > > -- Alexander Klimetschek alexander.klimetschek@... |
|
|
Re: Empty content from any versionThank you for you prompt reply. But method getInStream() in my transfer object returns byte[]. In this section it's alright.
I run my project using jcr-jca on jboss 4.2. Maybe it helps. I am confusion.((
|
|
|
Re: Empty content from any versionI have this problem for now. Though this code works fine:
Node rootNode = session.getRootNode(); Node documentNode = rootNode.getNode("test.txt"); Node contentNode = documentNode.getNode("jcr:content"); InputStream data = contentNode.getProperty("jcr:data").getStream(); "data" - not empty. And when i try do this with version i get empty data from content node. I am not understanding what i do wrong.(
|
|
|
Re: Empty content from any versionWhat is "versionName" from the code in your first mail? Could you
iterate over all versions in the history, print them out and check if they contain data? You can do it with VersionHistory.getAllVersions(). Regards, Alex -- Alexander Klimetschek alexander.klimetschek@... |
|
|
Re: Empty content from any versionYes i did this. Data in all versions from VersionHistory is empty.
|
|
|
Re: Empty content from any versionAnd this is true only for my jboss instance - on jboss all data in versionhistory is empty. If i run this example standalone - all work fine.(
repository.xml is the same. What is thet means? Thanks, Stas
|
|
|
Re: Empty content from any versionSo it seems like jackrabbit-jca or JBoss make the difference... but I
am wondering what kind of problem would only affect binary properties in versioned nodes. Are you using transactions? And could you post the repository.xml? Regards, Alex -- Alexander Klimetschek alexander.klimetschek@... |
|
|
Re: Empty content from any versionI deploy jackrabbit-server.rar for test and then deploy jcr-ds.xml
<connection-factories> <tx-connection-factory> <jndi-name>jcr/local</jndi-name> <xa-transaction/> <rar-name>jackrabbit-server.rar</rar-name> <connection-definition>javax.jcr.Repository</connection-definition> <config-property name="homeDir" type="java.lang.String">/temp/jackrabbit</config-property> <config-property name="configFile" type="java.lang.String">classpath:repository.xml</config-property> <config-property name="bindSessionToTransaction" type="java.lang.Boolean">true</config-property> </tx-connection-factory> </connection-factories> I don't touch reposotory.xml. This is text from it: <Repository> <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem"> </FileSystem> <Security appName="Jackrabbit"> <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager"> </AccessManager> <LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule"> </LoginModule> </Security> <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/> <Workspace name="${wsp.name}"> <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem"> </FileSystem> <PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.DerbyPersistenceManager"> </PersistenceManager> <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex"> </SearchIndex> </Workspace> <Versioning rootPath="${rep.home}/version"> <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem"> </FileSystem> <PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.DerbyPersistenceManager"> </PersistenceManager> </Versioning> <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex"> </SearchIndex> </Repository> And then i get Repository like this: InitialContext ctx = new InitialContext(); Repository repository = (Repository) ctx.lookup("java:jcr/local"); What is wrong? Thanks, Stas
|
|
|
Re: Empty content from any versionOn Tue, Jun 10, 2008 at 4:54 PM, travmik <travmik@...> wrote:
> > I deploy jackrabbit-server.rar for test and then deploy jcr-ds.xml > > <connection-factories> > <tx-connection-factory> > <jndi-name>jcr/local</jndi-name> > <xa-transaction/> > <rar-name>jackrabbit-server.rar</rar-name> > <connection-definition>javax.jcr.Repository</connection-definition> > <config-property name="homeDir" > type="java.lang.String">/temp/jackrabbit</config-property> > <config-property name="configFile" > type="java.lang.String">classpath:repository.xml</config-property> > <config-property name="bindSessionToTransaction" > type="java.lang.Boolean">true</config-property> > </tx-connection-factory> > </connection-factories> Looks like you are using transactions implicitly. Could be a bug in Jackrabbit's XA transactions implementation when it comes to versioning of binary properties. Does anyone that is familiar with this code knows more? Regards, Alex -- Alexander Klimetschek alexander.klimetschek@... |
|
|
Re: Empty content from any versionYou are right. We changed <tx-connection-factory> for <no-tx-connection-factory>. This is all.)) Thx you.
|
| Free Forum Powered by Nabble | Forum Help |