0
我有一个关于通过名为data的inputStream
类型的属性过滤资源的xpath表达式的问题。 我怎样才能做一个文本搜索,例如这是工作:通过输入流属性搜索
String xpath1 = "<my app path>//element(*, nt:resource) [jcr:contains(@jcr:mimeType,'*plain*')]";
String xpath2 = "<my app path>//element(*, nt:resource) [jcr:contains(@jcr:encoding,'*utf*')]";
但是,这是行不通的。
String xpath3 = "<my app path>//element(*, nt:resource) [jcr:contains(@jcr:data,'*plain*')]";
真正的事实是,我们使用一些自定义节点,让我们解释的属性定义:
在Java条款...
public class Resource extends BaseNode {
/** Encoding media type. It cannot be null or empty. */
@Field(jcrName = "jcr:encoding", jcrDefaultValue = "")
private String encoding;
/** Resource's MIME type. It cannot be null or empty. */
@Field(jcrName="jcr:mimeType", jcrDefaultValue = "")
private String mimeType;
/** Resource's size (bytes). */
@Field(jcrName="skl:size")
private long size;
/** Resource's content data as stream. It cannot be null. */
@Field(jcrName="jcr:data")
private InputStream data;
...
}
@Node(jcrType = "baseNode", isAbstract = true)
public abstract class BaseNode {
@Field(jcrName = "name", id = true)
protected String name;
@Field(jcrName = "creationDate")
protected Date creationDate;
...
}
而在JackRabbit用条款.. 。
<!-- Base node type definition -->
<nodeType name="docs:baseNode"
isMixin="false"
hasOrderableChildNodes="false" >
<supertypes>
<supertype>nt:hierarchyNode</supertype>
</supertypes>
<propertyDefinition name="docs:name"
requiredType="String"
autoCreated="false"
mandatory="true"
onParentVersion="COPY"
protected="false"
multiple="false" />
<propertyDefinition name="docs:searchPath"
requiredType="String"
autoCreated="false"
mandatory="false"
onParentVersion="COPY"
protected="false"
multiple="false" />
<propertyDefinition name="docs:creationDate"
requiredType="Date"
autoCreated="false"
mandatory="true"
onParentVersion="COPY"
protected="false"
multiple="false" />
<propertyDefinition name="docs:lastModified"
requiredType="Date"
autoCreated="false"
mandatory="true"
onParentVersion="COPY"
protected="false"
multiple="false" />
<childNodeDefinition name="*"
defaultPrimaryType="docs:baseNode"
autoCreated="false"
mandatory="false"
onParentVersion="COPY"
protected="false"
sameNameSiblings="false">
<requiredPrimaryTypes>
<requiredPrimaryType>docs:baseNode</requiredPrimaryType>
</requiredPrimaryTypes>
</childNodeDefinition>
</nodeType>
<!-- Resource node type definition -->
<nodeType name="skl:resource"
isMixin="false"
hasOrderableChildNodes="false" >
<supertypes>
<supertype>docs:baseNode</supertype>
<supertype>nt:resource</supertype>
</supertypes>
<propertyDefinition name="skl:size"
requiredType="Long"
autoCreated="false"
mandatory="true"
onParentVersion="COPY"
protected="false"
multiple="false" />
<propertyDefinition name="skl:externalUri"
requiredType="String"
autoCreated="false"
mandatory="false"
onParentVersion="COPY"
protected="false"
multiple="false" />
</nodeType>
问题是,我如何执行此查询以便通过jcr:data属性进行过滤。
感谢您的数据Randall。我会看看!。不幸的是,使用老版本的Jackrabbit的版本不符合2.0 JCR规范(是的..我们已经过时了,并且害怕将所有版本移到另一个版本..这只是巨大的,软件本身的故事你知道什么我们正在谈论ejjeje)。 – Victor 2012-07-17 13:48:54
我明白了。请注意,JCR 2.0 API与JCR 1.0向后兼容 - 应支持所有JCR 1.0代码(假定实现正确地执行了它们的工作)。是的,有些方法已被弃用(通常是因为它们远非理想;例如Node.save()),但它们仍然应该工作。祝你好运! – 2012-07-17 16:54:29
非常感谢您的支持和鼓励!可悲的是,我仍然无法弄清楚如何解决这些问题......但我会铭记你的建议。 – Victor 2012-07-17 20:23:27