Am 14.03.2013 um 17:50 schrieb Stefan Guggisberg <[email protected]>:

> On Thursday, March 14, 2013, Ulrich wrote:
> 
>> When running this code:
>> 
>> 
>> Property jcrdata;
>> for (PropertyIterator pi = fileNode.getProperties(); pi.hasNext(); ) {
>>        Property p = pi.nextProperty();
>>        LOGGER.info("Property is: " + p.getName() + "=" +
>> p.getValue().getString());
>> }
>> jcrdata = fileNode.getProperty("jcr:data");
>> 
>> the for-loop works fine and displays the property "jcr:data" and it's
>> value. But
>> the last line:
>>       Property jcrdata = fileNode.getProperty("jcr:data");
>> fails with "javax.jcr.PathNotFoundException: jcr:data".
> 
> 
> what is the node type of fileNode?
> 
> i assume it's nt:file. nt:file doesn't declare a jcr:data property.
> it declares a jcr:content node which commonly is a nt:resource.
> nt:resource does declare a jcr:data property.
> 
> i.e. fileNode.getNode("jcr:content").getProperty("jcr:data")
> 
> cheers
> stefan
fileNode is the child of a "nt:file"-node and has the node-name "jcr:content". 
The complete code would have shown. But this is not the point here. As you can 
see in the second sample, the property can be processed for this node, so it is 
proofed, it is there (and I know it for sure - I have defined it).
There is something very strange with my repository, I think. The program used 
to run until today. Ok, I changed something but not here. I have no clue, how 
my changes may have affected the behaviour this way.

Property jcrdata;
for (PropertyIterator pi = fileNode.getProperties(); pi.hasNext(); ) 
     Property p = pi.nextProperty();
     LOGGER.info("Property is: " + p.getName() + "=");
     p.getValue().getString());
     if (p.getName().equals("jcr:data")) 
         jcrdata = p;
}
jcrdata = fileNode.getProperty("jcr:data");

This code also fails in the last line - this proofs that the property is 
retrieved from the very same node.

Ulrich

Reply via email to