REPO-4969: -merge branch 'master' into support/SP/8.50.N

This commit is contained in:
Andrei Forascu
2020-02-26 15:35:03 +02:00
8 changed files with 33298 additions and 19925 deletions

View File

@@ -43,4 +43,4 @@ jobs:
# Add email to link commits to user # Add email to link commits to user
- git config user.email "${GIT_EMAIL}" - git config user.email "${GIT_EMAIL}"
# Skip building of release commits # Skip building of release commits
- mvn --batch-mode -q -DscmCommentPrefix="[maven-release-plugin][skip ci] " -Dusername="${GIT_USERNAME}" -Dpassword="${GIT_PASSWORD}" -DskipTests -Darguments=-DskipTests release:clean release:prepare release:perform - mvn --batch-mode -q -DscmCommentPrefix="[maven-release-plugin][skip ci] " -Dusername="${GIT_USERNAME}" -Dpassword="${GIT_PASSWORD}" -DskipTests -Darguments=-DskipTests release:clean release:prepare release:perform

72
pom.xml
View File

@@ -27,8 +27,8 @@
</distributionManagement> </distributionManagement>
<properties> <properties>
<dependency.alfresco-core.version>7.26</dependency.alfresco-core.version> <dependency.alfresco-core.version>7.27</dependency.alfresco-core.version>
<dependency.cxf.version>3.3.2</dependency.cxf.version> <dependency.cxf.version>3.3.5</dependency.cxf.version>
<!-- Files to exclude from SonarQube analysis --> <!-- Files to exclude from SonarQube analysis -->
<sonar.exclusions> <sonar.exclusions>
source/java/org/alfresco/repo/search/impl/parsers/CMIS*er.java, source/java/org/alfresco/repo/search/impl/parsers/CMIS*er.java,
@@ -83,7 +83,7 @@
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version> <version>3.2.0</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
@@ -171,7 +171,7 @@
<dependency> <dependency>
<groupId>org.bouncycastle</groupId> <groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk15on</artifactId> <artifactId>bcmail-jdk15on</artifactId>
<version>1.62</version> <version>1.64</version>
</dependency> </dependency>
<!-- upgrade dependency from TIKA --> <!-- upgrade dependency from TIKA -->
<dependency> <dependency>
@@ -189,7 +189,7 @@
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>28.0-jre</version> <version>28.2-jre</version>
</dependency> </dependency>
<!-- upgrade dependency from TIKA --> <!-- upgrade dependency from TIKA -->
<dependency> <dependency>
@@ -201,7 +201,7 @@
<dependency> <dependency>
<groupId>org.apache.pdfbox</groupId> <groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId> <artifactId>pdfbox</artifactId>
<version>2.0.15</version> <version>2.0.17</version>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@@ -228,19 +228,12 @@
<dependency> <dependency>
<groupId>org.jibx</groupId> <groupId>org.jibx</groupId>
<artifactId>jibx-run</artifactId> <artifactId>jibx-run</artifactId>
<version>1.3.1</version> <version>1.3.3</version>
</dependency> </dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.9</version>
</dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId> <artifactId>jackson-annotations</artifactId>
<version>2.9.9</version> <version>2.10.2</version>
</dependency> </dependency>
<dependency> <dependency>
@@ -249,17 +242,6 @@
<version>3.5.2</version> <version>3.5.2</version>
</dependency> </dependency>
<!-- the cxf libs were updated, see dependencyManagement section --> <!-- the cxf libs were updated, see dependencyManagement section -->
<dependency>
<groupId>org.apache.chemistry.opencmis</groupId>
<artifactId>chemistry-opencmis-client-impl</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependency>
<groupId>org.apache.chemistry.opencmis</groupId> <groupId>org.apache.chemistry.opencmis</groupId>
<artifactId>chemistry-opencmis-commons-impl</artifactId> <artifactId>chemistry-opencmis-commons-impl</artifactId>
@@ -282,16 +264,6 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>woodstox-core-asl</artifactId>
<version>4.4.1</version>
</dependency>
<!-- This is now deployed at: <!-- This is now deployed at:
| http://artifacts.alfresco.com/nexus/content/repositories/thirdparty/org/acegisecurity/acegi-security/0.8.2_patched/ | http://artifacts.alfresco.com/nexus/content/repositories/thirdparty/org/acegisecurity/acegi-security/0.8.2_patched/
--> -->
@@ -308,12 +280,7 @@
<dependency> <dependency>
<groupId>xerces</groupId> <groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId> <artifactId>xercesImpl</artifactId>
<version>2.11.0-alfresco-patched-20180402</version> <version>2.12.0-alfresco-patched-20191004</version>
</dependency>
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3</artifactId>
<version>1.1.3_8</version>
</dependency> </dependency>
<!-- Tika --> <!-- Tika -->
<dependency> <dependency>
@@ -340,27 +307,12 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.gagravarr</groupId>
<artifactId>vorbis-java-core</artifactId>
<version>0.8</version>
</dependency>
<dependency>
<groupId>org.gagravarr</groupId>
<artifactId>vorbis-java-tika</artifactId>
<version>0.8</version>
</dependency>
<dependency>
<groupId>com.googlecode.juniversalchardet</groupId>
<artifactId>juniversalchardet</artifactId>
<version>1.0.3</version>
</dependency>
<!-- Test dependencies --> <!-- Test dependencies -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.12</version> <version>4.13</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@@ -371,8 +323,8 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-core</artifactId>
<version>1.10.19</version> <version>3.2.4</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,46 @@
# Antlr Grammars
The grammar files in this package (e.g. `FTS.g`) are written using the Antlr 3 syntax.
The java lexer and parser files are generated from the grammar files, along with the files
containing the tokens.
The easiest way to make changes to the grammar files is by using
[AntlrWorks 1.5](https://www.antlr3.org/download.html). This can be used to step through the
evaluations made while parsing troublesome input, and can help visualise the resulting
decision tree. AntlrWorks includes a menu option to compile the grammar, and will generate
replacements for the existing files.
AntlrWorks will fail to parse the grammar file if it contains references to unknown classes
(for example FTS.g contains references to MismatchedTokenException and FTSQueryException).
To work around this issue then temporarily replace these exceptions with RuntimeExceptions.
Once changes to the grammar have been completed then these can either be manually fixed in
the generated output or compilation can be done via the command line. This requires the
[antlr jar](http://www.antlr3.org/download/antlr-3.5.2-complete-no-st3.jar) to be downloaded:
```bash
java -jar ~/Downloads/antlr-3.5.2-complete-no-st3.jar -o . src/main/java/org/alfresco/repo/search/impl/parsers/FTS.g
```
For some grammars then Antlr generates Java files that cannot be compiled due to the
64KB limit on methods. Attempting to compile this code will result in the error "Code too
large". In particular this is true of [FTS.g](FTS.g). To work around this issue then once
the code has been generated using Antlr it must be refactored to ensure no single method is
too large. For example, in [FTSParser.java](FTSParser.java) several larger blocks of code
have been manually extracted to smaller methods that look like:
```java
private int specialStateTransition7(int LA17_9)
{
int s;
s = -1;
if ( (LA17_9==STAR) ) {s = 25;}
else if ( (LA17_9==DOTDOT) && (synpred3_FTS())) {s = 27;}
else if ( (LA17_9==COMMA||LA17_9==DOT) && (synpred5_FTS())) {s = 28;}
...
else if ( (LA17_9==MINUS) && (synpred5_FTS())) {s = 57;}
return s;
}
```
To verify the grammar behaves how we expect then there are unit tests in
`org.alfresco.repo.search.impl.parsers`. These use gunit files to specify expected input and
output pairs for different entry points in the grammar. More details about guint file can
be found on the [Antlr 3 wiki](https://theantlrguy.atlassian.net/wiki/spaces/ANTLR3/pages/2687338/gUnit+-+Grammar+Unit+Testing).

View File

@@ -25,7 +25,6 @@
*/ */
package org.alfresco.util; package org.alfresco.util;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@@ -37,11 +36,13 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.jar.JarEntry; import java.util.jar.JarEntry;
@@ -81,7 +82,7 @@ public abstract class ConfigFileFinder
AtomicBoolean somethingRead = new AtomicBoolean(false); AtomicBoolean somethingRead = new AtomicBoolean(false);
// Try reading resources in a jar // Try reading resources in a jar
final File jarFile = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath()); final File jarFile = new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI());
if (jarFile.isFile()) if (jarFile.isFile())
{ {
readFromJar(jarFile, path, log, successReadingConfig, somethingRead); readFromJar(jarFile, path, log, successReadingConfig, somethingRead);
@@ -89,11 +90,15 @@ public abstract class ConfigFileFinder
else else
{ {
// Try reading resources from disk // Try reading resources from disk
URL url = getClass().getClassLoader().getResource(path); Iterator<URL> pathUrls = getClass().getClassLoader().getResources(path).asIterator();
if (url != null) while(pathUrls.hasNext())
{ {
String urlPath = url.getPath(); URL url = pathUrls.next();
readFromDisk(urlPath, log, successReadingConfig, somethingRead); if (url != null)
{
String urlPath = url.getPath();
readFromDisk(urlPath, log, successReadingConfig, somethingRead);
}
} }
} }
@@ -108,7 +113,7 @@ public abstract class ConfigFileFinder
log.debug("No config read from "+path); log.debug("No config read from "+path);
} }
} }
catch (IOException e) catch (IOException | URISyntaxException e)
{ {
log.error("Error reading from "+path, e); log.error("Error reading from "+path, e);
successReadingConfig.set(false); successReadingConfig.set(false);
@@ -203,7 +208,7 @@ public abstract class ConfigFileFinder
boolean successReadingConfig = true; boolean successReadingConfig = true;
try try
{ {
JsonNode jsonNode = jsonObjectMapper.readValue(reader, new TypeReference<JsonNode>() {}); JsonNode jsonNode = jsonObjectMapper.readValue(reader, JsonNode.class);
String readFromMessage = readFrom + ' ' + path; String readFromMessage = readFrom + ' ' + path;
if (log.isTraceEnabled()) if (log.isTraceEnabled())
{ {

View File

@@ -21,6 +21,8 @@ ftsQuery:
"test_txt_woof" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM test_txt_woof))))" "test_txt_woof" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM test_txt_woof))))"
"test,txt,woof" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM test , txt , woof))))" "test,txt,woof" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM test , txt , woof))))"
"test\:txt\:woof" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM test\\:txt\\:woof))))" "test\:txt\:woof" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM test\\:txt\\:woof))))"
"name-dash:file" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM file (FIELD_REF name-dash)))))"
"name-dash:file.txt" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM file . txt (FIELD_REF name-dash)))))"
"+\++" -> "(DISJUNCTION (CONJUNCTION (MANDATORY (TERM \\++))))" "+\++" -> "(DISJUNCTION (CONJUNCTION (MANDATORY (TERM \\++))))"
".txt" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM . txt))))" ".txt" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM . txt))))"
"*.txt" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM * . txt))))" "*.txt" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM * . txt))))"
@@ -60,6 +62,7 @@ ftsQuery:
"10" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM 10))))" "10" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM 10))))"
"-10" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM -10))))" "-10" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM -10))))"
"cm_content.mimetype:\"text/plain\"" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (PHRASE \"text/plain\" (FIELD_REF cm_content.mimetype)))))" "cm_content.mimetype:\"text/plain\"" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (PHRASE \"text/plain\" (FIELD_REF cm_content.mimetype)))))"
"name:file.txt" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM file . txt (FIELD_REF name)))))"
"10.10.pdf" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM 10 . 10 . pdf))))" "10.10.pdf" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM 10 . 10 . pdf))))"
"TYPE:cm:content" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM content (FIELD_REF cm (PREFIX TYPE))))))" "TYPE:cm:content" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM content (FIELD_REF cm (PREFIX TYPE))))))"
"TYPE:content" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM content (FIELD_REF TYPE)))))" "TYPE:content" -> "(DISJUNCTION (CONJUNCTION (DEFAULT (TERM content (FIELD_REF TYPE)))))"
@@ -190,8 +193,10 @@ ftsTest:
ftsTermOrPhrase: ftsTermOrPhrase:
"name:woof" -> "(TERM woof (FIELD_REF name))" "name:woof" -> "(TERM woof (FIELD_REF name))"
"name:woof.txt" -> "(TERM woof . txt (FIELD_REF name))"
"cm_name:woof" -> "(TERM woof (FIELD_REF cm_name))" "cm_name:woof" -> "(TERM woof (FIELD_REF cm_name))"
"cm:name:woof" -> "(TERM woof (FIELD_REF name (PREFIX cm)))" "cm:name:woof" -> "(TERM woof (FIELD_REF name (PREFIX cm)))"
"content.mimetype:woof.txt" -> "(TERM woof . txt (FIELD_REF content.mimetype))"
"{http://www.alfresco.org/model/content/1.0}name:woof" -> "(TERM woof (FIELD_REF name (NAME_SPACE {http://www.alfresco.org/model/content/1.0})))" "{http://www.alfresco.org/model/content/1.0}name:woof" -> "(TERM woof (FIELD_REF name (NAME_SPACE {http://www.alfresco.org/model/content/1.0})))"
"\"zebra\"" -> "(PHRASE \"zebra\")" "\"zebra\"" -> "(PHRASE \"zebra\")"
"'zebra'" -> "(PHRASE 'zebra')" "'zebra'" -> "(PHRASE 'zebra')"
@@ -204,8 +209,10 @@ ftsTermOrPhrase:
ftsExactTermOrPhrase: ftsExactTermOrPhrase:
"=name:woof" -> "(EXACT_TERM woof (FIELD_REF name))" "=name:woof" -> "(EXACT_TERM woof (FIELD_REF name))"
"=name:woof.txt" -> "(EXACT_TERM woof . txt (FIELD_REF name))"
"=cm_name:woof" -> "(EXACT_TERM woof (FIELD_REF cm_name))" "=cm_name:woof" -> "(EXACT_TERM woof (FIELD_REF cm_name))"
"=cm:name:woof" -> "(EXACT_TERM woof (FIELD_REF name (PREFIX cm)))" "=cm:name:woof" -> "(EXACT_TERM woof (FIELD_REF name (PREFIX cm)))"
"=content.mimetype:woof.txt" -> "(EXACT_TERM woof . txt (FIELD_REF content.mimetype))"
"={http://www.alfresco.org/model/content/1.0}name:woof" -> "(EXACT_TERM woof (FIELD_REF name (NAME_SPACE {http://www.alfresco.org/model/content/1.0})))" "={http://www.alfresco.org/model/content/1.0}name:woof" -> "(EXACT_TERM woof (FIELD_REF name (NAME_SPACE {http://www.alfresco.org/model/content/1.0})))"
@@ -213,8 +220,10 @@ ftsExactTermOrPhrase:
ftsTokenisedTermOrPhrase: ftsTokenisedTermOrPhrase:
"~woof" -> "(TERM woof)" "~woof" -> "(TERM woof)"
"~name:woof" -> "(TERM woof (FIELD_REF name))" "~name:woof" -> "(TERM woof (FIELD_REF name))"
"~name:woof.txt" -> "(TERM woof . txt (FIELD_REF name))"
"~cm_name:woof" -> "(TERM woof (FIELD_REF cm_name))" "~cm_name:woof" -> "(TERM woof (FIELD_REF cm_name))"
"~cm:name:woof" -> "(TERM woof (FIELD_REF name (PREFIX cm)))" "~cm:name:woof" -> "(TERM woof (FIELD_REF name (PREFIX cm)))"
"~content.mimetype:woof.txt" -> "(TERM woof . txt (FIELD_REF content.mimetype))"
"~{http://www.alfresco.org/model/content/1.0}name:woof" -> "(TERM woof (FIELD_REF name (NAME_SPACE {http://www.alfresco.org/model/content/1.0})))" "~{http://www.alfresco.org/model/content/1.0}name:woof" -> "(TERM woof (FIELD_REF name (NAME_SPACE {http://www.alfresco.org/model/content/1.0})))"