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