jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Mitterdorfer <daniel.mitterdor...@salzburgresearch.at>
Subject Re: XPath query returns no results
Date Mon, 19 Nov 2007 14:17:57 GMT
Hi Marcel,

Marcel Reutegger wrote:
> Hi Daniel,
>
> that's quite strange. I tried to reproduce the issue, but was unable 
> to do so. Is there anything unusual in the log files that might 
> explain why the queries fail?
>
I just noticed one strange thing though. If I execute the query 
"/jcr:root/*" I only get: "/jcr:system (rep:system)". However, as you 
can see in the dump in my first message I would have expected that my 
"interedu" node is the sibling node of "jcr:system" and thus included in 
the result (I have copied the relevant part of the dump below).

(rep:root)
Prop: jcr:primaryType = rep:root
 jcr:system (rep:system)
 Prop: jcr:primaryType = rep:system
 <<large subtree here - irrelevant to the problem>>
 interedu (nt:unstructured)
 Prop: jcr:primaryType = nt:unstructured
[...]

So my #save() method makes me suspicious (see below a slightly 
simplified version):

private static final String APPLICATION_ROOT_NODE = "interedu";
//...
public void save(final InputStream data, final String originalName) {
  final JcrConstants constants = new JcrConstants(session);
  final Node root = session.getRootNode();
  Node applicationRoot = null;
  // create the application root node if necessary
  if (root.hasNode(APPLICATION_ROOT_NODE)) {
    applicationRoot = root.getNode(APPLICATION_ROOT_NODE);
  } else {
    applicationRoot = root.addNode(APPLICATION_ROOT_NODE);
  }
  final Node assetNode = applicationRoot.addNode(fileName, 
constants.getNT_FILE());

  // the assetNode is the 'entry point' for an asset.
  assetNode.addMixin(constants.getMIX_REFERENCEABLE());

  Node contentNode = assetNode.addNode(constants.getJCR_CONTENT(), 
constants.getNT_RESOURCE());
  // only the content node is versionable, not its parent!
  contentNode.addMixin(constants.getMIX_VERSIONABLE());
  try {
    final JcrConstants constants = new JcrConstants(session);
    contentNode.setProperty(constants.getJCR_DATA(), data);
    contentNode.setProperty(constants.getJCR_MIMETYPE(), 
MimeTypeDetector.getMimetype(originalName));
    contentNode.setProperty(constants.getJCR_LASTMODIFIED(), 
Calendar.getInstance().getTimeInMillis());
    session.save();
    contentNode.checkin();
  } finally {
    IOUtils.closeQuietly(data);
  }
}

bye,

Daniel

Mime
View raw message