You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by gruiz <gr...@germinus.com> on 2006/04/04 10:05:50 UTC
Re: Removing a node of type nt:file
Hi Thomas.
When we delete a Node, first we follow this steps:
1. Get parent Node
2. Get desired Node
3. Delete desired Node
4. Save parent Node
I think, the problem is that you save the session, not the parent Node.
We do this in this way:
Node del = session.getNodeByUUID(uuid);
Node parent = del.getParent();
del.remove();
parent.save();
Regards
thomasg wrote:
>Hi, I am adding a nt:file node and nt:resource, confirming that a search
>finds a word, trying to remove the file node and then confriming that the
>same search returns nothing. This proceeds as expected except that I get the
>following warning when doing the second session.save():
>
>WARN org.apache.jackrabbit.core.value.BLOBFileValue - Error while deleting
>BLOBFileValue: failed to delete
>C:\DocumentSearchTests\dms\workspaces\dms\blobs\2a\71\c0fc697e44fc9de4c577a3788abb\%7bhttp%3a%2f%2fwww.jcp.org%2fjcr%2f1.0%7ddata.0.bin
>
>This is the add / remove part of the code:
>
>//add
>Node folderNode = root.addNode("foldernode", "nt:folder");
>File file = new File(TEST_DIR +
>"largewordfile/massivewordfiletotestaddtime.doc");
>Node fileNode = folderNode.addNode(file.getName(), "nt:file");
>Node resourceNode = fileNode.addNode("jcr:content", "nt:resource");
>resourceNode.setProperty("jcr:mimeType", MIME_TYPE);
>resourceNode.setProperty("jcr:data", new FileInputStream(file));
>Calendar lastModified = Calendar.getInstance();
>lastModified.setTimeInMillis(file.lastModified());
>resourceNode.setProperty("jcr:lastModified", lastModified);
>session.save();
>
>//remove
>folderNode = root.getNode("foldernode");
>fileNode = folderNode.getNode(file.getName());
>fileNode.remove();
>folderNode.remove();
>session.save(); //Warning here
>
>Is this a reasonable way to be removing a nt:file node and associated
>nt:resource node? Any comments would be welcome.
>
>Thanks, Thomas
>
>
>
>--
>View this message in context: http://www.nabble.com/Removing-a-node-of-type-nt%3Afile-t1373899.html#a3687050
>Sent from the Jackrabbit - Dev forum at Nabble.com.
>
>
>
>
>
Re: Removing a node of type nt:file
Posted by thomasg <th...@hotmail.com>.
Hi. what you suggested does delete the required node but I still get the
warning.
Cheers, Thomas
--
View this message in context: http://www.nabble.com/Removing-a-node-of-type-nt%3Afile-t1373899.html#a3768462
Sent from the Jackrabbit - Dev forum at Nabble.com.