[ https://issues.apache.org/jira/browse/JCR-1860?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tobias Bocanegra reassigned JCR-1860: ------------------------------------- Assignee: Tobias Bocanegra > Error occurs when restore nt:resource node after delete > ------------------------------------------------------- > > Key: JCR-1860 > URL: https://issues.apache.org/jira/browse/JCR-1860 > Project: Jackrabbit Content Repository > Issue Type: Bug > Components: jackrabbit-core > Affects Versions: core 1.4.5 > Environment: windows xp professional > Reporter: Gao Tiantian > Assignee: Tobias Bocanegra > > Today, i write a JUnit test about restore nt:resource node, then i got > something wrong. > I add a nt:unstructured node parentNode under my testRootNode, it's > versionable. > Then i add a nt:resource node fileNode under parentNode, also the fileNode is > versionable. > First I remove the fileNode, then I want to restore, then i got something > wrong like this: > javax.jcr.nodetype.ConstraintViolationException: > /testRootNode/testRestoreParent/testRestoreFile: mandatory property > {http://www.jcp.org/jcr/1.0}lastModified does not exist > at > org.apache.jackrabbit.core.ItemImpl.validateTransientItems(ItemImpl.java:538) > at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1205) > at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:897) > at > org.apache.jackrabbit.core.NodeImpl.internalRestore(NodeImpl.java:3812) > at > org.apache.jackrabbit.core.NodeImpl.restoreByLabel(NodeImpl.java:3165) > at > com.nikoyo.dm6p.core.version.VersionRestoreTest.testRestoreFile(VersionRestoreTest.java:151) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at junit.framework.TestCase.runTest(TestCase.java:154) > at junit.framework.TestCase.runBare(TestCase.java:127) > at junit.framework.TestResult$1.protect(TestResult.java:106) > at junit.framework.TestResult.runProtected(TestResult.java:124) > at junit.framework.TestResult.run(TestResult.java:109) > at junit.framework.TestCase.run(TestCase.java:118) > at > org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) > at > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) > This is the test code of my junit test: > Node parentNode = testRootNode.addNode("testRestoreParent"); > parentNode.addMixin(JcrConstants.MIX_VERSIONABLE); > parentNode.setProperty("prop1", "111"); > parentNode.setProperty("prop2", 1111); > save(); > // parentNode adds a child nt:resource node, and it' versionable > parentNode.checkout(); > Node fileNode = parentNode.addNode("testRestoreFile", "nt:resource"); > fileNode.addMixin(JcrConstants.MIX_VERSIONABLE); > fileNode.setProperty(JcrConstants.JCR_ENCODING, "utf-8"); > fileNode.setProperty(JcrConstants.JCR_MIMETYPE, "text/plain"); > fileNode.setProperty(JcrConstants.JCR_LASTMODIFIED, Calendar.getInstance()); > fileNode.setProperty(JcrConstants.JCR_DATA, new ByteArrayInputStream("test > restore nt:resource node".getBytes())); > save(); > fileNode.checkout(); > fileNode.checkin(); > // version label 1.0 > VersionHistory versionHistory = parentNode.getVersionHistory(); > Version version1 = parentNode.checkin(); > versionHistory.addVersionLabel(version1.getName(), "1.0", true); > // parentNode remove the child nt:resource node > parentNode.checkout(); > fileNode.remove(); > save(); > // version label 1.1 > Version version2 = parentNode.checkin(); > versionHistory.addVersionLabel(version2.getName(), "1.1", true); > // restore version 1.0 > parentNode.restoreByLabel("1.0", true); -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.