You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by thomasg <th...@hotmail.com> on 2006/03/31 12:25:40 UTC

Removing a node of type nt:file

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 Marcel Reutegger <ma...@gmx.net>.
Hi Martin,

I've received your patch, thanks.

I have also introduced a lazy reader in all the text filters, which 
conflicts with your patch. but as promised, I'll also fix the missing 
stream close.

regards
  marcel

Martin Perez wrote:
> That's fine. I suppose that you have received my patch.
> 
> Martin
> 
> On 4/6/06, Marcel Reutegger <ma...@gmx.net> wrote:
>> Martin Perez wrote:
>>> Yes, the problem with the filters is that if I'm not wrong, they are
>> called
>>> three times each time you make a simple save() operation. There is a bug
>>> opened about that but it's complex to be solved.
>>>
>>> Thomas, don't worry about the textfilters, I really didn't know that
>> after
>>> getting a stream through BlobFileValue you had to close it. I will fix
>> all
>>> the text filters about that.
>> martin, I'm currently working on the text filters to fix JCR-264. while
>> doing that I will also fix the missing close calls.
>>
>>
>> regards
>>   marcel
>>
> 



Re: Removing a node of type nt:file

Posted by Martin Perez <mp...@gmail.com>.
That's fine. I suppose that you have received my patch.

Martin

On 4/6/06, Marcel Reutegger <ma...@gmx.net> wrote:
>
> Martin Perez wrote:
> > Yes, the problem with the filters is that if I'm not wrong, they are
> called
> > three times each time you make a simple save() operation. There is a bug
> > opened about that but it's complex to be solved.
> >
> > Thomas, don't worry about the textfilters, I really didn't know that
> after
> > getting a stream through BlobFileValue you had to close it. I will fix
> all
> > the text filters about that.
>
> martin, I'm currently working on the text filters to fix JCR-264. while
> doing that I will also fix the missing close calls.
>
>
> regards
>   marcel
>

Re: Removing a node of type nt:file

Posted by Marcel Reutegger <ma...@gmx.net>.
Martin Perez wrote:
> Yes, the problem with the filters is that if I'm not wrong, they are called
> three times each time you make a simple save() operation. There is a bug
> opened about that but it's complex to be solved.
> 
> Thomas, don't worry about the textfilters, I really didn't know that after
> getting a stream through BlobFileValue you had to close it. I will fix all
> the text filters about that.

martin, I'm currently working on the text filters to fix JCR-264. while 
doing that I will also fix the missing close calls.


regards
  marcel

Re: Removing a node of type nt:file

Posted by Martin Perez <mp...@gmail.com>.
Yes, the problem with the filters is that if I'm not wrong, they are called
three times each time you make a simple save() operation. There is a bug
opened about that but it's complex to be solved.

Thomas, don't worry about the textfilters, I really didn't know that after
getting a stream through BlobFileValue you had to close it. I will fix all
the text filters about that.

Martin

On 4/6/06, thomasg <th...@hotmail.com> wrote:
>
>
> Yep, you're right. I removed the text filters and the deleting error goes
> away. Looks like quite a simple fix in the word text filter, I'll change
> and
> test. On the subject of another thread, removing the filters also greatly
> reduces the time taken for session.save() to return so this call must be
> asynchronously applying the text filters as you suggested. Cheers, Thomas
> --
> View this message in context:
> http://www.nabble.com/Removing-a-node-of-type-nt%3Afile-t1373899.html#a3781226
> Sent from the Jackrabbit - Dev forum at Nabble.com.
>
>

Re: Removing a node of type nt:file

Posted by thomasg <th...@hotmail.com>.
Yep, you're right. I removed the text filters and the deleting error goes
away. Looks like quite a simple fix in the word text filter, I'll change and
test. On the subject of another thread, removing the filters also greatly
reduces the time taken for session.save() to return so this call must be
asynchronously applying the text filters as you suggested. Cheers, Thomas
--
View this message in context: http://www.nabble.com/Removing-a-node-of-type-nt%3Afile-t1373899.html#a3781226
Sent from the Jackrabbit - Dev forum at Nabble.com.


Re: Removing a node of type nt:file

Posted by Marcel Reutegger <ma...@gmx.net>.
Hi Thomas,

I suspect it's the word text filter which does not close a stream.

could you please quickly check by removing all the configuration for 
text filters and re-run the test?

Thanks

regards
  marcel

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 Stefan Guggisberg <st...@gmail.com>.
hi thomas
i quickly tried to reproduce the issue with the code you supplied
but i couldn't find any such warning in the log.

a possible explanation for this warning:

you're storing blob's in the file system rather than in the db
(i.e. "externalBLOBs=true") and you're not properly closing
input streams obtained from the binary property (e.g. by calling
prop.getStream()) before deleting the property.

cheers
stefan

On 3/31/06, thomasg <th...@hotmail.com> 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>.
Cheers Marcel,

I hacked the text filter code and rebuilt and the error disappeared. I'll
get the latest code and rebuild that soon. 
Thomas
--
View this message in context: http://www.nabble.com/Removing-a-node-of-type-nt%3Afile-t1373899.html#a3800579
Sent from the Jackrabbit - Dev forum at Nabble.com.


Re: Removing a node of type nt:file

Posted by Marcel Reutegger <ma...@gmx.net>.
Hi Thomas,

resolving issue JCR-264 should also solve this warning with open file 
handles.

if you like you can give it a try by building the text filter module in 
trunk and replace the existing text filter jar file in your environment.

the warning should then disappear and the word document is only filtered 
when necessary and not right on save.

regards
  marcel

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.


Re: Removing a node of type nt:file

Posted by gruiz <gr...@germinus.com>.
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.
>
>
>
>  
>