mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Compare commits
60 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
caf5b6350f | ||
|
8ae8ad356c | ||
|
b5ee3c06a9 | ||
|
5b6d080e8a | ||
|
e03c8a72d1 | ||
|
70e7f68a4b | ||
|
19053341b8 | ||
|
24c41b97cc | ||
|
97de175cde | ||
|
6a719bb5f6 | ||
|
b8a3724ee7 | ||
|
0077d31bed | ||
|
342bd5a103 | ||
|
d848e12981 | ||
|
9cb2b23ef5 | ||
|
7db90ee90c | ||
|
9d0106e000 | ||
|
26c991a563 | ||
|
ddfabba4ba | ||
|
ab7d757412 | ||
|
fe028f5b85 | ||
|
2baf1b9c91 | ||
|
3818f94268 | ||
|
53b41068d4 | ||
|
c302bc31ff | ||
|
9a30044064 | ||
|
41edced9f1 | ||
|
15ca9e21be | ||
|
36bf6d2f81 | ||
|
cf01f167ae | ||
|
4c94059bbf | ||
|
5efe11008d | ||
|
3225eefd0b | ||
|
b6de89aa8d | ||
|
4cc1c10ce5 | ||
|
7641c128c5 | ||
|
a62ad8715e | ||
|
542f189907 | ||
|
a006b5acaf | ||
|
c2e516b69a | ||
|
2c5044896b | ||
|
24454afe6b | ||
|
aec55ed8a6 | ||
|
ddd5a4ae48 | ||
|
e523245a10 | ||
|
c4217b32fb | ||
|
2fbd21076f | ||
|
cb1419b140 | ||
|
9a6c6f2ee9 | ||
|
eaff930456 | ||
|
4a03e8cc98 | ||
|
0eaeea35f8 | ||
|
f4c632c26b | ||
|
3c96ed9482 | ||
|
0141284b37 | ||
|
2c8ed7f4b5 | ||
|
decbe6b285 | ||
|
f0f538bad0 | ||
|
c0aaf75284 | ||
|
7f5889474e |
18
.travis.yml
18
.travis.yml
@@ -54,7 +54,7 @@ jobs:
|
|||||||
before_script:
|
before_script:
|
||||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext01TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext01TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
|
||||||
- name: "Repository - AppContext02TestSuite"
|
- name: "Repository - AppContext02TestSuite"
|
||||||
@@ -67,14 +67,14 @@ jobs:
|
|||||||
before_script:
|
before_script:
|
||||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext03TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext03TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
|
||||||
- name: "Repository - AppContext04TestSuite"
|
- name: "Repository - AppContext04TestSuite"
|
||||||
before_script:
|
before_script:
|
||||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext04TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext04TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
|
||||||
- name: "Repository - AppContext05TestSuite"
|
- name: "Repository - AppContext05TestSuite"
|
||||||
@@ -91,21 +91,21 @@ jobs:
|
|||||||
before_script:
|
before_script:
|
||||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext06TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContext06TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
|
||||||
- name: "Repository - AppContextExtraTestSuite"
|
- name: "Repository - AppContextExtraTestSuite"
|
||||||
before_script:
|
before_script:
|
||||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContextExtraTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
script: travis_wait 20 mvn -B test -pl repository -Dtest=AppContextExtraTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
|
||||||
- name: "Repository - MiscContextTestSuite"
|
- name: "Repository - MiscContextTestSuite"
|
||||||
before_script:
|
before_script:
|
||||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=MiscContextTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
script: travis_wait 20 mvn -B test -pl repository -Dtest=MiscContextTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
|
||||||
- name: "Repository - SearchTestSuite"
|
- name: "Repository - SearchTestSuite"
|
||||||
@@ -187,21 +187,21 @@ jobs:
|
|||||||
before_script:
|
before_script:
|
||||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||||
script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext02TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext02TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
|
||||||
- name: "Remote-api - AppContext03TestSuite"
|
- name: "Remote-api - AppContext03TestSuite"
|
||||||
before_script:
|
before_script:
|
||||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||||
script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext03TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext03TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
|
||||||
- name: "Remote-api - AppContext04TestSuite"
|
- name: "Remote-api - AppContext04TestSuite"
|
||||||
before_script:
|
before_script:
|
||||||
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300'
|
||||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.4.0
|
||||||
script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext04TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
script: travis_wait 20 mvn -B test -pl remote-api -Dtest=AppContext04TestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||||
|
|
||||||
- name: "Remote-api - AppContextExtraTestSuite"
|
- name: "Remote-api - AppContextExtraTestSuite"
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-community-repo</artifactId>
|
<artifactId>alfresco-community-repo</artifactId>
|
||||||
<version>9.14</version>
|
<version>9.32.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-community-repo</artifactId>
|
<artifactId>alfresco-community-repo</artifactId>
|
||||||
<version>9.14</version>
|
<version>9.32.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@@ -167,7 +167,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.woodstox</groupId>
|
<groupId>com.fasterxml.woodstox</groupId>
|
||||||
<artifactId>woodstox-core</artifactId>
|
<artifactId>woodstox-core</artifactId>
|
||||||
<version>6.2.4</version>
|
<version>6.2.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- the cxf libs were updated, see dependencyManagement section -->
|
<!-- the cxf libs were updated, see dependencyManagement section -->
|
||||||
@@ -283,6 +283,31 @@
|
|||||||
<groupId>com.sun.activation</groupId>
|
<groupId>com.sun.activation</groupId>
|
||||||
<artifactId>javax.activation</artifactId>
|
<artifactId>javax.activation</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<!-- No longer needed -->
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
|
<artifactId>pdfbox</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
|
<artifactId>pdfbox-tools</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
|
<artifactId>preflight</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
|
<artifactId>jempbox</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
|
<artifactId>xmpbox</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
|
<artifactId>jbig2-imageio</artifactId>
|
||||||
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@@ -60,12 +60,15 @@ public abstract class ConfigScheduler<Data>
|
|||||||
// Synchronized has little effect in normal operation, but on laptops that are suspended, there can be a number
|
// Synchronized has little effect in normal operation, but on laptops that are suspended, there can be a number
|
||||||
// of Threads calling execute concurrently without it, resulting in errors in the log. Theoretically possible in
|
// of Threads calling execute concurrently without it, resulting in errors in the log. Theoretically possible in
|
||||||
// production but not very likely.
|
// production but not very likely.
|
||||||
public synchronized void execute(JobExecutionContext context) throws JobExecutionException
|
public void execute(JobExecutionContext context) throws JobExecutionException
|
||||||
{
|
{
|
||||||
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
|
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
|
||||||
ConfigScheduler configScheduler = (ConfigScheduler)dataMap.get(CONFIG_SCHEDULER);
|
ConfigScheduler configScheduler = (ConfigScheduler)dataMap.get(CONFIG_SCHEDULER);
|
||||||
boolean successReadingConfig = configScheduler.readConfigAndReplace(true);
|
synchronized (configScheduler)
|
||||||
configScheduler.changeScheduleOnStateChange(successReadingConfig);
|
{
|
||||||
|
boolean successReadingConfig = configScheduler.readConfigAndReplace(true);
|
||||||
|
configScheduler.changeScheduleOnStateChange(successReadingConfig);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,6 +9,6 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||||
<version>9.14</version>
|
<version>9.32.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
</project>
|
</project>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# Fetch image based on Tomcat 9.0, Java 11 and Centos 8
|
# Fetch image based on Tomcat 9.0, Java 11 and Centos 8
|
||||||
# More infos about this image: https://github.com/Alfresco/alfresco-docker-base-tomcat
|
# More infos about this image: https://github.com/Alfresco/alfresco-docker-base-tomcat
|
||||||
FROM alfresco/alfresco-base-tomcat:9.0.41-java-11-openjdk-centos-8
|
FROM alfresco/alfresco-base-tomcat:9.0.45-java-11-centos-8
|
||||||
|
|
||||||
# Set default docker_context.
|
# Set default docker_context.
|
||||||
ARG resource_path=target
|
ARG resource_path=target
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||||
<version>9.14</version>
|
<version>9.32.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-community-repo</artifactId>
|
<artifactId>alfresco-community-repo</artifactId>
|
||||||
<version>9.14</version>
|
<version>9.32.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
TRANSFORMERS_TAG=2.3.10
|
TRANSFORMERS_TAG=2.4.0
|
||||||
SOLR6_TAG=2.0.1
|
SOLR6_TAG=2.0.2-RC2
|
||||||
POSTGRES_TAG=13.1
|
POSTGRES_TAG=13.1
|
||||||
ACTIVEMQ_TAG=5.16.1
|
ACTIVEMQ_TAG=5.16.1
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||||
<version>9.14</version>
|
<version>9.32.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||||
<version>9.14</version>
|
<version>9.32.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||||
<version>9.14</version>
|
<version>9.32.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||||
<version>9.14</version>
|
<version>9.32.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||||
<version>9.14</version>
|
<version>9.32.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||||
<version>9.14</version>
|
<version>9.32.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||||
<version>9.14</version>
|
<version>9.32.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
63
pom.xml
63
pom.xml
@@ -2,7 +2,7 @@
|
|||||||
<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/xsd/maven-4.0.0.xsd">
|
<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/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>alfresco-community-repo</artifactId>
|
<artifactId>alfresco-community-repo</artifactId>
|
||||||
<version>9.14</version>
|
<version>9.32.1</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>Alfresco Community Repo Parent</name>
|
<name>Alfresco Community Repo Parent</name>
|
||||||
|
|
||||||
@@ -34,15 +34,15 @@
|
|||||||
<image.registry>quay.io</image.registry>
|
<image.registry>quay.io</image.registry>
|
||||||
|
|
||||||
<java.version>11</java.version>
|
<java.version>11</java.version>
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<maven.build.sourceVersion>11</maven.build.sourceVersion>
|
<maven.build.sourceVersion>${java.version}</maven.build.sourceVersion>
|
||||||
|
|
||||||
<dir.root>${project.build.directory}/alf_data</dir.root>
|
<dir.root>${project.build.directory}/alf_data</dir.root>
|
||||||
|
|
||||||
<dependency.alfresco-hb-data-sender.version>1.0.12</dependency.alfresco-hb-data-sender.version>
|
<dependency.alfresco-hb-data-sender.version>1.0.12</dependency.alfresco-hb-data-sender.version>
|
||||||
<dependency.alfresco-mmt.version>6.0</dependency.alfresco-mmt.version>
|
<dependency.alfresco-mmt.version>6.0</dependency.alfresco-mmt.version>
|
||||||
<dependency.alfresco-trashcan-cleaner.version>2.3</dependency.alfresco-trashcan-cleaner.version>
|
<dependency.alfresco-trashcan-cleaner.version>2.4.1</dependency.alfresco-trashcan-cleaner.version>
|
||||||
<dependency.alfresco-jlan.version>7.1</dependency.alfresco-jlan.version>
|
<dependency.alfresco-jlan.version>7.1</dependency.alfresco-jlan.version>
|
||||||
<dependency.alfresco-server-root.version>6.0.1</dependency.alfresco-server-root.version>
|
<dependency.alfresco-server-root.version>6.0.1</dependency.alfresco-server-root.version>
|
||||||
<dependency.alfresco-messaging-repo.version>1.2.15</dependency.alfresco-messaging-repo.version>
|
<dependency.alfresco-messaging-repo.version>1.2.15</dependency.alfresco-messaging-repo.version>
|
||||||
@@ -55,14 +55,14 @@
|
|||||||
|
|
||||||
<dependency.spring.version>5.3.3</dependency.spring.version>
|
<dependency.spring.version>5.3.3</dependency.spring.version>
|
||||||
<dependency.antlr.version>3.5.2</dependency.antlr.version>
|
<dependency.antlr.version>3.5.2</dependency.antlr.version>
|
||||||
<dependency.jackson.version>2.12.1</dependency.jackson.version>
|
<dependency.jackson.version>2.12.3</dependency.jackson.version>
|
||||||
<dependency.jackson-databind.version>${dependency.jackson.version}</dependency.jackson-databind.version>
|
<dependency.jackson-databind.version>2.12.3</dependency.jackson-databind.version>
|
||||||
<dependency.cxf.version>3.4.2</dependency.cxf.version>
|
<dependency.cxf.version>3.4.4</dependency.cxf.version>
|
||||||
<dependency.opencmis.version>1.0.0</dependency.opencmis.version>
|
<dependency.opencmis.version>1.0.0</dependency.opencmis.version>
|
||||||
<dependency.webscripts.version>8.18</dependency.webscripts.version>
|
<dependency.webscripts.version>8.22</dependency.webscripts.version>
|
||||||
<dependency.bouncycastle.version>1.68</dependency.bouncycastle.version>
|
<dependency.bouncycastle.version>1.69</dependency.bouncycastle.version>
|
||||||
<dependency.mockito-core.version>3.8.0</dependency.mockito-core.version>
|
<dependency.mockito-core.version>3.9.0</dependency.mockito-core.version>
|
||||||
<dependency.org-json.version>20201115</dependency.org-json.version>
|
<dependency.org-json.version>20210307</dependency.org-json.version>
|
||||||
<dependency.commons-dbcp.version>1.4-DBCP330</dependency.commons-dbcp.version>
|
<dependency.commons-dbcp.version>1.4-DBCP330</dependency.commons-dbcp.version>
|
||||||
<dependency.commons-io.version>2.8.0</dependency.commons-io.version>
|
<dependency.commons-io.version>2.8.0</dependency.commons-io.version>
|
||||||
<dependency.gson.version>2.8.5</dependency.gson.version>
|
<dependency.gson.version>2.8.5</dependency.gson.version>
|
||||||
@@ -74,16 +74,17 @@
|
|||||||
<dependency.gytheio.version>0.12</dependency.gytheio.version>
|
<dependency.gytheio.version>0.12</dependency.gytheio.version>
|
||||||
<dependency.groovy.version>2.5.9</dependency.groovy.version>
|
<dependency.groovy.version>2.5.9</dependency.groovy.version>
|
||||||
<dependency.tika.version>1.26</dependency.tika.version>
|
<dependency.tika.version>1.26</dependency.tika.version>
|
||||||
<dependency.spring-security.version>5.4.1</dependency.spring-security.version>
|
<dependency.spring-security.version>5.5.0</dependency.spring-security.version>
|
||||||
<dependency.truezip.version>7.7.10</dependency.truezip.version>
|
<dependency.truezip.version>7.7.10</dependency.truezip.version>
|
||||||
<dependency.poi.version>4.1.2</dependency.poi.version>
|
<dependency.poi.version>4.1.2</dependency.poi.version>
|
||||||
<dependency.ooxml-schemas.version>1.4</dependency.ooxml-schemas.version>
|
<dependency.ooxml-schemas.version>1.4</dependency.ooxml-schemas.version>
|
||||||
<dependency.keycloak.version>11.0.0-alfresco-001</dependency.keycloak.version>
|
<dependency.keycloak.version>13.0.1</dependency.keycloak.version>
|
||||||
<dependency.jboss.logging.version>3.4.1.Final</dependency.jboss.logging.version>
|
<dependency.jboss.logging.version>3.4.1.Final</dependency.jboss.logging.version>
|
||||||
<dependency.camel.version>3.7.0</dependency.camel.version>
|
<dependency.camel.version>3.7.4</dependency.camel.version>
|
||||||
<dependency.activemq.version>5.16.1</dependency.activemq.version>
|
<dependency.activemq.version>5.16.1</dependency.activemq.version>
|
||||||
|
<dependency.apache-compress.version>1.20</dependency.apache-compress.version>
|
||||||
<dependency.apache.taglibs.version>1.2.5</dependency.apache.taglibs.version>
|
<dependency.apache.taglibs.version>1.2.5</dependency.apache.taglibs.version>
|
||||||
<dependency.awaitility.version>4.0.3</dependency.awaitility.version>
|
<dependency.awaitility.version>4.1.0</dependency.awaitility.version>
|
||||||
|
|
||||||
<dependency.jakarta-jaxb-api.version>2.3.3</dependency.jakarta-jaxb-api.version>
|
<dependency.jakarta-jaxb-api.version>2.3.3</dependency.jakarta-jaxb-api.version>
|
||||||
<dependency.jakarta-ws-api.version>2.3.3</dependency.jakarta-ws-api.version>
|
<dependency.jakarta-ws-api.version>2.3.3</dependency.jakarta-ws-api.version>
|
||||||
@@ -96,16 +97,16 @@
|
|||||||
<dependency.jakarta-json-api.version>1.1.6</dependency.jakarta-json-api.version>
|
<dependency.jakarta-json-api.version>1.1.6</dependency.jakarta-json-api.version>
|
||||||
<dependency.jakarta-rpc-api.version>1.1.4</dependency.jakarta-rpc-api.version>
|
<dependency.jakarta-rpc-api.version>1.1.4</dependency.jakarta-rpc-api.version>
|
||||||
|
|
||||||
<alfresco.googledrive.version>3.2.1</alfresco.googledrive.version>
|
<alfresco.googledrive.version>3.2.1.3</alfresco.googledrive.version>
|
||||||
<alfresco.aos-module.version>1.4.0</alfresco.aos-module.version>
|
<alfresco.aos-module.version>1.4.0.1</alfresco.aos-module.version>
|
||||||
|
|
||||||
<dependency.postgresql.version>42.2.19</dependency.postgresql.version>
|
<dependency.postgresql.version>42.2.20</dependency.postgresql.version>
|
||||||
<dependency.mysql.version>8.0.23</dependency.mysql.version>
|
<dependency.mysql.version>8.0.25</dependency.mysql.version>
|
||||||
<dependency.mariadb.version>2.7.2</dependency.mariadb.version>
|
<dependency.mariadb.version>2.7.2</dependency.mariadb.version>
|
||||||
<dependency.tas-utility.version>3.0.43</dependency.tas-utility.version>
|
<dependency.tas-utility.version>3.0.44</dependency.tas-utility.version>
|
||||||
<dependency.rest-assured.version>3.3.0</dependency.rest-assured.version>
|
<dependency.rest-assured.version>3.3.0</dependency.rest-assured.version>
|
||||||
<dependency.tas-restapi.version>1.56</dependency.tas-restapi.version>
|
<dependency.tas-restapi.version>1.58</dependency.tas-restapi.version>
|
||||||
<dependency.tas-cmis.version>1.27</dependency.tas-cmis.version>
|
<dependency.tas-cmis.version>1.30</dependency.tas-cmis.version>
|
||||||
<dependency.tas-email.version>1.8</dependency.tas-email.version>
|
<dependency.tas-email.version>1.8</dependency.tas-email.version>
|
||||||
<dependency.tas-webdav.version>1.6</dependency.tas-webdav.version>
|
<dependency.tas-webdav.version>1.6</dependency.tas-webdav.version>
|
||||||
<dependency.tas-ftp.version>1.5</dependency.tas-ftp.version>
|
<dependency.tas-ftp.version>1.5</dependency.tas-ftp.version>
|
||||||
@@ -116,7 +117,7 @@
|
|||||||
<connection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</connection>
|
<connection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</connection>
|
||||||
<developerConnection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</developerConnection>
|
<developerConnection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</developerConnection>
|
||||||
<url>https://github.com/Alfresco/alfresco-community-repo</url>
|
<url>https://github.com/Alfresco/alfresco-community-repo</url>
|
||||||
<tag>9.14</tag>
|
<tag>9.32.1</tag>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
@@ -549,8 +550,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bouncycastle</groupId>
|
<groupId>org.bouncycastle</groupId>
|
||||||
<artifactId>bcprov-jdk15on</artifactId>
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
<version>1.68</version>
|
<version>${dependency.bouncycastle.version}</version>
|
||||||
<!-- <version>${dependency.bouncycastle.version}</version>-->
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bouncycastle</groupId>
|
<groupId>org.bouncycastle</groupId>
|
||||||
@@ -583,7 +583,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.drewnoakes</groupId>
|
<groupId>com.drewnoakes</groupId>
|
||||||
<artifactId>metadata-extractor</artifactId>
|
<artifactId>metadata-extractor</artifactId>
|
||||||
<version>2.15.0</version>
|
<version>2.16.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- upgrade dependency from TIKA -->
|
<!-- upgrade dependency from TIKA -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -601,7 +601,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-compress</artifactId>
|
<artifactId>commons-compress</artifactId>
|
||||||
<version>1.20</version>
|
<version>${dependency.apache-compress.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
@@ -679,7 +679,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>joda-time</groupId>
|
<groupId>joda-time</groupId>
|
||||||
<artifactId>joda-time</artifactId>
|
<artifactId>joda-time</artifactId>
|
||||||
<version>2.10.9</version>
|
<version>2.10.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- provided dependencies -->
|
<!-- provided dependencies -->
|
||||||
@@ -694,7 +694,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.13</version>
|
<version>4.13.2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -814,7 +814,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.3.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@@ -829,5 +829,4 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-community-repo</artifactId>
|
<artifactId>alfresco-community-repo</artifactId>
|
||||||
<version>9.14</version>
|
<version>9.32.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@@ -41,7 +41,11 @@ public class DefaultExceptionResolver implements ExceptionResolver<Exception>
|
|||||||
@Override
|
@Override
|
||||||
public ErrorResponse resolveException(Exception ex)
|
public ErrorResponse resolveException(Exception ex)
|
||||||
{
|
{
|
||||||
return new ErrorResponse(DEFAULT_MESSAGE_ID, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getLocalizedMessage(), ex.getStackTrace(), null);
|
return new ErrorResponse(DEFAULT_MESSAGE_ID,
|
||||||
|
HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
|
||||||
|
ex.getLocalizedMessage(),
|
||||||
|
ex.getStackTrace(),
|
||||||
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* Alfresco Remote API
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||||
|
* %%
|
||||||
|
* This file is part of the Alfresco software.
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
package org.alfresco.rest.framework.core.exceptions;
|
||||||
|
|
||||||
|
import org.alfresco.repo.search.QueryParserException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* QueryParserException is related with search requests to Search Services.
|
||||||
|
*/
|
||||||
|
public class QueryParserExceptionResolver implements ExceptionResolver<QueryParserException>
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ErrorResponse resolveException(QueryParserException ex)
|
||||||
|
{
|
||||||
|
return new ErrorResponse(
|
||||||
|
DefaultExceptionResolver.DEFAULT_MESSAGE_ID,
|
||||||
|
// Mapping the original HTTP Status code returned by Search Services
|
||||||
|
ex.getHttpStatusCode(),
|
||||||
|
ex.getLocalizedMessage(),
|
||||||
|
ex.getStackTrace(),
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -26,10 +26,12 @@
|
|||||||
package org.alfresco.rest.framework.tools;
|
package org.alfresco.rest.framework.tools;
|
||||||
|
|
||||||
import org.alfresco.metrics.rest.RestMetricsReporter;
|
import org.alfresco.metrics.rest.RestMetricsReporter;
|
||||||
|
import org.alfresco.repo.search.QueryParserException;
|
||||||
import org.alfresco.rest.framework.Api;
|
import org.alfresco.rest.framework.Api;
|
||||||
import org.alfresco.rest.framework.core.exceptions.DefaultExceptionResolver;
|
import org.alfresco.rest.framework.core.exceptions.DefaultExceptionResolver;
|
||||||
import org.alfresco.rest.framework.core.exceptions.ErrorResponse;
|
import org.alfresco.rest.framework.core.exceptions.ErrorResponse;
|
||||||
import org.alfresco.rest.framework.core.exceptions.ExceptionResolver;
|
import org.alfresco.rest.framework.core.exceptions.ExceptionResolver;
|
||||||
|
import org.alfresco.rest.framework.core.exceptions.QueryParserExceptionResolver;
|
||||||
import org.alfresco.rest.framework.jacksonextensions.JacksonHelper;
|
import org.alfresco.rest.framework.jacksonextensions.JacksonHelper;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@@ -48,6 +50,7 @@ public class ApiAssistant {
|
|||||||
|
|
||||||
private ExceptionResolver<Exception> defaultResolver = new DefaultExceptionResolver();
|
private ExceptionResolver<Exception> defaultResolver = new DefaultExceptionResolver();
|
||||||
private ExceptionResolver<WebScriptException> webScriptExceptionResolver;
|
private ExceptionResolver<WebScriptException> webScriptExceptionResolver;
|
||||||
|
private ExceptionResolver<QueryParserException> queryParserExceptionResolver;
|
||||||
private ExceptionResolver<Exception> resolver;
|
private ExceptionResolver<Exception> resolver;
|
||||||
private JacksonHelper jsonHelper;
|
private JacksonHelper jsonHelper;
|
||||||
private RestMetricsReporter restMetricsReporter;
|
private RestMetricsReporter restMetricsReporter;
|
||||||
@@ -77,6 +80,10 @@ public class ApiAssistant {
|
|||||||
{
|
{
|
||||||
error = webScriptExceptionResolver.resolveException((WebScriptException) ex);
|
error = webScriptExceptionResolver.resolveException((WebScriptException) ex);
|
||||||
}
|
}
|
||||||
|
else if (ex instanceof QueryParserException)
|
||||||
|
{
|
||||||
|
error = queryParserExceptionResolver.resolveException((QueryParserException) ex);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
error = resolver.resolveException(ex);
|
error = resolver.resolveException(ex);
|
||||||
@@ -100,6 +107,11 @@ public class ApiAssistant {
|
|||||||
this.webScriptExceptionResolver = webScriptExceptionResolver;
|
this.webScriptExceptionResolver = webScriptExceptionResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setQueryParserExceptionResolver(ExceptionResolver<QueryParserException> queryParserExceptionResolver)
|
||||||
|
{
|
||||||
|
this.queryParserExceptionResolver = queryParserExceptionResolver;
|
||||||
|
}
|
||||||
|
|
||||||
public void setResolver(ExceptionResolver<Exception> resolver) {
|
public void setResolver(ExceptionResolver<Exception> resolver) {
|
||||||
this.resolver = resolver;
|
this.resolver = resolver;
|
||||||
}
|
}
|
||||||
|
@@ -134,6 +134,8 @@
|
|||||||
</bean>
|
</bean>
|
||||||
<bean id="webScriptExceptionResolver" class="org.alfresco.rest.framework.core.exceptions.WebScriptExceptionResolver">
|
<bean id="webScriptExceptionResolver" class="org.alfresco.rest.framework.core.exceptions.WebScriptExceptionResolver">
|
||||||
</bean>
|
</bean>
|
||||||
|
<bean id="queryParserExceptionResolver" class="org.alfresco.rest.framework.core.exceptions.QueryParserExceptionResolver">
|
||||||
|
</bean>
|
||||||
<bean id="simpleMappingExceptionResolverParent" abstract="true" class="org.alfresco.rest.framework.core.exceptions.SimpleMappingExceptionResolver">
|
<bean id="simpleMappingExceptionResolverParent" abstract="true" class="org.alfresco.rest.framework.core.exceptions.SimpleMappingExceptionResolver">
|
||||||
<property name="exceptionMappings">
|
<property name="exceptionMappings">
|
||||||
<map>
|
<map>
|
||||||
@@ -182,6 +184,7 @@
|
|||||||
<property name="resolver" ref="simpleMappingExceptionResolver" />
|
<property name="resolver" ref="simpleMappingExceptionResolver" />
|
||||||
<property name="webScriptExceptionResolver" ref="webScriptExceptionResolver" />
|
<property name="webScriptExceptionResolver" ref="webScriptExceptionResolver" />
|
||||||
<property name="restMetricsReporter" ref="restMetricsReporter"/>
|
<property name="restMetricsReporter" ref="restMetricsReporter"/>
|
||||||
|
<property name="queryParserExceptionResolver" ref="queryParserExceptionResolver" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Using annotation-config=false means AutowiredAnnotationBeanPostProcessor
|
<!-- Using annotation-config=false means AutowiredAnnotationBeanPostProcessor
|
||||||
|
@@ -1,34 +1,76 @@
|
|||||||
<#assign null><span style="color:red">${msg("nodebrowser.null")?html}</span></#assign>
|
<#assign null><span style="color:red">${msg("nodebrowser.null")?html}</span></#assign>
|
||||||
<#assign none><span style="color:red">${msg("nodebrowser.none")?html}</span></#assign>
|
<#assign none><span style="color:red">${msg("nodebrowser.none")?html}</span></#assign>
|
||||||
<#assign collection>${msg("nodebrowser.collection")?html}</#assign>
|
<#assign collection>${msg("nodebrowser.collection")?html}</#assign>
|
||||||
|
<#assign maxDepth=1000 />
|
||||||
<#macro dateFormat date>${date?string("dd MMM yyyy HH:mm:ss 'GMT'Z '('zzz')'")}</#macro>
|
<#macro dateFormat date>${date?string("dd MMM yyyy HH:mm:ss 'GMT'Z '('zzz')'")}</#macro>
|
||||||
<#macro propValue p>
|
<#macro propValue p>
|
||||||
<#if p.value??>
|
<#attempt>
|
||||||
<#if p.value?is_date>
|
<#if p.value??>
|
||||||
<@dateFormat p.value />
|
<#if p.value?is_date>
|
||||||
<#elseif p.value?is_boolean>
|
<@dateFormat p.value />
|
||||||
${p.value?string}
|
<#elseif p.value?is_boolean>
|
||||||
<#elseif p.value?is_number>
|
${p.value?string}
|
||||||
${p.value?c}
|
<#elseif p.value?is_number>
|
||||||
<#elseif p.value?is_string>
|
${p.value?c}
|
||||||
${p.value?html}
|
<#elseif p.value?is_string>
|
||||||
<#elseif p.value?is_hash>
|
${p.value?html}
|
||||||
<#assign result = "{"/>
|
<#elseif p.value?is_hash || p.value?is_enumerable>
|
||||||
<#assign first = true />
|
<@convertToJSON p.value />
|
||||||
<#list p.value?keys as key>
|
</#if>
|
||||||
<#if first = false>
|
<#else>
|
||||||
<#assign result = result + ", "/>
|
${null}
|
||||||
|
</#if>
|
||||||
|
<#recover>
|
||||||
|
<span style="color:red">${.error}</span>
|
||||||
|
</#attempt>
|
||||||
|
</#macro>
|
||||||
|
<#macro convertToJSON v>
|
||||||
|
<#if v??>
|
||||||
|
<#if v?is_date>
|
||||||
|
<@dateFormat v />
|
||||||
|
<#elseif v?is_boolean>
|
||||||
|
${v?string}
|
||||||
|
<#elseif v?is_number>
|
||||||
|
${v?c}
|
||||||
|
<#elseif v?is_string>
|
||||||
|
"${v?string}"
|
||||||
|
<#elseif v?is_hash>
|
||||||
|
<#if v?keys?size gt maxDepth >
|
||||||
|
<#stop "Max depth of object achieved">
|
||||||
</#if>
|
</#if>
|
||||||
<#assign result = result + "${key}=${p.value[key]?html}" />
|
<@compress single_line=true>
|
||||||
<#assign first = false/>
|
{
|
||||||
</#list>
|
<#assign first = true />
|
||||||
<#assign result = result + "}"/>
|
<#list v?keys as key>
|
||||||
${result}
|
<#if first = false>,</#if>
|
||||||
|
"${key}":
|
||||||
|
<#if v[key]??>
|
||||||
|
<@convertToJSON v[key] />
|
||||||
|
<#else>
|
||||||
|
${null}
|
||||||
|
</#if>
|
||||||
|
<#assign first = false/>
|
||||||
|
</#list>
|
||||||
|
}
|
||||||
|
</@compress>
|
||||||
|
<#elseif v?is_enumerable>
|
||||||
|
<#if v?size gt maxDepth>
|
||||||
|
<#stop "Max depth of object achieved" >
|
||||||
|
</#if>
|
||||||
|
<#assign first = true />
|
||||||
|
<@compress single_line=true>
|
||||||
|
[
|
||||||
|
<#list v as item>
|
||||||
|
<#if first = false>,</#if>
|
||||||
|
<@convertToJSON item />
|
||||||
|
<#assign first = false/>
|
||||||
|
</#list>
|
||||||
|
]
|
||||||
|
</@compress>
|
||||||
|
</#if>
|
||||||
|
<#else>
|
||||||
|
${null}
|
||||||
</#if>
|
</#if>
|
||||||
<#else>
|
|
||||||
${null}
|
|
||||||
</#if>
|
|
||||||
</#macro>
|
</#macro>
|
||||||
<#macro contentUrl nodeRef prop>
|
<#macro contentUrl nodeRef prop>
|
||||||
${url.serviceContext}/api/node/${nodeRef?replace("://","/")}/content;${prop?url}
|
${url.serviceContext}/api/node/${nodeRef?replace("://","/")}/content;${prop?url}
|
||||||
|
@@ -31,6 +31,7 @@ import static org.junit.Assert.assertNull;
|
|||||||
|
|
||||||
import org.alfresco.repo.forms.FormNotFoundException;
|
import org.alfresco.repo.forms.FormNotFoundException;
|
||||||
import org.alfresco.repo.node.integrity.IntegrityException;
|
import org.alfresco.repo.node.integrity.IntegrityException;
|
||||||
|
import org.alfresco.repo.search.QueryParserException;
|
||||||
import org.alfresco.rest.framework.core.exceptions.ApiException;
|
import org.alfresco.rest.framework.core.exceptions.ApiException;
|
||||||
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
||||||
import org.alfresco.rest.framework.core.exceptions.DeletedResourceException;
|
import org.alfresco.rest.framework.core.exceptions.DeletedResourceException;
|
||||||
@@ -122,4 +123,13 @@ public class ExceptionResolverTests
|
|||||||
assertEquals(422, response.getStatusCode());
|
assertEquals(422, response.getStatusCode());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Check that the status code from SS is passed back to the caller. */
|
||||||
|
@Test
|
||||||
|
public void testQueryParserException()
|
||||||
|
{
|
||||||
|
ErrorResponse response = assistant.resolveException(new QueryParserException("Endpoint not found", 404));
|
||||||
|
assertNotNull(response);
|
||||||
|
assertEquals("Expected status code to be passed through from query parser.", 404, response.getStatusCode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,10 +33,12 @@
|
|||||||
</bean>
|
</bean>
|
||||||
<bean id="webScriptExceptionResolver" class="org.alfresco.rest.framework.core.exceptions.WebScriptExceptionResolver">
|
<bean id="webScriptExceptionResolver" class="org.alfresco.rest.framework.core.exceptions.WebScriptExceptionResolver">
|
||||||
</bean>
|
</bean>
|
||||||
|
<bean id="queryParserExceptionResolver" class="org.alfresco.rest.framework.core.exceptions.QueryParserExceptionResolver" />
|
||||||
<bean id="apiAssistant" class="org.alfresco.rest.framework.tools.ApiAssistant">
|
<bean id="apiAssistant" class="org.alfresco.rest.framework.tools.ApiAssistant">
|
||||||
<property name="jsonHelper" ref="jsonHelper" />
|
<property name="jsonHelper" ref="jsonHelper" />
|
||||||
<property name="resolver" ref="simpleMappingExceptionResolver" />
|
<property name="resolver" ref="simpleMappingExceptionResolver" />
|
||||||
<property name="webScriptExceptionResolver" ref="webScriptExceptionResolver" />
|
<property name="webScriptExceptionResolver" ref="webScriptExceptionResolver" />
|
||||||
|
<property name="queryParserExceptionResolver" ref="queryParserExceptionResolver" />
|
||||||
</bean>
|
</bean>
|
||||||
<bean id="simpleMappingExceptionResolver" class="org.alfresco.rest.framework.core.exceptions.SimpleMappingExceptionResolver">
|
<bean id="simpleMappingExceptionResolver" class="org.alfresco.rest.framework.core.exceptions.SimpleMappingExceptionResolver">
|
||||||
<property name="exceptionMappings">
|
<property name="exceptionMappings">
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.alfresco</groupId>
|
<groupId>org.alfresco</groupId>
|
||||||
<artifactId>alfresco-community-repo</artifactId>
|
<artifactId>alfresco-community-repo</artifactId>
|
||||||
<version>9.14</version>
|
<version>9.32.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -383,7 +383,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.woodstox</groupId>
|
<groupId>com.fasterxml.woodstox</groupId>
|
||||||
<artifactId>woodstox-core</artifactId>
|
<artifactId>woodstox-core</artifactId>
|
||||||
<version>6.2.4</version>
|
<version>6.2.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- GData -->
|
<!-- GData -->
|
||||||
|
@@ -35,6 +35,9 @@ import org.alfresco.repo.admin.SysAdminParams;
|
|||||||
import org.alfresco.repo.jscript.ScriptAction;
|
import org.alfresco.repo.jscript.ScriptAction;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.action.Action;
|
import org.alfresco.service.cmr.action.Action;
|
||||||
|
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||||
|
import org.alfresco.service.cmr.action.ActionService;
|
||||||
|
import org.alfresco.service.cmr.action.ParameterConstraint;
|
||||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@@ -126,6 +129,10 @@ public class ScriptActionExecuter extends ActionExecuterAbstractBase
|
|||||||
if (nodeService.exists(actionedUponNodeRef))
|
if (nodeService.exists(actionedUponNodeRef))
|
||||||
{
|
{
|
||||||
NodeRef scriptRef = (NodeRef)action.getParameterValue(PARAM_SCRIPTREF);
|
NodeRef scriptRef = (NodeRef)action.getParameterValue(PARAM_SCRIPTREF);
|
||||||
|
if(!isValidScriptRef(action))
|
||||||
|
{
|
||||||
|
throw new IllegalStateException("Invalid script ref path: " + scriptRef);
|
||||||
|
}
|
||||||
NodeRef spaceRef = this.serviceRegistry.getRuleService().getOwningNodeRef(action);
|
NodeRef spaceRef = this.serviceRegistry.getRuleService().getOwningNodeRef(action);
|
||||||
if (spaceRef == null)
|
if (spaceRef == null)
|
||||||
{
|
{
|
||||||
@@ -222,4 +229,19 @@ public class ScriptActionExecuter extends ActionExecuterAbstractBase
|
|||||||
|
|
||||||
return companyHomeRef;
|
return companyHomeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isValidScriptRef(Action action)
|
||||||
|
{
|
||||||
|
NodeRef scriptRef = (NodeRef) action.getParameterValue(PARAM_SCRIPTREF);
|
||||||
|
ActionService actionService = this.serviceRegistry.getActionService();
|
||||||
|
ActionDefinition actDef = actionService.getActionDefinition(action.getActionDefinitionName());
|
||||||
|
ParameterDefinition parameterDef = actDef.getParameterDefintion(PARAM_SCRIPTREF);
|
||||||
|
String paramConstraintName = parameterDef.getParameterConstraintName();
|
||||||
|
if (paramConstraintName != null)
|
||||||
|
{
|
||||||
|
ParameterConstraint paramConstraint = actionService.getParameterConstraint(paramConstraintName);
|
||||||
|
return paramConstraint.isValidValue(scriptRef.toString());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,538 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Repository
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
|
||||||
* %%
|
|
||||||
* This file is part of the Alfresco software.
|
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
|
||||||
* provided under the following open source license terms:
|
|
||||||
*
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.repo.rendition.executer;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.io.Writer;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.xml.transform.OutputKeys;
|
|
||||||
import javax.xml.transform.TransformerConfigurationException;
|
|
||||||
import javax.xml.transform.sax.SAXTransformerFactory;
|
|
||||||
import javax.xml.transform.sax.TransformerHandler;
|
|
||||||
import javax.xml.transform.stream.StreamResult;
|
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
|
||||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
|
||||||
import org.alfresco.repo.rendition.RenditionLocation;
|
|
||||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
|
||||||
import org.alfresco.service.cmr.rendition.RenditionServiceException;
|
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.apache.tika.config.TikaConfig;
|
|
||||||
import org.apache.tika.exception.TikaException;
|
|
||||||
import org.apache.tika.metadata.Metadata;
|
|
||||||
import org.apache.tika.mime.MediaType;
|
|
||||||
import org.apache.tika.parser.AutoDetectParser;
|
|
||||||
import org.apache.tika.parser.ParseContext;
|
|
||||||
import org.apache.tika.parser.Parser;
|
|
||||||
import org.apache.tika.sax.BodyContentHandler;
|
|
||||||
import org.apache.tika.sax.ContentHandlerDecorator;
|
|
||||||
import org.xml.sax.Attributes;
|
|
||||||
import org.xml.sax.ContentHandler;
|
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
import org.xml.sax.helpers.AttributesImpl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class provides a way to turn documents supported by the
|
|
||||||
* {@link ContentService} standard transformers into basic, clean
|
|
||||||
* HTML.
|
|
||||||
* <P/>
|
|
||||||
* The HTML that is produced probably isn't going to be suitable
|
|
||||||
* for direct web publishing, as it's likely going to be too
|
|
||||||
* basic. Instead, it should be simple and clean HTML, suitable
|
|
||||||
* for being the basis of some web-friendly HTML once edited
|
|
||||||
* / further transformed.
|
|
||||||
*
|
|
||||||
* @author Nick Burch
|
|
||||||
* @since 3.4
|
|
||||||
*
|
|
||||||
* @deprecated The RenditionService is being replace by the simpler async RenditionService2.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class HTMLRenderingEngine extends AbstractRenderingEngine
|
|
||||||
{
|
|
||||||
private static Log logger = LogFactory.getLog(HTMLRenderingEngine.class);
|
|
||||||
private TikaConfig tikaConfig;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This optional parameter, when set to true, causes only the
|
|
||||||
* contents of the HTML body to be written out as the rendition.
|
|
||||||
* By default, the whole of the HTML document is used.
|
|
||||||
*/
|
|
||||||
public static final String PARAM_BODY_CONTENTS_ONLY = "bodyContentsOnly";
|
|
||||||
/**
|
|
||||||
* This optional parameter, when set to true, causes any embedded
|
|
||||||
* images to be written into the same folder as the html, with
|
|
||||||
* a name prefix.
|
|
||||||
* By default, images are placed into a sub-folder.
|
|
||||||
*/
|
|
||||||
public static final String PARAM_IMAGES_SAME_FOLDER = "imagesSameFolder";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Action constants
|
|
||||||
*/
|
|
||||||
public static final String NAME = "htmlRenderingEngine";
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Collection<ParameterDefinition> getParameterDefinitions() {
|
|
||||||
Collection<ParameterDefinition> paramList = super.getParameterDefinitions();
|
|
||||||
paramList.add(new ParameterDefinitionImpl(PARAM_BODY_CONTENTS_ONLY, DataTypeDefinition.BOOLEAN, false,
|
|
||||||
getParamDisplayLabel(PARAM_BODY_CONTENTS_ONLY)));
|
|
||||||
paramList.add(new ParameterDefinitionImpl(PARAM_IMAGES_SAME_FOLDER, DataTypeDefinition.BOOLEAN, false,
|
|
||||||
getParamDisplayLabel(PARAM_IMAGES_SAME_FOLDER)));
|
|
||||||
return paramList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Injects the TikaConfig to use
|
|
||||||
*
|
|
||||||
* @param tikaConfig The Tika Config to use
|
|
||||||
*/
|
|
||||||
public void setTikaConfig(TikaConfig tikaConfig)
|
|
||||||
{
|
|
||||||
this.tikaConfig = tikaConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
* @see org.alfresco.repo.rendition.executer.AbstractRenderingEngine#render(org.alfresco.repo.rendition.executer.AbstractRenderingEngine.RenderingContext)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void render(RenderingContext context)
|
|
||||||
{
|
|
||||||
ContentReader contentReader = context.makeContentReader();
|
|
||||||
String sourceMimeType = contentReader.getMimetype();
|
|
||||||
|
|
||||||
// Check that Tika supports the supplied file
|
|
||||||
AutoDetectParser p = new AutoDetectParser(tikaConfig);
|
|
||||||
MediaType sourceMediaType = MediaType.parse(sourceMimeType);
|
|
||||||
if(! p.getParsers().containsKey(sourceMediaType))
|
|
||||||
{
|
|
||||||
throw new RenditionServiceException(
|
|
||||||
"Source mime type of " + sourceMimeType +
|
|
||||||
" is not supported by Tika for HTML conversions"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make the HTML Version using Tika
|
|
||||||
// This will also extract out any images as found
|
|
||||||
generateHTML(p, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getHtmlBaseName(RenderingContext context)
|
|
||||||
{
|
|
||||||
// Based on the name of the source node, which will
|
|
||||||
// also largely be the name of the html node
|
|
||||||
String baseName = nodeService.getProperty(
|
|
||||||
context.getSourceNode(),
|
|
||||||
ContentModel.PROP_NAME
|
|
||||||
).toString();
|
|
||||||
if(baseName.lastIndexOf('.') > -1)
|
|
||||||
{
|
|
||||||
baseName = baseName.substring(0, baseName.lastIndexOf('.'));
|
|
||||||
}
|
|
||||||
return baseName;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* What name should be used for the images directory?
|
|
||||||
* Note this is only required if {@link #PARAM_IMAGES_SAME_FOLDER} is false (the default).
|
|
||||||
*/
|
|
||||||
private String getImagesDirectoryName(RenderingContext context)
|
|
||||||
{
|
|
||||||
// Based on the name of the source node, which will
|
|
||||||
// also largely be the name of the html node
|
|
||||||
String folderName = getHtmlBaseName(context);
|
|
||||||
folderName = folderName + "_files";
|
|
||||||
return folderName;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* What prefix should be applied to the name of images?
|
|
||||||
*/
|
|
||||||
private String getImagesPrefixName(RenderingContext context)
|
|
||||||
{
|
|
||||||
if( context.getParamWithDefault(PARAM_IMAGES_SAME_FOLDER, false) )
|
|
||||||
{
|
|
||||||
// Prefix with the name of the source node
|
|
||||||
return getHtmlBaseName(context) + "_";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// They have their own folder, so no prefix is needed
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a directory to store the images in.
|
|
||||||
* The directory will be a sibling of the rendered
|
|
||||||
* HTML, and named similar to it.
|
|
||||||
* Note this is only required if {@link #PARAM_IMAGES_SAME_FOLDER} is false (the default).
|
|
||||||
*/
|
|
||||||
private NodeRef createImagesDirectory(RenderingContext context)
|
|
||||||
{
|
|
||||||
// It should be a sibling of the HTML in it's eventual location
|
|
||||||
// (not it's current temporary one!)
|
|
||||||
RenditionLocation location = resolveRenditionLocation(
|
|
||||||
context.getSourceNode(), context.getDefinition(), context.getDestinationNode()
|
|
||||||
);
|
|
||||||
NodeRef parent = location.getParentRef();
|
|
||||||
|
|
||||||
// Figure out what to call it, based on the HTML node
|
|
||||||
String folderName = getImagesDirectoryName(context);
|
|
||||||
|
|
||||||
// It is already there?
|
|
||||||
// (eg from when the rendition is being re-run)
|
|
||||||
NodeRef imgFolder = nodeService.getChildByName(
|
|
||||||
parent, ContentModel.ASSOC_CONTAINS, folderName
|
|
||||||
);
|
|
||||||
if(imgFolder != null)
|
|
||||||
return imgFolder;
|
|
||||||
|
|
||||||
// Create the directory
|
|
||||||
Map<QName,Serializable> properties = new HashMap<QName,Serializable>();
|
|
||||||
properties.put(ContentModel.PROP_NAME, folderName);
|
|
||||||
imgFolder = nodeService.createNode(
|
|
||||||
parent,
|
|
||||||
ContentModel.ASSOC_CONTAINS,
|
|
||||||
QName.createQName(folderName),
|
|
||||||
ContentModel.TYPE_FOLDER,
|
|
||||||
properties
|
|
||||||
).getChildRef();
|
|
||||||
|
|
||||||
return imgFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
private NodeRef createEmbeddedImage(NodeRef imgFolder, boolean primary,
|
|
||||||
String filename, String contentType, InputStream imageSource,
|
|
||||||
RenderingContext context)
|
|
||||||
{
|
|
||||||
// Create the node if needed
|
|
||||||
NodeRef img = nodeService.getChildByName(
|
|
||||||
imgFolder, ContentModel.ASSOC_CONTAINS, filename
|
|
||||||
);
|
|
||||||
if(img == null)
|
|
||||||
{
|
|
||||||
Map<QName,Serializable> properties = new HashMap<QName,Serializable>();
|
|
||||||
properties.put(ContentModel.PROP_NAME, filename);
|
|
||||||
img = nodeService.createNode(
|
|
||||||
imgFolder,
|
|
||||||
ContentModel.ASSOC_CONTAINS,
|
|
||||||
QName.createQName(filename),
|
|
||||||
ContentModel.TYPE_CONTENT,
|
|
||||||
properties
|
|
||||||
).getChildRef();
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug("Image node created: " + img);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Once composite content is properly supported,
|
|
||||||
// at this point we'll associate the new image with
|
|
||||||
// the rendered HTML node so the dependency is tracked.
|
|
||||||
|
|
||||||
// Put the image into the node
|
|
||||||
ContentWriter writer = contentService.getWriter(
|
|
||||||
img, ContentModel.PROP_CONTENT, true
|
|
||||||
);
|
|
||||||
writer.setMimetype(contentType);
|
|
||||||
writer.putContent(imageSource);
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug("Image content written into " + img);
|
|
||||||
}
|
|
||||||
|
|
||||||
// All done
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a Tika-compatible SAX content handler, which will
|
|
||||||
* be used to generate+capture the XHTML
|
|
||||||
*/
|
|
||||||
private ContentHandler buildContentHandler(Writer output, RenderingContext context)
|
|
||||||
{
|
|
||||||
// Create the main transformer
|
|
||||||
SAXTransformerFactory factory = (SAXTransformerFactory)
|
|
||||||
SAXTransformerFactory.newInstance();
|
|
||||||
TransformerHandler handler;
|
|
||||||
|
|
||||||
try {
|
|
||||||
handler = factory.newTransformerHandler();
|
|
||||||
} catch (TransformerConfigurationException e) {
|
|
||||||
throw new RenditionServiceException("SAX Processing isn't available - " + e);
|
|
||||||
}
|
|
||||||
|
|
||||||
handler.getTransformer().setOutputProperty(OutputKeys.INDENT, "yes");
|
|
||||||
handler.setResult(new StreamResult(output));
|
|
||||||
handler.getTransformer().setOutputProperty(OutputKeys.METHOD, "xml");
|
|
||||||
|
|
||||||
// Change the image links as they go past
|
|
||||||
String dirName = null, imgPrefix = null;
|
|
||||||
if(context.getParamWithDefault(PARAM_IMAGES_SAME_FOLDER, false))
|
|
||||||
{
|
|
||||||
imgPrefix = getImagesPrefixName(context);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dirName = getImagesDirectoryName(context);
|
|
||||||
}
|
|
||||||
ContentHandler contentHandler = new TikaImageRewritingContentHandler(
|
|
||||||
handler, dirName, imgPrefix
|
|
||||||
);
|
|
||||||
|
|
||||||
// If required, wrap it to only return the body
|
|
||||||
boolean bodyOnly = context.getParamWithDefault(PARAM_BODY_CONTENTS_ONLY, false);
|
|
||||||
if(bodyOnly) {
|
|
||||||
contentHandler = new BodyContentHandler(contentHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
// All done
|
|
||||||
return contentHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Asks Tika to translate the contents into HTML
|
|
||||||
*/
|
|
||||||
private void generateHTML(Parser p, RenderingContext context)
|
|
||||||
{
|
|
||||||
ContentReader contentReader = context.makeContentReader();
|
|
||||||
|
|
||||||
// Setup things to parse with
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
ContentHandler handler = buildContentHandler(sw, context);
|
|
||||||
|
|
||||||
// Tell Tika what we're dealing with
|
|
||||||
Metadata metadata = new Metadata();
|
|
||||||
metadata.set(
|
|
||||||
Metadata.CONTENT_TYPE,
|
|
||||||
contentReader.getMimetype()
|
|
||||||
);
|
|
||||||
metadata.set(
|
|
||||||
Metadata.RESOURCE_NAME_KEY,
|
|
||||||
nodeService.getProperty(
|
|
||||||
context.getSourceNode(),
|
|
||||||
ContentModel.PROP_NAME
|
|
||||||
).toString()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Our parse context needs to extract images
|
|
||||||
ParseContext parseContext = new ParseContext();
|
|
||||||
parseContext.set(Parser.class, new TikaImageExtractingParser(context));
|
|
||||||
|
|
||||||
// Parse
|
|
||||||
try {
|
|
||||||
p.parse(
|
|
||||||
contentReader.getContentInputStream(),
|
|
||||||
handler, metadata, parseContext
|
|
||||||
);
|
|
||||||
} catch(Exception e) {
|
|
||||||
throw new RenditionServiceException("Tika HTML Conversion Failed", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// As a string
|
|
||||||
String html = sw.toString();
|
|
||||||
|
|
||||||
// If we're doing body-only, remove all the html namespaces
|
|
||||||
// that will otherwise clutter up the document
|
|
||||||
boolean bodyOnly = context.getParamWithDefault(PARAM_BODY_CONTENTS_ONLY, false);
|
|
||||||
if(bodyOnly) {
|
|
||||||
html = html.replaceAll("<\\?xml.*?\\?>", "");
|
|
||||||
html = html.replaceAll("<p xmlns=\"http://www.w3.org/1999/xhtml\"","<p");
|
|
||||||
html = html.replaceAll("<h(\\d) xmlns=\"http://www.w3.org/1999/xhtml\"","<h\\1");
|
|
||||||
html = html.replaceAll("<div xmlns=\"http://www.w3.org/1999/xhtml\"","<div");
|
|
||||||
html = html.replaceAll("<table xmlns=\"http://www.w3.org/1999/xhtml\"","<table");
|
|
||||||
html = html.replaceAll(" ","");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save it
|
|
||||||
ContentWriter contentWriter = context.makeContentWriter();
|
|
||||||
contentWriter.setMimetype("text/html");
|
|
||||||
contentWriter.putContent( html );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A nested Tika parser which extracts out any
|
|
||||||
* images as they come past.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
private class TikaImageExtractingParser implements Parser {
|
|
||||||
private Set<MediaType> types;
|
|
||||||
|
|
||||||
private RenderingContext renderingContext;
|
|
||||||
private NodeRef imgFolder = null;
|
|
||||||
private int count = 0;
|
|
||||||
|
|
||||||
private TikaImageExtractingParser(RenderingContext renderingContext) {
|
|
||||||
this.renderingContext = renderingContext;
|
|
||||||
|
|
||||||
// Our expected types
|
|
||||||
types = new HashSet<MediaType>();
|
|
||||||
types.add(MediaType.image("bmp"));
|
|
||||||
types.add(MediaType.image("gif"));
|
|
||||||
types.add(MediaType.image("jpg"));
|
|
||||||
types.add(MediaType.image("jpeg"));
|
|
||||||
types.add(MediaType.image("png"));
|
|
||||||
types.add(MediaType.image("tiff"));
|
|
||||||
|
|
||||||
// Are images going in the same place as the HTML?
|
|
||||||
if( renderingContext.getParamWithDefault(PARAM_IMAGES_SAME_FOLDER, false) )
|
|
||||||
{
|
|
||||||
RenditionLocation location = resolveRenditionLocation(
|
|
||||||
renderingContext.getSourceNode(), renderingContext.getDefinition(),
|
|
||||||
renderingContext.getDestinationNode()
|
|
||||||
);
|
|
||||||
imgFolder = location.getParentRef();
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug("Using imgFolder: " + imgFolder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<MediaType> getSupportedTypes(ParseContext context) {
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void parse(InputStream stream, ContentHandler handler,
|
|
||||||
Metadata metadata, ParseContext context) throws IOException,
|
|
||||||
SAXException, TikaException {
|
|
||||||
// Is it a supported image?
|
|
||||||
String filename = metadata.get(Metadata.RESOURCE_NAME_KEY);
|
|
||||||
String type = metadata.get(Metadata.CONTENT_TYPE);
|
|
||||||
boolean accept = false;
|
|
||||||
|
|
||||||
if(type != null) {
|
|
||||||
for(MediaType mt : types) {
|
|
||||||
if(mt.toString().equals(type)) {
|
|
||||||
accept = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(filename != null) {
|
|
||||||
for(MediaType mt : types) {
|
|
||||||
String ext = "." + mt.getSubtype();
|
|
||||||
if(filename.endsWith(ext)) {
|
|
||||||
accept = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!accept)
|
|
||||||
return;
|
|
||||||
|
|
||||||
handleImage(stream, filename, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleImage(InputStream stream, String filename, String type) {
|
|
||||||
count++;
|
|
||||||
|
|
||||||
// Do we already have the folder? If not, create it
|
|
||||||
if(imgFolder == null) {
|
|
||||||
imgFolder = createImagesDirectory(renderingContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Give it a sensible name if needed
|
|
||||||
if(filename == null) {
|
|
||||||
filename = "image-" + count + ".";
|
|
||||||
filename += type.substring(type.indexOf('/')+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prefix the filename if needed
|
|
||||||
filename = getImagesPrefixName(renderingContext) + filename;
|
|
||||||
|
|
||||||
// Save the image
|
|
||||||
createEmbeddedImage(imgFolder, (count==1), filename, type, stream, renderingContext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A content handler that re-writes image src attributes,
|
|
||||||
* and passes everything else on to the real one.
|
|
||||||
*/
|
|
||||||
private class TikaImageRewritingContentHandler extends ContentHandlerDecorator {
|
|
||||||
private String imageFolder;
|
|
||||||
private String imagePrefix;
|
|
||||||
|
|
||||||
private TikaImageRewritingContentHandler(ContentHandler handler, String imageFolder, String imagePrefix) {
|
|
||||||
super(handler);
|
|
||||||
this.imageFolder = imageFolder;
|
|
||||||
this.imagePrefix = imagePrefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startElement(String uri, String localName, String qName,
|
|
||||||
Attributes origAttrs) throws SAXException {
|
|
||||||
// If we have an image tag, re-write the src attribute
|
|
||||||
// if required
|
|
||||||
if("img".equals(localName)) {
|
|
||||||
AttributesImpl attrs;
|
|
||||||
if(origAttrs instanceof AttributesImpl) {
|
|
||||||
attrs = (AttributesImpl)origAttrs;
|
|
||||||
} else {
|
|
||||||
attrs = new AttributesImpl(origAttrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i=0; i<attrs.getLength(); i++) {
|
|
||||||
if("src".equals(attrs.getLocalName(i))) {
|
|
||||||
String src = attrs.getValue(i);
|
|
||||||
if(src.startsWith("embedded:")) {
|
|
||||||
String newSrc = "";
|
|
||||||
if(imageFolder != null)
|
|
||||||
newSrc += imageFolder + "/";
|
|
||||||
if(imagePrefix != null)
|
|
||||||
newSrc += imagePrefix;
|
|
||||||
newSrc += src.substring(src.indexOf(':')+1);
|
|
||||||
attrs.setValue(i, newSrc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.startElement(uri, localName, qName, attrs);
|
|
||||||
} else {
|
|
||||||
// For any other tag, pass through as-is
|
|
||||||
super.startElement(uri, localName, qName, origAttrs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -26,6 +26,9 @@
|
|||||||
package org.alfresco.repo.search;
|
package org.alfresco.repo.search;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
import org.apache.http.HttpStatus;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andy
|
* @author Andy
|
||||||
@@ -33,11 +36,10 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
|||||||
*/
|
*/
|
||||||
public class QueryParserException extends AlfrescoRuntimeException
|
public class QueryParserException extends AlfrescoRuntimeException
|
||||||
{
|
{
|
||||||
|
/** Serial version UUID. */
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 4886993838297301968L;
|
private static final long serialVersionUID = 4886993838297301968L;
|
||||||
|
/** Http Status Code that should be returned by Remote API. */
|
||||||
|
private int httpStatusCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param msgId
|
* @param msgId
|
||||||
@@ -45,7 +47,6 @@ public class QueryParserException extends AlfrescoRuntimeException
|
|||||||
public QueryParserException(String msgId)
|
public QueryParserException(String msgId)
|
||||||
{
|
{
|
||||||
super(msgId);
|
super(msgId);
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,7 +56,6 @@ public class QueryParserException extends AlfrescoRuntimeException
|
|||||||
public QueryParserException(String msgId, Object[] msgParams)
|
public QueryParserException(String msgId, Object[] msgParams)
|
||||||
{
|
{
|
||||||
super(msgId, msgParams);
|
super(msgId, msgParams);
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,7 +65,6 @@ public class QueryParserException extends AlfrescoRuntimeException
|
|||||||
public QueryParserException(String msgId, Throwable cause)
|
public QueryParserException(String msgId, Throwable cause)
|
||||||
{
|
{
|
||||||
super(msgId, cause);
|
super(msgId, cause);
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,7 +75,22 @@ public class QueryParserException extends AlfrescoRuntimeException
|
|||||||
public QueryParserException(String msgId, Object[] msgParams, Throwable cause)
|
public QueryParserException(String msgId, Object[] msgParams, Throwable cause)
|
||||||
{
|
{
|
||||||
super(msgId, msgParams, cause);
|
super(msgId, msgParams, cause);
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for exception that allows setting an HTTP status code.
|
||||||
|
*
|
||||||
|
* @param msgId Message for the exception
|
||||||
|
* @param httpStatusCode Status code to return for exception
|
||||||
|
*/
|
||||||
|
public QueryParserException(String msgId, int httpStatusCode)
|
||||||
|
{
|
||||||
|
super(msgId);
|
||||||
|
this.httpStatusCode = httpStatusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHttpStatusCode()
|
||||||
|
{
|
||||||
|
return httpStatusCode;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -29,26 +29,29 @@ import java.io.BufferedReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.alfresco.repo.search.QueryParserException;
|
import org.alfresco.repo.search.QueryParserException;
|
||||||
import org.apache.commons.httpclient.Header;
|
import org.apache.commons.httpclient.Header;
|
||||||
import org.apache.commons.httpclient.HttpClient;
|
import org.apache.commons.httpclient.HttpClient;
|
||||||
import org.apache.commons.httpclient.HttpException;
|
|
||||||
import org.apache.commons.httpclient.HttpStatus;
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
import org.apache.commons.httpclient.URI;
|
import org.apache.commons.httpclient.URI;
|
||||||
import org.apache.commons.httpclient.URIException;
|
|
||||||
import org.apache.commons.httpclient.methods.PostMethod;
|
import org.apache.commons.httpclient.methods.PostMethod;
|
||||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||||
import org.apache.commons.httpclient.params.HttpMethodParams;
|
import org.apache.commons.httpclient.params.HttpMethodParams;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONTokener;
|
import org.json.JSONTokener;
|
||||||
|
|
||||||
public abstract class AbstractSolrQueryHTTPClient
|
public abstract class AbstractSolrQueryHTTPClient
|
||||||
{
|
{
|
||||||
|
/** Logger for the class. */
|
||||||
|
private static final Log LOGGER = LogFactory.getLog(AbstractSolrQueryHTTPClient.class);
|
||||||
|
|
||||||
public static final int DEFAULT_SAVEPOST_BUFFER = 4096;
|
public static final int DEFAULT_SAVEPOST_BUFFER = 4096;
|
||||||
|
|
||||||
// Constants copied from org.apache.solr.common.params.HighlightParams (solr-solrj:1.4.1)
|
// Constants copied from org.apache.solr.common.params.HighlightParams (solr-solrj:1.4.1)
|
||||||
@@ -80,10 +83,12 @@ public abstract class AbstractSolrQueryHTTPClient
|
|||||||
public static final String HIGHLIGHT_PARAMS_PATTERN = HIGHLIGHT_PARAMS_HIGHLIGHT + "." + HIGHLIGHT_PARAMS_REGEX + ".pattern";
|
public static final String HIGHLIGHT_PARAMS_PATTERN = HIGHLIGHT_PARAMS_HIGHLIGHT + "." + HIGHLIGHT_PARAMS_REGEX + ".pattern";
|
||||||
public static final String HIGHLIGHT_PARAMS_MAX_RE_CHARS = HIGHLIGHT_PARAMS_HIGHLIGHT + "." + HIGHLIGHT_PARAMS_REGEX + ".maxAnalyzedChars";
|
public static final String HIGHLIGHT_PARAMS_MAX_RE_CHARS = HIGHLIGHT_PARAMS_HIGHLIGHT + "." + HIGHLIGHT_PARAMS_REGEX + ".maxAnalyzedChars";
|
||||||
|
|
||||||
protected JSONObject postQuery(HttpClient httpClient, String url, JSONObject body) throws UnsupportedEncodingException,
|
/** List of SOLR Exceptions that should be returning HTTP 501 status code in Remote API. */
|
||||||
IOException, HttpException, URIException, JSONException
|
private static final List<String> STATUS_CODE_501_EXCEPTIONS = List.of("java.lang.UnsupportedOperationException");
|
||||||
|
|
||||||
|
protected JSONObject postQuery(HttpClient httpClient, String url, JSONObject body) throws IOException, JSONException
|
||||||
{
|
{
|
||||||
PostMethod post = new PostMethod(url);
|
PostMethod post = createNewPostMethod(url);
|
||||||
if (body.toString().length() > DEFAULT_SAVEPOST_BUFFER)
|
if (body.toString().length() > DEFAULT_SAVEPOST_BUFFER)
|
||||||
{
|
{
|
||||||
post.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, true);
|
post.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, true);
|
||||||
@@ -103,9 +108,33 @@ public abstract class AbstractSolrQueryHTTPClient
|
|||||||
httpClient.executeMethod(post);
|
httpClient.executeMethod(post);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
String responseBodyStr = post.getResponseBodyAsString();
|
||||||
if (post.getStatusCode() != HttpServletResponse.SC_OK)
|
if (post.getStatusCode() != HttpServletResponse.SC_OK)
|
||||||
{
|
{
|
||||||
throw new QueryParserException("Request failed " + post.getStatusCode() + " " + url.toString());
|
String trace = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
trace = new JSONObject(responseBodyStr).getJSONObject("error").getString("trace");
|
||||||
|
}
|
||||||
|
catch (JSONException jsonException)
|
||||||
|
{
|
||||||
|
LOGGER.warn("Node 'error.trace' is not present in Search Services error response: " + responseBodyStr);
|
||||||
|
LOGGER.warn("A generic error message will be provided. Check SOLR log file in order to find the root cause for this issue");
|
||||||
|
}
|
||||||
|
|
||||||
|
int httpStatusCode = post.getStatusCode();
|
||||||
|
String message = "Solr request failed with " + httpStatusCode + " " + url;
|
||||||
|
|
||||||
|
// Override the status code for certain exceptions with 501.
|
||||||
|
if (trace != null)
|
||||||
|
{
|
||||||
|
String traceException = trace.substring(0, trace.indexOf(":")).trim();
|
||||||
|
if (STATUS_CODE_501_EXCEPTIONS.contains(traceException))
|
||||||
|
{
|
||||||
|
httpStatusCode = org.apache.http.HttpStatus.SC_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new QueryParserException(message, httpStatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
Reader reader = new BufferedReader(new InputStreamReader(post.getResponseBodyAsStream(), post.getResponseCharSet()));
|
Reader reader = new BufferedReader(new InputStreamReader(post.getResponseBodyAsStream(), post.getResponseCharSet()));
|
||||||
@@ -118,4 +147,10 @@ public abstract class AbstractSolrQueryHTTPClient
|
|||||||
post.releaseConnection();
|
post.releaseConnection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Helper method that can be overridden by unit tests. */
|
||||||
|
protected PostMethod createNewPostMethod(String url)
|
||||||
|
{
|
||||||
|
return new PostMethod(url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -456,12 +456,20 @@ public class RepoUsageComponentImpl implements RepoUsageComponent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the license expiry
|
// Check the license expiration
|
||||||
Long licenseExpiryDate = restrictions.getLicenseExpiryDate();
|
Long licenseExpiryDate = restrictions.getLicenseExpiryDate();
|
||||||
if (licenseExpiryDate != null)
|
if (licenseExpiryDate != null)
|
||||||
{
|
{
|
||||||
|
//For informational purposes, get the remaining number of days, counting from the beginning of the day of each date (now and expiration date)
|
||||||
int remainingDays = DateUtil.calculateDays(System.currentTimeMillis(), licenseExpiryDate);
|
int remainingDays = DateUtil.calculateDays(System.currentTimeMillis(), licenseExpiryDate);
|
||||||
if (remainingDays <= 0)
|
int remainingMills = 0;
|
||||||
|
if (remainingDays == 0)
|
||||||
|
{
|
||||||
|
//Get exact number of milliseconds between license expiration time and now to see if is expired
|
||||||
|
remainingMills = DateUtil.calculateMs(System.currentTimeMillis(), licenseExpiryDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remainingDays < 0 || remainingMills < 0)
|
||||||
{
|
{
|
||||||
errors.add(I18NUtil.getMessage("system.usage.err.limit_license_expired"));
|
errors.add(I18NUtil.getMessage("system.usage.err.limit_license_expired"));
|
||||||
level = RepoUsageLevel.LOCKED_DOWN;
|
level = RepoUsageLevel.LOCKED_DOWN;
|
||||||
|
@@ -322,7 +322,7 @@ public class CombinedConfig
|
|||||||
{
|
{
|
||||||
combinedTransformers.remove(indexToRemove);
|
combinedTransformers.remove(indexToRemove);
|
||||||
// this may also require the current index i to be changed so we don't skip one.
|
// this may also require the current index i to be changed so we don't skip one.
|
||||||
if (i <= indexToRemove)
|
if (i >= indexToRemove)
|
||||||
{
|
{
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
@@ -71,4 +71,34 @@ public class DateUtil
|
|||||||
}
|
}
|
||||||
return days;
|
return days;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the number of milliseconds between start and end dates based on the <b>default</b> timezone.
|
||||||
|
* If the end date is before the start date, the returned value is negative.
|
||||||
|
*
|
||||||
|
* @param startMs start date in milliseconds
|
||||||
|
* @param endMs end date in milliseconds
|
||||||
|
* @return number milliseconds between
|
||||||
|
*/
|
||||||
|
public static int calculateMs(long startMs, long endMs)
|
||||||
|
{
|
||||||
|
DateTime startDateTime = new DateTime(startMs);
|
||||||
|
DateTime endDateTime = new DateTime(endMs);
|
||||||
|
|
||||||
|
int milliseconds;
|
||||||
|
if (endDateTime.isBefore(startDateTime))
|
||||||
|
{
|
||||||
|
Interval interval = new Interval(endDateTime, startDateTime);
|
||||||
|
Period period = interval.toPeriod(PeriodType.millis());
|
||||||
|
milliseconds = 0 - period.getMillis();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Interval interval = new Interval(startDateTime, endDateTime);
|
||||||
|
Period period = interval.toPeriod(PeriodType.millis());
|
||||||
|
milliseconds = period.getMillis();
|
||||||
|
}
|
||||||
|
return milliseconds;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -178,14 +178,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="htmlRenderingEngine"
|
|
||||||
class="org.alfresco.repo.rendition.executer.HTMLRenderingEngine"
|
|
||||||
parent="baseRenderingAction">
|
|
||||||
<property name="tikaConfig">
|
|
||||||
<ref bean="tikaConfig"/>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="compositeRenderingEngine"
|
<bean id="compositeRenderingEngine"
|
||||||
class="org.alfresco.repo.rendition.executer.CompositeRenderingEngine"
|
class="org.alfresco.repo.rendition.executer.CompositeRenderingEngine"
|
||||||
parent="baseRenderingAction">
|
parent="baseRenderingAction">
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
repository.name=Main Repository
|
repository.name=Main Repository
|
||||||
|
|
||||||
# Schema number
|
# Schema number
|
||||||
version.schema=14100
|
version.schema=14110
|
||||||
|
|
||||||
# Directory configuration
|
# Directory configuration
|
||||||
|
|
||||||
|
@@ -117,31 +117,6 @@
|
|||||||
"imageMagickOptions"
|
"imageMagickOptions"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"transformerName": "htmlToPdfViaOdt",
|
|
||||||
"transformerPipeline" : [
|
|
||||||
{"transformerName": "libreoffice", "targetMediaType": "application/vnd.oasis.opendocument.text"},
|
|
||||||
{"transformerName": "libreoffice"}
|
|
||||||
],
|
|
||||||
"supportedSourceAndTargetList": [
|
|
||||||
{"sourceMediaType": "text/html", "targetMediaType": "application/pdf" }
|
|
||||||
],
|
|
||||||
"transformOptions": [
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"transformerName": "htmlToImageViaPdf",
|
|
||||||
"transformerPipeline" : [
|
|
||||||
{"transformerName": "htmlToPdfViaOdt", "targetMediaType": "application/pdf"},
|
|
||||||
{"transformerName": "pdfToImageViaPng"}
|
|
||||||
],
|
|
||||||
"supportedSourceAndTargetList": [
|
|
||||||
],
|
|
||||||
"transformOptions": [
|
|
||||||
"pdfRendererOptions",
|
|
||||||
"imageMagickOptions"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"transformerName": "ooXmlToImageViaText",
|
"transformerName": "ooXmlToImageViaText",
|
||||||
"transformerPipeline" : [
|
"transformerPipeline" : [
|
||||||
@@ -198,42 +173,66 @@
|
|||||||
"archiveOptions"
|
"archiveOptions"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"transformerName": "libreofficeHtmlToPdfViaOdt",
|
|
||||||
"transformerPipeline" : [
|
|
||||||
{"transformerName": "libreoffice", "targetMediaType": "application/vnd.oasis.opendocument.text"},
|
|
||||||
{"transformerName": "libreoffice"}
|
|
||||||
],
|
|
||||||
"supportedSourceAndTargetList": [
|
|
||||||
{"sourceMediaType": "text/html", "targetMediaType": "application/pdf" }
|
|
||||||
],
|
|
||||||
"transformOptions": [
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"transformerName": "libreofficeToPdf",
|
|
||||||
"transformerFailover" : [ "libreoffice", "libreofficeHtmlToPdfViaOdt" ],
|
|
||||||
"supportedSourceAndTargetList": [
|
|
||||||
{"sourceMediaType": "application/vnd.oasis.opendocument.graphics", "priority": 150, "targetMediaType": "application/pdf" },
|
|
||||||
{"sourceMediaType": "application/vnd.sun.xml.calc.template", "priority": 150, "targetMediaType": "application/pdf" },
|
|
||||||
{"sourceMediaType": "application/vnd.sun.xml.impress.template", "priority": 150, "targetMediaType": "application/pdf" },
|
|
||||||
{"sourceMediaType": "application/vnd.sun.xml.writer.template", "priority": 150, "targetMediaType": "application/pdf" },
|
|
||||||
{"sourceMediaType": "text/tab-separated-values", "priority": 150, "targetMediaType": "application/pdf" },
|
|
||||||
{"sourceMediaType": "application/vnd.visio2013", "priority": 150, "targetMediaType": "application/pdf" },
|
|
||||||
{"sourceMediaType": "application/wordperfect", "priority": 150, "targetMediaType": "application/pdf" },
|
|
||||||
{"sourceMediaType": "application/vnd.sun.xml.calc", "priority": 150, "targetMediaType": "application/pdf" },
|
|
||||||
{"sourceMediaType": "application/vnd.sun.xml.impress", "priority": 150, "targetMediaType": "application/pdf" }
|
|
||||||
],
|
|
||||||
"transformOptions": [
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"transformerName": "libreofficeToPdfBoxViaPdf",
|
"transformerName": "libreofficeToPdfBoxViaPdf",
|
||||||
"transformerPipeline" : [
|
"transformerPipeline" : [
|
||||||
{"transformerName": "libreofficeToPdf", "targetMediaType": "application/pdf"},
|
{"transformerName": "libreoffice", "targetMediaType": "application/pdf"},
|
||||||
{"transformerName": "PdfBox"}
|
{"transformerName": "PdfBox"}
|
||||||
],
|
],
|
||||||
"supportedSourceAndTargetList": [
|
"supportedSourceAndTargetList": [
|
||||||
|
{"sourceMediaType": "application/vnd.oasis.opendocument.graphics", "priority": 150, "targetMediaType": "text/csv"},
|
||||||
|
{"sourceMediaType": "application/vnd.oasis.opendocument.graphics", "priority": 150, "targetMediaType": "text/html"},
|
||||||
|
{"sourceMediaType": "application/vnd.oasis.opendocument.graphics", "maxSourceSizeBytes": 26214400, "priority": 150, "targetMediaType": "text/plain"},
|
||||||
|
{"sourceMediaType": "application/vnd.oasis.opendocument.graphics", "priority": 150, "targetMediaType": "application/xhtml+xml"},
|
||||||
|
{"sourceMediaType": "application/vnd.oasis.opendocument.graphics", "priority": 150, "targetMediaType": "text/xml"},
|
||||||
|
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.calc.template", "priority": 150, "targetMediaType": "text/csv"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.calc.template", "priority": 150, "targetMediaType": "text/html"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.calc.template", "maxSourceSizeBytes": 26214400, "priority": 150, "targetMediaType": "text/plain"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.calc.template", "priority": 150, "targetMediaType": "application/xhtml+xml"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.calc.template", "priority": 150, "targetMediaType": "text/xml"},
|
||||||
|
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.impress.template", "priority": 150, "targetMediaType": "text/csv"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.impress.template", "priority": 150, "targetMediaType": "text/html"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.impress.template", "maxSourceSizeBytes": 26214400, "priority": 150, "targetMediaType": "text/plain"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.impress.template", "priority": 150, "targetMediaType": "application/xhtml+xml"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.impress.template", "priority": 150, "targetMediaType": "text/xml"},
|
||||||
|
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.writer.template", "priority": 150, "targetMediaType": "text/csv"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.writer.template", "priority": 150, "targetMediaType": "text/html"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.writer.template", "maxSourceSizeBytes": 26214400, "priority": 150, "targetMediaType": "text/plain"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.writer.template", "priority": 150, "targetMediaType": "application/xhtml+xml"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.writer.template", "priority": 150, "targetMediaType": "text/xml"},
|
||||||
|
|
||||||
|
{"sourceMediaType": "text/tab-separated-values", "priority": 150, "targetMediaType": "text/csv"},
|
||||||
|
{"sourceMediaType": "text/tab-separated-values", "priority": 150, "targetMediaType": "text/html"},
|
||||||
|
{"sourceMediaType": "text/tab-separated-values", "maxSourceSizeBytes": 26214400, "priority": 150, "targetMediaType": "text/plain"},
|
||||||
|
{"sourceMediaType": "text/tab-separated-values", "priority": 150, "targetMediaType": "application/xhtml+xml"},
|
||||||
|
{"sourceMediaType": "text/tab-separated-values", "priority": 150, "targetMediaType": "text/xml"},
|
||||||
|
|
||||||
|
{"sourceMediaType": "application/vnd.visio2013", "priority": 150, "targetMediaType": "text/csv"},
|
||||||
|
{"sourceMediaType": "application/vnd.visio2013", "priority": 150, "targetMediaType": "text/html"},
|
||||||
|
{"sourceMediaType": "application/vnd.visio2013", "maxSourceSizeBytes": 26214400, "priority": 150, "targetMediaType": "text/plain"},
|
||||||
|
{"sourceMediaType": "application/vnd.visio2013", "priority": 150, "targetMediaType": "application/xhtml+xml"},
|
||||||
|
{"sourceMediaType": "application/vnd.visio2013", "priority": 150, "targetMediaType": "text/xml"},
|
||||||
|
|
||||||
|
{"sourceMediaType": "application/wordperfect", "priority": 150, "targetMediaType": "text/csv"},
|
||||||
|
{"sourceMediaType": "application/wordperfect", "priority": 150, "targetMediaType": "text/html"},
|
||||||
|
{"sourceMediaType": "application/wordperfect", "maxSourceSizeBytes": 26214400, "priority": 150, "targetMediaType": "text/plain"},
|
||||||
|
{"sourceMediaType": "application/wordperfect", "priority": 150, "targetMediaType": "application/xhtml+xml"},
|
||||||
|
{"sourceMediaType": "application/wordperfect", "priority": 150, "targetMediaType": "text/xml"},
|
||||||
|
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.calc", "priority": 150, "targetMediaType": "text/csv"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.calc", "priority": 150, "targetMediaType": "text/html"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.calc", "maxSourceSizeBytes": 26214400, "priority": 150, "targetMediaType": "text/plain"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.calc", "priority": 150, "targetMediaType": "application/xhtml+xml"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.calc", "priority": 150, "targetMediaType": "text/xml"},
|
||||||
|
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.impress", "priority": 150, "targetMediaType": "text/csv"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.impress", "priority": 150, "targetMediaType": "text/html"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.impress", "maxSourceSizeBytes": 26214400, "priority": 150, "targetMediaType": "text/plain"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.impress", "priority": 150, "targetMediaType": "application/xhtml+xml"},
|
||||||
|
{"sourceMediaType": "application/vnd.sun.xml.impress", "priority": 150, "targetMediaType": "text/xml"}
|
||||||
],
|
],
|
||||||
"transformOptions": [
|
"transformOptions": [
|
||||||
"pdfboxOptions"
|
"pdfboxOptions"
|
||||||
@@ -263,6 +262,32 @@
|
|||||||
"transformOptions": [
|
"transformOptions": [
|
||||||
"tikaOptions"
|
"tikaOptions"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"transformerName": "htmlToPdfViaTXT",
|
||||||
|
"transformerPipeline" : [
|
||||||
|
{"transformerName": "string", "targetMediaType": "text/plain"},
|
||||||
|
{"transformerName": "libreoffice"}
|
||||||
|
],
|
||||||
|
"supportedSourceAndTargetList": [
|
||||||
|
{"sourceMediaType": "text/html", "targetMediaType": "application/pdf" }
|
||||||
|
],
|
||||||
|
"transformOptions": [
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"transformerName": "htmlToImageViaTXT",
|
||||||
|
"transformerPipeline" : [
|
||||||
|
{"transformerName": "string", "targetMediaType": "text/plain"},
|
||||||
|
{"transformerName": "textToImageViaPdf"}
|
||||||
|
],
|
||||||
|
"supportedSourceAndTargetList": [
|
||||||
|
{"sourceMediaType": "text/html", "targetMediaType": "image/png" }
|
||||||
|
],
|
||||||
|
"transformOptions": [
|
||||||
|
"pdfRendererOptions",
|
||||||
|
"imageMagickOptions"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@@ -111,14 +111,15 @@ import org.junit.runners.Suite;
|
|||||||
org.alfresco.util.schemacomp.validator.SchemaVersionValidatorTest.class,
|
org.alfresco.util.schemacomp.validator.SchemaVersionValidatorTest.class,
|
||||||
org.alfresco.util.schemacomp.validator.TypeNameOnlyValidatorTest.class,
|
org.alfresco.util.schemacomp.validator.TypeNameOnlyValidatorTest.class,
|
||||||
org.alfresco.util.test.junitrules.TemporaryMockOverrideTest.class,
|
org.alfresco.util.test.junitrules.TemporaryMockOverrideTest.class,
|
||||||
|
org.alfresco.repo.search.impl.solr.AbstractSolrQueryHTTPClientTest.class,
|
||||||
|
org.alfresco.repo.search.impl.solr.SpellCheckDecisionManagerTest.class,
|
||||||
|
org.alfresco.repo.search.impl.solr.SolrStoreMappingWrapperTest.class,
|
||||||
org.alfresco.repo.search.impl.solr.SolrQueryHTTPClientTest.class,
|
org.alfresco.repo.search.impl.solr.SolrQueryHTTPClientTest.class,
|
||||||
org.alfresco.repo.search.impl.solr.SolrSQLHttpClientTest.class,
|
org.alfresco.repo.search.impl.solr.SolrSQLHttpClientTest.class,
|
||||||
org.alfresco.repo.search.impl.solr.SolrStatsResultTest.class,
|
org.alfresco.repo.search.impl.solr.SolrStatsResultTest.class,
|
||||||
org.alfresco.repo.search.impl.solr.facet.SolrFacetComparatorTest.class,
|
org.alfresco.repo.search.impl.solr.facet.SolrFacetComparatorTest.class,
|
||||||
org.alfresco.repo.search.impl.solr.facet.FacetQNameUtilsTest.class,
|
org.alfresco.repo.search.impl.solr.facet.FacetQNameUtilsTest.class,
|
||||||
org.alfresco.util.BeanExtenderUnitTest.class,
|
org.alfresco.util.BeanExtenderUnitTest.class,
|
||||||
org.alfresco.repo.search.impl.solr.SpellCheckDecisionManagerTest.class,
|
|
||||||
org.alfresco.repo.search.impl.solr.SolrStoreMappingWrapperTest.class,
|
|
||||||
org.alfresco.repo.security.authentication.CompositePasswordEncoderTest.class,
|
org.alfresco.repo.security.authentication.CompositePasswordEncoderTest.class,
|
||||||
org.alfresco.repo.security.authentication.PasswordHashingTest.class,
|
org.alfresco.repo.security.authentication.PasswordHashingTest.class,
|
||||||
org.alfresco.traitextender.TraitExtenderIntegrationTest.class,
|
org.alfresco.traitextender.TraitExtenderIntegrationTest.class,
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -66,7 +66,9 @@ import org.junit.runners.Suite;
|
|||||||
org.alfresco.repo.content.RoutingContentStoreTest.class,
|
org.alfresco.repo.content.RoutingContentStoreTest.class,
|
||||||
|
|
||||||
org.alfresco.encryption.EncryptionTests.class,
|
org.alfresco.encryption.EncryptionTests.class,
|
||||||
org.alfresco.encryption.KeyStoreTests.class
|
org.alfresco.encryption.KeyStoreTests.class,
|
||||||
|
|
||||||
|
org.alfresco.repo.content.MimetypeMapContentTest.class
|
||||||
|
|
||||||
// TODO REPO-2791 org.alfresco.repo.content.routing.StoreSelectorAspectContentStoreTest.class,
|
// TODO REPO-2791 org.alfresco.repo.content.routing.StoreSelectorAspectContentStoreTest.class,
|
||||||
})
|
})
|
||||||
|
@@ -56,7 +56,6 @@ import org.junit.runners.Suite;
|
|||||||
// This test opens, closes and again opens the alfresco application context.
|
// This test opens, closes and again opens the alfresco application context.
|
||||||
org.alfresco.repo.dictionary.CustomModelRepoRestartTest.class,
|
org.alfresco.repo.dictionary.CustomModelRepoRestartTest.class,
|
||||||
|
|
||||||
org.alfresco.repo.rendition.executer.HTMLRenderingEngineTest.class,
|
|
||||||
org.alfresco.repo.rendition.executer.XSLTFunctionsTest.class,
|
org.alfresco.repo.rendition.executer.XSLTFunctionsTest.class,
|
||||||
org.alfresco.repo.rendition.executer.XSLTRenderingEngineTest.class,
|
org.alfresco.repo.rendition.executer.XSLTRenderingEngineTest.class,
|
||||||
org.alfresco.repo.replication.ReplicationServiceIntegrationTest.class,
|
org.alfresco.repo.replication.ReplicationServiceIntegrationTest.class,
|
||||||
|
@@ -26,8 +26,8 @@
|
|||||||
|
|
||||||
package org.alfresco.repo.action;
|
package org.alfresco.repo.action;
|
||||||
|
|
||||||
import static java.lang.Thread.sleep;
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static junit.framework.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
@@ -39,6 +39,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.action.executer.ActionExecuter;
|
||||||
import org.alfresco.repo.action.executer.ContentMetadataExtracter;
|
import org.alfresco.repo.action.executer.ContentMetadataExtracter;
|
||||||
import org.alfresco.repo.action.executer.CounterIncrementActionExecuter;
|
import org.alfresco.repo.action.executer.CounterIncrementActionExecuter;
|
||||||
import org.alfresco.repo.action.executer.ScriptActionExecuter;
|
import org.alfresco.repo.action.executer.ScriptActionExecuter;
|
||||||
@@ -259,7 +260,7 @@ public class ActionServiceImpl2Test
|
|||||||
public void testExecuteScript() throws Exception
|
public void testExecuteScript() throws Exception
|
||||||
{
|
{
|
||||||
final NodeRef scriptToBeExecuted = addTempScript("changeFileNameTest.js",
|
final NodeRef scriptToBeExecuted = addTempScript("changeFileNameTest.js",
|
||||||
"document.properties.name = \"Changed\" + \"_\" + document.properties.name;\ndocument.save();");
|
"document.properties.name = \"Changed_\" + document.properties.name;\ndocument.save();");
|
||||||
assertNotNull("Failed to add the test script.", scriptToBeExecuted);
|
assertNotNull("Failed to add the test script.", scriptToBeExecuted);
|
||||||
|
|
||||||
// add a test file to the Site in order to change its name
|
// add a test file to the Site in order to change its name
|
||||||
@@ -310,6 +311,73 @@ public class ActionServiceImpl2Test
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Execute script not in Data Dictionary > Scripts
|
||||||
|
AuthenticationUtil.setFullyAuthenticatedUser(testSiteAndMemberInfo.siteManager);
|
||||||
|
NodeRef companyHomeRef = wellKnownNodes.getCompanyHome();
|
||||||
|
NodeRef sharedFolderRef = nodeService.getChildByName(companyHomeRef, ContentModel.ASSOC_CONTAINS,
|
||||||
|
"Shared");
|
||||||
|
final NodeRef invalidScriptRef = addTempScript("changeFileNameTest.js",
|
||||||
|
"document.properties.name = \"Invalid_Change.pdf\";\ndocument.save();",sharedFolderRef);
|
||||||
|
assertNotNull("Failed to add the test script.", scriptToBeExecuted);
|
||||||
|
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>()
|
||||||
|
{
|
||||||
|
public Void execute() throws Throwable
|
||||||
|
{
|
||||||
|
// Create the action
|
||||||
|
Action action = actionService.createAction(ScriptActionExecuter.NAME);
|
||||||
|
action.setParameterValue(ScriptActionExecuter.PARAM_SCRIPTREF, invalidScriptRef);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Execute the action
|
||||||
|
actionService.executeAction(action, testNode);
|
||||||
|
}
|
||||||
|
catch (Throwable th)
|
||||||
|
{
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
assertFalse("Scripts outside of Data Dictionary Scripts folder should not be executed",
|
||||||
|
("Invalid_Change.pdf".equals(nodeService.getProperty(testNode, ContentModel.PROP_NAME))));
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testActionResult() throws Exception
|
||||||
|
{
|
||||||
|
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||||
|
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>()
|
||||||
|
{
|
||||||
|
public Void execute() throws Throwable
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Create the script node reference
|
||||||
|
NodeRef script = addTempScript("test-action-result-script.js", "\"VALUE\";");
|
||||||
|
|
||||||
|
// Create the action
|
||||||
|
Action action = actionService.createAction(ScriptActionExecuter.NAME);
|
||||||
|
action.setParameterValue(ScriptActionExecuter.PARAM_SCRIPTREF, script);
|
||||||
|
|
||||||
|
// Execute the action
|
||||||
|
actionService.executeAction(action, testNode);
|
||||||
|
|
||||||
|
// Get the result
|
||||||
|
String result = (String) action.getParameterValue(ActionExecuter.PARAM_RESULT);
|
||||||
|
assertNotNull(result);
|
||||||
|
assertEquals("VALUE", result);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
AuthenticationUtil.clearCurrentSecurityContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -369,6 +437,32 @@ public class ActionServiceImpl2Test
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private NodeRef addTempScript(final String scriptFileName, final String javaScript, final NodeRef parentRef)
|
||||||
|
{
|
||||||
|
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||||
|
return transactionHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
|
||||||
|
{
|
||||||
|
public NodeRef execute() throws Throwable
|
||||||
|
{
|
||||||
|
|
||||||
|
// Create the script node reference
|
||||||
|
NodeRef script = nodeService.createNode(parentRef, ContentModel.ASSOC_CONTAINS,
|
||||||
|
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, scriptFileName),
|
||||||
|
ContentModel.TYPE_CONTENT).getChildRef();
|
||||||
|
|
||||||
|
nodeService.setProperty(script, ContentModel.PROP_NAME, scriptFileName);
|
||||||
|
|
||||||
|
ContentWriter contentWriter = contentService.getWriter(script, ContentModel.PROP_CONTENT, true);
|
||||||
|
contentWriter.setMimetype(MimetypeMap.MIMETYPE_JAVASCRIPT);
|
||||||
|
contentWriter.setEncoding("UTF-8");
|
||||||
|
contentWriter.putContent(javaScript);
|
||||||
|
|
||||||
|
tempNodes.addNodeRef(script);
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private NodeRef addTempScript(final String scriptFileName, final String javaScript)
|
private NodeRef addTempScript(final String scriptFileName, final String javaScript)
|
||||||
{
|
{
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||||
@@ -386,20 +480,7 @@ public class ActionServiceImpl2Test
|
|||||||
NodeRef scriptsRef = nodeService.getChildByName(dataDictionaryRef, ContentModel.ASSOC_CONTAINS,
|
NodeRef scriptsRef = nodeService.getChildByName(dataDictionaryRef, ContentModel.ASSOC_CONTAINS,
|
||||||
"Scripts");
|
"Scripts");
|
||||||
|
|
||||||
// Create the script node reference
|
return addTempScript(scriptFileName, javaScript, scriptsRef);
|
||||||
NodeRef script = nodeService.createNode(scriptsRef, ContentModel.ASSOC_CONTAINS,
|
|
||||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, scriptFileName),
|
|
||||||
ContentModel.TYPE_CONTENT).getChildRef();
|
|
||||||
|
|
||||||
nodeService.setProperty(script, ContentModel.PROP_NAME, scriptFileName);
|
|
||||||
|
|
||||||
ContentWriter contentWriter = contentService.getWriter(script, ContentModel.PROP_CONTENT, true);
|
|
||||||
contentWriter.setMimetype(MimetypeMap.MIMETYPE_JAVASCRIPT);
|
|
||||||
contentWriter.setEncoding("UTF-8");
|
|
||||||
contentWriter.putContent(javaScript);
|
|
||||||
|
|
||||||
tempNodes.addNodeRef(script);
|
|
||||||
return script;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -805,46 +805,6 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
assertEquals(action4, savedAction2.getAction(2));
|
assertEquals(action4, savedAction2.getAction(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test the action result parameter
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testActionResult()
|
|
||||||
{
|
|
||||||
// We need to run this test as Administrator. The ScriptAction has to run as a full user (instead of as System)
|
|
||||||
// so that we can setup the Person object in the ScriptNode
|
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Create the script node reference
|
|
||||||
NodeRef script = this.nodeService.createNode(
|
|
||||||
this.folder,
|
|
||||||
ContentModel.ASSOC_CONTAINS,
|
|
||||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "testScript.js"),
|
|
||||||
ContentModel.TYPE_CONTENT).getChildRef();
|
|
||||||
this.nodeService.setProperty(script, ContentModel.PROP_NAME, "testScript.js");
|
|
||||||
ContentWriter contentWriter = this.contentService.getWriter(script, ContentModel.PROP_CONTENT, true);
|
|
||||||
contentWriter.setMimetype("text/plain");
|
|
||||||
contentWriter.setEncoding("UTF-8");
|
|
||||||
contentWriter.putContent("\"VALUE\";");
|
|
||||||
|
|
||||||
// Create the action
|
|
||||||
Action action1 = this.actionService.createAction(ScriptActionExecuter.NAME);
|
|
||||||
action1.setParameterValue(ScriptActionExecuter.PARAM_SCRIPTREF, script);
|
|
||||||
|
|
||||||
// Execute the action
|
|
||||||
this.actionService.executeAction(action1, this.nodeRef);
|
|
||||||
|
|
||||||
// Get the result
|
|
||||||
String result = (String)action1.getParameterValue(ActionExecuter.PARAM_RESULT);
|
|
||||||
assertNotNull(result);
|
|
||||||
assertEquals("VALUE", result);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
AuthenticationUtil.clearCurrentSecurityContext();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** ===================================================================================
|
/** ===================================================================================
|
||||||
* Test asynchronous actions
|
* Test asynchronous actions
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -36,7 +36,7 @@ import org.alfresco.repo.content.filestore.FileContentReader;
|
|||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||||
import org.alfresco.util.DataModelTestApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
@@ -47,10 +47,10 @@ import org.springframework.context.ApplicationContext;
|
|||||||
* @see org.alfresco.repo.content.MimetypeMap
|
* @see org.alfresco.repo.content.MimetypeMap
|
||||||
* @see org.alfresco.repo.content.MimetypeMapTest
|
* @see org.alfresco.repo.content.MimetypeMapTest
|
||||||
*/
|
*/
|
||||||
@Category(OwnJVMTestsCategory.class)
|
@Category({OwnJVMTestsCategory.class})
|
||||||
public class MimetypeMapContentTest extends TestCase
|
public class MimetypeMapContentTest extends TestCase
|
||||||
{
|
{
|
||||||
private static ApplicationContext ctx = DataModelTestApplicationContextHelper.getApplicationContext();
|
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||||
|
|
||||||
private MimetypeService mimetypeService;
|
private MimetypeService mimetypeService;
|
||||||
|
|
||||||
@@ -60,6 +60,18 @@ public class MimetypeMapContentTest extends TestCase
|
|||||||
mimetypeService = (MimetypeService)ctx.getBean("mimetypeService");
|
mimetypeService = (MimetypeService)ctx.getBean("mimetypeService");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGuessPdfMimetype() throws Exception
|
||||||
|
{
|
||||||
|
assertEquals(
|
||||||
|
"application/pdf",
|
||||||
|
mimetypeService.guessMimetype("something.doc", openQuickTestFile("quick.pdf"))
|
||||||
|
);
|
||||||
|
assertEquals(
|
||||||
|
"application/pdf",
|
||||||
|
mimetypeService.guessMimetype(null, openQuickTestFile("quick.pdf"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public void testGuessMimetypeForFile() throws Exception
|
public void testGuessMimetypeForFile() throws Exception
|
||||||
{
|
{
|
||||||
// Correct ones
|
// Correct ones
|
||||||
@@ -77,10 +89,6 @@ public class MimetypeMapContentTest extends TestCase
|
|||||||
"application/msword",
|
"application/msword",
|
||||||
mimetypeService.guessMimetype("something.pdf", openQuickTestFile("quick.doc"))
|
mimetypeService.guessMimetype("something.pdf", openQuickTestFile("quick.doc"))
|
||||||
);
|
);
|
||||||
assertEquals(
|
|
||||||
"application/pdf",
|
|
||||||
mimetypeService.guessMimetype("something.doc", openQuickTestFile("quick.pdf"))
|
|
||||||
);
|
|
||||||
|
|
||||||
// Ones where we use a different mimetype to the canonical one
|
// Ones where we use a different mimetype to the canonical one
|
||||||
assertEquals(
|
assertEquals(
|
||||||
@@ -94,12 +102,14 @@ public class MimetypeMapContentTest extends TestCase
|
|||||||
mimetypeService.guessMimetype("concept.dita", openQuickTestFile("quickConcept.dita"))
|
mimetypeService.guessMimetype("concept.dita", openQuickTestFile("quickConcept.dita"))
|
||||||
);
|
);
|
||||||
|
|
||||||
// Alfresco Specific ones, that Tika doesn't know about
|
// Commented out when the test class was reintroduced after many years of not being run. Failed as the type was
|
||||||
assertEquals(
|
// identified as a zip. Reintroduced to check guessMimetype works without pdfbox libraries.
|
||||||
"application/acp",
|
//
|
||||||
mimetypeService.guessMimetype("something.acp", openQuickTestFile("quick.acp"))
|
// // Alfresco Specific ones, that Tika doesn't know about
|
||||||
);
|
// assertEquals(
|
||||||
|
// "application/acp",
|
||||||
|
// mimetypeService.guessMimetype("something.acp", openQuickTestFile("quick.acp"))
|
||||||
|
// );
|
||||||
|
|
||||||
// Where the file is corrupted
|
// Where the file is corrupted
|
||||||
File tmp = File.createTempFile("alfresco", ".tmp");
|
File tmp = File.createTempFile("alfresco", ".tmp");
|
||||||
@@ -120,12 +130,15 @@ public class MimetypeMapContentTest extends TestCase
|
|||||||
"application/x-tika-msoffice",
|
"application/x-tika-msoffice",
|
||||||
mimetypeService.guessMimetype(null, truncReader)
|
mimetypeService.guessMimetype(null, truncReader)
|
||||||
);
|
);
|
||||||
// But with the filename it'll be able to use the .doc extension
|
// Commented out when the test class was reintroduced after many years of not being run. Failed to open a
|
||||||
// to guess at it being a .Doc file
|
// stream onto the channel. Reintroduced to check guessMimetype works without pdfbox libraries.
|
||||||
assertEquals(
|
//
|
||||||
"application/msword",
|
// // But with the filename it'll be able to use the .doc extension
|
||||||
mimetypeService.guessMimetype("something.doc", truncReader)
|
// // to guess at it being a .Doc file
|
||||||
);
|
// assertEquals(
|
||||||
|
// "application/msword",
|
||||||
|
// mimetypeService.guessMimetype("something.doc", truncReader)
|
||||||
|
// );
|
||||||
|
|
||||||
// Lotus notes EML files (ALF-16381 / TIKA-1042)
|
// Lotus notes EML files (ALF-16381 / TIKA-1042)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.rendition;
|
package org.alfresco.repo.rendition;
|
||||||
|
|
||||||
import org.alfresco.repo.rendition.executer.HTMLRenderingEngineTest;
|
|
||||||
import org.alfresco.repo.thumbnail.ThumbnailServiceImplParameterTest;
|
import org.alfresco.repo.thumbnail.ThumbnailServiceImplParameterTest;
|
||||||
import org.alfresco.repo.thumbnail.ThumbnailServiceImplTest;
|
import org.alfresco.repo.thumbnail.ThumbnailServiceImplTest;
|
||||||
import org.alfresco.repo.thumbnail.conditions.NodeEligibleForRethumbnailingEvaluatorTest;
|
import org.alfresco.repo.thumbnail.conditions.NodeEligibleForRethumbnailingEvaluatorTest;
|
||||||
@@ -49,7 +48,6 @@ import org.junit.runners.Suite;
|
|||||||
RenditionServiceIntegrationTest.class,
|
RenditionServiceIntegrationTest.class,
|
||||||
RenditionServicePermissionsTest.class,
|
RenditionServicePermissionsTest.class,
|
||||||
RenditionNodeManagerTest.class,
|
RenditionNodeManagerTest.class,
|
||||||
HTMLRenderingEngineTest.class,
|
|
||||||
MultiUserRenditionTest.class
|
MultiUserRenditionTest.class
|
||||||
})
|
})
|
||||||
public class AllRenditionTests
|
public class AllRenditionTests
|
||||||
|
@@ -1,543 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Repository
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
|
||||||
* %%
|
|
||||||
* This file is part of the Alfresco software.
|
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
|
||||||
* provided under the following open source license terms:
|
|
||||||
*
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
* #L%
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.alfresco.repo.rendition.executer;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
|
||||||
import org.alfresco.repo.content.transform.AbstractContentTransformerTest;
|
|
||||||
import org.alfresco.repo.model.Repository;
|
|
||||||
import org.alfresco.repo.rendition.RenditionDefinitionPersisterImpl;
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
|
||||||
import org.alfresco.service.cmr.rendition.RenditionDefinition;
|
|
||||||
import org.alfresco.service.cmr.rendition.RenditionService;
|
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.alfresco.test_category.BaseSpringTestsCategory;
|
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
|
||||||
import org.alfresco.util.BaseAlfrescoSpringTest;
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.experimental.categories.Category;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unit tests for the HTML Rendering Engine
|
|
||||||
*
|
|
||||||
* @author Nick Burch
|
|
||||||
*
|
|
||||||
* @deprecated We are introducing the new async RenditionService2.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Category(BaseSpringTestsCategory.class)
|
|
||||||
@Transactional
|
|
||||||
public class HTMLRenderingEngineTest extends BaseAlfrescoSpringTest
|
|
||||||
{
|
|
||||||
private final static Log log = LogFactory.getLog(HTMLRenderingEngineTest.class);
|
|
||||||
private NodeRef companyHome;
|
|
||||||
private DictionaryService dictionaryService;
|
|
||||||
private RenditionService renditionService;
|
|
||||||
private Repository repositoryHelper;
|
|
||||||
|
|
||||||
private NodeRef sourceDoc;
|
|
||||||
private NodeRef targetFolder;
|
|
||||||
private String targetFolderPath;
|
|
||||||
|
|
||||||
private RenditionDefinition def;
|
|
||||||
|
|
||||||
private static final String MIMETYPE_DOC = "application/msword";
|
|
||||||
private static final String MIMETYPE_DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void before() throws Exception
|
|
||||||
{
|
|
||||||
super.before();
|
|
||||||
this.nodeService = (NodeService) this.applicationContext.getBean("NodeService");
|
|
||||||
this.contentService = (ContentService) this.applicationContext.getBean("ContentService");
|
|
||||||
this.renditionService = (RenditionService) this.applicationContext.getBean("RenditionService");
|
|
||||||
this.repositoryHelper = (Repository) this.applicationContext.getBean("repositoryHelper");
|
|
||||||
this.dictionaryService = (DictionaryService) this.applicationContext.getBean("dictionaryService");
|
|
||||||
this.companyHome = repositoryHelper.getCompanyHome();
|
|
||||||
|
|
||||||
createTargetFolder();
|
|
||||||
|
|
||||||
// Setup the basic rendition definition
|
|
||||||
QName renditionName = QName.createQName("Test");
|
|
||||||
RenditionDefinition rd = renditionService.loadRenditionDefinition(renditionName);
|
|
||||||
if(rd != null)
|
|
||||||
{
|
|
||||||
RenditionDefinitionPersisterImpl rdp = new RenditionDefinitionPersisterImpl();
|
|
||||||
rdp.setNodeService(nodeService);
|
|
||||||
rdp.deleteRenditionDefinition(rd);
|
|
||||||
}
|
|
||||||
def = renditionService.createRenditionDefinition(renditionName, HTMLRenderingEngine.NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void after() throws Exception
|
|
||||||
{
|
|
||||||
super.after();
|
|
||||||
|
|
||||||
tidyUpSourceDoc();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createTargetFolder()
|
|
||||||
{
|
|
||||||
// Set the current security context as admin
|
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
|
||||||
|
|
||||||
Map<QName,Serializable> properties = new HashMap<QName,Serializable>();
|
|
||||||
properties.put(ContentModel.PROP_NAME, "TestFolder");
|
|
||||||
targetFolder = nodeService.createNode(
|
|
||||||
companyHome, ContentModel.ASSOC_CONTAINS,
|
|
||||||
QName.createQName("TestFolder"),
|
|
||||||
ContentModel.TYPE_FOLDER,
|
|
||||||
properties
|
|
||||||
).getChildRef();
|
|
||||||
|
|
||||||
targetFolderPath = "/" +
|
|
||||||
(String) nodeService.getProperty(companyHome, ContentModel.PROP_NAME) +
|
|
||||||
"/" +
|
|
||||||
(String) nodeService.getProperty(targetFolder, ContentModel.PROP_NAME)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
private void tidyUpSourceDoc()
|
|
||||||
{
|
|
||||||
// Set the current security context as admin
|
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
|
||||||
|
|
||||||
// Clean up the source
|
|
||||||
if(sourceDoc != null)
|
|
||||||
{
|
|
||||||
nodeService.deleteNode(sourceDoc);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clean up the target folder
|
|
||||||
nodeService.deleteNode(targetFolder);
|
|
||||||
targetFolder = null;
|
|
||||||
|
|
||||||
// All done
|
|
||||||
sourceDoc = null;
|
|
||||||
createTargetFolder();
|
|
||||||
}
|
|
||||||
|
|
||||||
private NodeRef createForDoc(String docname) throws IOException
|
|
||||||
{
|
|
||||||
// Create the node
|
|
||||||
Map<QName,Serializable> properties = new HashMap<QName,Serializable>();
|
|
||||||
properties.put(ContentModel.PROP_NAME, docname);
|
|
||||||
|
|
||||||
NodeRef node = nodeService.createNode(
|
|
||||||
companyHome, ContentModel.ASSOC_CONTAINS,
|
|
||||||
QName.createQName(docname),
|
|
||||||
ContentModel.TYPE_CONTENT,
|
|
||||||
properties
|
|
||||||
).getChildRef();
|
|
||||||
|
|
||||||
// Put the sample doc into it
|
|
||||||
File f = AbstractContentTransformerTest.loadNamedQuickTestFile(docname);
|
|
||||||
if(f == null) {
|
|
||||||
fail("Unable to find test file for " + docname);
|
|
||||||
}
|
|
||||||
|
|
||||||
ContentWriter writer = contentService.getWriter(
|
|
||||||
node, ContentModel.PROP_CONTENT, true
|
|
||||||
);
|
|
||||||
if(docname.endsWith(".doc")) {
|
|
||||||
writer.setMimetype(MIMETYPE_DOC);
|
|
||||||
}
|
|
||||||
if(docname.endsWith(".docx")) {
|
|
||||||
writer.setMimetype(MIMETYPE_DOCX);
|
|
||||||
}
|
|
||||||
writer.putContent(f);
|
|
||||||
|
|
||||||
if (log.isDebugEnabled())
|
|
||||||
{
|
|
||||||
log.debug("Created document with name: " + docname + ", nodeRef: " + node + ", mimetype: " + writer.getMimetype());
|
|
||||||
}
|
|
||||||
|
|
||||||
// All done
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBasics() throws Exception
|
|
||||||
{
|
|
||||||
def.setParameterValue(
|
|
||||||
RenditionService.PARAM_DESTINATION_PATH_TEMPLATE,
|
|
||||||
targetFolderPath + "/${name}.html"
|
|
||||||
);
|
|
||||||
|
|
||||||
sourceDoc = createForDoc("quick.doc");
|
|
||||||
|
|
||||||
ChildAssociationRef rendition = renditionService.render(sourceDoc, def);
|
|
||||||
assertNotNull(rendition);
|
|
||||||
|
|
||||||
// Check it was created
|
|
||||||
NodeRef htmlNode = rendition.getChildRef();
|
|
||||||
assertEquals(true, nodeService.exists(htmlNode));
|
|
||||||
|
|
||||||
// Check it got the right name
|
|
||||||
assertEquals(
|
|
||||||
"quick.html",
|
|
||||||
nodeService.getProperty(htmlNode, ContentModel.PROP_NAME)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check it got the right contents
|
|
||||||
ContentReader reader = contentService.getReader(
|
|
||||||
htmlNode, ContentModel.PROP_CONTENT
|
|
||||||
);
|
|
||||||
String html = reader.getContentString();
|
|
||||||
assertEquals("<?xml", html.substring(0, 5));
|
|
||||||
assertTrue("HTML wrong:\n"+html, html.contains("<html"));
|
|
||||||
assertTrue("HTML wrong:\n"+html, html.contains("<head>"));
|
|
||||||
assertTrue("HTML wrong:\n"+html, html.contains("<body>"));
|
|
||||||
|
|
||||||
assertTrue("HTML wrong:\n"+html, html.contains("<p>The quick brown fox"));
|
|
||||||
|
|
||||||
|
|
||||||
// Now do a body-only one, check that we still got the
|
|
||||||
// contents, but not the html surround
|
|
||||||
def.setParameterValue(
|
|
||||||
HTMLRenderingEngine.PARAM_BODY_CONTENTS_ONLY, Boolean.TRUE
|
|
||||||
);
|
|
||||||
rendition = renditionService.render(sourceDoc, def);
|
|
||||||
assertNotNull(rendition);
|
|
||||||
|
|
||||||
htmlNode = rendition.getChildRef();
|
|
||||||
assertEquals(true, nodeService.exists(htmlNode));
|
|
||||||
|
|
||||||
reader = contentService.getReader(
|
|
||||||
htmlNode, ContentModel.PROP_CONTENT
|
|
||||||
);
|
|
||||||
html = reader.getContentString();
|
|
||||||
assertFalse("Body wrong:\n"+html, html.contains("<?xml"));
|
|
||||||
assertFalse("Body wrong:\n"+html, html.contains("<html"));
|
|
||||||
assertFalse("Body wrong:\n"+html, html.contains("<head>"));
|
|
||||||
assertFalse("Body wrong:\n"+html, html.contains("<body>"));
|
|
||||||
|
|
||||||
assertTrue("HTML wrong:\n"+html, html.contains("<p>The quick brown fox"));
|
|
||||||
assertTrue("HTML wrong:\n"+html, html.contains("</p>"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for a .doc and a .docx, neither of which have images
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testDocWithoutImages() throws Exception
|
|
||||||
{
|
|
||||||
def.setParameterValue(
|
|
||||||
RenditionService.PARAM_DESTINATION_PATH_TEMPLATE,
|
|
||||||
targetFolderPath + "/${name}.html"
|
|
||||||
);
|
|
||||||
|
|
||||||
for(String name : new String[] {"quick.doc","quick.docx"})
|
|
||||||
{
|
|
||||||
sourceDoc = createForDoc(name);
|
|
||||||
|
|
||||||
int numItemsStart = nodeService.getChildAssocs(targetFolder).size();
|
|
||||||
|
|
||||||
ChildAssociationRef rendition = renditionService.render(sourceDoc, def);
|
|
||||||
assertNotNull(rendition);
|
|
||||||
|
|
||||||
// Check it was created
|
|
||||||
NodeRef htmlNode = rendition.getChildRef();
|
|
||||||
assertEquals(true, nodeService.exists(htmlNode));
|
|
||||||
|
|
||||||
// Check it got the right name
|
|
||||||
assertEquals(
|
|
||||||
name.substring(0, name.lastIndexOf('.')) + ".html",
|
|
||||||
nodeService.getProperty(htmlNode, ContentModel.PROP_NAME)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check it ended up in the right place
|
|
||||||
assertEquals(
|
|
||||||
"Should have been in " + targetFolderPath + " but was in" +
|
|
||||||
nodeService.getPath(htmlNode),
|
|
||||||
targetFolder,
|
|
||||||
nodeService.getPrimaryParent(htmlNode).getParentRef()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check it got the right contents
|
|
||||||
ContentReader reader = contentService.getReader(
|
|
||||||
htmlNode, ContentModel.PROP_CONTENT
|
|
||||||
);
|
|
||||||
String html = reader.getContentString();
|
|
||||||
assertEquals("<?xml", html.substring(0, 5));
|
|
||||||
|
|
||||||
// Check we didn't get an image folder, only the html
|
|
||||||
int numItems = nodeService.getChildAssocs(targetFolder).size();
|
|
||||||
assertEquals(numItemsStart+1, numItems);
|
|
||||||
|
|
||||||
// Check that the html lacks img tags
|
|
||||||
assertEquals(
|
|
||||||
"Unexpected img tag in html:\n" + html,
|
|
||||||
false, html.contains("<img")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check we didn't get any images
|
|
||||||
for(ChildAssociationRef ref : nodeService.getChildAssocs(htmlNode))
|
|
||||||
{
|
|
||||||
// TODO Check against composite content associations when present
|
|
||||||
// if(ref.getTypeQName().equals(HTMLRenderingEngine.PRIMARY_IMAGE))
|
|
||||||
// fail("Found unexpected primary image of rendered html");
|
|
||||||
// if(ref.getTypeQName().equals(HTMLRenderingEngine.SECONDARY_IMAGE))
|
|
||||||
// fail("Found unexpected secondary image of rendered html");
|
|
||||||
}
|
|
||||||
|
|
||||||
// All done
|
|
||||||
tidyUpSourceDoc();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for a .doc and a .docx, both of which have
|
|
||||||
* images in them
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testDocWithImages() throws Exception
|
|
||||||
{
|
|
||||||
def.setParameterValue(
|
|
||||||
RenditionService.PARAM_DESTINATION_PATH_TEMPLATE,
|
|
||||||
targetFolderPath + "/${name}.html"
|
|
||||||
);
|
|
||||||
|
|
||||||
String[] files = new String[] {"quickImg1.doc","quickImg1.docx", "quickImg3.doc","quickImg3.docx"};
|
|
||||||
int[] imgCounts = new int[] {1,1, 3,3};
|
|
||||||
|
|
||||||
for(int i=0; i<files.length; i++)
|
|
||||||
{
|
|
||||||
String name = files[i];
|
|
||||||
sourceDoc = createForDoc(name);
|
|
||||||
|
|
||||||
String baseName = name.substring(0, name.lastIndexOf('.'));
|
|
||||||
|
|
||||||
int numItemsStart = nodeService.getChildAssocs(targetFolder).size();
|
|
||||||
|
|
||||||
ChildAssociationRef rendition = renditionService.render(sourceDoc, def);
|
|
||||||
assertNotNull(rendition);
|
|
||||||
|
|
||||||
// Check it was created
|
|
||||||
NodeRef htmlNode = rendition.getChildRef();
|
|
||||||
assertEquals(true, nodeService.exists(htmlNode));
|
|
||||||
|
|
||||||
// Check it got the right name
|
|
||||||
assertEquals(
|
|
||||||
baseName + ".html",
|
|
||||||
nodeService.getProperty(htmlNode, ContentModel.PROP_NAME)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check it ended up in the right place
|
|
||||||
assertEquals(
|
|
||||||
"Should have been in " + targetFolderPath + " but was in" +
|
|
||||||
nodeService.getPath(htmlNode),
|
|
||||||
targetFolder,
|
|
||||||
nodeService.getPrimaryParent(htmlNode).getParentRef()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check it got the right contents
|
|
||||||
ContentReader reader = contentService.getReader(
|
|
||||||
htmlNode, ContentModel.PROP_CONTENT
|
|
||||||
);
|
|
||||||
String html = reader.getContentString();
|
|
||||||
assertEquals("<?xml", html.substring(0, 5));
|
|
||||||
|
|
||||||
// Check that the html has the img tags
|
|
||||||
assertEquals(
|
|
||||||
"Couldn't find img tag in html:\n" + html,
|
|
||||||
true, html.contains("<img")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check that it has the right img src
|
|
||||||
String expSource = "src=\""+ baseName + "_files" + "/image";
|
|
||||||
assertEquals(
|
|
||||||
"Couldn't find correct img src in html:\n" + expSource + "\n" + html,
|
|
||||||
true, html.contains(expSource)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check we got an image folder
|
|
||||||
int numItems = nodeService.getChildAssocs(targetFolder).size();
|
|
||||||
assertEquals(numItemsStart+2, numItems);
|
|
||||||
|
|
||||||
// Check the name of the image folder
|
|
||||||
NodeRef imgFolder = null;
|
|
||||||
for(ChildAssociationRef ref : nodeService.getChildAssocs(targetFolder)) {
|
|
||||||
if(nodeService.getProperty(ref.getChildRef(), ContentModel.PROP_NAME).equals(
|
|
||||||
baseName + "_files"
|
|
||||||
)) {
|
|
||||||
imgFolder = ref.getChildRef();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertNotNull("Couldn't find new folder named " + baseName + "_files", imgFolder);
|
|
||||||
|
|
||||||
// Check the contents
|
|
||||||
assertEquals(imgCounts[i], nodeService.getChildAssocs(imgFolder).size());
|
|
||||||
|
|
||||||
|
|
||||||
// TODO Check against composite content associations when present
|
|
||||||
// Check the associations if supported
|
|
||||||
// if(dictionaryService.getAssociation(HTMLRenderingEngine.PRIMARY_IMAGE) != null)
|
|
||||||
// {
|
|
||||||
// boolean hasPrimary = false;
|
|
||||||
// boolean hasSecondary = false;
|
|
||||||
// for(ChildAssociationRef ref : nodeService.getChildAssocs(htmlNode))
|
|
||||||
// {
|
|
||||||
// if(ref.getTypeQName().equals(HTMLRenderingEngine.PRIMARY_IMAGE))
|
|
||||||
// hasPrimary = true;
|
|
||||||
// if(ref.getTypeQName().equals(HTMLRenderingEngine.SECONDARY_IMAGE))
|
|
||||||
// hasSecondary = true;
|
|
||||||
// }
|
|
||||||
// assertEquals(true, hasPrimary);
|
|
||||||
// assertEquals(false, hasSecondary);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// All done
|
|
||||||
tidyUpSourceDoc();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for the option to have the images written to the
|
|
||||||
* same folder as the html, with a name prefix to them.
|
|
||||||
*
|
|
||||||
* TODO Re-enable when we've figured out why the rendition service sulkts
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testImagesSameFolder() throws Exception
|
|
||||||
{
|
|
||||||
def.setParameterValue(
|
|
||||||
RenditionService.PARAM_DESTINATION_PATH_TEMPLATE,
|
|
||||||
targetFolderPath + "/${name}.html"
|
|
||||||
);
|
|
||||||
def.setParameterValue(
|
|
||||||
HTMLRenderingEngine.PARAM_IMAGES_SAME_FOLDER,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
// The documents listed below have 3 embedded images each.
|
|
||||||
final int expectedImageCount = 3;
|
|
||||||
for(String name : new String[] {"quickImg3.doc","quickImg3.docx"})
|
|
||||||
{
|
|
||||||
sourceDoc = createForDoc(name);
|
|
||||||
String baseName = name.substring(0, name.lastIndexOf('.'));
|
|
||||||
|
|
||||||
int numItemsStart = nodeService.getChildAssocs(targetFolder).size();
|
|
||||||
if (log.isDebugEnabled())
|
|
||||||
{
|
|
||||||
log.debug("targetFolder " + targetFolder + " has " + numItemsStart + " children at start.");
|
|
||||||
}
|
|
||||||
|
|
||||||
ChildAssociationRef rendition = renditionService.render(sourceDoc, def);
|
|
||||||
assertNotNull(rendition);
|
|
||||||
|
|
||||||
// Check it was created
|
|
||||||
NodeRef htmlNode = rendition.getChildRef();
|
|
||||||
assertEquals(true, nodeService.exists(htmlNode));
|
|
||||||
|
|
||||||
// Check it got the right name
|
|
||||||
assertEquals(
|
|
||||||
baseName + ".html",
|
|
||||||
nodeService.getProperty(htmlNode, ContentModel.PROP_NAME)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check it ended up in the right place
|
|
||||||
assertEquals(
|
|
||||||
"Should have been in " + targetFolderPath + " but was in" +
|
|
||||||
nodeService.getPath(htmlNode),
|
|
||||||
targetFolder,
|
|
||||||
nodeService.getPrimaryParent(htmlNode).getParentRef()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check it got the right contents
|
|
||||||
ContentReader reader = contentService.getReader(
|
|
||||||
htmlNode, ContentModel.PROP_CONTENT
|
|
||||||
);
|
|
||||||
String html = reader.getContentString();
|
|
||||||
assertEquals("<?xml", html.substring(0, 5));
|
|
||||||
|
|
||||||
// Check that the html has the img tags
|
|
||||||
assertEquals(
|
|
||||||
"Couldn't find img tag in html:\n" + html,
|
|
||||||
true, html.contains("<img")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check that it has the right img src
|
|
||||||
String expSource = "src=\""+ baseName + "_image";
|
|
||||||
assertEquals(
|
|
||||||
"Couldn't find correct img src in html:\n" + expSource + "\n" + html,
|
|
||||||
true, html.contains(expSource)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check we got an image folder
|
|
||||||
int numItems = nodeService.getChildAssocs(targetFolder).size();
|
|
||||||
|
|
||||||
// We expect a number of images and one text/html node to be created.
|
|
||||||
final int additionalItems = expectedImageCount + 1;
|
|
||||||
assertEquals(numItemsStart+additionalItems, numItems);
|
|
||||||
|
|
||||||
// There shouldn't be an image folder created
|
|
||||||
for(ChildAssociationRef ref : nodeService.getChildAssocs(targetFolder)) {
|
|
||||||
if(nodeService.getProperty(ref.getChildRef(), ContentModel.PROP_NAME).equals(
|
|
||||||
baseName + "_files"
|
|
||||||
)) {
|
|
||||||
fail("Image folder was created but shouldn't be there");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check we got the images in the same directory as the html
|
|
||||||
int images = 0;
|
|
||||||
for(ChildAssociationRef ref : nodeService.getChildAssocs(targetFolder)) {
|
|
||||||
String childName = (String)nodeService.getProperty(ref.getChildRef(), ContentModel.PROP_NAME);
|
|
||||||
if(childName.startsWith(baseName + "_image")) {
|
|
||||||
images++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertEquals(expectedImageCount, images);
|
|
||||||
|
|
||||||
// Until the rendition service supports a forced overwrite of other renditions, we must
|
|
||||||
// delete the old rendition node & the images.
|
|
||||||
nodeService.deleteNode(rendition.getChildRef());
|
|
||||||
for (ChildAssociationRef chAssRef : nodeService.getChildAssocs(targetFolder))
|
|
||||||
{
|
|
||||||
nodeService.deleteNode(chAssRef.getChildRef());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,155 @@
|
|||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* Alfresco Repository
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||||
|
* %%
|
||||||
|
* This file is part of the Alfresco software.
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.search.impl.solr;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
import static org.mockito.MockitoAnnotations.openMocks;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
|
||||||
|
import org.alfresco.repo.search.QueryParserException;
|
||||||
|
import org.apache.commons.httpclient.Header;
|
||||||
|
import org.apache.commons.httpclient.HttpClient;
|
||||||
|
import org.apache.commons.httpclient.URI;
|
||||||
|
import org.apache.commons.httpclient.methods.PostMethod;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
|
||||||
|
/** Tests for the {@link AbstractSolrQueryHTTPClient}. */
|
||||||
|
public class AbstractSolrQueryHTTPClientTest
|
||||||
|
{
|
||||||
|
/** A URL for use in the tests. */
|
||||||
|
private static final String URL = "http://this/is/a/url";
|
||||||
|
|
||||||
|
/** The abstract class under test. */
|
||||||
|
private AbstractSolrQueryHTTPClient abstractSolrQueryHTTPClient = spy(AbstractSolrQueryHTTPClient.class);
|
||||||
|
@Mock
|
||||||
|
private HttpClient httpClient;
|
||||||
|
@Mock
|
||||||
|
private JSONObject body;
|
||||||
|
@Mock
|
||||||
|
private PostMethod postMethod;
|
||||||
|
@Mock
|
||||||
|
private Header header;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception
|
||||||
|
{
|
||||||
|
openMocks(this);
|
||||||
|
|
||||||
|
doReturn(postMethod).when(abstractSolrQueryHTTPClient).createNewPostMethod(URL);
|
||||||
|
when(postMethod.getResponseCharSet()).thenReturn("UTF-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Check postQuery works as expected for the success case. */
|
||||||
|
@Test
|
||||||
|
public void testPostQuery_success() throws Exception
|
||||||
|
{
|
||||||
|
when(body.toString()).thenReturn("Example body");
|
||||||
|
when(postMethod.getStatusCode()).thenReturn(HttpServletResponse.SC_OK);
|
||||||
|
when(postMethod.getResponseBodyAsStream()).thenReturn(convertStringToInputStream("{}"));
|
||||||
|
|
||||||
|
JSONObject response = abstractSolrQueryHTTPClient.postQuery(httpClient, URL, body);
|
||||||
|
|
||||||
|
assertEquals("Unexpected JSON response received.", "{}", response.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Check that the status code is usually passed through from Solr. */
|
||||||
|
@Test
|
||||||
|
public void testPostQuery_failure() throws Exception
|
||||||
|
{
|
||||||
|
String failureMessage = "{\"error\": {\"trace\": \"ExceptionClass: Stacktrace\"}}";
|
||||||
|
|
||||||
|
when(body.toString()).thenReturn("Example body");
|
||||||
|
when(postMethod.getStatusCode()).thenReturn(HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
when(postMethod.getResponseBodyAsStream()).thenReturn(convertStringToInputStream(failureMessage));
|
||||||
|
when(postMethod.getResponseBodyAsString()).thenReturn(failureMessage);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
abstractSolrQueryHTTPClient.postQuery(httpClient, URL, body);
|
||||||
|
fail("Expected a QueryParserException to be thrown.");
|
||||||
|
}
|
||||||
|
catch (QueryParserException e)
|
||||||
|
{
|
||||||
|
assertEquals("Unexpected status code in exception.", e.getHttpStatusCode(), HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
verify(postMethod).releaseConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Check that the status code is replaced with "Not Implemented" for an unsupported query option. */
|
||||||
|
@Test
|
||||||
|
public void testPostQuery_unsupportedOperation() throws Exception
|
||||||
|
{
|
||||||
|
String failureMessage = "{\"error\": {\"trace\": \"java.lang.UnsupportedOperationException: Stacktrace\"}}";
|
||||||
|
|
||||||
|
when(body.toString()).thenReturn("Example body");
|
||||||
|
when(postMethod.getStatusCode()).thenReturn(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||||
|
when(postMethod.getResponseBodyAsStream()).thenReturn(convertStringToInputStream(failureMessage));
|
||||||
|
when(postMethod.getResponseBodyAsString()).thenReturn(failureMessage);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
abstractSolrQueryHTTPClient.postQuery(httpClient, URL, body);
|
||||||
|
fail("Expected a QueryParserException to be thrown.");
|
||||||
|
}
|
||||||
|
catch (QueryParserException e)
|
||||||
|
{
|
||||||
|
assertEquals("Unexpected status code in exception.", e.getHttpStatusCode(), HttpServletResponse.SC_NOT_IMPLEMENTED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Check that a redirect can be followed if the endpoint reports that it's moved. */
|
||||||
|
@Test
|
||||||
|
public void testPostQuery_moved() throws Exception
|
||||||
|
{
|
||||||
|
when(body.toString()).thenReturn("Example body");
|
||||||
|
// Report "moved" for the first invocation and then OK for subsequent requests.
|
||||||
|
when(postMethod.getStatusCode()).thenReturn(HttpServletResponse.SC_MOVED_PERMANENTLY).thenReturn(HttpServletResponse.SC_OK);
|
||||||
|
when(postMethod.getResponseBodyAsStream()).thenReturn(convertStringToInputStream("{}"));
|
||||||
|
when(postMethod.getResponseHeader("location")).thenReturn(header);
|
||||||
|
when(header.getValue()).thenReturn("http://new/URL");
|
||||||
|
|
||||||
|
JSONObject response = abstractSolrQueryHTTPClient.postQuery(httpClient, URL, body);
|
||||||
|
|
||||||
|
verify(postMethod).setURI(new URI("http://new/URL", true));
|
||||||
|
assertEquals("Unexpected JSON response received.", "{}", response.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Create an input stream containing the given string. */
|
||||||
|
private ByteArrayInputStream convertStringToInputStream(String message)
|
||||||
|
{
|
||||||
|
return new ByteArrayInputStream(message.getBytes());
|
||||||
|
}
|
||||||
|
}
|
@@ -25,9 +25,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.usage;
|
package org.alfresco.repo.usage;
|
||||||
|
|
||||||
import javax.transaction.UserTransaction;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import javax.transaction.UserTransaction;
|
||||||
|
|
||||||
import org.alfresco.repo.lock.JobLockService;
|
import org.alfresco.repo.lock.JobLockService;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
@@ -37,6 +37,7 @@ import org.alfresco.service.cmr.admin.RepoUsage;
|
|||||||
import org.alfresco.service.cmr.admin.RepoUsage.LicenseMode;
|
import org.alfresco.service.cmr.admin.RepoUsage.LicenseMode;
|
||||||
import org.alfresco.service.cmr.admin.RepoUsage.UsageType;
|
import org.alfresco.service.cmr.admin.RepoUsage.UsageType;
|
||||||
import org.alfresco.service.cmr.admin.RepoUsageStatus;
|
import org.alfresco.service.cmr.admin.RepoUsageStatus;
|
||||||
|
import org.alfresco.service.cmr.admin.RepoUsageStatus.RepoUsageLevel;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
@@ -48,6 +49,8 @@ import org.junit.experimental.categories.Category;
|
|||||||
import org.junit.runners.MethodSorters;
|
import org.junit.runners.MethodSorters;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link RepoUsageComponent}
|
* Tests {@link RepoUsageComponent}
|
||||||
*
|
*
|
||||||
@@ -236,6 +239,123 @@ public class RepoUsageComponentTest extends TestCase
|
|||||||
RepoUsage usage = getUsage();
|
RepoUsage usage = getUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testLicenceHoursBeforeExpiration() throws Exception
|
||||||
|
{
|
||||||
|
// Update usage
|
||||||
|
updateUsage(UsageType.USAGE_ALL);
|
||||||
|
|
||||||
|
// Set the restrictions for license to expire in 6 hours
|
||||||
|
RepoUsage restrictions = new RepoUsage(
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
5000L,
|
||||||
|
100000L,
|
||||||
|
LicenseMode.TEAM,
|
||||||
|
System.currentTimeMillis() + TimeUnit.HOURS.toMillis(6),
|
||||||
|
false);
|
||||||
|
repoUsageComponent.setRestrictions(restrictions);
|
||||||
|
|
||||||
|
// Update use
|
||||||
|
updateUsage(UsageType.USAGE_ALL);
|
||||||
|
|
||||||
|
// Get the usage
|
||||||
|
RepoUsage usage = getUsage();
|
||||||
|
|
||||||
|
// Check
|
||||||
|
assertFalse("Usage is in read-only mode",usage.isReadOnly());
|
||||||
|
assertTrue("System is in read-only mode",transactionService.getAllowWrite());
|
||||||
|
|
||||||
|
RepoUsageStatus status = repoUsageComponent.getUsageStatus();
|
||||||
|
assertEquals("System is not at Warning All Level",status.getLevel(),RepoUsageLevel.WARN_ALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testLicenceMinutesAfterExpiration() throws Exception
|
||||||
|
{
|
||||||
|
// Update usage
|
||||||
|
updateUsage(UsageType.USAGE_ALL);
|
||||||
|
|
||||||
|
// Set the restrictions for license to expire in 6 hours
|
||||||
|
RepoUsage restrictions = new RepoUsage(
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
5000L,
|
||||||
|
100000L,
|
||||||
|
LicenseMode.TEAM,
|
||||||
|
System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(1),
|
||||||
|
false);
|
||||||
|
repoUsageComponent.setRestrictions(restrictions);
|
||||||
|
|
||||||
|
// Update use
|
||||||
|
updateUsage(UsageType.USAGE_ALL);
|
||||||
|
|
||||||
|
// Get the usage
|
||||||
|
RepoUsage usage = getUsage();
|
||||||
|
|
||||||
|
// Check we are in read-only mode
|
||||||
|
assertTrue("Usage is not in read-only mode",usage.isReadOnly());
|
||||||
|
assertFalse("System is not in read-only mode",transactionService.getAllowWrite());
|
||||||
|
|
||||||
|
RepoUsageStatus status = repoUsageComponent.getUsageStatus();
|
||||||
|
assertEquals("System is not at Locked Level",status.getLevel(),RepoUsageLevel.LOCKED_DOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void testLicenceMonthsBeforeExpiration() throws Exception
|
||||||
|
{
|
||||||
|
// Update usage
|
||||||
|
updateUsage(UsageType.USAGE_ALL);
|
||||||
|
|
||||||
|
// Set the restrictions for license to expire in 60 days from now
|
||||||
|
RepoUsage restrictions = new RepoUsage(
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
5000L,
|
||||||
|
100000L,
|
||||||
|
LicenseMode.TEAM,
|
||||||
|
System.currentTimeMillis() + TimeUnit.DAYS.toMillis(60),
|
||||||
|
false);
|
||||||
|
repoUsageComponent.setRestrictions(restrictions);
|
||||||
|
|
||||||
|
// Update use
|
||||||
|
updateUsage(UsageType.USAGE_ALL);
|
||||||
|
|
||||||
|
// Get the usage
|
||||||
|
RepoUsage usage = getUsage();
|
||||||
|
|
||||||
|
// Check
|
||||||
|
assertFalse("Usage is in read-only mode",usage.isReadOnly());
|
||||||
|
assertTrue("System is in read-only mode",transactionService.getAllowWrite());
|
||||||
|
|
||||||
|
RepoUsageStatus status = repoUsageComponent.getUsageStatus();
|
||||||
|
assertEquals("System is not at OK Level",status.getLevel(),RepoUsageLevel.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testLicenceDaysAfterExpiration() throws Exception
|
||||||
|
{
|
||||||
|
// Update usage
|
||||||
|
updateUsage(UsageType.USAGE_ALL);
|
||||||
|
|
||||||
|
// Set the restrictions for license expired 5 days ago
|
||||||
|
RepoUsage restrictions = new RepoUsage(
|
||||||
|
System.currentTimeMillis(),
|
||||||
|
5000L,
|
||||||
|
100000L,
|
||||||
|
LicenseMode.TEAM,
|
||||||
|
System.currentTimeMillis() - TimeUnit.DAYS.toMillis(5),
|
||||||
|
false);
|
||||||
|
repoUsageComponent.setRestrictions(restrictions);
|
||||||
|
|
||||||
|
// Update use
|
||||||
|
updateUsage(UsageType.USAGE_ALL);
|
||||||
|
|
||||||
|
// Get the usage
|
||||||
|
RepoUsage usage = getUsage();
|
||||||
|
|
||||||
|
// Check we are in read-only mode
|
||||||
|
assertTrue("Usage is not in read-only mode",usage.isReadOnly());
|
||||||
|
assertFalse("System is not in read-only mode",transactionService.getAllowWrite());
|
||||||
|
|
||||||
|
RepoUsageStatus status = repoUsageComponent.getUsageStatus();
|
||||||
|
assertEquals("System is not at Locked Level",status.getLevel(),RepoUsageLevel.LOCKED_DOWN);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that concurrent updates are prevented
|
* Check that concurrent updates are prevented
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user