exo-jcr SVN: r236 - in kernel/trunk: packaging and 4 other directories.
by do-not-reply@jboss.org
Author: dbaeli
Date: 2009-10-06 22:37:18 -0400 (Tue, 06 Oct 2009)
New Revision: 236
Added:
kernel/trunk/packaging/
kernel/trunk/packaging/module/
kernel/trunk/packaging/module/pom.xml
kernel/trunk/packaging/module/src/
kernel/trunk/packaging/module/src/main/
kernel/trunk/packaging/module/src/main/javascript/
kernel/trunk/packaging/module/src/main/javascript/kernel.packaging.module.js
Modified:
kernel/trunk/pom.xml
Log:
EXOJCR-171: module.js file for core attached in the source code
* same dependencies in the pom.xml
* no hard-coded module version (support for maven release plugin)
Property changes on: kernel/trunk/packaging/module
___________________________________________________________________
Name: svn:ignore
+ target
Added: kernel/trunk/packaging/module/pom.xml
===================================================================
--- kernel/trunk/packaging/module/pom.xml (rev 0)
+++ kernel/trunk/packaging/module/pom.xml 2009-10-07 02:37:18 UTC (rev 236)
@@ -0,0 +1,66 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>kernel-parent</artifactId>
+ <version>2.2.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>kernel.packaging.module</artifactId>
+ <packaging>pom</packaging>
+ <name>eXo Kernel Build module</name>
+
+ <properties>
+ <exobuild.name>kernel</exobuild.name>
+ <exobuild.type>module</exobuild.type>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>prepare</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>target</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/javascript</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.3</version>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>target/${exobuild.name}.packaging.${exobuild.type}.js</file>
+ <type>js</type>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: kernel/trunk/packaging/module/src/main/javascript/kernel.packaging.module.js
===================================================================
--- kernel/trunk/packaging/module/src/main/javascript/kernel.packaging.module.js (rev 0)
+++ kernel/trunk/packaging/module/src/main/javascript/kernel.packaging.module.js 2009-10-07 02:37:18 UTC (rev 236)
@@ -0,0 +1,59 @@
+eXo.require("eXo.projects.Module") ;
+eXo.require("eXo.projects.Product") ;
+
+function getModule(params) {
+ var module = new Module();
+
+ module.version = "${project.version}" ;//
+ module.relativeMavenRepo = "org/exoplatform/kernel" ;
+ module.relativeSRCRepo = "kernel" ;
+ module.name = "kernel" ;
+
+ module.commons =
+ new Project("org.exoplatform.kernel", "exo.kernel.commons", "jar", module.version).
+ addDependency(new Project("commons-lang", "commons-lang", "jar", "2.3")).
+ addDependency(new Project("xpp3", "xpp3", "jar", "1.1.3.4.O")).
+// addDependency(new Project("xstream", "xstream", "jar", "1.2")).
+ addDependency(new Project("dom4j", "dom4j", "jar", "1.6.1"));
+
+ module.container =
+ new Project("org.exoplatform.kernel", "exo.kernel.container", "jar", module.version).
+ addDependency(module.commons).
+ addDependency(new Project("picocontainer", "picocontainer", "jar", "1.1")).
+// addDependency(new Project("org.codehaus.groovy", "groovy-all", "jar", "1.5.6")).
+ addDependency(new Project("commons-beanutils", "commons-beanutils", "jar", "1.6")).
+ addDependency(new Project("org.jibx", "jibx-run", "jar", "1.2.1")).
+ addDependency(new Project("org.jibx", "jibx-bind", "jar", "1.2.1")).
+ addDependency(new Project("asm", "asm", "jar", "1.5.3")).
+ addDependency(new Project("cglib", "cglib", "jar", "2.1_3"));
+
+ module.misc = {} ;
+ module.misc.drools =
+ new Project("drools", "drools-core", "jar", "2.0").
+ addDependency(new Project("janino", "janino", "jar", "2.3.2")).
+ addDependency(new Project("drools", "drools-base", "jar", "2.0")).
+ addDependency(new Project("drools", "drools-io", "jar", "2.0")).
+ addDependency(new Project("drools", "drools-java", "jar", "2.0")).
+ addDependency(new Project("drools", "drools-smf", "jar", "2.0")) ;
+
+ module.component = {};
+ module.component.common =
+ new Project("org.exoplatform.kernel", "exo.kernel.component.common", "jar", module.version).
+ addDependency(new Project("quartz", "quartz", "jar", "1.5.0-RC2")).
+ addDependency(new Project("javax.activation", "activation", "jar", "1.1")).
+ addDependency(new Project("javax.mail", "mail", "jar", "1.4"));
+
+ module.component.command =
+ new Project("org.exoplatform.kernel", "exo.kernel.component.command", "jar", module.version).
+ addDependency(new Project("commons-chain", "commons-chain", "jar", "1.0")).
+ addDependency(new Project("commons-digester", "commons-digester", "jar", "1.6"));
+
+ module.component.cache =
+ new Project("org.exoplatform.kernel", "exo.kernel.component.cache", "jar", module.version) ;
+
+ module.component.remote =
+ new Project("org.exoplatform.kernel", "exo.kernel.component.remote", "jar", module.version).
+ addDependency(new Project("javagroups", "jgroups-all", "jar", "2.5.2"));
+
+ return module;
+}
Modified: kernel/trunk/pom.xml
===================================================================
--- kernel/trunk/pom.xml 2009-10-07 02:36:27 UTC (rev 235)
+++ kernel/trunk/pom.xml 2009-10-07 02:37:18 UTC (rev 236)
@@ -54,6 +54,7 @@
<module>component/remote</module>
<module>component/cache</module>
<module>component/command</module>
+ <module>packaging/module</module>
</modules>
<dependencyManagement>
14 years, 11 months
exo-jcr SVN: r235 - in core/trunk: packaging and 4 other directories.
by do-not-reply@jboss.org
Author: dbaeli
Date: 2009-10-06 22:36:27 -0400 (Tue, 06 Oct 2009)
New Revision: 235
Added:
core/trunk/packaging/
core/trunk/packaging/module/
core/trunk/packaging/module/dependencies.txt
core/trunk/packaging/module/pom.xml
core/trunk/packaging/module/src/
core/trunk/packaging/module/src/main/
core/trunk/packaging/module/src/main/javascript/
core/trunk/packaging/module/src/main/javascript/core.packaging.module.js
Modified:
core/trunk/pom.xml
Log:
EXOJCR-172: module.js file for core attached in the source code
* same dependencies in the pom.xml
* no hard-coded module version (support for maven release plugin)
Property changes on: core/trunk/packaging/module
___________________________________________________________________
Name: svn:ignore
+ target
Added: core/trunk/packaging/module/dependencies.txt
===================================================================
--- core/trunk/packaging/module/dependencies.txt (rev 0)
+++ core/trunk/packaging/module/dependencies.txt 2009-10-07 02:36:27 UTC (rev 235)
@@ -0,0 +1,85 @@
+Generated during core-2.3.0-Beta02 release
+org.exoplatform.core:exo.core.packaging.module:pom:2.3.0-SNAPSHOT
++- org.exoplatform.core:exo.core.component.database:jar:2.3.0-SNAPSHOT:compile
+| +- org.exoplatform.kernel:exo.kernel.component.common:jar:2.2.0-Beta01:compile
+| | +- javax.activation:activation:jar:1.1:compile
+| | +- jotm:jotm:jar:2.0.10:compile
+| | | +- jotm:jotm_jrmp_stubs:jar:2.0.10:compile
+| | | +- org.objectweb.carol:carol:jar:2.0.5:compile
+| | | \- howl:howl-logger:jar:0.1.11:compile
+| | +- quartz:quartz:jar:1.5.0-RC2:compile
+| | +- javax.mail:mail:jar:1.4:compile
+| | \- javax.transaction:jta:jar:1.0.1B:compile
+| +- org.exoplatform.kernel:exo.kernel.component.cache:jar:2.2.0-Beta01:compile
+| | \- org.exoplatform.kernel:exo.kernel.component.remote:jar:2.2.0-Beta01:compile
+| | \- jgroups:jgroups:jar:2.6.10.GA:compile
+| +- hsqldb:hsqldb:jar:1.8.0.7:runtime
+| +- com.experlog:xapool:jar:1.5.0:compile
+| +- c3p0:c3p0:jar:0.9.1.2:runtime
+| +- org.hibernate:hibernate-core:jar:3.3.1.GA:compile
+| | +- antlr:antlr:jar:2.7.6:compile
+| | +- commons-collections:commons-collections:jar:3.1:compile
+| | \- dom4j:dom4j:jar:1.6.1:compile
+| | +- jaxme:jaxme-api:jar:0.3:compile
+| | +- jaxen:jaxen:jar:1.1-beta-6:compile
+| | +- msv:xsdlib:jar:20030807:compile
+| | +- msv:relaxngDatatype:jar:20030807:compile
+| | +- pull-parser:pull-parser:jar:2:compile
+| | +- xpp3:xpp3:jar:1.1.3.3:compile
+| | +- stax:stax-api:jar:1.0:compile
+| | \- xml-apis:xml-apis:jar:1.0.b2:compile
+| +- xdoclet:xdoclet-hibernate-module:jar:1.2.3:compile
+| | \- commons-logging:commons-logging:jar:1.1:compile
+| | +- log4j:log4j:jar:1.2.12:compile
+| | +- logkit:logkit:jar:1.0.1:compile
+| | \- avalon-framework:avalon-framework:jar:4.1.3:compile
+| +- xdoclet:xdoclet:jar:1.2.3:compile
+| +- xdoclet:xdoclet-xdoclet-module:jar:1.2:compile
+| +- xdoclet:xjavadoc:jar:1.0.3:compile
+| +- javassist:javassist:jar:3.4.GA:compile
+| \- org.hibernate:hibernate-annotations:jar:3.4.0.GA:compile
+| +- org.hibernate:ejb3-persistence:jar:1.0.2.GA:compile
+| \- org.hibernate:hibernate-commons-annotations:jar:3.1.0.GA:compile
++- org.exoplatform.core:exo.core.component.document:jar:2.3.0-SNAPSHOT:compile
+| +- pdfbox:pdfbox:jar:0.7.3:compile
+| | +- org.fontbox:fontbox:jar:0.1.0:compile
+| | +- org.jempbox:jempbox:jar:0.2.0:compile
+| | +- bouncycastle:bcmail-jdk14:jar:136:compile
+| | \- bouncycastle:bcprov-jdk14:jar:136:compile
+| +- com.lowagie:itext:jar:2.1.0:compile
+| +- org.htmlparser:htmlparser:jar:1.6:compile
+| | \- com.sun:tools:jar:1.5.0:system
+| +- org.apache.poi:poi:jar:3.0.2-FINAL:compile
+| \- org.apache.poi:poi-scratchpad:jar:3.0.2-FINAL:compile
++- org.exoplatform.core:exo.core.component.organization.api:jar:2.3.0-SNAPSHOT:compile
+| +- org.exoplatform.kernel:exo.kernel.container:jar:2.2.0-Beta01:compile
+| | +- org.exoplatform.kernel:exo.kernel.commons:jar:2.2.0-Beta01:compile
+| | | +- commons-lang:commons-lang:jar:2.3:compile
+| | | +- org.slf4j:slf4j-api:jar:1.5.6:compile
+| | | \- org.slf4j:slf4j-log4j12:jar:1.5.6:compile
+| | +- org.exoplatform.tool:exo.tool.framework.junit:jar:1.2.0:compile
+| | | +- javax.portlet:portlet-api:jar:2.0:compile
+| | | \- javax.faces:jsf-api:jar:1.2:compile
+| | +- javax.servlet:servlet-api:jar:2.4:compile
+| | +- picocontainer:picocontainer:jar:1.1:compile
+| | | +- jmock:jmock:jar:1.0.1:compile
+| | | \- xstream:xstream:jar:1.0.2:compile
+| | +- commons-beanutils:commons-beanutils:jar:1.6:compile
+| | +- org.jibx:jibx-run:jar:1.2.1:compile
+| | +- org.jibx:jibx-bind:jar:1.2.1:compile
+| | | \- bcel:bcel:jar:5.1:compile
+| | \- org.jibx:jibx-extras:jar:1.2.1:compile
+| \- javax.ejb:ejb:jar:2.1:compile
++- org.exoplatform.core:exo.core.component.organization.ldap:jar:2.3.0-SNAPSHOT:compile
+| +- org.exoplatform.core:exo.core.component.ldap:jar:2.3.0-SNAPSHOT:compile
+| \- org.exoplatform.core:exo.core.component.organization.jdbc:jar:2.3.0-SNAPSHOT:compile
++- org.exoplatform.core:exo.core.component.security.core:jar:2.3.0-SNAPSHOT:compile
++- org.exoplatform.core:exo.core.component.xml-processing:jar:2.3.0-SNAPSHOT:compile
+| +- jtidy:jtidy:jar:4aug2000r7-dev:compile
+| \- xml-resolver:xml-resolver:jar:1.1:compile
++- org.exoplatform.core:exo.core.component.script.groovy:jar:2.3.0-SNAPSHOT:compile
+| \- org.codehaus.groovy:groovy-all:jar:1.5.7:compile
+| +- org.apache.ant:ant:jar:1.7.0:compile
+| | \- org.apache.ant:ant-launcher:jar:1.7.0:compile
+| \- jline:jline:jar:0.9.94:compile
+\- junit:junit:jar:3.8.2:test (scope not updated to compile)
Added: core/trunk/packaging/module/pom.xml
===================================================================
--- core/trunk/packaging/module/pom.xml (rev 0)
+++ core/trunk/packaging/module/pom.xml 2009-10-07 02:36:27 UTC (rev 235)
@@ -0,0 +1,77 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>core-parent</artifactId>
+ <version>2.3.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>core.packaging.module</artifactId>
+ <packaging>pom</packaging>
+ <name>eXo Core Build module</name>
+
+ <properties>
+ <exobuild.name>core</exobuild.name>
+ <exobuild.type>module</exobuild.type>
+ </properties>
+
+ <!-- declare the same dependencies than in the module.js -->
+ <dependencies>
+ <dependency><groupId>org.exoplatform.core</groupId><artifactId>exo.core.component.database</artifactId><version>2.3.0-SNAPSHOT</version></dependency>
+ <dependency><groupId>org.exoplatform.core</groupId><artifactId>exo.core.component.document</artifactId><version>2.3.0-SNAPSHOT</version></dependency>
+ <dependency><groupId>org.exoplatform.core</groupId><artifactId>exo.core.component.organization.api</artifactId><version>2.3.0-SNAPSHOT</version></dependency>
+ <dependency><groupId>org.exoplatform.core</groupId><artifactId>exo.core.component.organization.ldap</artifactId><version>2.3.0-SNAPSHOT</version></dependency>
+ <dependency><groupId>org.exoplatform.core</groupId><artifactId>exo.core.component.security.core</artifactId><version>2.3.0-SNAPSHOT</version></dependency>
+ <dependency><groupId>org.exoplatform.core</groupId><artifactId>exo.core.component.xml-processing</artifactId><version>2.3.0-SNAPSHOT</version></dependency>
+ <dependency><groupId>org.exoplatform.core</groupId><artifactId>exo.core.component.script.groovy</artifactId><version>2.3.0-SNAPSHOT</version></dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>prepare</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>target</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/javascript</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.3</version>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>target/${exobuild.name}.packaging.${exobuild.type}.js</file>
+ <type>js</type>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added: core/trunk/packaging/module/src/main/javascript/core.packaging.module.js
===================================================================
--- core/trunk/packaging/module/src/main/javascript/core.packaging.module.js (rev 0)
+++ core/trunk/packaging/module/src/main/javascript/core.packaging.module.js 2009-10-07 02:36:27 UTC (rev 235)
@@ -0,0 +1,67 @@
+eXo.require("eXo.projects.Module") ;
+eXo.require("eXo.projects.Product") ;
+
+function getModule(params) {
+
+ var module = new Module();
+
+ module.version = "${project.version}" ;//
+ module.relativeMavenRepo = "org/exoplatform/core" ;
+ module.relativeSRCRepo = "core" ;
+ module.name = "core" ;
+
+ module.component = {}
+
+ module.component.ldap = new Project("org.exoplatform.core", "exo.core.component.ldap", "jar", module.version) ;
+
+ module.component.database =
+ new Project("org.exoplatform.core", "exo.core.component.database", "jar", module.version) .
+ addDependency(new Project("com.experlog", "xapool", "jar", "1.5.0")).
+ addDependency(new Project("org.hibernate", "hibernate-core", "jar", "3.3.1.GA")).
+ addDependency(new Project("org.hibernate", "hibernate-annotations", "jar", "3.4.0.GA")).
+ addDependency(new Project("org.hibernate", "hibernate-commons-annotations", "jar", "3.1.0.GA")).
+ addDependency(new Project("org.hibernate", "ejb3-persistence", "jar", "1.0.2.GA")).
+ addDependency(new Project("javassist", "javassist", "jar", "3.4.GA")).
+ addDependency(new Project("xdoclet", "xdoclet-hibernate-module", "jar", "1.2.3")).
+ addDependency(new Project("xdoclet", "xdoclet", "jar", "1.2.3")).
+ addDependency(new Project("xdoclet", "xdoclet-xdoclet-module", "jar", "1.2")).
+ addDependency(new Project("xdoclet", "xjavadoc", "jar", "1.0.3")).
+ addDependency(new Project("commons-collections", "commons-collections", "jar", "3.1")).
+ addDependency(new Project("c3p0", "c3p0", "jar", "0.9.1.2")).
+ addDependency(new Project("antlr", "antlr", "jar", "2.7.6rc1")).
+ addDependency(new Project("javax.transaction", "jta", "jar", "1.0.1B")).
+ addDependency(new Project("jotm", "jotm_jrmp_stubs", "jar", "2.0.10")).
+ addDependency(new Project("jotm", "jotm", "jar", "2.0.10")).
+ addDependency(new Project("howl", "howl-logger", "jar", "0.1.11")).
+ addDependency(new Project("hsqldb", "hsqldb", "jar", "1.8.0.7")).
+ addDependency(new Project("javax.resource", "connector-api", "jar", "1.5"));
+
+ module.component.documents =
+ new Project("org.exoplatform.core", "exo.core.component.document", "jar", module.version).
+ addDependency(new Project("pdfbox", "pdfbox", "jar", "0.7.3")).
+ addDependency(new Project("com.lowagie", "itext", "jar", "2.1.0")).
+ addDependency(new Project("bouncycastle", "bcmail-jdk14", "jar", "136")).
+ addDependency(new Project("bouncycastle", "bcprov-jdk14", "jar", "136")).
+ addDependency(new Project("html-parser", "html-parser", "jar", "1.6")).
+ addDependency(new Project("org.apache.poi", "poi", "jar", "3.0.2-FINAL")).
+ addDependency(new Project("org.apache.poi", "poi-scratchpad", "jar", "3.0.2-FINAL"));
+
+ module.component.organization =
+ new Project("org.exoplatform.core", "exo.core.component.organization.api", "jar", module.version).
+ addDependency(new Project("org.exoplatform.core", "exo.core.component.organization.jdbc", "jar", module.version));
+
+ module.component.organization.ldap =
+ new Project("org.exoplatform.core", "exo.core.component.organization.ldap", "jar", module.version);
+
+ module.component.security = {}
+ module.component.security.core =
+ new Project("org.exoplatform.core", "exo.core.component.security.core", "jar", module.version) ;
+
+ module.component.xmlProcessing =
+ new Project("org.exoplatform.core", "exo.core.component.xml-processing", "jar", module.version) ;
+
+ module.component.resources = new Project("org.exoplatform.core", "exo.core.component.database", "jar", module.version);
+
+ module.component.scriptGroovy = new Project("org.exoplatform.core", "exo.core.component.script.groovy", "jar", module.version) ;
+ return module;
+}
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2009-10-06 14:57:30 UTC (rev 234)
+++ core/trunk/pom.xml 2009-10-07 02:36:27 UTC (rev 235)
@@ -59,6 +59,7 @@
<module>component/xml-processing</module>
<module>component/script/groovy</module>
<module>component/web/css</module>
+ <module>packaging/module</module>
</modules>
<dependencyManagement>
14 years, 11 months
exo-jcr SVN: r234 - in jcr/trunk/component/core/src: test/java/org/exoplatform/services/jcr/usecases and 1 other directory.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-10-06 10:57:30 -0400 (Tue, 06 Oct 2009)
New Revision: 234
Added:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrIndexReader.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrIndexSearcher.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrQuery.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrQueryParser.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrTermQuery.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrTextExtractor.java
Removed:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitIndexReader.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitIndexSearcher.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitQuery.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitQueryParser.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitTermQuery.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitTextExtractor.java
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LocalNameQuery.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryBuilder.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneVirtualTableResolver.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MatchAllDocsQuery.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MoreLikeThis.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiColumnQuery.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiColumnQueryAdapter.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NameQuery.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NameRangeQuery.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryHitsQuery.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SortedLuceneQueryHits.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestExcerpt.java
Log:
EXOJCR-161 : Classes renamed
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -55,7 +55,7 @@
* Implements a lucene <code>Query</code> which returns the child nodes of the
* nodes selected by another <code>Query</code>.
*/
-class ChildAxisQuery extends Query implements JackrabbitQuery
+class ChildAxisQuery extends Query implements JcrQuery
{
/**
@@ -269,7 +269,7 @@
/**
* {@inheritDoc}
*/
- public QueryHits execute(JackrabbitIndexSearcher searcher, SessionImpl session, Sort sort) throws IOException
+ public QueryHits execute(JcrIndexSearcher searcher, SessionImpl session, Sort sort) throws IOException
{
if (sort.getSort().length == 0 && matchesAnyChildNode())
{
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -49,7 +49,7 @@
* whether the nodes selected by that sub query are descendants or self of
* nodes selected by a context query.
*/
-class DescendantSelfAxisQuery extends Query implements JackrabbitQuery {
+class DescendantSelfAxisQuery extends Query implements JcrQuery {
/**
* The logger instance for this class.
@@ -229,7 +229,7 @@
/**
* {@inheritDoc}
*/
- public QueryHits execute(final JackrabbitIndexSearcher searcher,
+ public QueryHits execute(final JcrIndexSearcher searcher,
final SessionImpl session,
final Sort sort) throws IOException {
// Query tt = ((BooleanClause)((BooleanQuery)subQuery).clauses().get(0)).getQuery();
Deleted: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitIndexReader.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitIndexReader.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitIndexReader.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.exoplatform.services.jcr.impl.core.query.lucene;
-
-import java.io.IOException;
-
-
-import org.apache.lucene.index.FilterIndexReader;
-import org.apache.lucene.index.IndexReader;
-
-/**
- * <code>JackrabbitIndexReader</code> wraps an index reader and
- * {@link ReleaseableIndexReader#release() releases} the underlying reader
- * when a client calls {@link #close()} on this reader. This allows reusing
- * of the underlying index reader instance.
- */
-public final class JackrabbitIndexReader
- extends FilterIndexReader
- implements HierarchyResolver, MultiIndexReader {
-
- /**
- * The hierarchy resolver.
- */
- private final HierarchyResolver resolver;
-
- /**
- * The underlying index reader exposed as a {@link MultiIndexReader}.
- */
- private final MultiIndexReader reader;
-
- /**
- * Creates a new <code>JackrabbitIndexReader</code>. The passed index reader
- * must also implement the interfaces {@link HierarchyResolver} and
- * {@link MultiIndexReader}.
- *
- * @param in the underlying index reader.
- * @throws IllegalArgumentException if <code>in</code> does not implement
- * {@link HierarchyResolver} and
- * {@link MultiIndexReader}.
- */
- public JackrabbitIndexReader(IndexReader in) {
- super(in);
- if (!(in instanceof MultiIndexReader)) {
- throw new IllegalArgumentException("IndexReader must also implement MultiIndexReader");
- }
- if (!(in instanceof HierarchyResolver)) {
- throw new IllegalArgumentException("IndexReader must also implement HierarchyResolver");
- }
- this.resolver = (HierarchyResolver) in;
- this.reader = (MultiIndexReader) in;
- }
-
- //--------------------------< FilterIndexReader >---------------------------
-
- /**
- * Calls release on the underlying {@link MultiIndexReader} instead of
- * closing it.
- *
- * @throws IOException if an error occurs while releaseing the underlying
- * index reader.
- */
- protected void doClose() throws IOException {
- reader.release();
- }
-
- //------------------------< HierarchyResolver >-----------------------------
-
- /**
- * {@inheritDoc}
- */
- public int[] getParents(int n, int[] docNumbers) throws IOException {
- return resolver.getParents(n, docNumbers);
- }
-
- //-------------------------< MultiIndexReader >-----------------------------
-
- /**
- * {@inheritDoc}
- */
- public IndexReader[] getIndexReaders() {
- return reader.getIndexReaders();
- }
-
- /**
- * {@inheritDoc}
- */
- public ForeignSegmentDocId createDocId(String uuid) throws IOException {
- return reader.createDocId(uuid);
- }
-
- /**
- * {@inheritDoc}
- */
- public int getDocumentNumber(ForeignSegmentDocId docId) throws IOException {
- return reader.getDocumentNumber(docId);
- }
-
- /**
- * {@inheritDoc}
- */
- public void release() throws IOException {
- reader.release();
- }
-}
Deleted: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitIndexSearcher.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitIndexSearcher.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitIndexSearcher.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -1,141 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.exoplatform.services.jcr.impl.core.query.lucene;
-
-import java.io.IOException;
-
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.Sort;
-import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
-import org.exoplatform.services.jcr.impl.core.SessionImpl;
-import org.exoplatform.services.jcr.impl.core.query.lucene.constraint.EvaluationContext;
-
-/**
- * <code>JackrabbitIndexSearcher</code> implements an index searcher with
- * jackrabbit specific optimizations.
- */
-public class JackrabbitIndexSearcher
- extends IndexSearcher
- implements EvaluationContext {
-
- /**
- * The session that executes the query.
- */
- private final SessionImpl session;
-
- /**
- * The underlying index reader.
- */
- private final IndexReader reader;
-
- /**
- * The item state manager of the workspace.
- */
- private final ItemDataConsumer ism;
-
- /**
- * Creates a new jackrabbit index searcher.
- *
- * @param s the session that executes the query.
- * @param r the index reader.
- * @param ism the shared item state manager.
- */
- public JackrabbitIndexSearcher(SessionImpl s,
- IndexReader r,
- ItemDataConsumer ism) {
- super(r);
- this.session = s;
- this.reader = r;
- this.ism = ism;
- }
-
- /**
- * Executes the query and returns the hits that match the query.
- *
- * @param query the query to execute.
- * @param sort the sort criteria.
- * @param resultFetchHint a hint on how many results should be fetched.
- * @param selectorName the single selector name for the query hits.
- * @return the query hits.
- * @throws IOException if an error occurs while executing the query.
- */
- public MultiColumnQueryHits execute(Query query,
- Sort sort,
- long resultFetchHint,
- InternalQName selectorName)
- throws IOException {
- return new QueryHitsAdapter(
- evaluate(query, sort, resultFetchHint), selectorName);
- }
-
- /**
- * Evaluates the query and returns the hits that match the query.
- *
- * @param query the query to execute.
- * @param sort the sort criteria.
- * @param resultFetchHint a hint on how many results should be fetched.
- * @return the query hits.
- * @throws IOException if an error occurs while executing the query.
- */
- public QueryHits evaluate(Query query, Sort sort, long resultFetchHint)
- throws IOException {
- query = query.rewrite(reader);
- QueryHits hits = null;
- if (query instanceof JackrabbitQuery) {
- hits = ((JackrabbitQuery) query).execute(this, session, sort);
- }
- if (hits == null) {
- if (sort == null) {
- hits = new LuceneQueryHits(reader, this, query);
- } else {
- hits = new SortedLuceneQueryHits(
- reader, this, query, sort, resultFetchHint);
- }
- }
- return hits;
- }
-
- //------------------------< EvaluationContext >-----------------------------
-
- /**
- * Evaluates the query and returns the hits that match the query.
- *
- * @param query the query to execute.
- * @return the query hits.
- * @throws IOException if an error occurs while executing the query.
- */
- public QueryHits evaluate(Query query) throws IOException {
- return evaluate(query, new Sort(), Integer.MAX_VALUE);
- }
-
- /**
- * @return session that executes the query.
- */
- public SessionImpl getSession() {
- return session;
- }
-
- /**
- * @return the item state manager of the workspace.
- */
- public ItemDataConsumer getItemStateManager() {
- return ism;
- }
-}
Deleted: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitQuery.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitQuery.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitQuery.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.exoplatform.services.jcr.impl.core.query.lucene;
-
-import java.io.IOException;
-
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.Sort;
-import org.exoplatform.services.jcr.impl.core.SessionImpl;
-
-/**
- * <code>JackrabbitQuery</code> defines an interface for Jackrabbit query
- * implementations that are at the root of the lucene query tree. It gives the
- * implementation the opportunity to execute in an optimized way returning
- * {@link QueryHits} instead of a result that is tied to Lucene.
- */
-public interface JackrabbitQuery {
-
- /**
- * Executes this query and returns {@link QueryHits} or <code>null</code> if
- * this query should be executed using the regular Lucene API.
- * <p/>
- * <b>Important note:</b> an implementation <b>must not</b> call
- * {@link JackrabbitIndexSearcher#execute(Query, Sort, long)}
- * with this query instance as a parameter, otherwise a stack overflow will
- * occur.
- *
- * @param searcher the jackrabbit index searcher.
- * @param session the session that executes the query.
- * @param sort the sort criteria that must be reflected in the returned
- * {@link QueryHits}.
- * @return the query hits or <code>null</code> if the regular Lucene API
- * should be used by the caller.
- * @throws IOException if an error occurs while executing the query.
- */
- public QueryHits execute(JackrabbitIndexSearcher searcher,
- SessionImpl session,
- Sort sort)
- throws IOException;
-}
Deleted: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitQueryParser.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitQueryParser.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitQueryParser.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -1,205 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.exoplatform.services.jcr.impl.core.query.lucene;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.Query;
-
-/**
- * <code>JackrabbitQueryParser</code> extends the standard lucene query parser
- * and adds JCR specific customizations.
- */
-public class JackrabbitQueryParser extends QueryParser {
-
- /**
- * The Jackrabbit synonym provider or <code>null</code> if there is none.
- */
- private final SynonymProvider synonymProvider;
-
- /**
- * Creates a new query parser instance.
- *
- * @param fieldName the field name.
- * @param analyzer the analyzer.
- * @param synonymProvider the synonym provider or <code>null</code> if none
- * is available.
- */
- public JackrabbitQueryParser(String fieldName,
- Analyzer analyzer,
- SynonymProvider synonymProvider) {
- super(fieldName, analyzer);
- this.synonymProvider = synonymProvider;
- setAllowLeadingWildcard(true);
- setDefaultOperator(Operator.AND);
- }
-
- /**
- * {@inheritDoc}
- */
- public Query parse(String textsearch) throws ParseException {
- // replace escaped ' with just '
- StringBuffer rewritten = new StringBuffer();
- // the default lucene query parser recognizes 'AND' and 'NOT' as
- // keywords.
- textsearch = textsearch.replaceAll("AND", "and");
- textsearch = textsearch.replaceAll("NOT", "not");
- boolean escaped = false;
- for (int i = 0; i < textsearch.length(); i++) {
- if (textsearch.charAt(i) == '\\') {
- if (escaped) {
- rewritten.append("\\\\");
- escaped = false;
- } else {
- escaped = true;
- }
- } else if (textsearch.charAt(i) == '\'') {
- if (escaped) {
- escaped = false;
- }
- rewritten.append(textsearch.charAt(i));
- } else if (textsearch.charAt(i) == '~') {
- if (i == 0 || Character.isWhitespace(textsearch.charAt(i - 1))) {
- // escape tilde so we can use it for similarity query
- rewritten.append("\\");
- }
- rewritten.append('~');
- } else {
- if (escaped) {
- rewritten.append('\\');
- escaped = false;
- }
- rewritten.append(textsearch.charAt(i));
- }
- }
- return super.parse(rewritten.toString());
- }
-
- /**
- * Factory method for generating a synonym query.
- * Called when parser parses an input term token that has the synonym
- * prefix (~term) prepended.
- *
- * @param field Name of the field query will use.
- * @param termStr Term token to use for building term for the query
- *
- * @return Resulting {@link Query} built for the term
- * @exception ParseException throw in overridden method to disallow
- */
- protected Query getSynonymQuery(String field, String termStr)
- throws ParseException {
- List synonyms = new ArrayList();
- synonyms.add(new BooleanClause(getFieldQuery(field, termStr),
- BooleanClause.Occur.SHOULD));
- if (synonymProvider != null) {
- String[] terms = synonymProvider.getSynonyms(termStr);
- for (int i = 0; i < terms.length; i++) {
- synonyms.add(new BooleanClause(getFieldQuery(field, terms[i]),
- BooleanClause.Occur.SHOULD));
- }
- }
- if (synonyms.size() == 1) {
- return ((BooleanClause) synonyms.get(0)).getQuery();
- } else {
- return getBooleanQuery(synonyms);
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- protected Query getFieldQuery(String field, String queryText)
- throws ParseException {
- if (queryText.startsWith("~")) {
- // synonym query
- return getSynonymQuery(field, queryText.substring(1));
- } else {
- return super.getFieldQuery(field, queryText);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected Query getPrefixQuery(String field, String termStr)
- throws ParseException {
- return getWildcardQuery(field, termStr + "*");
- }
-
- /**
- * {@inheritDoc}
- */
- protected Query getWildcardQuery(String field, String termStr)
- throws ParseException {
- if (getLowercaseExpandedTerms()) {
- termStr = termStr.toLowerCase();
- }
- return new WildcardQuery(field, null, translateWildcards(termStr));
- }
-
- /**
- * Translates unescaped wildcards '*' and '?' into '%' and '_'.
- *
- * @param input the input String.
- * @return the translated String.
- */
- private String translateWildcards(String input) {
- StringBuffer translated = new StringBuffer(input.length());
- boolean escaped = false;
- for (int i = 0; i < input.length(); i++) {
- if (input.charAt(i) == '\\') {
- if (escaped) {
- translated.append("\\\\");
- escaped = false;
- } else {
- escaped = true;
- }
- } else if (input.charAt(i) == '*') {
- if (escaped) {
- translated.append('*');
- escaped = false;
- } else {
- translated.append('%');
- }
- } else if (input.charAt(i) == '?') {
- if (escaped) {
- translated.append('?');
- escaped = false;
- } else {
- translated.append('_');
- }
- } else if (input.charAt(i) == '%' || input.charAt(i) == '_') {
- // escape every occurrence of '%' and '_'
- escaped = false;
- translated.append('\\').append(input.charAt(i));
- } else {
- if (escaped) {
- translated.append('\\');
- escaped = false;
- }
- translated.append(input.charAt(i));
- }
- }
- return translated.toString();
- }
-}
Deleted: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitTermQuery.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitTermQuery.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitTermQuery.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.exoplatform.services.jcr.impl.core.query.lucene;
-
-import java.io.IOException;
-
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.Explanation;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.Scorer;
-import org.apache.lucene.search.Searcher;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.Weight;
-
-/**
- * <code>JackrabbitTermQuery</code> implements a {@link TermQuery} where score
- * values are retrieved on a per index segment basis using {@link MultiScorer}.
- */
-public class JackrabbitTermQuery extends TermQuery {
-
- private static final long serialVersionUID = 4244799812287335957L;
-
- public JackrabbitTermQuery(Term t) {
- super(t);
- }
-
- protected Weight createWeight(Searcher searcher) throws IOException {
- return new JackrabbitTermWeight(searcher, super.createWeight(searcher));
- }
-
- /**
- * The weight implementation.
- */
- protected class JackrabbitTermWeight extends AbstractWeight {
-
- private static final long serialVersionUID = -2070964510010945854L;
-
- /**
- * The default lucene TermQuery weight.
- */
- private final Weight weight;
-
- public JackrabbitTermWeight(Searcher searcher, Weight weight) {
- super(searcher);
- this.weight = weight;
- }
-
- /**
- * {@inheritDoc}
- */
- protected Scorer createScorer(IndexReader reader) throws IOException {
- return weight.scorer(reader);
- }
-
- /**
- * {@inheritDoc}
- */
- public Query getQuery() {
- return JackrabbitTermQuery.this;
- }
-
- /**
- * {@inheritDoc}
- */
- public float getValue() {
- return weight.getValue();
- }
-
- /**
- * {@inheritDoc}
- */
- public float sumOfSquaredWeights() throws IOException {
- return weight.sumOfSquaredWeights();
- }
-
- /**
- * {@inheritDoc}
- */
- public void normalize(float norm) {
- weight.normalize(norm);
- }
-
- /**
- * {@inheritDoc}
- */
- public Explanation explain(IndexReader reader, int doc) throws
- IOException {
- return weight.explain(reader, doc);
- }
- }
-}
Deleted: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitTextExtractor.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitTextExtractor.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitTextExtractor.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -1,182 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.exoplatform.services.jcr.impl.core.query.lucene;
-
-//
-///**
-// * Backwards-compatible Jackrabbit text extractor component. This class
-// * implements the following functionality:
-// * <ul>
-// * <li>
-// * Parses the configured {@link TextExtractor} and {@link TextFilter}
-// * class names and instantiates the configured classes.
-// * </li>
-// * <li>
-// * Acts as the delegate extractor for any configured
-// * {@link DelegatingTextExtractor} instances.
-// * </li>
-// * <li>
-// * Maintains a {@link CompositeTextExtractor} instance that contains
-// * all the configured extractors and to which all text extraction calls
-// * are delegated.
-// * </li>
-// * <li>
-// * Creates a {@link TextFilterExtractor} adapter for a configured
-// * {@link TextFilter} instance when it is first used and adds that adapter
-// * to the composite extractor for use in text extraction.
-// * </li>
-// * <li>
-// * Logs a warning and creates a dummy {@link EmptyTextExtractor} instance
-// * for any unsupported content types when first detected. The dummy
-// * extractor is added to the composite extractor to prevent future
-// * warnings about the same content type.
-// * </li>
-// * </ul>
-// */
-public class JackrabbitTextExtractor
-{
- //implements TextExtractor {
-
- // /**
- // * Logger instance.
- // */
- // private static final Logger logger =
- // LoggerFactory.getLogger(JackrabbitTextExtractor.class);
- //
- // /**
- // * Set of content types that are known to be supported by the
- // * composite extractor.
- // */
- // private final Set types = new HashSet();
- //
- // /**
- // * Composite extractor used to for all text extration tasks. Contains
- // * all the {@link TextExtractor} instances for directly supported content
- // * types, the {@link TextFilterExtractor} adapters for backwards
- // * compatibility with configured {@link TextFilter} instances that have
- // * already been used, and the dummy {@link EmptyTextExtractor} instances
- // * created for unsupported content types.
- // */
- // private final CompositeTextExtractor extractor =
- // new CompositeTextExtractor();
- //
- // /**
- // * Configured {@link TextFilter} instances. Used for backwards
- // * compatibility with existing configuration files and {@link TextFilter}
- // * implementations.
- // */
- // private final Collection filters = new ArrayList();
- //
- // /**
- // * Creates a Jackrabbit text extractor containing the configured component
- // * classes.
- // *
- // * @param classes configured {@link TextExtractor} (and {@link TextFilter})
- // * class names (space- or comma-separated)
- // */
- // public JackrabbitTextExtractor(String classes) {
- // logger.debug("JackrabbitTextExtractor({})", classes);
- // StringTokenizer tokenizer = new StringTokenizer(classes, ", \t\n\r\f");
- // while (tokenizer.hasMoreTokens()) {
- // String name = tokenizer.nextToken();
- // try {
- // Object object = Class.forName(name).newInstance();
- // if (object instanceof DelegatingTextExtractor) {
- // ((DelegatingTextExtractor) object)
- // .setDelegateTextExtractor(this);
- // }
- // if (object instanceof TextExtractor) {
- // extractor.addTextExtractor((TextExtractor) object);
- // } else if (object instanceof TextFilter) {
- // filters.add(object);
- // } else {
- // logger.warn("Unknown text extractor class: {}", name);
- // }
- // } catch (ClassNotFoundException e) {
- // logger.warn("Extractor class not found: " + name, e);
- // } catch (LinkageError e) {
- // logger.warn("Extractor dependency not found: " + name, e);
- // } catch (IllegalAccessException e) {
- // logger.warn("Extractor constructor not accessible: " + name, e);
- // } catch (InstantiationException e) {
- // logger.warn("Extractor instantiation failed: " + name, e);
- // }
- // }
- //
- // types.addAll(Arrays.asList(extractor.getContentTypes()));
- // }
- //
- // //-------------------------------------------------------< TextExtractor >
- //
- // /**
- // * Returns the content types that the component extractors are known
- // * to support.
- // *
- // * @return supported content types
- // */
- // public String[] getContentTypes() {
- // return extractor.getContentTypes(); // and then some
- // }
- //
- // /**
- // * Extracts the text content from the given binary stream. The given
- // * content type is used to look up a configured text extractor to which
- // * to delegate the request.
- // * <p>
- // * If a matching extractor is not found, then the configured text filters
- // * searched for an instance that claims to support the given content type.
- // * A text extractor adapter is created for that filter and saved in the
- // * extractor map for future use before delegating the request to the
- // * adapter.
- // * <p>
- // * If not even a text filter is found for the given content type, a warning
- // * is logged and an empty text extractor is created for that content type
- // * and saved in the extractor map for future use before delegating the
- // * request to the empty extractor.
- // *
- // * @param stream binary stream
- // * @param type content type
- // * @param encoding character encoding, or <code>null</code>
- // * @return reader for the text content of the binary stream
- // * @throws IOException if the binary stream can not be read
- // */
- // public Reader extractText(InputStream stream, String type, String encoding)
- // throws IOException {
- // logger.debug("extractText(stream, {}, {})", type, encoding);
- // if (!types.contains(type)) {
- // Iterator iterator = filters.iterator();
- // while (iterator.hasNext()) {
- // TextFilter filter = (TextFilter) iterator.next();
- // if (filter.canFilter(type)) {
- // types.add(type);
- // extractor.addTextExtractor(
- // new TextFilterExtractor(type, filter));
- // break;
- // }
- // }
- // }
- //
- // if (!types.contains(type)) {
- // logger.debug("Full text indexing of {} is not supported", type);
- // types.add(type);
- // extractor.addTextExtractor(new EmptyTextExtractor(type));
- // }
- //
- // return extractor.extractText(stream, type, encoding);
- // }
-
-}
Copied: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrIndexReader.java (from rev 230, jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitIndexReader.java)
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrIndexReader.java (rev 0)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrIndexReader.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.exoplatform.services.jcr.impl.core.query.lucene;
+
+import java.io.IOException;
+
+
+import org.apache.lucene.index.FilterIndexReader;
+import org.apache.lucene.index.IndexReader;
+
+/**
+ * <code>JackrabbitIndexReader</code> wraps an index reader and
+ * {@link ReleaseableIndexReader#release() releases} the underlying reader
+ * when a client calls {@link #close()} on this reader. This allows reusing
+ * of the underlying index reader instance.
+ */
+public final class JcrIndexReader
+ extends FilterIndexReader
+ implements HierarchyResolver, MultiIndexReader {
+
+ /**
+ * The hierarchy resolver.
+ */
+ private final HierarchyResolver resolver;
+
+ /**
+ * The underlying index reader exposed as a {@link MultiIndexReader}.
+ */
+ private final MultiIndexReader reader;
+
+ /**
+ * Creates a new <code>JackrabbitIndexReader</code>. The passed index reader
+ * must also implement the interfaces {@link HierarchyResolver} and
+ * {@link MultiIndexReader}.
+ *
+ * @param in the underlying index reader.
+ * @throws IllegalArgumentException if <code>in</code> does not implement
+ * {@link HierarchyResolver} and
+ * {@link MultiIndexReader}.
+ */
+ public JcrIndexReader(IndexReader in) {
+ super(in);
+ if (!(in instanceof MultiIndexReader)) {
+ throw new IllegalArgumentException("IndexReader must also implement MultiIndexReader");
+ }
+ if (!(in instanceof HierarchyResolver)) {
+ throw new IllegalArgumentException("IndexReader must also implement HierarchyResolver");
+ }
+ this.resolver = (HierarchyResolver) in;
+ this.reader = (MultiIndexReader) in;
+ }
+
+ //--------------------------< FilterIndexReader >---------------------------
+
+ /**
+ * Calls release on the underlying {@link MultiIndexReader} instead of
+ * closing it.
+ *
+ * @throws IOException if an error occurs while releaseing the underlying
+ * index reader.
+ */
+ protected void doClose() throws IOException {
+ reader.release();
+ }
+
+ //------------------------< HierarchyResolver >-----------------------------
+
+ /**
+ * {@inheritDoc}
+ */
+ public int[] getParents(int n, int[] docNumbers) throws IOException {
+ return resolver.getParents(n, docNumbers);
+ }
+
+ //-------------------------< MultiIndexReader >-----------------------------
+
+ /**
+ * {@inheritDoc}
+ */
+ public IndexReader[] getIndexReaders() {
+ return reader.getIndexReaders();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ForeignSegmentDocId createDocId(String uuid) throws IOException {
+ return reader.createDocId(uuid);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getDocumentNumber(ForeignSegmentDocId docId) throws IOException {
+ return reader.getDocumentNumber(docId);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void release() throws IOException {
+ reader.release();
+ }
+}
Property changes on: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrIndexReader.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrIndexSearcher.java (from rev 230, jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitIndexSearcher.java)
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrIndexSearcher.java (rev 0)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrIndexSearcher.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.exoplatform.services.jcr.impl.core.query.lucene;
+
+import java.io.IOException;
+
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Sort;
+import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.jcr.impl.core.query.lucene.constraint.EvaluationContext;
+
+/**
+ * <code>JackrabbitIndexSearcher</code> implements an index searcher with
+ * jackrabbit specific optimizations.
+ */
+public class JcrIndexSearcher
+ extends IndexSearcher
+ implements EvaluationContext {
+
+ /**
+ * The session that executes the query.
+ */
+ private final SessionImpl session;
+
+ /**
+ * The underlying index reader.
+ */
+ private final IndexReader reader;
+
+ /**
+ * The item state manager of the workspace.
+ */
+ private final ItemDataConsumer ism;
+
+ /**
+ * Creates a new jackrabbit index searcher.
+ *
+ * @param s the session that executes the query.
+ * @param r the index reader.
+ * @param ism the shared item state manager.
+ */
+ public JcrIndexSearcher(SessionImpl s,
+ IndexReader r,
+ ItemDataConsumer ism) {
+ super(r);
+ this.session = s;
+ this.reader = r;
+ this.ism = ism;
+ }
+
+ /**
+ * Executes the query and returns the hits that match the query.
+ *
+ * @param query the query to execute.
+ * @param sort the sort criteria.
+ * @param resultFetchHint a hint on how many results should be fetched.
+ * @param selectorName the single selector name for the query hits.
+ * @return the query hits.
+ * @throws IOException if an error occurs while executing the query.
+ */
+ public MultiColumnQueryHits execute(Query query,
+ Sort sort,
+ long resultFetchHint,
+ InternalQName selectorName)
+ throws IOException {
+ return new QueryHitsAdapter(
+ evaluate(query, sort, resultFetchHint), selectorName);
+ }
+
+ /**
+ * Evaluates the query and returns the hits that match the query.
+ *
+ * @param query the query to execute.
+ * @param sort the sort criteria.
+ * @param resultFetchHint a hint on how many results should be fetched.
+ * @return the query hits.
+ * @throws IOException if an error occurs while executing the query.
+ */
+ public QueryHits evaluate(Query query, Sort sort, long resultFetchHint)
+ throws IOException {
+ query = query.rewrite(reader);
+ QueryHits hits = null;
+ if (query instanceof JcrQuery) {
+ hits = ((JcrQuery) query).execute(this, session, sort);
+ }
+ if (hits == null) {
+ if (sort == null) {
+ hits = new LuceneQueryHits(reader, this, query);
+ } else {
+ hits = new SortedLuceneQueryHits(
+ reader, this, query, sort, resultFetchHint);
+ }
+ }
+ return hits;
+ }
+
+ //------------------------< EvaluationContext >-----------------------------
+
+ /**
+ * Evaluates the query and returns the hits that match the query.
+ *
+ * @param query the query to execute.
+ * @return the query hits.
+ * @throws IOException if an error occurs while executing the query.
+ */
+ public QueryHits evaluate(Query query) throws IOException {
+ return evaluate(query, new Sort(), Integer.MAX_VALUE);
+ }
+
+ /**
+ * @return session that executes the query.
+ */
+ public SessionImpl getSession() {
+ return session;
+ }
+
+ /**
+ * @return the item state manager of the workspace.
+ */
+ public ItemDataConsumer getItemStateManager() {
+ return ism;
+ }
+}
Property changes on: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrIndexSearcher.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrQuery.java (from rev 230, jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitQuery.java)
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrQuery.java (rev 0)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrQuery.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.exoplatform.services.jcr.impl.core.query.lucene;
+
+import java.io.IOException;
+
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Sort;
+import org.exoplatform.services.jcr.impl.core.SessionImpl;
+
+/**
+ * <code>JackrabbitQuery</code> defines an interface for Jackrabbit query
+ * implementations that are at the root of the lucene query tree. It gives the
+ * implementation the opportunity to execute in an optimized way returning
+ * {@link QueryHits} instead of a result that is tied to Lucene.
+ */
+public interface JcrQuery {
+
+ /**
+ * Executes this query and returns {@link QueryHits} or <code>null</code> if
+ * this query should be executed using the regular Lucene API.
+ * <p/>
+ * <b>Important note:</b> an implementation <b>must not</b> call
+ * {@link JcrIndexSearcher#execute(Query, Sort, long)}
+ * with this query instance as a parameter, otherwise a stack overflow will
+ * occur.
+ *
+ * @param searcher the jackrabbit index searcher.
+ * @param session the session that executes the query.
+ * @param sort the sort criteria that must be reflected in the returned
+ * {@link QueryHits}.
+ * @return the query hits or <code>null</code> if the regular Lucene API
+ * should be used by the caller.
+ * @throws IOException if an error occurs while executing the query.
+ */
+ public QueryHits execute(JcrIndexSearcher searcher,
+ SessionImpl session,
+ Sort sort)
+ throws IOException;
+}
Property changes on: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrQuery.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrQueryParser.java (from rev 230, jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitQueryParser.java)
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrQueryParser.java (rev 0)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrQueryParser.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -0,0 +1,205 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.exoplatform.services.jcr.impl.core.query.lucene;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.Query;
+
+/**
+ * <code>JackrabbitQueryParser</code> extends the standard lucene query parser
+ * and adds JCR specific customizations.
+ */
+public class JcrQueryParser extends QueryParser {
+
+ /**
+ * The Jackrabbit synonym provider or <code>null</code> if there is none.
+ */
+ private final SynonymProvider synonymProvider;
+
+ /**
+ * Creates a new query parser instance.
+ *
+ * @param fieldName the field name.
+ * @param analyzer the analyzer.
+ * @param synonymProvider the synonym provider or <code>null</code> if none
+ * is available.
+ */
+ public JcrQueryParser(String fieldName,
+ Analyzer analyzer,
+ SynonymProvider synonymProvider) {
+ super(fieldName, analyzer);
+ this.synonymProvider = synonymProvider;
+ setAllowLeadingWildcard(true);
+ setDefaultOperator(Operator.AND);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Query parse(String textsearch) throws ParseException {
+ // replace escaped ' with just '
+ StringBuffer rewritten = new StringBuffer();
+ // the default lucene query parser recognizes 'AND' and 'NOT' as
+ // keywords.
+ textsearch = textsearch.replaceAll("AND", "and");
+ textsearch = textsearch.replaceAll("NOT", "not");
+ boolean escaped = false;
+ for (int i = 0; i < textsearch.length(); i++) {
+ if (textsearch.charAt(i) == '\\') {
+ if (escaped) {
+ rewritten.append("\\\\");
+ escaped = false;
+ } else {
+ escaped = true;
+ }
+ } else if (textsearch.charAt(i) == '\'') {
+ if (escaped) {
+ escaped = false;
+ }
+ rewritten.append(textsearch.charAt(i));
+ } else if (textsearch.charAt(i) == '~') {
+ if (i == 0 || Character.isWhitespace(textsearch.charAt(i - 1))) {
+ // escape tilde so we can use it for similarity query
+ rewritten.append("\\");
+ }
+ rewritten.append('~');
+ } else {
+ if (escaped) {
+ rewritten.append('\\');
+ escaped = false;
+ }
+ rewritten.append(textsearch.charAt(i));
+ }
+ }
+ return super.parse(rewritten.toString());
+ }
+
+ /**
+ * Factory method for generating a synonym query.
+ * Called when parser parses an input term token that has the synonym
+ * prefix (~term) prepended.
+ *
+ * @param field Name of the field query will use.
+ * @param termStr Term token to use for building term for the query
+ *
+ * @return Resulting {@link Query} built for the term
+ * @exception ParseException throw in overridden method to disallow
+ */
+ protected Query getSynonymQuery(String field, String termStr)
+ throws ParseException {
+ List synonyms = new ArrayList();
+ synonyms.add(new BooleanClause(getFieldQuery(field, termStr),
+ BooleanClause.Occur.SHOULD));
+ if (synonymProvider != null) {
+ String[] terms = synonymProvider.getSynonyms(termStr);
+ for (int i = 0; i < terms.length; i++) {
+ synonyms.add(new BooleanClause(getFieldQuery(field, terms[i]),
+ BooleanClause.Occur.SHOULD));
+ }
+ }
+ if (synonyms.size() == 1) {
+ return ((BooleanClause) synonyms.get(0)).getQuery();
+ } else {
+ return getBooleanQuery(synonyms);
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Query getFieldQuery(String field, String queryText)
+ throws ParseException {
+ if (queryText.startsWith("~")) {
+ // synonym query
+ return getSynonymQuery(field, queryText.substring(1));
+ } else {
+ return super.getFieldQuery(field, queryText);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Query getPrefixQuery(String field, String termStr)
+ throws ParseException {
+ return getWildcardQuery(field, termStr + "*");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Query getWildcardQuery(String field, String termStr)
+ throws ParseException {
+ if (getLowercaseExpandedTerms()) {
+ termStr = termStr.toLowerCase();
+ }
+ return new WildcardQuery(field, null, translateWildcards(termStr));
+ }
+
+ /**
+ * Translates unescaped wildcards '*' and '?' into '%' and '_'.
+ *
+ * @param input the input String.
+ * @return the translated String.
+ */
+ private String translateWildcards(String input) {
+ StringBuffer translated = new StringBuffer(input.length());
+ boolean escaped = false;
+ for (int i = 0; i < input.length(); i++) {
+ if (input.charAt(i) == '\\') {
+ if (escaped) {
+ translated.append("\\\\");
+ escaped = false;
+ } else {
+ escaped = true;
+ }
+ } else if (input.charAt(i) == '*') {
+ if (escaped) {
+ translated.append('*');
+ escaped = false;
+ } else {
+ translated.append('%');
+ }
+ } else if (input.charAt(i) == '?') {
+ if (escaped) {
+ translated.append('?');
+ escaped = false;
+ } else {
+ translated.append('_');
+ }
+ } else if (input.charAt(i) == '%' || input.charAt(i) == '_') {
+ // escape every occurrence of '%' and '_'
+ escaped = false;
+ translated.append('\\').append(input.charAt(i));
+ } else {
+ if (escaped) {
+ translated.append('\\');
+ escaped = false;
+ }
+ translated.append(input.charAt(i));
+ }
+ }
+ return translated.toString();
+ }
+}
Property changes on: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrQueryParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrTermQuery.java (from rev 230, jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitTermQuery.java)
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrTermQuery.java (rev 0)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrTermQuery.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.exoplatform.services.jcr.impl.core.query.lucene;
+
+import java.io.IOException;
+
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.Explanation;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Scorer;
+import org.apache.lucene.search.Searcher;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.Weight;
+
+/**
+ * <code>JackrabbitTermQuery</code> implements a {@link TermQuery} where score
+ * values are retrieved on a per index segment basis using {@link MultiScorer}.
+ */
+public class JcrTermQuery extends TermQuery {
+
+ private static final long serialVersionUID = 4244799812287335957L;
+
+ public JcrTermQuery(Term t) {
+ super(t);
+ }
+
+ protected Weight createWeight(Searcher searcher) throws IOException {
+ return new JackrabbitTermWeight(searcher, super.createWeight(searcher));
+ }
+
+ /**
+ * The weight implementation.
+ */
+ protected class JackrabbitTermWeight extends AbstractWeight {
+
+ private static final long serialVersionUID = -2070964510010945854L;
+
+ /**
+ * The default lucene TermQuery weight.
+ */
+ private final Weight weight;
+
+ public JackrabbitTermWeight(Searcher searcher, Weight weight) {
+ super(searcher);
+ this.weight = weight;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Scorer createScorer(IndexReader reader) throws IOException {
+ return weight.scorer(reader);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Query getQuery() {
+ return JcrTermQuery.this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public float getValue() {
+ return weight.getValue();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public float sumOfSquaredWeights() throws IOException {
+ return weight.sumOfSquaredWeights();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void normalize(float norm) {
+ weight.normalize(norm);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Explanation explain(IndexReader reader, int doc) throws
+ IOException {
+ return weight.explain(reader, doc);
+ }
+ }
+}
Property changes on: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrTermQuery.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrTextExtractor.java (from rev 230, jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JackrabbitTextExtractor.java)
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrTextExtractor.java (rev 0)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrTextExtractor.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.exoplatform.services.jcr.impl.core.query.lucene;
+
+//
+///**
+// * Backwards-compatible Jackrabbit text extractor component. This class
+// * implements the following functionality:
+// * <ul>
+// * <li>
+// * Parses the configured {@link TextExtractor} and {@link TextFilter}
+// * class names and instantiates the configured classes.
+// * </li>
+// * <li>
+// * Acts as the delegate extractor for any configured
+// * {@link DelegatingTextExtractor} instances.
+// * </li>
+// * <li>
+// * Maintains a {@link CompositeTextExtractor} instance that contains
+// * all the configured extractors and to which all text extraction calls
+// * are delegated.
+// * </li>
+// * <li>
+// * Creates a {@link TextFilterExtractor} adapter for a configured
+// * {@link TextFilter} instance when it is first used and adds that adapter
+// * to the composite extractor for use in text extraction.
+// * </li>
+// * <li>
+// * Logs a warning and creates a dummy {@link EmptyTextExtractor} instance
+// * for any unsupported content types when first detected. The dummy
+// * extractor is added to the composite extractor to prevent future
+// * warnings about the same content type.
+// * </li>
+// * </ul>
+// */
+public class JcrTextExtractor
+{
+ //implements TextExtractor {
+
+ // /**
+ // * Logger instance.
+ // */
+ // private static final Logger logger =
+ // LoggerFactory.getLogger(JackrabbitTextExtractor.class);
+ //
+ // /**
+ // * Set of content types that are known to be supported by the
+ // * composite extractor.
+ // */
+ // private final Set types = new HashSet();
+ //
+ // /**
+ // * Composite extractor used to for all text extration tasks. Contains
+ // * all the {@link TextExtractor} instances for directly supported content
+ // * types, the {@link TextFilterExtractor} adapters for backwards
+ // * compatibility with configured {@link TextFilter} instances that have
+ // * already been used, and the dummy {@link EmptyTextExtractor} instances
+ // * created for unsupported content types.
+ // */
+ // private final CompositeTextExtractor extractor =
+ // new CompositeTextExtractor();
+ //
+ // /**
+ // * Configured {@link TextFilter} instances. Used for backwards
+ // * compatibility with existing configuration files and {@link TextFilter}
+ // * implementations.
+ // */
+ // private final Collection filters = new ArrayList();
+ //
+ // /**
+ // * Creates a Jackrabbit text extractor containing the configured component
+ // * classes.
+ // *
+ // * @param classes configured {@link TextExtractor} (and {@link TextFilter})
+ // * class names (space- or comma-separated)
+ // */
+ // public JackrabbitTextExtractor(String classes) {
+ // logger.debug("JackrabbitTextExtractor({})", classes);
+ // StringTokenizer tokenizer = new StringTokenizer(classes, ", \t\n\r\f");
+ // while (tokenizer.hasMoreTokens()) {
+ // String name = tokenizer.nextToken();
+ // try {
+ // Object object = Class.forName(name).newInstance();
+ // if (object instanceof DelegatingTextExtractor) {
+ // ((DelegatingTextExtractor) object)
+ // .setDelegateTextExtractor(this);
+ // }
+ // if (object instanceof TextExtractor) {
+ // extractor.addTextExtractor((TextExtractor) object);
+ // } else if (object instanceof TextFilter) {
+ // filters.add(object);
+ // } else {
+ // logger.warn("Unknown text extractor class: {}", name);
+ // }
+ // } catch (ClassNotFoundException e) {
+ // logger.warn("Extractor class not found: " + name, e);
+ // } catch (LinkageError e) {
+ // logger.warn("Extractor dependency not found: " + name, e);
+ // } catch (IllegalAccessException e) {
+ // logger.warn("Extractor constructor not accessible: " + name, e);
+ // } catch (InstantiationException e) {
+ // logger.warn("Extractor instantiation failed: " + name, e);
+ // }
+ // }
+ //
+ // types.addAll(Arrays.asList(extractor.getContentTypes()));
+ // }
+ //
+ // //-------------------------------------------------------< TextExtractor >
+ //
+ // /**
+ // * Returns the content types that the component extractors are known
+ // * to support.
+ // *
+ // * @return supported content types
+ // */
+ // public String[] getContentTypes() {
+ // return extractor.getContentTypes(); // and then some
+ // }
+ //
+ // /**
+ // * Extracts the text content from the given binary stream. The given
+ // * content type is used to look up a configured text extractor to which
+ // * to delegate the request.
+ // * <p>
+ // * If a matching extractor is not found, then the configured text filters
+ // * searched for an instance that claims to support the given content type.
+ // * A text extractor adapter is created for that filter and saved in the
+ // * extractor map for future use before delegating the request to the
+ // * adapter.
+ // * <p>
+ // * If not even a text filter is found for the given content type, a warning
+ // * is logged and an empty text extractor is created for that content type
+ // * and saved in the extractor map for future use before delegating the
+ // * request to the empty extractor.
+ // *
+ // * @param stream binary stream
+ // * @param type content type
+ // * @param encoding character encoding, or <code>null</code>
+ // * @return reader for the text content of the binary stream
+ // * @throws IOException if the binary stream can not be read
+ // */
+ // public Reader extractText(InputStream stream, String type, String encoding)
+ // throws IOException {
+ // logger.debug("extractText(stream, {}, {})", type, encoding);
+ // if (!types.contains(type)) {
+ // Iterator iterator = filters.iterator();
+ // while (iterator.hasNext()) {
+ // TextFilter filter = (TextFilter) iterator.next();
+ // if (filter.canFilter(type)) {
+ // types.add(type);
+ // extractor.addTextExtractor(
+ // new TextFilterExtractor(type, filter));
+ // break;
+ // }
+ // }
+ // }
+ //
+ // if (!types.contains(type)) {
+ // logger.debug("Full text indexing of {} is not supported", type);
+ // types.add(type);
+ // extractor.addTextExtractor(new EmptyTextExtractor(type));
+ // }
+ //
+ // return extractor.extractText(stream, type, encoding);
+ // }
+
+}
Property changes on: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/JcrTextExtractor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LocalNameQuery.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LocalNameQuery.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LocalNameQuery.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -55,7 +55,7 @@
*/
public Query rewrite(IndexReader reader) throws IOException {
if (version.getVersion() >= IndexFormatVersion.V3.getVersion()) {
- return new JackrabbitTermQuery(new Term(FieldNames.LOCAL_NAME, localName));
+ return new JcrTermQuery(new Term(FieldNames.LOCAL_NAME, localName));
} else {
throw new IOException("LocalNameQuery requires IndexFormatVersion V3");
}
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryBuilder.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryBuilder.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryBuilder.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -336,7 +336,7 @@
} catch (RepositoryException e) {
// will never happen, prefixes are created when unknown
}
- return new JackrabbitTermQuery(new Term(FieldNames.PROPERTIES,
+ return new JcrTermQuery(new Term(FieldNames.PROPERTIES,
FieldNames.createNamedValue(field, value)));
}
@@ -434,7 +434,7 @@
+ fieldname.substring(idx + 1);
}
- QueryParser parser = new JackrabbitQueryParser(fieldname, analyzer,
+ QueryParser parser = new JcrQueryParser(fieldname, analyzer,
synonymProvider);
Query context = parser.parse(node.getQuery());
if (relPath != null
@@ -491,17 +491,17 @@
InternalQName nameTest = steps[0].getNameTest();
if (nameTest == null) {
// this is equivalent to the root node
- context = new JackrabbitTermQuery(new Term(FieldNames.UUID,
+ context = new JcrTermQuery(new Term(FieldNames.UUID,
Constants.ROOT_UUID));
} else if (nameTest.getName().length() == 0) {
// root node
- context = new JackrabbitTermQuery(new Term(FieldNames.UUID,
+ context = new JcrTermQuery(new Term(FieldNames.UUID,
Constants.ROOT_UUID));
} else {
// then this is a node != the root node
// will never match anything!
BooleanQuery and = new BooleanQuery();
- and.add(new JackrabbitTermQuery(new Term(FieldNames.UUID,
+ and.add(new JcrTermQuery(new Term(FieldNames.UUID,
Constants.ROOT_UUID)), Occur.MUST);
and.add(new NameQuery(nameTest, indexFormatVersion,
nsMappings), Occur.MUST);
@@ -513,7 +513,7 @@
} else {
// path is 1) relative or 2) descendant-or-self
// use root node as context
- context = new JackrabbitTermQuery(new Term(FieldNames.UUID,
+ context = new JcrTermQuery(new Term(FieldNames.UUID,
Constants.ROOT_UUID));
}
} else {
@@ -789,7 +789,7 @@
} else if (transform[0] == TransformConstants.TRANSFORM_LOWER_CASE) {
q = new CaseTermQuery.Lower(t);
} else {
- q = new JackrabbitTermQuery(t);
+ q = new JcrTermQuery(t);
}
or.add(q, Occur.SHOULD);
}
@@ -888,12 +888,12 @@
} else if (transform[0] == TransformConstants.TRANSFORM_LOWER_CASE) {
q = new CaseTermQuery.Lower(t);
} else {
- q = new JackrabbitTermQuery(t);
+ q = new JcrTermQuery(t);
}
notQuery.add(q, Occur.MUST_NOT);
}
// and exclude all nodes where 'field' is multi valued
- notQuery.add(new JackrabbitTermQuery(new Term(FieldNames.MVP,
+ notQuery.add(new JcrTermQuery(new Term(FieldNames.MVP,
field)), Occur.MUST_NOT);
query = notQuery;
break;
@@ -913,7 +913,7 @@
// valued
Term t = new Term(FieldNames.PROPERTIES, FieldNames
.createNamedValue(field, stringValues[i]));
- Query svp = new NotQuery(new JackrabbitTermQuery(new Term(
+ Query svp = new NotQuery(new JcrTermQuery(new Term(
FieldNames.MVP, field)));
BooleanQuery and = new BooleanQuery();
Query q;
@@ -922,7 +922,7 @@
} else if (transform[0] == TransformConstants.TRANSFORM_LOWER_CASE) {
q = new CaseTermQuery.Lower(t);
} else {
- q = new JackrabbitTermQuery(t);
+ q = new JcrTermQuery(t);
}
and.add(q, Occur.MUST);
and.add(svp, Occur.MUST);
@@ -1043,7 +1043,7 @@
*/
private Query createSingleValueConstraint(Query q, String propName) {
// get nodes with multi-values in propName
- Query mvp = new JackrabbitTermQuery(new Term(FieldNames.MVP, propName));
+ Query mvp = new JcrTermQuery(new Term(FieldNames.MVP, propName));
// now negate, that gives the nodes that have propName as single
// values but also all others
Query svp = new NotQuery(mvp);
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneVirtualTableResolver.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneVirtualTableResolver.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneVirtualTableResolver.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -132,13 +132,13 @@
query = new BooleanQuery();
} else if (terms.size() == 1) {
- query = new JackrabbitTermQuery(terms.get(0));
+ query = new JcrTermQuery(terms.get(0));
} else {
final BooleanQuery b = new BooleanQuery();
for (final Object element : terms) {
// b.add(new TermQuery((Term) element), Occur.SHOULD);
- b.add(new JackrabbitTermQuery((Term) element), Occur.SHOULD);
+ b.add(new JcrTermQuery((Term) element), Occur.SHOULD);
}
query = b;
}
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MatchAllDocsQuery.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MatchAllDocsQuery.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MatchAllDocsQuery.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -25,16 +25,16 @@
/**
* <code>MatchAllDocsQuery</code> extends the lucene <code>MatchAllDocsQuery</code>
- * and in addition implements {@link JackrabbitQuery}.
+ * and in addition implements {@link JcrQuery}.
*/
public class MatchAllDocsQuery
extends org.apache.lucene.search.MatchAllDocsQuery
- implements JackrabbitQuery {
+ implements JcrQuery {
/**
* {@inheritDoc}
*/
- public QueryHits execute(JackrabbitIndexSearcher searcher,
+ public QueryHits execute(JcrIndexSearcher searcher,
SessionImpl session,
Sort sort) throws IOException {
if (sort.getSort().length == 0) {
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MoreLikeThis.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MoreLikeThis.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MoreLikeThis.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -564,7 +564,7 @@
while (((cur = q.pop()) != null)) {
Object[] ar = (Object[]) cur;
- TermQuery tq = new JackrabbitTermQuery(new Term((String) ar[1], (String) ar[0]));
+ TermQuery tq = new JcrTermQuery(new Term((String) ar[1], (String) ar[0]));
if (boost) {
if (qterms == 0) {
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiColumnQuery.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiColumnQuery.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiColumnQuery.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -35,7 +35,7 @@
* @return the query hits.
* @throws IOException if an error occurs while executing the query.
*/
- public MultiColumnQueryHits execute(JackrabbitIndexSearcher searcher,
+ public MultiColumnQueryHits execute(JcrIndexSearcher searcher,
Sort sort,
long resultFetchHint)
throws IOException;
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiColumnQueryAdapter.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiColumnQueryAdapter.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiColumnQueryAdapter.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -64,7 +64,7 @@
/**
* {@inheritDoc}
*/
- public MultiColumnQueryHits execute(JackrabbitIndexSearcher searcher,
+ public MultiColumnQueryHits execute(JcrIndexSearcher searcher,
Sort sort,
long resultFetchHint)
throws IOException {
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NameQuery.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NameQuery.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NameQuery.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -76,16 +76,16 @@
if (version.getVersion() >= IndexFormatVersion.V3.getVersion()) {
// use LOCAL_NAME and NAMESPACE_URI field
BooleanQuery name = new BooleanQuery();
- name.add(new JackrabbitTermQuery(new Term(FieldNames.NAMESPACE_URI, nodeName.getNamespace())),
+ name.add(new JcrTermQuery(new Term(FieldNames.NAMESPACE_URI, nodeName.getNamespace())),
BooleanClause.Occur.MUST);
- name.add(new JackrabbitTermQuery(new Term(FieldNames.LOCAL_NAME,
+ name.add(new JcrTermQuery(new Term(FieldNames.LOCAL_NAME,
nodeName.getName())),
BooleanClause.Occur.MUST);
return name;
} else {
// use LABEL field
try {
- return new JackrabbitTermQuery(new Term(FieldNames.LABEL,
+ return new JcrTermQuery(new Term(FieldNames.LABEL,
nsMappings.translateName(nodeName)));
} catch (IllegalNameException e) {
throw Util.createIOException(e);
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NameRangeQuery.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NameRangeQuery.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NameRangeQuery.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -99,7 +99,7 @@
{
RangeQuery localNames = new RangeQuery(getLowerLocalNameTerm(), getUpperLocalNameTerm(), inclusive);
BooleanQuery query = new BooleanQuery();
- query.add(new JackrabbitTermQuery(new Term(FieldNames.NAMESPACE_URI, getNamespaceURI())),
+ query.add(new JcrTermQuery(new Term(FieldNames.NAMESPACE_URI, getNamespaceURI())),
BooleanClause.Occur.MUST);
query.add(localNames, BooleanClause.Occur.MUST);
return query.rewrite(reader);
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryHitsQuery.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryHitsQuery.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryHitsQuery.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -39,7 +39,7 @@
* <code>QueryHitsQuery</code> exposes a {@link QueryHits} implementation again
* as a Lucene Query.
*/
-public class QueryHitsQuery extends Query implements JackrabbitQuery{
+public class QueryHitsQuery extends Query implements JcrQuery{
/**
* The underlying query hits.
@@ -81,7 +81,7 @@
/**
* {@inheritDoc}
*/
- public QueryHits execute(JackrabbitIndexSearcher searcher,
+ public QueryHits execute(JcrIndexSearcher searcher,
SessionImpl session,
Sort sort) throws IOException {
if (sort.getSort().length == 0) {
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -804,7 +804,7 @@
Sort sort = new Sort(createSortFields(orderProps, orderSpecs));
final IndexReader reader = getIndexReader(queryImpl.needsSystemTree());
- JackrabbitIndexSearcher searcher = new JackrabbitIndexSearcher(session,
+ JcrIndexSearcher searcher = new JcrIndexSearcher(session,
reader, getContext().getItemStateManager());
searcher.setSimilarity(getSimilarity());
return new FilterMultiColumnQueryHits(searcher.execute(query, sort,
@@ -848,7 +848,7 @@
Sort sort = new Sort(createSortFields(orderProps, orderSpecs));
final IndexReader reader = getIndexReader();
- JackrabbitIndexSearcher searcher = new JackrabbitIndexSearcher(session,
+ JcrIndexSearcher searcher = new JcrIndexSearcher(session,
reader, getContext().getItemStateManager());
searcher.setSimilarity(getSimilarity());
return new FilterMultiColumnQueryHits(query.execute(searcher, sort,
@@ -1024,7 +1024,7 @@
} else {
reader = index.getIndexReader();
}
- return new JackrabbitIndexReader(reader);
+ return new JcrIndexReader(reader);
}
/**
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SortedLuceneQueryHits.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SortedLuceneQueryHits.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SortedLuceneQueryHits.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -59,7 +59,7 @@
/**
* The index searcher.
*/
- private final JackrabbitIndexSearcher searcher;
+ private final JcrIndexSearcher searcher;
/**
* The query to execute.
@@ -102,7 +102,7 @@
* @throws IOException if an error occurs while reading from the index.
*/
public SortedLuceneQueryHits(IndexReader reader,
- JackrabbitIndexSearcher searcher,
+ JcrIndexSearcher searcher,
Query query,
Sort sort,
long resultFetchHint) throws IOException {
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -103,7 +103,7 @@
public static Query createMatchAllQuery(String name, IndexFormatVersion version) {
if (version.getVersion() >= IndexFormatVersion.V2.getVersion()) {
// new index format style
- return new JackrabbitTermQuery(new Term(FieldNames.PROPERTIES_SET, name));
+ return new JcrTermQuery(new Term(FieldNames.PROPERTIES_SET, name));
} else {
return new MatchAllQuery(name);
}
Modified: jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestExcerpt.java
===================================================================
--- jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestExcerpt.java 2009-10-06 14:11:58 UTC (rev 233)
+++ jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestExcerpt.java 2009-10-06 14:57:30 UTC (rev 234)
@@ -46,18 +46,19 @@
+ "the configuration parameter for this setting is:" + "This is the test for Excerpt query";
private String string1_excerpt =
- "<div><span>the configuration parameter for this setting is:This is the "
- + "<strong>test</strong> for Excerpt query</span></div>";
+ "<div><span>Node1 Additionally there is a parameter that controls the format of the "
+ + "<strong>excerpt</strong> created. In JCR 1.9 the default is set ...</span><span>"
+ + "the configuration parameter for this setting is:This is the test for "
+ + "<strong>Excerpt</strong> query</span></div>";
private String s2 =
- "It is a test for Excerpt query.Searching with synonyms is integrated in the jcr:contains() "
+ "It is a test for excerpt query.Searching with synonyms is integrated in the jcr:contains() "
+ "function and uses the same syntax " + "like synonym searches with Google. If a search "
+ "term is prefixed with ~ also synonyms of the search term are considered. Example:";
private String string2_excerpt =
- "<div><span>Node2 It is a <strong>test</strong> for Excerpt query."
- + "Searching with synonyms is integrated in the jcr:contains() function and "
- + "uses the same syntax like synonym ...</span></div>";
+ // "<div><span>It is a test for <strong>excerpt</strong> query.Searching with synonyms is integrated in the jcr:contains() function and uses the same syntax like synonym searches ...</span></div>";
+ "<div><span>Node2 It is a test for <strong>excerpt</strong> query.Searching with synonyms is integrated in the jcr:contains() function and uses the same syntax like synonym ...</span></div>";
private String s3 = "JCR supports such features as Lucene Fuzzy Searches";
@@ -104,15 +105,17 @@
public void testExcerpt() throws Exception
{
- Node node1 = testRoot.addNode("Node1", "exo:article");
+ Node excerptTest = testRoot.addNode("testExcerpt");
+
+ Node node1 = excerptTest.addNode("Node1", "exo:article");
node1.setProperty("exo:title", "Node1");
node1.setProperty("exo:text", s1);
- Node node2 = testRoot.addNode("Node2", "exo:article");
+ Node node2 = excerptTest.addNode("Node2", "exo:article");
node2.setProperty("exo:title", "Node2");
node2.setProperty("exo:text", s2);
- Node node3 = testRoot.addNode("Node3", "exo:article");
+ Node node3 = excerptTest.addNode("Node3", "exo:article");
node3.setProperty("exo:title", "Node3");
node3.setProperty("exo:text", s3);
@@ -120,37 +123,47 @@
QueryManager queryManager = testSession.getWorkspace().getQueryManager();
Query q1 =
- queryManager.createQuery("select exo:text, excerpt(.) from exo:article where contains(., 'test')", Query.SQL);
- QueryResult result1 = q1.execute();
- for (RowIterator it = result1.getRows(); it.hasNext();)
+ queryManager.createQuery("select exo:text, excerpt(.) from exo:article where jcr:path LIKE '"
+ + excerptTest.getPath() + "/%' and contains(., 'excerpt') ORDER BY exo:title", Query.SQL);
+ for (int i = 0; i < 10; i++)
{
- Row r = it.nextRow();
- Value excerpt = r.getValue("rep:excerpt(.)");
- Value text = r.getValue("exo:text");
- if (text.getString().equals(s1))
- {
- assertEquals(string1_excerpt, excerpt.getString());
- }
- else if (text.getString().equals(s2))
- {
- assertEquals(string2_excerpt, excerpt.getString());
- }
+ checkResult(q1);
}
- Query q2 = queryManager.createQuery("//*[jcr:contains(., 'test')]/(@exo:text|rep:excerpt(.))", Query.XPATH);
- QueryResult result2 = q2.execute();
- for (RowIterator it = result2.getRows(); it.hasNext();)
+ Query q2 =
+ queryManager.createQuery("/jcr:root/" + excerptTest.getPath()
+ + "//*[jcr:contains(., 'excerpt')]/(@exo:text|rep:excerpt(.)) order by @exo:title", Query.XPATH);
+ for (int i = 0; i < 10; i++)
{
+ checkResult(q2);
+ }
+
+ }
+
+ private void checkResult(Query query) throws RepositoryException
+ {
+ QueryResult result2 = query.execute();
+ RowIterator rows = result2.getRows();
+ assertEquals(2, rows.getSize());
+
+ for (RowIterator it = rows; it.hasNext();)
+ {
Row r = it.nextRow();
Value excerpt = r.getValue("rep:excerpt(.)");
Value text = r.getValue("exo:text");
+ System.out.println(excerpt.getString());
+ System.out.println(text.getString());
+
if (text.getString().equals(s1))
{
- assertEquals(string1_excerpt, excerpt.getString());
+ System.out.println("s1" + string1_excerpt.equals(excerpt.getString()));
+
+ //assertEquals(string1_excerpt, excerpt.getString());
}
else if (text.getString().equals(s2))
{
- assertEquals(string2_excerpt, excerpt.getString());
+ System.out.println("s2" + string2_excerpt.equals(excerpt.getString()));
+ //assertEquals(string2_excerpt, excerpt.getString());
}
}
}
14 years, 12 months
exo-jcr SVN: r233 - in kernel/trunk/container/src: test/java/org/exoplatform/container and 1 other directory.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2009-10-06 10:11:58 -0400 (Tue, 06 Oct 2009)
New Revision: 233
Modified:
kernel/trunk/container/src/main/java/org/exoplatform/container/PortalContainerContext.java
kernel/trunk/container/src/test/java/org/exoplatform/container/TestPortalContainerInitTaskContextComparator.java
kernel/trunk/container/src/test/java/org/exoplatform/container/TestWebAppInitContextComparator.java
Log:
EXOJCR-166: Support separated ear delivery
Upgrade to servlet api 2.5
Modified: kernel/trunk/container/src/main/java/org/exoplatform/container/PortalContainerContext.java
===================================================================
--- kernel/trunk/container/src/main/java/org/exoplatform/container/PortalContainerContext.java 2009-10-05 15:26:29 UTC (rev 232)
+++ kernel/trunk/container/src/main/java/org/exoplatform/container/PortalContainerContext.java 2009-10-06 14:11:58 UTC (rev 233)
@@ -363,4 +363,15 @@
{
getPortalContext().setAttribute(name, object);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getContextPath()
+ {
+ StringBuilder result = new StringBuilder();
+ result.append('/');
+ result.append(container.getName());
+ return result.toString();
+ }
}
Modified: kernel/trunk/container/src/test/java/org/exoplatform/container/TestPortalContainerInitTaskContextComparator.java
===================================================================
--- kernel/trunk/container/src/test/java/org/exoplatform/container/TestPortalContainerInitTaskContextComparator.java 2009-10-05 15:26:29 UTC (rev 232)
+++ kernel/trunk/container/src/test/java/org/exoplatform/container/TestPortalContainerInitTaskContextComparator.java 2009-10-06 14:11:58 UTC (rev 233)
@@ -210,5 +210,10 @@
}
+ public String getContextPath()
+ {
+ return null;
+ }
+
}
}
Modified: kernel/trunk/container/src/test/java/org/exoplatform/container/TestWebAppInitContextComparator.java
===================================================================
--- kernel/trunk/container/src/test/java/org/exoplatform/container/TestWebAppInitContextComparator.java 2009-10-05 15:26:29 UTC (rev 232)
+++ kernel/trunk/container/src/test/java/org/exoplatform/container/TestWebAppInitContextComparator.java 2009-10-06 14:11:58 UTC (rev 233)
@@ -208,5 +208,10 @@
}
+ public String getContextPath()
+ {
+ return null;
+ }
+
}
}
14 years, 12 months
exo-jcr SVN: r232 - jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-10-05 11:26:29 -0400 (Mon, 05 Oct 2009)
New Revision: 232
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingConfigurationImpl.java
Log:
EXOJCR-161 : test updated
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingConfigurationImpl.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingConfigurationImpl.java 2009-10-05 15:17:03 UTC (rev 231)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingConfigurationImpl.java 2009-10-05 15:26:29 UTC (rev 232)
@@ -59,1022 +59,1130 @@
* <code>IndexingConfigurationImpl</code> implements a concrete indexing
* configuration.
*/
-public class IndexingConfigurationImpl implements IndexingConfiguration {
+public class IndexingConfigurationImpl implements IndexingConfiguration
+{
- /**
- * The logger instance for this class
- */
- private static final Logger log = LoggerFactory
- .getLogger(IndexingConfigurationImpl.class);
+ /**
+ * The logger instance for this class
+ */
+ private static final Logger log = LoggerFactory.getLogger(IndexingConfigurationImpl.class);
- /**
- * The path factory instance.
- */
- // private static final PathFactory PATH_FACTORY =
- // PathFactoryImpl.getInstance();
- /**
- * A namespace resolver for parsing QNames in the configuration.
- */
- private LocationFactory resolver;
+ /**
+ * The path factory instance.
+ */
+ // private static final PathFactory PATH_FACTORY =
+ // PathFactoryImpl.getInstance();
+ /**
+ * A namespace resolver for parsing QNames in the configuration.
+ */
+ private LocationFactory resolver;
- /**
- * The item state manager to retrieve additional item states.
- */
- private ItemDataConsumer ism;
+ /**
+ * The item state manager to retrieve additional item states.
+ */
+ private ItemDataConsumer ism;
- /**
- * A hierarchy resolver for the item state manager.
- */
- // private HierarchyManager hmgr;
- /**
- * The {@link IndexingRule}s inside this configuration.
- */
- private Map<InternalQName, List<IndexingRule>> configElements = new HashMap<InternalQName, List<IndexingRule>>();
+ /**
+ * A hierarchy resolver for the item state manager.
+ */
+ // private HierarchyManager hmgr;
+ /**
+ * The {@link IndexingRule}s inside this configuration.
+ */
+ private Map<InternalQName, List<IndexingRule>> configElements = new HashMap<InternalQName, List<IndexingRule>>();
- /**
- * The indexing aggregates inside this configuration.
- */
- private AggregateRule[] aggregateRules;
+ /**
+ * The indexing aggregates inside this configuration.
+ */
+ private AggregateRule[] aggregateRules;
- /**
- * The configured analyzers for indexing properties.
- */
- private Map<String, Analyzer> analyzers = new HashMap<String, Analyzer>();
+ /**
+ * The configured analyzers for indexing properties.
+ */
+ private Map<String, Analyzer> analyzers = new HashMap<String, Analyzer>();
- /**
- * {@inheritDoc}
- */
- public void init(Element config, QueryHandlerContext context,
- NamespaceMappings nsMappings) throws Exception {
- ism = context.getItemStateManager();
+ /**
+ * {@inheritDoc}
+ */
+ public void init(Element config, QueryHandlerContext context, NamespaceMappings nsMappings) throws Exception
+ {
+ ism = context.getItemStateManager();
- NamespaceAccessor nsResolver = new AdditionalNamespaceResolver(
- getNamespaces(config));
- resolver = new LocationFactory(nsResolver);// new
- // ParsingNameResolver(NameFactoryImpl.getInstance(),
- // nsResolver);
+ NamespaceAccessor nsResolver = new AdditionalNamespaceResolver(getNamespaces(config));
+ resolver = new LocationFactory(nsResolver);// new
+ // ParsingNameResolver(NameFactoryImpl.getInstance(),
+ // nsResolver);
- NodeTypeDataManager ntReg = context.getNodeTypeDataManager();
- List<NodeTypeData> ntNames = ntReg.getAllNodeTypes();
- List<AggregateRuleImpl> idxAggregates = new ArrayList<AggregateRuleImpl>();
- NodeList indexingConfigs = config.getChildNodes();
- for (int i = 0; i < indexingConfigs.getLength(); i++) {
- Node configNode = indexingConfigs.item(i);
- if (configNode.getNodeName().equals("index-rule")) {
- IndexingRule element = new IndexingRule(configNode);
- // register under node type and all its sub types
- log.debug("Found rule '{}' for NodeType '{}'", element, element
- .getNodeTypeName());
- for (NodeTypeData nodeTypeData : ntNames) {
+ NodeTypeDataManager ntReg = context.getNodeTypeDataManager();
+ List<NodeTypeData> ntNames = ntReg.getAllNodeTypes();
+ List<AggregateRuleImpl> idxAggregates = new ArrayList<AggregateRuleImpl>();
+ NodeList indexingConfigs = config.getChildNodes();
+ for (int i = 0; i < indexingConfigs.getLength(); i++)
+ {
+ Node configNode = indexingConfigs.item(i);
+ if (configNode.getNodeName().equals("index-rule"))
+ {
+ IndexingRule element = new IndexingRule(configNode);
+ // register under node type and all its sub types
+ log.debug("Found rule '{}' for NodeType '{}'", element, element.getNodeTypeName());
+ for (NodeTypeData nodeTypeData : ntNames)
+ {
- if (ntReg.isNodeType(element.getNodeTypeName(),
- nodeTypeData.getName())) {
- List<IndexingRule> perNtConfig = configElements
- .get(nodeTypeData);
- if (perNtConfig == null) {
- perNtConfig = new ArrayList<IndexingRule>();
- configElements.put(nodeTypeData.getName(),
- perNtConfig);
- }
- log.debug("Registering it for name '{}'", nodeTypeData);
- perNtConfig.add(new IndexingRule(element, nodeTypeData
- .getName()));
- }
- }
- } else if (configNode.getNodeName().equals("aggregate")) {
- idxAggregates.add(new AggregateRuleImpl(configNode, resolver,
- ism));
- } else if (configNode.getNodeName().equals("analyzers")) {
- NodeList childNodes = configNode.getChildNodes();
- for (int j = 0; j < childNodes.getLength(); j++) {
- Node analyzerNode = childNodes.item(j);
- if (analyzerNode.getNodeName().equals("analyzer")) {
- String analyzerClassName = analyzerNode.getAttributes()
- .getNamedItem("class").getNodeValue();
- try {
- Class clazz = Class.forName(analyzerClassName);
- if (clazz == JcrStandartAnalyzer.class) {
- log
- .warn("Not allowed to configure "
- + JcrStandartAnalyzer.class
- .getName()
- + " for a property. "
- + "Using default analyzer for that property.");
- } else if (Analyzer.class.isAssignableFrom(clazz)) {
- Analyzer analyzer = (Analyzer) clazz
- .newInstance();
- NodeList propertyChildNodes = analyzerNode
- .getChildNodes();
- for (int k = 0; k < propertyChildNodes
- .getLength(); k++) {
- Node propertyNode = propertyChildNodes
- .item(k);
- if (propertyNode.getNodeName().equals(
- "property")) {
- // get property name
- InternalQName propName = resolver
- .parseJCRName(
- getTextContent(propertyNode))
- .getInternalName();
- String fieldName = nsMappings
- .translateName(propName);
- // set analyzer for the fulltext
- // property fieldname
- int idx = fieldName.indexOf(':');
- fieldName = fieldName.substring(0,
- idx + 1)
- + FieldNames.FULLTEXT_PREFIX
- + fieldName.substring(idx + 1);
- Object prevAnalyzer = analyzers.put(
- fieldName, analyzer);
- if (prevAnalyzer != null) {
- log
- .warn("Property "
- + propName
- .getName()
- + " has been configured for multiple analyzers. "
- + " Last configured analyzer is used");
- }
- }
- }
- } else {
- log
- .warn("org.apache.lucene.analysis.Analyzer is not a superclass of "
- + analyzerClassName
- + ". Ignoring this configure analyzer");
- }
- } catch (ClassNotFoundException e) {
- log.warn("Analyzer class not found: "
- + analyzerClassName, e);
- }
- }
- }
- }
+ if (ntReg.isNodeType(element.getNodeTypeName(), nodeTypeData.getName()))
+ {
+ List<IndexingRule> perNtConfig = configElements.get(nodeTypeData);
+ if (perNtConfig == null)
+ {
+ perNtConfig = new ArrayList<IndexingRule>();
+ configElements.put(nodeTypeData.getName(), perNtConfig);
+ }
+ log.debug("Registering it for name '{}'", nodeTypeData);
+ perNtConfig.add(new IndexingRule(element, nodeTypeData.getName()));
+ }
+ }
+ }
+ else if (configNode.getNodeName().equals("aggregate"))
+ {
+ idxAggregates.add(new AggregateRuleImpl(configNode, resolver, ism));
+ }
+ else if (configNode.getNodeName().equals("analyzers"))
+ {
+ NodeList childNodes = configNode.getChildNodes();
+ for (int j = 0; j < childNodes.getLength(); j++)
+ {
+ Node analyzerNode = childNodes.item(j);
+ if (analyzerNode.getNodeName().equals("analyzer"))
+ {
+ String analyzerClassName = analyzerNode.getAttributes().getNamedItem("class").getNodeValue();
+ try
+ {
+ Class clazz = Class.forName(analyzerClassName);
+ if (clazz == JcrStandartAnalyzer.class)
+ {
+ log.warn("Not allowed to configure " + JcrStandartAnalyzer.class.getName()
+ + " for a property. " + "Using default analyzer for that property.");
+ }
+ else if (Analyzer.class.isAssignableFrom(clazz))
+ {
+ Analyzer analyzer = (Analyzer)clazz.newInstance();
+ NodeList propertyChildNodes = analyzerNode.getChildNodes();
+ for (int k = 0; k < propertyChildNodes.getLength(); k++)
+ {
+ Node propertyNode = propertyChildNodes.item(k);
+ if (propertyNode.getNodeName().equals("property"))
+ {
+ // get property name
+ InternalQName propName =
+ resolver.parseJCRName(getTextContent(propertyNode)).getInternalName();
+ String fieldName = nsMappings.translateName(propName);
+ // set analyzer for the fulltext
+ // property fieldname
+ int idx = fieldName.indexOf(':');
+ fieldName =
+ fieldName.substring(0, idx + 1) + FieldNames.FULLTEXT_PREFIX
+ + fieldName.substring(idx + 1);
+ Object prevAnalyzer = analyzers.put(fieldName, analyzer);
+ if (prevAnalyzer != null)
+ {
+ log.warn("Property " + propName.getName()
+ + " has been configured for multiple analyzers. "
+ + " Last configured analyzer is used");
+ }
+ }
+ }
+ }
+ else
+ {
+ log.warn("org.apache.lucene.analysis.Analyzer is not a superclass of " + analyzerClassName
+ + ". Ignoring this configure analyzer");
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.warn("Analyzer class not found: " + analyzerClassName, e);
+ }
+ }
+ }
+ }
- }
- aggregateRules = idxAggregates.toArray(new AggregateRule[idxAggregates
- .size()]);
- }
+ }
+ aggregateRules = idxAggregates.toArray(new AggregateRule[idxAggregates.size()]);
+ }
- /**
- * Returns the configured indexing aggregate rules or <code>null</code> if
- * none exist.
- *
- * @return the configured rules or <code>null</code> if none exist.
- */
- public AggregateRule[] getAggregateRules() {
- return aggregateRules;
- }
+ /**
+ * Returns the configured indexing aggregate rules or <code>null</code> if
+ * none exist.
+ *
+ * @return the configured rules or <code>null</code> if none exist.
+ */
+ public AggregateRule[] getAggregateRules()
+ {
+ return aggregateRules;
+ }
- /**
- * Returns <code>true</code> if the property with the given name is fulltext
- * indexed according to this configuration.
- *
- * @param state
- * the node state.
- * @param propertyName
- * the name of a property.
- * @return <code>true</code> if the property is fulltext indexed;
- * <code>false</code> otherwise.
- */
- public boolean isIndexed(NodeData state, InternalQName propertyName) {
- IndexingRule rule = getApplicableIndexingRule(state);
- if (rule != null) {
- return rule.isIndexed(propertyName);
- }
- // none of the configs matches -> index property
- return true;
- }
+ /**
+ * Returns <code>true</code> if the property with the given name is fulltext
+ * indexed according to this configuration.
+ *
+ * @param state
+ * the node state.
+ * @param propertyName
+ * the name of a property.
+ * @return <code>true</code> if the property is fulltext indexed;
+ * <code>false</code> otherwise.
+ */
+ public boolean isIndexed(NodeData state, InternalQName propertyName)
+ {
+ IndexingRule rule = getApplicableIndexingRule(state);
+ if (rule != null)
+ {
+ return rule.isIndexed(propertyName);
+ }
+ // none of the configs matches -> index property
+ return true;
+ }
- /**
- * Returns the boost value for the given property name. If there is no
- * configuration entry for the property name the {@link #DEFAULT_BOOST} is
- * returned.
- *
- * @param state
- * the node state.
- * @param propertyName
- * the name of a property.
- * @return the boost value for the property.
- */
- public float getPropertyBoost(NodeData state, InternalQName propertyName) {
- IndexingRule rule = getApplicableIndexingRule(state);
- if (rule != null) {
- return rule.getBoost(propertyName);
- }
- return DEFAULT_BOOST;
- }
+ /**
+ * Returns the boost value for the given property name. If there is no
+ * configuration entry for the property name the {@link #DEFAULT_BOOST} is
+ * returned.
+ *
+ * @param state
+ * the node state.
+ * @param propertyName
+ * the name of a property.
+ * @return the boost value for the property.
+ */
+ public float getPropertyBoost(NodeData state, InternalQName propertyName)
+ {
+ IndexingRule rule = getApplicableIndexingRule(state);
+ if (rule != null)
+ {
+ return rule.getBoost(propertyName);
+ }
+ return DEFAULT_BOOST;
+ }
- /**
- * Returns the boost for the node scope fulltext index field.
- *
- * @param state
- * the node state.
- * @return the boost for the node scope fulltext index field.
- */
- public float getNodeBoost(NodeData state) {
- IndexingRule rule = getApplicableIndexingRule(state);
- if (rule != null) {
- return rule.getNodeBoost();
- }
- return DEFAULT_BOOST;
- }
+ /**
+ * Returns the boost for the node scope fulltext index field.
+ *
+ * @param state
+ * the node state.
+ * @return the boost for the node scope fulltext index field.
+ */
+ public float getNodeBoost(NodeData state)
+ {
+ IndexingRule rule = getApplicableIndexingRule(state);
+ if (rule != null)
+ {
+ return rule.getNodeBoost();
+ }
+ return DEFAULT_BOOST;
+ }
- /**
- * Returns <code>true</code> if the property with the given name should be
- * included in the node scope fulltext index. If there is not configuration
- * entry for that propery <code>false</code> is returned.
- *
- * @param state
- * the node state.
- * @param propertyName
- * the name of a property.
- * @return <code>true</code> if the property should be included in the node
- * scope fulltext index.
- */
- public boolean isIncludedInNodeScopeIndex(NodeData state,
- InternalQName propertyName) {
- IndexingRule rule = getApplicableIndexingRule(state);
- if (rule != null) {
- return rule.isIncludedInNodeScopeIndex(propertyName);
- }
- // none of the config elements matched -> default is to include
- return true;
- }
+ /**
+ * Returns <code>true</code> if the property with the given name should be
+ * included in the node scope fulltext index. If there is not configuration
+ * entry for that propery <code>false</code> is returned.
+ *
+ * @param state
+ * the node state.
+ * @param propertyName
+ * the name of a property.
+ * @return <code>true</code> if the property should be included in the node
+ * scope fulltext index.
+ */
+ public boolean isIncludedInNodeScopeIndex(NodeData state, InternalQName propertyName)
+ {
+ IndexingRule rule = getApplicableIndexingRule(state);
+ if (rule != null)
+ {
+ return rule.isIncludedInNodeScopeIndex(propertyName);
+ }
+ // none of the config elements matched -> default is to include
+ return true;
+ }
- /**
- * Returns <code>true</code> if the content of the property with the given
- * name should show up in an excerpt. If there is no configuration entry for
- * that property <code>true</code> is returned.
- *
- * @param state
- * the node state.
- * @param propertyName
- * the name of a property.
- * @return <code>true</code> if the content of the property should be
- * included in an excerpt; <code>false</code> otherwise.
- */
- public boolean useInExcerpt(NodeData state, InternalQName propertyName) {
- IndexingRule rule = getApplicableIndexingRule(state);
- if (rule != null) {
- return rule.useInExcerpt(propertyName);
- }
- // none of the config elements matched -> default is to include
- return true;
- }
+ /**
+ * Returns <code>true</code> if the content of the property with the given
+ * name should show up in an excerpt. If there is no configuration entry for
+ * that property <code>true</code> is returned.
+ *
+ * @param state
+ * the node state.
+ * @param propertyName
+ * the name of a property.
+ * @return <code>true</code> if the content of the property should be
+ * included in an excerpt; <code>false</code> otherwise.
+ */
+ public boolean useInExcerpt(NodeData state, InternalQName propertyName)
+ {
+ IndexingRule rule = getApplicableIndexingRule(state);
+ if (rule != null)
+ {
+ return rule.useInExcerpt(propertyName);
+ }
+ // none of the config elements matched -> default is to include
+ return true;
+ }
- /**
- * Returns the analyzer configured for the property with this fieldName (the
- * string representation ,JCR-style name, of the given
- * <code>InternalQName</code> prefixed with
- * <code>FieldNames.FULLTEXT_PREFIX</code>)), and <code>null</code> if none
- * is configured, or the configured analyzer cannot be found. If
- * <code>null</code> is returned, the default Analyzer is used.
- *
- * @param fieldName
- * the string representation ,JCR-style name, of the given
- * <code>InternalQName</code> prefixed with
- * <code>FieldNames.FULLTEXT_PREFIX</code>))
- * @return the <code>analyzer</code> to use for indexing this property
- */
- public Analyzer getPropertyAnalyzer(String fieldName) {
- if (analyzers.containsKey(fieldName)) {
- return analyzers.get(fieldName);
- }
- return null;
- }
+ /**
+ * Returns the analyzer configured for the property with this fieldName (the
+ * string representation ,JCR-style name, of the given
+ * <code>InternalQName</code> prefixed with
+ * <code>FieldNames.FULLTEXT_PREFIX</code>)), and <code>null</code> if none
+ * is configured, or the configured analyzer cannot be found. If
+ * <code>null</code> is returned, the default Analyzer is used.
+ *
+ * @param fieldName
+ * the string representation ,JCR-style name, of the given
+ * <code>InternalQName</code> prefixed with
+ * <code>FieldNames.FULLTEXT_PREFIX</code>))
+ * @return the <code>analyzer</code> to use for indexing this property
+ */
+ public Analyzer getPropertyAnalyzer(String fieldName)
+ {
+ if (analyzers.containsKey(fieldName))
+ {
+ return analyzers.get(fieldName);
+ }
+ return null;
+ }
- // ---------------------------------< internal
- // >-----------------------------
+ // ---------------------------------< internal
+ // >-----------------------------
- /**
- * Returns the first indexing rule that applies to the given node
- * <code>state</code>.
- *
- * @param state
- * a node state.
- * @return the indexing rule or <code>null</code> if none applies.
- */
- private IndexingRule getApplicableIndexingRule(NodeData state) {
- List<IndexingRule> rules = null;
- List<IndexingRule> r = configElements.get(state.getPrimaryTypeName());
- if (r != null) {
- rules = new ArrayList<IndexingRule>();
- rules.addAll(r);
- }
+ /**
+ * Returns the first indexing rule that applies to the given node
+ * <code>state</code>.
+ *
+ * @param state
+ * a node state.
+ * @return the indexing rule or <code>null</code> if none applies.
+ */
+ private IndexingRule getApplicableIndexingRule(NodeData state)
+ {
+ List<IndexingRule> rules = null;
+ List<IndexingRule> r = configElements.get(state.getPrimaryTypeName());
+ if (r != null)
+ {
+ rules = new ArrayList<IndexingRule>();
+ rules.addAll(r);
+ }
- InternalQName[] mixTypes = state.getMixinTypeNames();
- for (InternalQName mixType : mixTypes) {
- r = configElements.get(mixType);
- if (r != null) {
- if (rules == null) {
- rules = new ArrayList<IndexingRule>();
- }
- rules.addAll(r);
- }
- }
+ InternalQName[] mixTypes = state.getMixinTypeNames();
+ for (InternalQName mixType : mixTypes)
+ {
+ r = configElements.get(mixType);
+ if (r != null)
+ {
+ if (rules == null)
+ {
+ rules = new ArrayList<IndexingRule>();
+ }
+ rules.addAll(r);
+ }
+ }
- if (rules != null) {
- for (IndexingRule ir : rules) {
- if (ir.appliesTo(state)) {
- return ir;
- }
- }
- }
+ if (rules != null)
+ {
+ for (IndexingRule ir : rules)
+ {
+ if (ir.appliesTo(state))
+ {
+ return ir;
+ }
+ }
+ }
- // no applicable rule
- return null;
- }
+ // no applicable rule
+ return null;
+ }
- /**
- * Returns the namespaces declared on the <code>node</code>.
- *
- * @param node
- * a DOM node.
- * @return the namespaces
- */
- private Properties getNamespaces(Node node) {
- Properties namespaces = new Properties();
- NamedNodeMap attributes = node.getAttributes();
- for (int i = 0; i < attributes.getLength(); i++) {
- Attr attribute = (Attr) attributes.item(i);
- if (attribute.getName().startsWith("xmlns:")) {
- namespaces.setProperty(attribute.getName().substring(6),
- attribute.getValue());
- }
- }
- return namespaces;
- }
+ /**
+ * Returns the namespaces declared on the <code>node</code>.
+ *
+ * @param node
+ * a DOM node.
+ * @return the namespaces
+ */
+ private Properties getNamespaces(Node node)
+ {
+ Properties namespaces = new Properties();
+ NamedNodeMap attributes = node.getAttributes();
+ for (int i = 0; i < attributes.getLength(); i++)
+ {
+ Attr attribute = (Attr)attributes.item(i);
+ if (attribute.getName().startsWith("xmlns:"))
+ {
+ namespaces.setProperty(attribute.getName().substring(6), attribute.getValue());
+ }
+ }
+ return namespaces;
+ }
- /**
- * Creates property configurations defined in the <code>config</code>.
- *
- * @param config
- * the fulltext indexing configuration.
- * @param propConfigs
- * will be filled with exact <code>InternalQName</code> to
- * <code>PropertyConfig</code> mappings.
- * @param namePatterns
- * will be filled with <code>NamePattern</code>s.
- * @throws IllegalNameException
- * if the node type name contains illegal characters.
- * @throws RepositoryException
- */
- private void createPropertyConfigs(Node config,
- Map<InternalQName, PropertyConfig> propConfigs,
- List<NamePattern> namePatterns) throws IllegalNameException,
- RepositoryException {
- NodeList childNodes = config.getChildNodes();
- for (int i = 0; i < childNodes.getLength(); i++) {
- Node n = childNodes.item(i);
- if (n.getNodeName().equals("property")) {
- NamedNodeMap attributes = n.getAttributes();
- // get boost value
- float boost = 1.0f;
- Node boostAttr = attributes.getNamedItem("boost");
- if (boostAttr != null) {
- try {
- boost = Float.parseFloat(boostAttr.getNodeValue());
- } catch (NumberFormatException e) {
- // use default
- }
- }
+ /**
+ * Creates property configurations defined in the <code>config</code>.
+ *
+ * @param config
+ * the fulltext indexing configuration.
+ * @param propConfigs
+ * will be filled with exact <code>InternalQName</code> to
+ * <code>PropertyConfig</code> mappings.
+ * @param namePatterns
+ * will be filled with <code>NamePattern</code>s.
+ * @throws IllegalNameException
+ * if the node type name contains illegal characters.
+ * @throws RepositoryException
+ */
+ private void createPropertyConfigs(Node config, Map<InternalQName, PropertyConfig> propConfigs,
+ List<NamePattern> namePatterns) throws IllegalNameException, RepositoryException
+ {
+ NodeList childNodes = config.getChildNodes();
+ for (int i = 0; i < childNodes.getLength(); i++)
+ {
+ Node n = childNodes.item(i);
+ if (n.getNodeName().equals("property"))
+ {
+ NamedNodeMap attributes = n.getAttributes();
+ // get boost value
+ float boost = 1.0f;
+ Node boostAttr = attributes.getNamedItem("boost");
+ if (boostAttr != null)
+ {
+ try
+ {
+ boost = Float.parseFloat(boostAttr.getNodeValue());
+ }
+ catch (NumberFormatException e)
+ {
+ // use default
+ }
+ }
- // get nodeScopeIndex flag
- boolean nodeScopeIndex = true;
- Node nsIndex = attributes.getNamedItem("nodeScopeIndex");
- if (nsIndex != null) {
- nodeScopeIndex = Boolean.valueOf(nsIndex.getNodeValue())
- .booleanValue();
- }
+ // get nodeScopeIndex flag
+ boolean nodeScopeIndex = true;
+ Node nsIndex = attributes.getNamedItem("nodeScopeIndex");
+ if (nsIndex != null)
+ {
+ nodeScopeIndex = Boolean.valueOf(nsIndex.getNodeValue()).booleanValue();
+ }
- // get isRegexp flag
- boolean isRegexp = false;
- Node regexp = attributes.getNamedItem("isRegexp");
- if (regexp != null) {
- isRegexp = Boolean.valueOf(regexp.getNodeValue())
- .booleanValue();
- }
+ // get isRegexp flag
+ boolean isRegexp = false;
+ Node regexp = attributes.getNamedItem("isRegexp");
+ if (regexp != null)
+ {
+ isRegexp = Boolean.valueOf(regexp.getNodeValue()).booleanValue();
+ }
- // get useInExcerpt flag
- boolean useInExcerpt = true;
- Node excerpt = attributes.getNamedItem("useInExcerpt");
- if (excerpt != null) {
- useInExcerpt = Boolean.valueOf(excerpt.getNodeValue())
- .booleanValue();
- }
+ // get useInExcerpt flag
+ boolean useInExcerpt = true;
+ Node excerpt = attributes.getNamedItem("useInExcerpt");
+ if (excerpt != null)
+ {
+ useInExcerpt = Boolean.valueOf(excerpt.getNodeValue()).booleanValue();
+ }
- PropertyConfig pc = new PropertyConfig(boost, nodeScopeIndex,
- useInExcerpt);
+ PropertyConfig pc = new PropertyConfig(boost, nodeScopeIndex, useInExcerpt);
- if (isRegexp) {
- namePatterns.add(new NamePattern(getTextContent(n), pc,
- resolver));
- } else {
- InternalQName propName = resolver.parseJCRName(
- getTextContent(n)).getInternalName();
- propConfigs.put(propName, pc);
- }
- }
- }
- }
+ if (isRegexp)
+ {
+ namePatterns.add(new NamePattern(getTextContent(n), pc, resolver));
+ }
+ else
+ {
+ InternalQName propName = resolver.parseJCRName(getTextContent(n)).getInternalName();
+ propConfigs.put(propName, pc);
+ }
+ }
+ }
+ }
- /**
- * Gets the condition expression from the configuration.
- *
- * @param config
- * the config node.
- * @return the condition expression or <code>null</code> if there is no
- * condition set on the <code>config</code>.
- * @throws MalformedPathException
- * if the condition string is malformed.
- * @throws IllegalNameException
- * if a name contains illegal characters.
- * @throws RepositoryException
- */
- private PathExpression getCondition(Node config)
- throws IllegalNameException, RepositoryException {
- Node conditionAttr = config.getAttributes().getNamedItem("condition");
- if (conditionAttr == null) {
- return null;
- }
- String conditionString = conditionAttr.getNodeValue();
- int idx;
- int axis;
- InternalQName elementTest = null;
- InternalQName nameTest = null;
- InternalQName propertyName;
- String propertyValue;
+ /**
+ * Gets the condition expression from the configuration.
+ *
+ * @param config
+ * the config node.
+ * @return the condition expression or <code>null</code> if there is no
+ * condition set on the <code>config</code>.
+ * @throws MalformedPathException
+ * if the condition string is malformed.
+ * @throws IllegalNameException
+ * if a name contains illegal characters.
+ * @throws RepositoryException
+ */
+ private PathExpression getCondition(Node config) throws IllegalNameException, RepositoryException
+ {
+ Node conditionAttr = config.getAttributes().getNamedItem("condition");
+ if (conditionAttr == null)
+ {
+ return null;
+ }
+ String conditionString = conditionAttr.getNodeValue();
+ int idx;
+ int axis;
+ InternalQName elementTest = null;
+ InternalQName nameTest = null;
+ InternalQName propertyName;
+ String propertyValue;
- // parse axis
- if (conditionString.startsWith("ancestor::")) {
- axis = PathExpression.ANCESTOR;
- idx = "ancestor::".length();
- } else if (conditionString.startsWith("parent::")) {
- axis = PathExpression.PARENT;
- idx = "parent::".length();
- } else if (conditionString.startsWith("@")) {
- axis = PathExpression.SELF;
- idx = "@".length();
- } else {
- axis = PathExpression.CHILD;
- idx = 0;
- }
+ // parse axis
+ if (conditionString.startsWith("ancestor::"))
+ {
+ axis = PathExpression.ANCESTOR;
+ idx = "ancestor::".length();
+ }
+ else if (conditionString.startsWith("parent::"))
+ {
+ axis = PathExpression.PARENT;
+ idx = "parent::".length();
+ }
+ else if (conditionString.startsWith("@"))
+ {
+ axis = PathExpression.SELF;
+ idx = "@".length();
+ }
+ else
+ {
+ axis = PathExpression.CHILD;
+ idx = 0;
+ }
- try {
- if (conditionString.startsWith("element(", idx)) {
- int colon = conditionString.indexOf(',', idx
- + "element(".length());
- String name = conditionString.substring(
- idx + "element(".length(), colon).trim();
- if (!name.equals("*")) {
- nameTest = resolver.parseJCRName(ISO9075.decode(name))
- .getInternalName();
- }
- idx = conditionString.indexOf(")/@", colon);
- String type = conditionString.substring(colon + 1, idx).trim();
- elementTest = resolver.parseJCRName(ISO9075.decode(type))
- .getInternalName();
- idx += ")/@".length();
- } else {
- if (axis == PathExpression.ANCESTOR
- || axis == PathExpression.CHILD
- || axis == PathExpression.PARENT) {
- // simple name test
- String name = conditionString.substring(idx,
- conditionString.indexOf('/', idx));
- if (!name.equals("*")) {
- nameTest = resolver.parseJCRName(ISO9075.decode(name))
- .getInternalName();
- }
- idx += name.length() + "/@".length();
- }
- }
+ try
+ {
+ if (conditionString.startsWith("element(", idx))
+ {
+ int colon = conditionString.indexOf(',', idx + "element(".length());
+ String name = conditionString.substring(idx + "element(".length(), colon).trim();
+ if (!name.equals("*"))
+ {
+ nameTest = resolver.parseJCRName(ISO9075.decode(name)).getInternalName();
+ }
+ idx = conditionString.indexOf(")/@", colon);
+ String type = conditionString.substring(colon + 1, idx).trim();
+ elementTest = resolver.parseJCRName(ISO9075.decode(type)).getInternalName();
+ idx += ")/@".length();
+ }
+ else
+ {
+ if (axis == PathExpression.ANCESTOR || axis == PathExpression.CHILD || axis == PathExpression.PARENT)
+ {
+ // simple name test
+ String name = conditionString.substring(idx, conditionString.indexOf('/', idx));
+ if (!name.equals("*"))
+ {
+ nameTest = resolver.parseJCRName(ISO9075.decode(name)).getInternalName();
+ }
+ idx += name.length() + "/@".length();
+ }
+ }
- // parse property name
- int eq = conditionString.indexOf('=', idx);
- String name = conditionString.substring(idx, eq).trim();
- propertyName = resolver.parseJCRName(ISO9075.decode(name))
- .getInternalName();
+ // parse property name
+ int eq = conditionString.indexOf('=', idx);
+ String name = conditionString.substring(idx, eq).trim();
+ propertyName = resolver.parseJCRName(ISO9075.decode(name)).getInternalName();
- // parse string value
- int quote = conditionString.indexOf('\'', eq) + 1;
- propertyValue = conditionString.substring(quote, conditionString
- .indexOf('\'', quote));
- } catch (IndexOutOfBoundsException e) {
- throw new RepositoryException(conditionString);
- }
+ // parse string value
+ int quote = conditionString.indexOf('\'', eq) + 1;
+ propertyValue = conditionString.substring(quote, conditionString.indexOf('\'', quote));
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ throw new RepositoryException(conditionString);
+ }
- return new PathExpression(axis, elementTest, nameTest, propertyName,
- propertyValue);
- }
+ return new PathExpression(axis, elementTest, nameTest, propertyName, propertyValue);
+ }
- /**
- * @param node
- * a node.
- * @return the text content of the <code>node</code>.
- */
- private static String getTextContent(Node node) {
- StringBuffer content = new StringBuffer();
- NodeList nodes = node.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++) {
- Node n = nodes.item(i);
- if (n.getNodeType() == Node.TEXT_NODE) {
- content.append(((CharacterData) n).getData());
- }
- }
- return content.toString();
- }
+ /**
+ * @param node
+ * a node.
+ * @return the text content of the <code>node</code>.
+ */
+ private static String getTextContent(Node node)
+ {
+ StringBuffer content = new StringBuffer();
+ NodeList nodes = node.getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++)
+ {
+ Node n = nodes.item(i);
+ if (n.getNodeType() == Node.TEXT_NODE)
+ {
+ content.append(((CharacterData)n).getData());
+ }
+ }
+ return content.toString();
+ }
- /**
- * A property name pattern.
- */
- private static final class NamePattern {
+ /**
+ * A property name pattern.
+ */
+ private static final class NamePattern
+ {
- /**
- * The pattern to match.
- */
- private final Pattern pattern;
+ /**
+ * The pattern to match.
+ */
+ private final Pattern pattern;
- /**
- * The associated configuration.
- */
- private final PropertyConfig config;
+ /**
+ * The associated configuration.
+ */
+ private final PropertyConfig config;
- /**
- * Creates a new name pattern.
- *
- * @param pattern
- * the pattern as read from the configuration file.
- * @param config
- * the associated configuration.
- * @param resolver
- * a namespace resolver for parsing name from the
- * configuration.
- * @throws IllegalNameException
- * if the prefix of the name pattern is illegal.
- * @throws RepositoryException
- */
- private NamePattern(String pattern, PropertyConfig config,
- LocationFactory resolver) throws IllegalNameException,
- RepositoryException {
- String uri = Constants.NS_DEFAULT_URI;
- String localPattern = pattern;
- int idx = pattern.indexOf(':');
- if (idx != -1) {
- // use a dummy local name to get namespace uri
- uri = resolver.parseJCRName(pattern.substring(0, idx) + ":a")
- .getNamespace();
- localPattern = pattern.substring(idx + 1);
- }
- this.pattern = Pattern.name(uri, localPattern);
- this.config = config;
- }
+ /**
+ * Creates a new name pattern.
+ *
+ * @param pattern
+ * the pattern as read from the configuration file.
+ * @param config
+ * the associated configuration.
+ * @param resolver
+ * a namespace resolver for parsing name from the
+ * configuration.
+ * @throws IllegalNameException
+ * if the prefix of the name pattern is illegal.
+ * @throws RepositoryException
+ */
+ private NamePattern(String pattern, PropertyConfig config, LocationFactory resolver) throws IllegalNameException,
+ RepositoryException
+ {
+ String uri = Constants.NS_DEFAULT_URI;
+ String localPattern = pattern;
+ int idx = pattern.indexOf(':');
+ if (idx != -1)
+ {
+ // use a dummy local name to get namespace uri
+ uri = resolver.parseJCRName(pattern.substring(0, idx) + ":a").getNamespace();
+ localPattern = pattern.substring(idx + 1);
+ }
+ this.pattern = Pattern.name(uri, localPattern);
+ this.config = config;
+ }
- /**
- * @param path
- * the path to match.
- * @return <code>true</code> if <code>path</code> matches this name
- * pattern; <code>false</code> otherwise.
- */
- boolean matches(QPath path) {
- return pattern.match(path).isFullMatch();
- }
+ /**
+ * @param path
+ * the path to match.
+ * @return <code>true</code> if <code>path</code> matches this name
+ * pattern; <code>false</code> otherwise.
+ */
+ boolean matches(QPath path)
+ {
+ return pattern.match(path).isFullMatch();
+ }
- /**
- * @return the property configuration for this name pattern.
- */
- PropertyConfig getConfig() {
- return config;
- }
- }
+ /**
+ * @return the property configuration for this name pattern.
+ */
+ PropertyConfig getConfig()
+ {
+ return config;
+ }
+ }
- private class IndexingRule {
+ private class IndexingRule
+ {
- /**
- * The node type of this fulltext indexing rule.
- */
- private final InternalQName nodeTypeName;
+ /**
+ * The node type of this fulltext indexing rule.
+ */
+ private final InternalQName nodeTypeName;
- /**
- * Map of {@link PropertyConfig}. Key=InternalQName of property.
- */
- private final Map<InternalQName, PropertyConfig> propConfigs;
+ /**
+ * Map of {@link PropertyConfig}. Key=InternalQName of property.
+ */
+ private final Map<InternalQName, PropertyConfig> propConfigs;
- /**
- * List of {@link NamePattern}s.
- */
- private final List<NamePattern> namePatterns;
+ /**
+ * List of {@link NamePattern}s.
+ */
+ private final List<NamePattern> namePatterns;
- /**
- * An expression based on a relative path.
- */
- private final PathExpression condition;
+ /**
+ * An expression based on a relative path.
+ */
+ private final PathExpression condition;
- /**
- * The boost value for this config element.
- */
- private final float boost;
+ /**
+ * The boost value for this config element.
+ */
+ private final float boost;
- /**
- * Creates a new indexing rule base on an existing one, but for a
- * different node type name.
- *
- * @param original
- * the existing rule.
- * @param nodeTypeName
- * the node type name for the rule.
- */
- IndexingRule(IndexingRule original, InternalQName nodeTypeName) {
- this.nodeTypeName = nodeTypeName;
- this.propConfigs = original.propConfigs;
- this.namePatterns = original.namePatterns;
- this.condition = original.condition;
- this.boost = original.boost;
- }
+ /**
+ * Creates a new indexing rule base on an existing one, but for a
+ * different node type name.
+ *
+ * @param original
+ * the existing rule.
+ * @param nodeTypeName
+ * the node type name for the rule.
+ */
+ IndexingRule(IndexingRule original, InternalQName nodeTypeName)
+ {
+ this.nodeTypeName = nodeTypeName;
+ this.propConfigs = original.propConfigs;
+ this.namePatterns = original.namePatterns;
+ this.condition = original.condition;
+ this.boost = original.boost;
+ }
- /**
- *
- * @param config
- * the configuration for this rule.
- * @throws MalformedPathException
- * if the condition expression is malformed.
- * @throws IllegalNameException
- * if a name contains illegal characters.
- * @throws RepositoryException
- */
- IndexingRule(Node config) throws IllegalNameException,
- RepositoryException {
- this.nodeTypeName = getNodeTypeName(config);
- this.condition = getCondition(config);
- this.boost = getNodeBoost(config);
- this.propConfigs = new HashMap<InternalQName, PropertyConfig>();
- this.namePatterns = new ArrayList<NamePattern>();
- createPropertyConfigs(config, propConfigs, namePatterns);
- }
+ /**
+ *
+ * @param config
+ * the configuration for this rule.
+ * @throws MalformedPathException
+ * if the condition expression is malformed.
+ * @throws IllegalNameException
+ * if a name contains illegal characters.
+ * @throws RepositoryException
+ */
+ IndexingRule(Node config) throws IllegalNameException, RepositoryException
+ {
+ this.nodeTypeName = getNodeTypeName(config);
+ this.condition = getCondition(config);
+ this.boost = getNodeBoost(config);
+ this.propConfigs = new HashMap<InternalQName, PropertyConfig>();
+ this.namePatterns = new ArrayList<NamePattern>();
+ createPropertyConfigs(config, propConfigs, namePatterns);
+ }
- /**
- * Returns the name of the node type where this rule applies to.
- *
- * @return name of the node type.
- */
- public InternalQName getNodeTypeName() {
- return nodeTypeName;
- }
+ /**
+ * Returns the name of the node type where this rule applies to.
+ *
+ * @return name of the node type.
+ */
+ public InternalQName getNodeTypeName()
+ {
+ return nodeTypeName;
+ }
- /**
- * @return the value for the node boost.
- */
- public float getNodeBoost() {
- return boost;
- }
+ /**
+ * @return the value for the node boost.
+ */
+ public float getNodeBoost()
+ {
+ return boost;
+ }
- /**
- * Returns <code>true</code> if the property with the given name is
- * indexed according to this rule.
- *
- * @param propertyName
- * the name of a property.
- * @return <code>true</code> if the property is indexed;
- * <code>false</code> otherwise.
- */
- public boolean isIndexed(InternalQName propertyName) {
- return getConfig(propertyName) != null;
- }
+ /**
+ * Returns <code>true</code> if the property with the given name is
+ * indexed according to this rule.
+ *
+ * @param propertyName
+ * the name of a property.
+ * @return <code>true</code> if the property is indexed;
+ * <code>false</code> otherwise.
+ */
+ public boolean isIndexed(InternalQName propertyName)
+ {
+ return getConfig(propertyName) != null;
+ }
- /**
- * Returns the boost value for the given property name. If there is no
- * configuration entry for the property name the default boost value is
- * returned.
- *
- * @param propertyName
- * the name of a property.
- * @return the boost value for the property.
- */
- public float getBoost(InternalQName propertyName) {
- PropertyConfig config = getConfig(propertyName);
- if (config != null) {
- return config.boost;
- } else {
- return DEFAULT_BOOST;
- }
- }
+ /**
+ * Returns the boost value for the given property name. If there is no
+ * configuration entry for the property name the default boost value is
+ * returned.
+ *
+ * @param propertyName
+ * the name of a property.
+ * @return the boost value for the property.
+ */
+ public float getBoost(InternalQName propertyName)
+ {
+ PropertyConfig config = getConfig(propertyName);
+ if (config != null)
+ {
+ return config.boost;
+ }
+ else
+ {
+ return DEFAULT_BOOST;
+ }
+ }
- /**
- * Returns <code>true</code> if the property with the given name should
- * be included in the node scope fulltext index. If there is no
- * configuration entry for that propery <code>false</code> is returned.
- *
- * @param propertyName
- * the name of a property.
- * @return <code>true</code> if the property should be included in the
- * node scope fulltext index.
- */
- public boolean isIncludedInNodeScopeIndex(InternalQName propertyName) {
- PropertyConfig config = getConfig(propertyName);
- if (config != null) {
- return config.nodeScopeIndex;
- } else {
- return false;
- }
- }
+ /**
+ * Returns <code>true</code> if the property with the given name should
+ * be included in the node scope fulltext index. If there is no
+ * configuration entry for that propery <code>false</code> is returned.
+ *
+ * @param propertyName
+ * the name of a property.
+ * @return <code>true</code> if the property should be included in the
+ * node scope fulltext index.
+ */
+ public boolean isIncludedInNodeScopeIndex(InternalQName propertyName)
+ {
+ PropertyConfig config = getConfig(propertyName);
+ if (config != null)
+ {
+ return config.nodeScopeIndex;
+ }
+ else
+ {
+ return false;
+ }
+ }
- /**
- * Returns <code>true</code> if the content of the property with the
- * given name should show up in an excerpt. If there is no configuration
- * entry for that property <code>true</code> is returned.
- *
- * @param propertyName
- * the name of a property.
- * @return <code>true</code> if the content of the property should be
- * included in an excerpt; <code>false</code> otherwise.
- */
- public boolean useInExcerpt(InternalQName propertyName) {
- PropertyConfig config = getConfig(propertyName);
- if (config != null) {
- return config.useInExcerpt;
- } else {
- return true;
- }
- }
+ /**
+ * Returns <code>true</code> if the content of the property with the
+ * given name should show up in an excerpt. If there is no configuration
+ * entry for that property <code>true</code> is returned.
+ *
+ * @param propertyName
+ * the name of a property.
+ * @return <code>true</code> if the content of the property should be
+ * included in an excerpt; <code>false</code> otherwise.
+ */
+ public boolean useInExcerpt(InternalQName propertyName)
+ {
+ PropertyConfig config = getConfig(propertyName);
+ if (config != null)
+ {
+ return config.useInExcerpt;
+ }
+ else
+ {
+ return true;
+ }
+ }
- /**
- * Returns <code>true</code> if this rule applies to the given node
- * <code>state</code>.
- *
- * @param state
- * the state to check.
- * @return <code>true</code> the rule applies to the given node;
- * <code>false</code> otherwise.
- */
- public boolean appliesTo(NodeData state) {
- if (!nodeTypeName.equals(state.getPrimaryTypeName())) {
- return false;
- }
- if (condition == null) {
- return true;
- } else {
- return condition.evaluate(state);
- }
- }
+ /**
+ * Returns <code>true</code> if this rule applies to the given node
+ * <code>state</code>.
+ *
+ * @param state
+ * the state to check.
+ * @return <code>true</code> the rule applies to the given node;
+ * <code>false</code> otherwise.
+ */
+ public boolean appliesTo(NodeData state)
+ {
+ if (!nodeTypeName.equals(state.getPrimaryTypeName()))
+ {
+ return false;
+ }
+ if (condition == null)
+ {
+ return true;
+ }
+ else
+ {
+ return condition.evaluate(state);
+ }
+ }
- // -------------------------< internal
- // >---------------------------------
+ // -------------------------< internal
+ // >---------------------------------
- /**
- * @param propertyName
- * name of a property.
- * @return the property configuration or <code>null</code> if this
- * indexing rule does not contain a configuration for the given
- * property.
- */
- private PropertyConfig getConfig(InternalQName propertyName) {
- PropertyConfig config = propConfigs.get(propertyName);
- if (config != null) {
- return config;
- } else if (namePatterns.size() > 0) {
- QPath path = new QPath(new QPathEntry[] { new QPathEntry(
- propertyName, 1) });
- // check patterns
- for (Iterator<NamePattern> it = namePatterns.iterator(); it
- .hasNext();) {
- NamePattern np = it.next();
- if (np.matches(path)) {
- return np.getConfig();
- }
- }
- }
- return null;
- }
+ /**
+ * @param propertyName
+ * name of a property.
+ * @return the property configuration or <code>null</code> if this
+ * indexing rule does not contain a configuration for the given
+ * property.
+ */
+ private PropertyConfig getConfig(InternalQName propertyName)
+ {
+ PropertyConfig config = propConfigs.get(propertyName);
+ if (config != null)
+ {
+ return config;
+ }
+ else if (namePatterns.size() > 0)
+ {
+ QPath path = new QPath(new QPathEntry[]{new QPathEntry(propertyName, 1)});
+ // check patterns
+ for (Iterator<NamePattern> it = namePatterns.iterator(); it.hasNext();)
+ {
+ NamePattern np = it.next();
+ if (np.matches(path))
+ {
+ return np.getConfig();
+ }
+ }
+ }
+ return null;
+ }
- /**
- * Reads the node type of the root node of the indexing rule.
- *
- * @param config
- * the configuration.
- * @return the name of the node type.
- * @throws IllegalNameException
- * if the node type name contains illegal characters.
- * @throws RepositoryException
- */
- private InternalQName getNodeTypeName(Node config)
- throws IllegalNameException, RepositoryException {
- String ntString = config.getAttributes().getNamedItem("nodeType")
- .getNodeValue();
- return resolver.parseJCRName(ntString).getInternalName();
- }
+ /**
+ * Reads the node type of the root node of the indexing rule.
+ *
+ * @param config
+ * the configuration.
+ * @return the name of the node type.
+ * @throws IllegalNameException
+ * if the node type name contains illegal characters.
+ * @throws RepositoryException
+ */
+ private InternalQName getNodeTypeName(Node config) throws IllegalNameException, RepositoryException
+ {
+ String ntString = config.getAttributes().getNamedItem("nodeType").getNodeValue();
+ return resolver.parseJCRName(ntString).getInternalName();
+ }
- /**
- * Returns the node boost from the <code>config</code>.
- *
- * @param config
- * the configuration.
- * @return the configured node boost or the default boost if none is
- * configured.
- */
- private float getNodeBoost(Node config) {
- Node boost = config.getAttributes().getNamedItem("boost");
- if (boost != null) {
- try {
- return Float.parseFloat(boost.getNodeValue());
- } catch (NumberFormatException e) {
- // return default boost
- }
- }
- return DEFAULT_BOOST;
- }
- }
+ /**
+ * Returns the node boost from the <code>config</code>.
+ *
+ * @param config
+ * the configuration.
+ * @return the configured node boost or the default boost if none is
+ * configured.
+ */
+ private float getNodeBoost(Node config)
+ {
+ Node boost = config.getAttributes().getNamedItem("boost");
+ if (boost != null)
+ {
+ try
+ {
+ return Float.parseFloat(boost.getNodeValue());
+ }
+ catch (NumberFormatException e)
+ {
+ // return default boost
+ }
+ }
+ return DEFAULT_BOOST;
+ }
+ }
- /**
- * Simple class that holds boost and nodeScopeIndex flag.
- */
- private class PropertyConfig {
+ /**
+ * Simple class that holds boost and nodeScopeIndex flag.
+ */
+ private class PropertyConfig
+ {
- /**
- * The boost value for a property.
- */
- final float boost;
+ /**
+ * The boost value for a property.
+ */
+ final float boost;
- /**
- * Flag that indicates whether a property is included in the node scope
- * fulltext index of its parent.
- */
- final boolean nodeScopeIndex;
+ /**
+ * Flag that indicates whether a property is included in the node scope
+ * fulltext index of its parent.
+ */
+ final boolean nodeScopeIndex;
- /**
- * Flag that indicates whether the content of a property should be used
- * to create an excerpt.
- */
- final boolean useInExcerpt;
+ /**
+ * Flag that indicates whether the content of a property should be used
+ * to create an excerpt.
+ */
+ final boolean useInExcerpt;
- PropertyConfig(float boost, boolean nodeScopeIndex, boolean useInExcerpt) {
- this.boost = boost;
- this.nodeScopeIndex = nodeScopeIndex;
- this.useInExcerpt = useInExcerpt;
- }
- }
+ PropertyConfig(float boost, boolean nodeScopeIndex, boolean useInExcerpt)
+ {
+ this.boost = boost;
+ this.nodeScopeIndex = nodeScopeIndex;
+ this.useInExcerpt = useInExcerpt;
+ }
+ }
- private class PathExpression {
+ private class PathExpression
+ {
- static final int SELF = 0;
+ static final int SELF = 0;
- static final int CHILD = 1;
+ static final int CHILD = 1;
- static final int ANCESTOR = 2;
+ static final int ANCESTOR = 2;
- static final int PARENT = 3;
+ static final int PARENT = 3;
- private final int axis;
+ private final int axis;
- private final InternalQName elementTest;
+ private final InternalQName elementTest;
- private final InternalQName nameTest;
+ private final InternalQName nameTest;
- private final InternalQName propertyName;
+ private final InternalQName propertyName;
- private final String propertyValue;
+ private final String propertyValue;
- PathExpression(int axis, InternalQName elementTest,
- InternalQName nameTest, InternalQName propertyName,
- String propertyValue) {
- this.axis = axis;
- this.elementTest = elementTest;
- this.nameTest = nameTest;
- this.propertyName = propertyName;
- this.propertyValue = propertyValue;
- }
+ PathExpression(int axis, InternalQName elementTest, InternalQName nameTest, InternalQName propertyName,
+ String propertyValue)
+ {
+ this.axis = axis;
+ this.elementTest = elementTest;
+ this.nameTest = nameTest;
+ this.propertyName = propertyName;
+ this.propertyValue = propertyValue;
+ }
- /**
- * Evaluates this expression and returns <code>true</code> if the
- * condition matches using <code>state</code> as the context node state.
- *
- * @param context
- * the context from where the expression should be evaluated.
- * @return expression result.
- */
- boolean evaluate(final NodeData context) {
- // get iterator along specified axis
- Iterator nodeStates;
- if (axis == SELF) {
- nodeStates = Collections.singletonList(context).iterator();
- } else if (axis == CHILD) {
- List<NodeData> childs;
- try {
- childs = ism.getChildNodesData(context);
- nodeStates = childs.iterator();
- } catch (RepositoryException e) {
- nodeStates = Collections.<NodeData> emptyList().iterator();
- }
- } else if (axis == ANCESTOR) {
- try {
- nodeStates = new Iterator() {
+ /**
+ * Evaluates this expression and returns <code>true</code> if the
+ * condition matches using <code>state</code> as the context node state.
+ *
+ * @param context
+ * the context from where the expression should be evaluated.
+ * @return expression result.
+ */
+ boolean evaluate(final NodeData context)
+ {
+ // get iterator along specified axis
+ Iterator nodeStates;
+ if (axis == SELF)
+ {
+ nodeStates = Collections.singletonList(context).iterator();
+ }
+ else if (axis == CHILD)
+ {
+ List<NodeData> childs;
+ try
+ {
+ childs = ism.getChildNodesData(context);
+ nodeStates = childs.iterator();
+ }
+ catch (RepositoryException e)
+ {
+ nodeStates = Collections.<NodeData> emptyList().iterator();
+ }
+ }
+ else if (axis == ANCESTOR)
+ {
+ try
+ {
+ nodeStates = new Iterator()
+ {
- private NodeData next = (NodeData) ism
- .getItemData(context.getParentIdentifier());
+ private NodeData next = (NodeData)ism.getItemData(context.getParentIdentifier());
- public void remove() {
- throw new UnsupportedOperationException();
- }
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
- public boolean hasNext() {
- return next != null;
- }
+ public boolean hasNext()
+ {
+ return next != null;
+ }
- public Object next() {
- NodeData tmp = next;
- try {
- if (next.getParentIdentifier() != null) {
- next = (NodeData) ism.getItemData(next
- .getParentIdentifier());
- } else {
- next = null;
- }
- } catch (RepositoryException e) {
- next = null;
- }
- return tmp;
- }
- };
- } catch (RepositoryException e) {
- nodeStates = Collections.EMPTY_LIST.iterator();
- }
- } else if (axis == PARENT) {
- try {
- if (context.getParentIdentifier() != null) {
- NodeData state = (NodeData) ism.getItemData(context
- .getParentIdentifier());
- nodeStates = Collections.singletonList(state)
- .iterator();
- } else {
- nodeStates = Collections.EMPTY_LIST.iterator();
- }
- } catch (RepositoryException e) {
- nodeStates = Collections.EMPTY_LIST.iterator();
- }
- } else {
- // unsupported axis
- nodeStates = Collections.EMPTY_LIST.iterator();
- }
+ public Object next()
+ {
+ NodeData tmp = next;
+ try
+ {
+ if (next.getParentIdentifier() != null)
+ {
+ next = (NodeData)ism.getItemData(next.getParentIdentifier());
+ }
+ else
+ {
+ next = null;
+ }
+ }
+ catch (RepositoryException e)
+ {
+ next = null;
+ }
+ return tmp;
+ }
+ };
+ }
+ catch (RepositoryException e)
+ {
+ nodeStates = Collections.EMPTY_LIST.iterator();
+ }
+ }
+ else if (axis == PARENT)
+ {
+ try
+ {
+ if (context.getParentIdentifier() != null)
+ {
+ NodeData state = (NodeData)ism.getItemData(context.getParentIdentifier());
+ nodeStates = Collections.singletonList(state).iterator();
+ }
+ else
+ {
+ nodeStates = Collections.EMPTY_LIST.iterator();
+ }
+ }
+ catch (RepositoryException e)
+ {
+ nodeStates = Collections.EMPTY_LIST.iterator();
+ }
+ }
+ else
+ {
+ // unsupported axis
+ nodeStates = Collections.EMPTY_LIST.iterator();
+ }
- // check node type, name and property value for each
- while (nodeStates.hasNext()) {
- try {
- NodeData current = (NodeData) nodeStates.next();
- if ((elementTest != null)
- && !current.getPrimaryTypeName()
- .equals(elementTest)) {
- continue;
- }
- if ((nameTest != null)
- && !current.getQPath().getName().equals(nameTest)) {
- continue;
- }
+ // check node type, name and property value for each
+ while (nodeStates.hasNext())
+ {
+ try
+ {
+ NodeData current = (NodeData)nodeStates.next();
+ if ((elementTest != null) && !current.getPrimaryTypeName().equals(elementTest))
+ {
+ continue;
+ }
+ if ((nameTest != null) && !current.getQPath().getName().equals(nameTest))
+ {
+ continue;
+ }
- List<PropertyData> childProps = ism
- .getChildPropertiesData(current);
+ List<PropertyData> childProps = ism.getChildPropertiesData(current);
- PropertyData propState = null;
- for (PropertyData propertyData : childProps) {
- if (propertyData.getQPath().getName().equals(
- propertyName)) {
- propState = propertyData;
- break;
- }
+ PropertyData propState = null;
+ for (PropertyData propertyData : childProps)
+ {
+ if (propertyData.getQPath().getName().equals(propertyName))
+ {
+ propState = propertyData;
+ break;
+ }
- }
- if (propState == null) {
- continue;
- }
+ }
+ if (propState == null)
+ {
+ continue;
+ }
- List<ValueData> values = propState.getValues();
+ List<ValueData> values = propState.getValues();
- // if (values.get(i).toString().equals(propertyValue)) {
- // return true;
- // }
+ // if (values.get(i).toString().equals(propertyValue)) {
+ // return true;
+ // }
- if (propState.getType() == PropertyType.BINARY) {
- // skip binary values
- continue;
- }
+ if (propState.getType() == PropertyType.BINARY)
+ {
+ // skip binary values
+ continue;
+ }
- try {
- for (int i = 0; i < values.size(); i++) {
- byte[] bytes = values.get(i).getAsByteArray();
- String val = new String(bytes,
- Constants.DEFAULT_ENCODING);
- if (val.equals(propertyValue)) {
- return true;
- }
- }
- } catch (IOException e) {
- log.error(e.getLocalizedMessage());
- }
+ try
+ {
+ for (int i = 0; i < values.size(); i++)
+ {
+ byte[] bytes = values.get(i).getAsByteArray();
+ String val = new String(bytes, Constants.DEFAULT_ENCODING);
+ if (val.equals(propertyValue))
+ {
+ return true;
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ log.error(e.getLocalizedMessage());
+ }
- } catch (RepositoryException e) {
- log.error(e.getLocalizedMessage());
- }
- }
- return false;
- }
- }
+ }
+ catch (RepositoryException e)
+ {
+ log.error(e.getLocalizedMessage());
+ }
+ }
+ return false;
+ }
+
+ }
+
+ public Analyzer addPropertyAnalyzer(String propertyName, Analyzer analyzer)
+ {
+ return analyzers.put(propertyName, analyzer);
+ }
}
14 years, 12 months
exo-jcr SVN: r231 - jcr/trunk/component/core.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-10-05 11:17:03 -0400 (Mon, 05 Oct 2009)
New Revision: 231
Modified:
jcr/trunk/component/core/pom.xml
Log:
EXOJCR-161 : test TestExcerpt.java add to exclude
Modified: jcr/trunk/component/core/pom.xml
===================================================================
--- jcr/trunk/component/core/pom.xml 2009-10-05 15:07:37 UTC (rev 230)
+++ jcr/trunk/component/core/pom.xml 2009-10-05 15:17:03 UTC (rev 231)
@@ -430,6 +430,8 @@
<include>**/impl/**/Test*.java</include>
</includes>
<excludes>
+ <exclude>**/TestExcerpt.java</exclude>
+
<exclude>**/TestImport.java</exclude>
<exclude>**/TestRollbackBigFiles.java</exclude>
<exclude>**/TestErrorMultithreading.java</exclude>
14 years, 12 months
exo-jcr SVN: r230 - jcr/trunk/component/core/src/test/java/org.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-10-05 11:07:37 -0400 (Mon, 05 Oct 2009)
New Revision: 230
Modified:
jcr/trunk/component/core/src/test/java/org/
Log:
svn:ignore to org.apache in tests
Property changes on: jcr/trunk/component/core/src/test/java/org
___________________________________________________________________
Name: svn:ignore
+ apache
14 years, 12 months
exo-jcr SVN: r229 - in jcr/trunk/component/core: src/test/java/org/exoplatform/services/jcr/impl/core/query and 1 other directories.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-10-05 11:05:57 -0400 (Mon, 05 Oct 2009)
New Revision: 229
Modified:
jcr/trunk/component/core/pom.xml
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestIndexingConfig.java
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestExcerpt.java
Log:
EXOJCR-161 : test updated
Modified: jcr/trunk/component/core/pom.xml
===================================================================
--- jcr/trunk/component/core/pom.xml 2009-10-05 14:56:26 UTC (rev 228)
+++ jcr/trunk/component/core/pom.xml 2009-10-05 15:05:57 UTC (rev 229)
@@ -430,9 +430,6 @@
<include>**/impl/**/Test*.java</include>
</includes>
<excludes>
- <exclude>**/TestIndexingConfig.java</exclude>
- <exclude>**/TestExcerpt.java</exclude>
-
<exclude>**/TestImport.java</exclude>
<exclude>**/TestRollbackBigFiles.java</exclude>
<exclude>**/TestErrorMultithreading.java</exclude>
Modified: jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestIndexingConfig.java
===================================================================
--- jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestIndexingConfig.java 2009-10-05 14:56:26 UTC (rev 228)
+++ jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/query/TestIndexingConfig.java 2009-10-05 15:05:57 UTC (rev 229)
@@ -28,11 +28,18 @@
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.BooleanClause.Occur;
import org.exoplatform.services.jcr.impl.core.NodeImpl;
+import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
+import org.exoplatform.services.jcr.impl.core.query.lucene.FieldNames;
import org.exoplatform.services.jcr.impl.core.query.lucene.IndexingConfigurationImpl;
+import org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import java.io.IOException;
+
import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
/**
* Created by The eXo Platform SAS.
@@ -42,6 +49,10 @@
*/
public class TestIndexingConfig extends BaseQueryTest
{
+ private final String workspaceName = "ws2";
+
+ private final String repositoryName = "db1tck";
+
public final String testString1 = "The quick brown fox jumped over the lazy dogs";
public final String testString2 = "XY&Z Corporation - xyz(a)example.com";
@@ -64,16 +75,33 @@
*/
private final Log log = ExoLogger.getLogger("jcr.TestIndexingConfig");
+ private SearchManager searchManager;
+
+ private SearchIndex searchIndex;
+
+ private Session testSession;
+
@Override
public void setUp() throws Exception
{
super.setUp();
- IndexingConfigurationImpl indexingConfigurationImpl =
- (IndexingConfigurationImpl)defaultSearchIndex.getIndexingConfig();
-// indexingConfigurationImpl.setPropertyAnalyzer("FULL:" + simple, new SimpleAnalyzer());
-// indexingConfigurationImpl.setPropertyAnalyzer("FULL:" + whitespace, new WhitespaceAnalyzer());
-// indexingConfigurationImpl.setPropertyAnalyzer("FULL:" + stop, new StopAnalyzer());
- testRoot = root.addNode("testrootAnalyzers");
+
+ RepositoryImpl db1tckRepo = (RepositoryImpl)repositoryService.getRepository(repositoryName);
+ assertNotNull(db1tckRepo);
+ testSession = db1tckRepo.login(credentials, workspaceName);
+
+ searchManager = (SearchManager)db1tckRepo.getWorkspaceContainer(workspaceName).getComponent(SearchManager.class);
+ assertNotNull(searchManager);
+ searchIndex = (SearchIndex)(searchManager.getHandler());
+ assertNotNull(searchIndex);
+
+ IndexingConfigurationImpl indexingConfigurationImpl = (IndexingConfigurationImpl)searchIndex.getIndexingConfig();
+ assertNotNull(indexingConfigurationImpl);
+
+ indexingConfigurationImpl.addPropertyAnalyzer("FULL:" + simple, new SimpleAnalyzer());
+ indexingConfigurationImpl.addPropertyAnalyzer("FULL:" + whitespace, new WhitespaceAnalyzer());
+ indexingConfigurationImpl.addPropertyAnalyzer("FULL:" + stop, new StopAnalyzer());
+ testRoot = testSession.getRootNode().addNode("testrootAnalyzers");
root.save();
}
@@ -81,7 +109,7 @@
public void tearDown() throws Exception
{
testRoot.remove();
- root.save();
+ testSession.save();
super.tearDown();
}
@@ -95,14 +123,14 @@
Node testNode2 = testRoot.addNode("node2");
testNode2.setProperty(simple, testString2);
- root.save();
+ testSession.save();
// Test is there are all terms
// There must be [the] [quick] [brown] [fox] [jumped] [over] [the] [lazy] [dogs]
// in Node1
Document doc = this.getDocument(testNode1.getInternalIdentifier(), false);
- System.out.println(doc);
+ assertNotNull(doc);
TermQuery the = new TermQuery(new Term("FULL:" + simple, "the"));
TermQuery quick = new TermQuery(new Term("FULL:" + simple, "quick"));
@@ -123,7 +151,7 @@
compl.add(lazy, Occur.MUST);
compl.add(dogs, Occur.MUST);
- IndexReader ir = defaultSearchIndex.getIndexReader();
+ IndexReader ir = searchIndex.getIndexReader();
IndexSearcher is = new IndexSearcher(ir);
Hits hits = is.search(compl);
@@ -171,7 +199,7 @@
Node testNode2 = testRoot.addNode("node2");
testNode2.setProperty(whitespace, testString2);
- root.save();
+ testSession.save();
// Test is there are all terms
// There must be [The] [quick] [brown] [fox] [jumped] [over] [the] [lazy] [dogs]
@@ -198,7 +226,7 @@
compl.add(lazy, Occur.MUST);
compl.add(dogs, Occur.MUST);
- IndexReader ir = defaultSearchIndex.getIndexReader();
+ IndexReader ir = searchIndex.getIndexReader();
IndexSearcher is = new IndexSearcher(ir);
Hits hits = is.search(compl);
@@ -241,7 +269,7 @@
Node testNode2 = testRoot.addNode("node2");
testNode2.setProperty(stop, testString2);
- root.save();
+ testSession.save();
// Test is there are all terms
// There must be [quick] [brown] [fox] [jumped] [over] [lazy] [dogs]
@@ -264,7 +292,7 @@
compl.add(lazy, Occur.MUST);
compl.add(dogs, Occur.MUST);
- IndexReader ir = defaultSearchIndex.getIndexReader();
+ IndexReader ir = searchIndex.getIndexReader();
IndexSearcher is = new IndexSearcher(ir);
Hits hits = is.search(compl);
@@ -313,7 +341,7 @@
Node testNode2 = testRoot.addNode("node2");
testNode2.setProperty(def, testString2);
- root.save();
+ testSession.save();
// Test is there are all terms
// There must be [quick] [brown] [fox] [jumped] [over] [lazy] [dogs]
@@ -338,7 +366,7 @@
compl.add(lazy, Occur.MUST);
compl.add(dogs, Occur.MUST);
- IndexReader ir = defaultSearchIndex.getIndexReader();
+ IndexReader ir = searchIndex.getIndexReader();
IndexSearcher is = new IndexSearcher(ir);
Hits hits = is.search(compl);
@@ -372,4 +400,20 @@
}
}
+ protected Document getDocument(String nodeIdentifer, boolean includeSystemIndex) throws IOException,
+ RepositoryException
+ {
+ IndexReader reader = ((SearchIndex)searchManager.getHandler()).getIndexReader();
+ IndexSearcher is = new IndexSearcher(reader);
+ TermQuery query = new TermQuery(new Term(FieldNames.UUID, nodeIdentifer));
+
+ Hits result = is.search(query);
+
+ if (result.length() == 1)
+ return result.doc(0);
+ else if (result.length() > 1)
+ throw new RepositoryException("Results more then one");
+
+ return null;
+ }
}
Modified: jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestExcerpt.java
===================================================================
--- jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestExcerpt.java 2009-10-05 14:56:26 UTC (rev 228)
+++ jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestExcerpt.java 2009-10-05 15:05:57 UTC (rev 229)
@@ -18,12 +18,14 @@
*/
package org.exoplatform.services.jcr.usecases;
+import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.core.nodetype.ExtendedNodeTypeManager;
import java.io.InputStream;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import javax.jcr.Value;
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
@@ -43,13 +45,26 @@
+ "org.exoplatform.services.jcr.impl.core.query.lucene.DefaultHTMLExcerpt. "
+ "the configuration parameter for this setting is:" + "This is the test for Excerpt query";
+ private String string1_excerpt =
+ "<div><span>the configuration parameter for this setting is:This is the "
+ + "<strong>test</strong> for Excerpt query</span></div>";
+
private String s2 =
- "It is a test for Excerpt query."
- + "Searching with synonyms is integrated in the jcr:contains() function and uses the same syntax "
- + "like synonym searches with Google. If a search term is prefixed with ~ also synonyms of the search term are considered. Example:";
+ "It is a test for Excerpt query.Searching with synonyms is integrated in the jcr:contains() "
+ + "function and uses the same syntax " + "like synonym searches with Google. If a search "
+ + "term is prefixed with ~ also synonyms of the search term are considered. Example:";
+ private String string2_excerpt =
+ "<div><span>Node2 It is a <strong>test</strong> for Excerpt query."
+ + "Searching with synonyms is integrated in the jcr:contains() function and "
+ + "uses the same syntax like synonym ...</span></div>";
+
private String s3 = "JCR supports such features as Lucene Fuzzy Searches";
+ private Session testSession;
+
+ private Node testRoot;
+
/**
* Initialization flag.
*/
@@ -72,43 +87,71 @@
}
}
+ /**
+ * @see org.exoplatform.services.jcr.BaseStandaloneTest#setUp()
+ */
+ @Override
+ public void setUp() throws Exception
+ {
+ // TODO Auto-generated method stub
+ super.setUp();
+ ManageableRepository db1tckRepo = repositoryService.getRepository("db1tck");
+ assertNotNull(db1tckRepo);
+ testSession = db1tckRepo.login(credentials, "ws2");
+ testRoot = testSession.getRootNode();
+ }
+
public void testExcerpt() throws Exception
{
- System.out.println("\n\n----------Test Excerpt");
- Node node1 = root.addNode("Node1", "exo:article");
+ Node node1 = testRoot.addNode("Node1", "exo:article");
node1.setProperty("exo:title", "Node1");
node1.setProperty("exo:text", s1);
- Node node2 = root.addNode("Node2", "exo:article");
+ Node node2 = testRoot.addNode("Node2", "exo:article");
node2.setProperty("exo:title", "Node2");
node2.setProperty("exo:text", s2);
- Node node3 = root.addNode("Node3", "exo:article");
+ Node node3 = testRoot.addNode("Node3", "exo:article");
node3.setProperty("exo:title", "Node3");
node3.setProperty("exo:text", s3);
- session.save();
+ testSession.save();
- System.out.println("\n\n-----Test with SQL");
- QueryManager queryManager = session.getWorkspace().getQueryManager();
- Query q1 = queryManager.createQuery("select excerpt(.) from exo:article where contains(., 'test')", Query.SQL);
+ QueryManager queryManager = testSession.getWorkspace().getQueryManager();
+ Query q1 =
+ queryManager.createQuery("select exo:text, excerpt(.) from exo:article where contains(., 'test')", Query.SQL);
QueryResult result1 = q1.execute();
for (RowIterator it = result1.getRows(); it.hasNext();)
{
Row r = it.nextRow();
Value excerpt = r.getValue("rep:excerpt(.)");
- System.out.println("\n\n---" + excerpt.getString());
+ Value text = r.getValue("exo:text");
+ if (text.getString().equals(s1))
+ {
+ assertEquals(string1_excerpt, excerpt.getString());
+ }
+ else if (text.getString().equals(s2))
+ {
+ assertEquals(string2_excerpt, excerpt.getString());
+ }
}
- System.out.println("\n\n-----Test with XPATH");
Query q2 = queryManager.createQuery("//*[jcr:contains(., 'test')]/(@exo:text|rep:excerpt(.))", Query.XPATH);
QueryResult result2 = q2.execute();
for (RowIterator it = result2.getRows(); it.hasNext();)
{
Row r = it.nextRow();
Value excerpt = r.getValue("rep:excerpt(.)");
- System.out.println("\n\n---" + excerpt.getString());
+ Value text = r.getValue("exo:text");
+ if (text.getString().equals(s1))
+ {
+ assertEquals(string1_excerpt, excerpt.getString());
+ }
+ else if (text.getString().equals(s2))
+ {
+ assertEquals(string2_excerpt, excerpt.getString());
+ }
}
}
}
14 years, 12 months
exo-jcr SVN: r228 - jcr/trunk.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2009-10-05 10:56:26 -0400 (Mon, 05 Oct 2009)
New Revision: 228
Modified:
jcr/trunk/pom.xml
Log:
EXOJCR-166: Support separated ear delivery
Modified: jcr/trunk/pom.xml
===================================================================
--- jcr/trunk/pom.xml 2009-10-05 14:06:55 UTC (rev 227)
+++ jcr/trunk/pom.xml 2009-10-05 14:56:26 UTC (rev 228)
@@ -464,17 +464,11 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <skip>${exo.test.skip}</skip>
- <useFile>${exo.test.use.file}</useFile>
- <testFailureIgnore>${exo.test.failure.ignore}</testFailureIgnore>
- <classesDirectory>${exo.test.classesdirectory}</classesDirectory>
- <forkMode>${exo.test.forkMode}</forkMode>
<includes>
<include>**/${exo.test.includes}.java</include>
</includes>
<excludes>
<exclude>**/ftpclient/**/*.java</exclude>
- <exclude>**/TestEncoding.java</exclude>
</excludes>
</configuration>
</plugin>
14 years, 12 months
exo-jcr SVN: r227 - in jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav: command and 3 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-10-05 10:06:55 -0400 (Mon, 05 Oct 2009)
New Revision: 227
Modified:
jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java
jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java
jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/CollectionResource.java
jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropertyWriteUtil.java
Log:
EXOJCR-169 Support for specific characters added
Modified: jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
===================================================================
--- jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2009-10-05 13:26:34 UTC (rev 226)
+++ jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2009-10-05 14:06:55 UTC (rev 227)
@@ -69,8 +69,10 @@
import org.exoplatform.services.rest.resource.ResourceContainer;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
+import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
@@ -1151,7 +1153,42 @@
{
return repoPath.substring(0, repoPath.length() - 1);
}
- return repoPath;
+
+ String[] pathElements = repoPath.split("/");
+ StringBuffer escapedPath = new StringBuffer();
+ for (String element : pathElements)
+ {
+ try
+ {
+ if (element.contains(":"))
+ {
+ element = element.replaceAll(":", URLEncoder.encode(":", "UTF-8"));
+ }
+ if (element.contains("["))
+ {
+ element = element.replaceAll("\\[", URLEncoder.encode("[", "UTF-8"));
+ }
+ if (element.contains("]"))
+ {
+ element = element.replaceAll("]", URLEncoder.encode("]", "UTF-8"));
+ }
+ if (element.contains("'"))
+ {
+ element = element.replaceAll("'", URLEncoder.encode("'", "UTF-8"));
+ }
+ if (element.contains("\""))
+ {
+ element = element.replaceAll("\"", URLEncoder.encode("\"", "UTF-8"));
+ }
+ escapedPath.append(element + "/");
+ }
+ catch (Exception e)
+ {
+ log.warn(e.getMessage());
+ }
+ }
+
+ return escapedPath.toString().substring(0, escapedPath.length() - 1);
}
/**
Modified: jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java
===================================================================
--- jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java 2009-10-05 13:26:34 UTC (rev 226)
+++ jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java 2009-10-05 14:06:55 UTC (rev 227)
@@ -64,7 +64,7 @@
private static Log log = ExoLogger.getLogger(PropFindCommand.class);
/**
- * Webdav Propfind methos implementation.
+ * Webdav Propfind method implementation.
*
* @param session current session
* @param path resource path
Modified: jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java
===================================================================
--- jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java 2009-10-05 13:26:34 UTC (rev 226)
+++ jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/propfind/PropFindResponseEntity.java 2009-10-05 14:06:55 UTC (rev 227)
@@ -30,7 +30,9 @@
import java.io.IOException;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
+import java.net.URLDecoder;
import java.util.Set;
import javax.jcr.RepositoryException;
@@ -150,21 +152,23 @@
* @throws RepositoryException {@link RepositoryException}
* @throws IllegalResourceTypeException {@link IllegalResourceTypeException}
* @throws URISyntaxException {@link URISyntaxException}
+ * @throws UnsupportedEncodingException
*/
private void traverseResources(Resource resource, int counter) throws XMLStreamException, RepositoryException,
- IllegalResourceTypeException, URISyntaxException
+ IllegalResourceTypeException, URISyntaxException, UnsupportedEncodingException
{
xmlStreamWriter.writeStartElement("DAV:", "response");
xmlStreamWriter.writeStartElement("DAV:", "href");
+ String href = URLDecoder.decode(resource.getIdentifier().toASCIIString(), "UTF-8");
if (resource.isCollection())
{
- xmlStreamWriter.writeCharacters(resource.getIdentifier().toASCIIString() + "/");
+ xmlStreamWriter.writeCharacters(href + "/");
}
else
{
- xmlStreamWriter.writeCharacters(resource.getIdentifier().toASCIIString());
+ xmlStreamWriter.writeCharacters(href);
}
xmlStreamWriter.writeEndElement();
@@ -177,11 +181,6 @@
int d = depth;
- if (depth == -1)
- {
-
- }
-
if (resource.isCollection())
{
if (counter < d)
Modified: jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/CollectionResource.java
===================================================================
--- jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/CollectionResource.java 2009-10-05 13:26:34 UTC (rev 226)
+++ jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/resource/CollectionResource.java 2009-10-05 14:06:55 UTC (rev 227)
@@ -29,7 +29,9 @@
import java.io.InputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
+import java.io.UnsupportedEncodingException;
import java.net.URI;
+import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashSet;
@@ -418,7 +420,7 @@
writer.writeStartElement(XML_NODE);
writer.writeAttribute(PREFIX_XMLNS, PREFIX_LINK);
writer.writeAttribute(XLINK_XMLNS, XLINK_LINK);
- String itemName = node.getName();
+ String itemName = URLDecoder.decode(node.getName(), "UTF-8");
writer.writeAttribute(XML_NAME, itemName);
String itemPath = node.getPath();
writer.writeAttribute(XML_HREF, rootHref + itemPath);
@@ -437,8 +439,8 @@
{
Node childNode = ni.nextNode();
writer.writeStartElement(XML_NODE);
- writer.writeAttribute(XML_NAME, childNode.getName());
- String childNodeHref = rootHref + childNode.getPath();
+ writer.writeAttribute(XML_NAME, URLDecoder.decode(childNode.getName(), "UTF-8"));
+ String childNodeHref = rootHref + URLDecoder.decode(childNode.getPath(), "UTF-8");
writer.writeAttribute(XML_HREF, childNodeHref);
writer.writeEndElement();
}
@@ -453,6 +455,10 @@
{
LOG.error("Error has occured while xml processing : ", e);
}
+ catch (UnsupportedEncodingException e)
+ {
+ LOG.warn(e.getMessage());
+ }
finally
{
try
Modified: jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropertyWriteUtil.java
===================================================================
--- jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropertyWriteUtil.java 2009-10-05 13:26:34 UTC (rev 226)
+++ jcr/trunk/component/webdav/src/main/java/org/exoplatform/services/jcr/webdav/xml/PropertyWriteUtil.java 2009-10-05 14:06:55 UTC (rev 227)
@@ -20,6 +20,8 @@
import org.exoplatform.common.util.HierarchicalProperty;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -132,7 +134,14 @@
writeAttributes(xmlStreamWriter, prop);
- xmlStreamWriter.writeCharacters(prop.getValue());
+ try
+ {
+ xmlStreamWriter.writeCharacters(URLDecoder.decode(prop.getValue(), "UTF-8"));
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ e.printStackTrace();
+ }
xmlStreamWriter.writeEndElement();
}
}
14 years, 12 months