mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-17 14:21:39 +00:00
Compare commits
69 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
682917b948 | ||
|
5e38be6f7d | ||
|
ef441fc2c8 | ||
|
b9e4557973 | ||
|
5d67d39323 | ||
|
b32e3fc0b3 | ||
|
20dd0efc6f | ||
|
2a8811a109 | ||
|
14902b536a | ||
|
046116ddf0 | ||
|
0ca611dcfd | ||
|
d9daeae665 | ||
|
65675b9a1d | ||
|
dd93088c72 | ||
|
968cae0ee7 | ||
|
c28950843a | ||
|
28f1429a13 | ||
|
9bd54efc10 | ||
|
3c81ec949e | ||
|
53704a2c58 | ||
|
b4455f7d60 | ||
|
0617fbb0bf | ||
|
f748334f1e | ||
|
08748e8af5 | ||
|
ce62fb1da3 | ||
|
34f360211f | ||
|
b559e78827 | ||
|
1add8a0f08 | ||
|
5eb8767f4c | ||
|
7fb3386413 | ||
|
22945a30ea | ||
|
fc531f64ed | ||
|
98090ac48c | ||
|
33b64f483d | ||
|
5e2d939f4e | ||
|
26dbcd3e79 | ||
|
8ec9fa5f5e | ||
|
578becd586 | ||
|
1f6774f2ef | ||
|
9ff5f3b843 | ||
|
9e3bb59067 | ||
|
db47063830 | ||
|
562479bde4 | ||
|
e738e0a0fb | ||
|
eb703c19aa | ||
|
b772205539 | ||
|
b9c6b59129 | ||
|
cf7ce72209 | ||
|
7a58014c32 | ||
|
e964aab211 | ||
|
2d3cac3c27 | ||
|
3a495f7b3f | ||
|
949e257f19 | ||
|
dfb34140ac | ||
|
c1f78b1a17 | ||
|
8b70483aa0 | ||
|
3ebeac2eb4 | ||
|
d91a552925 | ||
|
8c91145b39 | ||
|
86fcf67016 | ||
|
48c85ec24f | ||
|
f446031069 | ||
|
a9dabb0e99 | ||
|
bdc95019ae | ||
|
ace87c9c3b | ||
|
af8b556bf8 | ||
|
5990fadb3b | ||
|
08b62afb10 | ||
|
d4bae73b86 |
@@ -25,10 +25,6 @@
|
||||
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<properties>
|
||||
<!-- WhiteSource token -->
|
||||
<org.whitesource.orgToken>${env.WHITESOURCE_API_KEY}</org.whitesource.orgToken>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
|
23
.travis.yml
23
.travis.yml
@@ -54,7 +54,7 @@ jobs:
|
||||
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 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.4.0
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
||||
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"
|
||||
@@ -67,14 +67,14 @@ jobs:
|
||||
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 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.4.0
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
||||
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"
|
||||
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 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.4.0
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
||||
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"
|
||||
@@ -91,21 +91,21 @@ jobs:
|
||||
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 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.4.0
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
||||
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"
|
||||
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 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.4.0
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
||||
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"
|
||||
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 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.4.0
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
||||
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"
|
||||
@@ -177,6 +177,11 @@ jobs:
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=AllDBTestsTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
|
||||
|
||||
- name: "Repository - Messaging tests"
|
||||
before_script:
|
||||
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
|
||||
script: travis_wait 20 mvn -B test -pl repository -Dtest=CamelRoutesTest,CamelComponentsTest
|
||||
|
||||
- name: "Remote-api - AppContext01TestSuite"
|
||||
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'
|
||||
@@ -187,21 +192,21 @@ jobs:
|
||||
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 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.4.0
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
||||
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"
|
||||
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 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.4.0
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
||||
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"
|
||||
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 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.4.0
|
||||
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.3.10
|
||||
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"
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>10.1</version>
|
||||
<version>11.9</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>10.1</version>
|
||||
<version>11.9</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
@@ -167,7 +167,7 @@
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.woodstox</groupId>
|
||||
<artifactId>woodstox-core</artifactId>
|
||||
<version>6.2.6</version>
|
||||
<version>6.2.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- the cxf libs were updated, see dependencyManagement section -->
|
||||
@@ -283,31 +283,6 @@
|
||||
<groupId>com.sun.activation</groupId>
|
||||
<artifactId>javax.activation</artifactId>
|
||||
</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>
|
||||
</dependency>
|
||||
|
||||
|
@@ -60,15 +60,12 @@ public abstract class ConfigScheduler<Data>
|
||||
// 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
|
||||
// production but not very likely.
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException
|
||||
public synchronized void execute(JobExecutionContext context) throws JobExecutionException
|
||||
{
|
||||
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
|
||||
ConfigScheduler configScheduler = (ConfigScheduler)dataMap.get(CONFIG_SCHEDULER);
|
||||
synchronized (configScheduler)
|
||||
{
|
||||
boolean successReadingConfig = configScheduler.readConfigAndReplace(true);
|
||||
configScheduler.changeScheduleOnStateChange(successReadingConfig);
|
||||
}
|
||||
boolean successReadingConfig = configScheduler.readConfigAndReplace(true);
|
||||
configScheduler.changeScheduleOnStateChange(successReadingConfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,6 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>10.1</version>
|
||||
<version>11.9</version>
|
||||
</parent>
|
||||
</project>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# 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
|
||||
FROM alfresco/alfresco-base-tomcat:9.0.45-java-11-centos-8
|
||||
FROM alfresco/alfresco-base-tomcat:9.0.41-java-11-openjdk-centos-8
|
||||
|
||||
# Set default docker_context.
|
||||
ARG resource_path=target
|
||||
@@ -66,11 +66,11 @@ RUN sed -i -e "s_log4j.appender.File.File\=alfresco.log_log4j.appender.File.File
|
||||
# fontconfig is required by Activiti worflow diagram generator
|
||||
# installing pinned dependencies as well
|
||||
RUN yum install -y fontconfig-2.13.1-3.el8 \
|
||||
dejavu-fonts-common-2.35-7.el8 \
|
||||
dejavu-fonts-common-2.35-6.el8 \
|
||||
fontpackages-filesystem-1.44-22.el8 \
|
||||
freetype-2.9.1-4.el8_3.1 \
|
||||
libpng-1.6.34-5.el8 \
|
||||
dejavu-sans-fonts-2.35-7.el8 && \
|
||||
dejavu-sans-fonts-2.35-6.el8 && \
|
||||
yum clean all
|
||||
|
||||
# The standard configuration is to have all Tomcat files owned by root with group GROUPNAME and whilst owner has read/write privileges,
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>10.1</version>
|
||||
<version>11.9</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>10.1</version>
|
||||
<version>11.9</version>
|
||||
</parent>
|
||||
|
||||
<profiles>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
TRANSFORMERS_TAG=2.4.0
|
||||
SOLR6_TAG=2.0.2-RC2
|
||||
TRANSFORMERS_TAG=2.3.10
|
||||
SOLR6_TAG=2.0.1
|
||||
POSTGRES_TAG=13.1
|
||||
ACTIVEMQ_TAG=5.16.1
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>10.1</version>
|
||||
<version>11.9</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>10.1</version>
|
||||
<version>11.9</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>10.1</version>
|
||||
<version>11.9</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>10.1</version>
|
||||
<version>11.9</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>10.1</version>
|
||||
<version>11.9</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2017 Alfresco Software Limited.
|
||||
* This file is part of Alfresco
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.renditions;
|
||||
/**
|
||||
* Handles tests related to api-explorer/#!/versions/createVersionRendition
|
||||
*/
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.core.RestResponse;
|
||||
import org.alfresco.rest.model.RestRenditionInfoModel;
|
||||
import org.alfresco.rest.model.RestRenditionInfoModelCollection;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
@Test(groups = { TestGroup.RENDITIONS }) public class RenditionVersionTests extends RestTest
|
||||
{
|
||||
private UserModel user;
|
||||
private SiteModel site;
|
||||
private FileModel file;
|
||||
|
||||
@BeforeClass(alwaysRun = true) public void dataPreparation() throws Exception
|
||||
{
|
||||
user = dataUser.createRandomTestUser();
|
||||
site = dataSite.usingUser(user).createPublicRandomSite();
|
||||
file = dataContent.usingUser(user).usingSite(site).createContent(DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanity test for the following endpoints:
|
||||
* POST /nodes/{nodeId}/versions/{versionId}/rendition
|
||||
* GET /nodes/{nodeId}/versions/{versionId}/renditions
|
||||
* GET /nodes/{nodeId}/versions/{versionId}/renditions/{renditionId}
|
||||
* GET /nodes/{nodeId}/versions/{versionId}/renditions/{renditionId}/content
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.RENDITIONS, TestGroup.SANITY }) @TestRail(section = {
|
||||
TestGroup.REST_API,
|
||||
TestGroup.RENDITIONS }, executionType = ExecutionType.SANITY, description = "Verify that the rendition can be created using POST /nodes/{nodeId}/versions/{versionId}/rendition") public void testRenditionForNodeVersions()
|
||||
throws Exception
|
||||
{
|
||||
File sampleFile = Utility.getResourceTestDataFile("sampleContent.txt");
|
||||
|
||||
STEP("1. Update the node content in order to increase version, PUT /nodes/{nodeId}/content.");
|
||||
// version update
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(file).updateNodeContent(sampleFile);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
STEP("2. Create the pdf rendition of txt file using RESTAPI");
|
||||
restClient.withCoreAPI().usingNode(file).createNodeVersionRendition("pdf", "1.1");
|
||||
restClient.assertStatusCodeIs(HttpStatus.ACCEPTED);
|
||||
|
||||
STEP("3. Verify pdf rendition of txt file is created");
|
||||
restClient.withCoreAPI().usingNode(file).getNodeVersionRenditionUntilIsCreated("pdf", "1.1").assertThat()
|
||||
.field("status").is("CREATED");
|
||||
|
||||
STEP("4. Verify pdf rendition of txt file is listed");
|
||||
RestRenditionInfoModelCollection renditionInfoModelCollection = restClient.withCoreAPI().usingNode(file)
|
||||
.getNodeVersionRenditionsInfo("1.1");
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
for (RestRenditionInfoModel restRenditionInfoModel : renditionInfoModelCollection.getEntries())
|
||||
{
|
||||
RestRenditionInfoModel renditionInfo = restRenditionInfoModel.onModel();
|
||||
String renditionId = renditionInfo.getId();
|
||||
if (renditionId == "pdf")
|
||||
{
|
||||
renditionInfo.assertThat().field("status").is("CREATED");
|
||||
}
|
||||
}
|
||||
|
||||
STEP("5. Verify pdf rendition of txt file has content");
|
||||
RestResponse restResponse = restClient.withCoreAPI().usingNode(file)
|
||||
.getNodeVersionRenditionContentUntilIsCreated("pdf", "1.1");
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restClient.assertHeaderValueContains("Content-Type", "application/pdf;charset=UTF-8");
|
||||
Assert.assertTrue(restResponse.getResponse().body().asInputStream().available() > 0);
|
||||
}
|
||||
|
||||
}
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>10.1</version>
|
||||
<version>11.9</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>10.1</version>
|
||||
<version>11.9</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -57,8 +57,8 @@ ModuleDetails shareServicesModule = moduleService.getModule("alfresco-share-serv
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Alfresco</title>
|
||||
<link rel="stylesheet" type="text/css" href="/<%=sysAdminParams.getAlfrescoContext()%>/css/reset.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/<%=sysAdminParams.getAlfrescoContext()%>/css/alfresco.css" />
|
||||
<link rel="stylesheet" type="text/css" href="./css/reset.css" />
|
||||
<link rel="stylesheet" type="text/css" href="./css/alfresco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="sticky-wrapper">
|
||||
|
@@ -4,21 +4,21 @@
|
||||
%%
|
||||
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
|
||||
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%
|
||||
@@ -57,19 +57,19 @@ ModuleDetails shareServicesModule = moduleService.getModule("alfresco-share-serv
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Alfresco</title>
|
||||
<link rel="stylesheet" type="text/css" href="/<%=sysAdminParams.getAlfrescoContext()%>/css/reset.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/<%=sysAdminParams.getAlfrescoContext()%>/css/alfresco.css" />
|
||||
<link rel="stylesheet" type="text/css" href="./css/reset.css" />
|
||||
<link rel="stylesheet" type="text/css" href="./css/alfresco.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="sticky-wrapper">
|
||||
<div class="index">
|
||||
|
||||
|
||||
<div class="title">
|
||||
<span class="logo"><a href="http://www.alfresco.com"><img src="./images/logo/logo.png" width="145" height="48" alt="" border="0" /></a></span>
|
||||
<span class="logo-separator"> </span>
|
||||
<h1>Welcome to Alfresco</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="index-list">
|
||||
<h4><%=descriptorService.getServerDescriptor().getEdition()%> - <%=descriptorService.getServerDescriptor().getVersion()%></h4>
|
||||
<p></p>
|
||||
@@ -94,7 +94,7 @@ ModuleDetails shareServicesModule = moduleService.getModule("alfresco-share-serv
|
||||
{
|
||||
%>
|
||||
<p>WARNING: The system is in Read Only mode, the License may have failed to deploy. Please visit the <a href="./s/enterprise/admin">Alfresco Administration Console</a> (admin only)</p>
|
||||
<%
|
||||
<%
|
||||
}
|
||||
if (descriptorService.getLicenseDescriptor() != null && descriptorService.getLicenseDescriptor().getLicenseMode().toString().equals("ENTERPRISE"))
|
||||
{
|
||||
@@ -120,7 +120,7 @@ ModuleDetails shareServicesModule = moduleService.getModule("alfresco-share-serv
|
||||
<p><a href="./api/-default-/public/cmis/versions/1.1/atom">CMIS 1.1 AtomPub Service Document</a></p>
|
||||
<p><a href="./api/-default-/public/cmis/versions/1.1/browser">CMIS 1.1 Browser Binding URL</a></p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="push"></div>
|
||||
</div>
|
||||
|
59
pom.xml
59
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>10.1</version>
|
||||
<version>11.9</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Alfresco Community Repo Parent</name>
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
<properties>
|
||||
<acs.version.major>7</acs.version.major>
|
||||
<acs.version.minor>0</acs.version.minor>
|
||||
<acs.version.revision>1</acs.version.revision>
|
||||
<acs.version.minor>1</acs.version.minor>
|
||||
<acs.version.revision>0</acs.version.revision>
|
||||
<acs.version.label />
|
||||
|
||||
<version.edition>Community</version.edition>
|
||||
@@ -34,15 +34,15 @@
|
||||
<image.registry>quay.io</image.registry>
|
||||
|
||||
<java.version>11</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<maven.build.sourceVersion>${java.version}</maven.build.sourceVersion>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.build.sourceVersion>11</maven.build.sourceVersion>
|
||||
|
||||
<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-mmt.version>6.0</dependency.alfresco-mmt.version>
|
||||
<dependency.alfresco-trashcan-cleaner.version>2.4.1</dependency.alfresco-trashcan-cleaner.version>
|
||||
<dependency.alfresco-trashcan-cleaner.version>2.3</dependency.alfresco-trashcan-cleaner.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-messaging-repo.version>1.2.15</dependency.alfresco-messaging-repo.version>
|
||||
@@ -55,12 +55,12 @@
|
||||
|
||||
<dependency.spring.version>5.3.3</dependency.spring.version>
|
||||
<dependency.antlr.version>3.5.2</dependency.antlr.version>
|
||||
<dependency.jackson.version>2.12.3</dependency.jackson.version>
|
||||
<dependency.jackson-databind.version>2.12.3</dependency.jackson-databind.version>
|
||||
<dependency.cxf.version>3.4.4</dependency.cxf.version>
|
||||
<dependency.jackson.version>2.12.2</dependency.jackson.version>
|
||||
<dependency.jackson-databind.version>${dependency.jackson.version}</dependency.jackson-databind.version>
|
||||
<dependency.cxf.version>3.4.3</dependency.cxf.version>
|
||||
<dependency.opencmis.version>1.0.0</dependency.opencmis.version>
|
||||
<dependency.webscripts.version>8.19</dependency.webscripts.version>
|
||||
<dependency.bouncycastle.version>1.69</dependency.bouncycastle.version>
|
||||
<dependency.webscripts.version>8.18</dependency.webscripts.version>
|
||||
<dependency.bouncycastle.version>1.68</dependency.bouncycastle.version>
|
||||
<dependency.mockito-core.version>3.9.0</dependency.mockito-core.version>
|
||||
<dependency.org-json.version>20210307</dependency.org-json.version>
|
||||
<dependency.commons-dbcp.version>1.4-DBCP330</dependency.commons-dbcp.version>
|
||||
@@ -74,17 +74,16 @@
|
||||
<dependency.gytheio.version>0.12</dependency.gytheio.version>
|
||||
<dependency.groovy.version>2.5.9</dependency.groovy.version>
|
||||
<dependency.tika.version>1.26</dependency.tika.version>
|
||||
<dependency.spring-security.version>5.5.0</dependency.spring-security.version>
|
||||
<dependency.spring-security.version>5.4.1</dependency.spring-security.version>
|
||||
<dependency.truezip.version>7.7.10</dependency.truezip.version>
|
||||
<dependency.poi.version>4.1.2</dependency.poi.version>
|
||||
<dependency.ooxml-schemas.version>1.4</dependency.ooxml-schemas.version>
|
||||
<dependency.keycloak.version>13.0.1</dependency.keycloak.version>
|
||||
<dependency.keycloak.version>11.0.0-alfresco-001</dependency.keycloak.version>
|
||||
<dependency.jboss.logging.version>3.4.1.Final</dependency.jboss.logging.version>
|
||||
<dependency.camel.version>3.7.4</dependency.camel.version>
|
||||
<dependency.camel.version>3.7.1</dependency.camel.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.awaitility.version>4.1.0</dependency.awaitility.version>
|
||||
<dependency.awaitility.version>4.0.3</dependency.awaitility.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>
|
||||
@@ -97,16 +96,16 @@
|
||||
<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>
|
||||
|
||||
<alfresco.googledrive.version>3.2.1.3</alfresco.googledrive.version>
|
||||
<alfresco.aos-module.version>1.4.0.1</alfresco.aos-module.version>
|
||||
<alfresco.googledrive.version>3.2.1</alfresco.googledrive.version>
|
||||
<alfresco.aos-module.version>1.4.0</alfresco.aos-module.version>
|
||||
|
||||
<dependency.postgresql.version>42.2.20</dependency.postgresql.version>
|
||||
<dependency.mysql.version>8.0.25</dependency.mysql.version>
|
||||
<dependency.postgresql.version>42.2.19</dependency.postgresql.version>
|
||||
<dependency.mysql.version>8.0.23</dependency.mysql.version>
|
||||
<dependency.mariadb.version>2.7.2</dependency.mariadb.version>
|
||||
<dependency.tas-utility.version>3.0.44</dependency.tas-utility.version>
|
||||
<dependency.rest-assured.version>3.3.0</dependency.rest-assured.version>
|
||||
<dependency.tas-restapi.version>1.58</dependency.tas-restapi.version>
|
||||
<dependency.tas-cmis.version>1.30</dependency.tas-cmis.version>
|
||||
<dependency.tas-restapi.version>1.57</dependency.tas-restapi.version>
|
||||
<dependency.tas-cmis.version>1.29</dependency.tas-cmis.version>
|
||||
<dependency.tas-email.version>1.8</dependency.tas-email.version>
|
||||
<dependency.tas-webdav.version>1.6</dependency.tas-webdav.version>
|
||||
<dependency.tas-ftp.version>1.5</dependency.tas-ftp.version>
|
||||
@@ -117,7 +116,7 @@
|
||||
<connection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</connection>
|
||||
<developerConnection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</developerConnection>
|
||||
<url>https://github.com/Alfresco/alfresco-community-repo</url>
|
||||
<tag>10.1</tag>
|
||||
<tag>11.9</tag>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
@@ -550,7 +549,8 @@
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>${dependency.bouncycastle.version}</version>
|
||||
<version>1.68</version>
|
||||
<!-- <version>${dependency.bouncycastle.version}</version>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
@@ -583,7 +583,7 @@
|
||||
<dependency>
|
||||
<groupId>com.drewnoakes</groupId>
|
||||
<artifactId>metadata-extractor</artifactId>
|
||||
<version>2.16.0</version>
|
||||
<version>2.15.0</version>
|
||||
</dependency>
|
||||
<!-- upgrade dependency from TIKA -->
|
||||
<dependency>
|
||||
@@ -601,7 +601,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<version>${dependency.apache-compress.version}</version>
|
||||
<version>1.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
@@ -694,7 +694,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.2</version>
|
||||
<version>4.13.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -814,7 +814,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.2.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -829,4 +829,5 @@
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>10.1</version>
|
||||
<version>11.9</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -716,7 +716,7 @@ public abstract class BaseSSOAuthenticationFilter extends BaseAuthenticationFilt
|
||||
}
|
||||
else
|
||||
{
|
||||
if((pathInfo.length() > 5 && !pathInfo.substring(0, 6).toLowerCase().equals("/cmis/")) && !pathInfo.equals("/discovery"))
|
||||
if(!pathInfo.substring(0, 6).toLowerCase().equals("/cmis/") && !pathInfo.equals("/discovery"))
|
||||
{
|
||||
// remove tenant
|
||||
int idx = pathInfo.indexOf('/', 1);
|
||||
|
@@ -41,11 +41,7 @@ public class DefaultExceptionResolver implements ExceptionResolver<Exception>
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -26,12 +26,10 @@
|
||||
package org.alfresco.rest.framework.tools;
|
||||
|
||||
import org.alfresco.metrics.rest.RestMetricsReporter;
|
||||
import org.alfresco.repo.search.QueryParserException;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.core.exceptions.DefaultExceptionResolver;
|
||||
import org.alfresco.rest.framework.core.exceptions.ErrorResponse;
|
||||
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.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -50,7 +48,6 @@ public class ApiAssistant {
|
||||
|
||||
private ExceptionResolver<Exception> defaultResolver = new DefaultExceptionResolver();
|
||||
private ExceptionResolver<WebScriptException> webScriptExceptionResolver;
|
||||
private ExceptionResolver<QueryParserException> queryParserExceptionResolver;
|
||||
private ExceptionResolver<Exception> resolver;
|
||||
private JacksonHelper jsonHelper;
|
||||
private RestMetricsReporter restMetricsReporter;
|
||||
@@ -80,10 +77,6 @@ public class ApiAssistant {
|
||||
{
|
||||
error = webScriptExceptionResolver.resolveException((WebScriptException) ex);
|
||||
}
|
||||
else if (ex instanceof QueryParserException)
|
||||
{
|
||||
error = queryParserExceptionResolver.resolveException((QueryParserException) ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
error = resolver.resolveException(ex);
|
||||
@@ -107,11 +100,6 @@ public class ApiAssistant {
|
||||
this.webScriptExceptionResolver = webScriptExceptionResolver;
|
||||
}
|
||||
|
||||
public void setQueryParserExceptionResolver(ExceptionResolver<QueryParserException> queryParserExceptionResolver)
|
||||
{
|
||||
this.queryParserExceptionResolver = queryParserExceptionResolver;
|
||||
}
|
||||
|
||||
public void setResolver(ExceptionResolver<Exception> resolver) {
|
||||
this.resolver = resolver;
|
||||
}
|
||||
|
@@ -134,8 +134,6 @@
|
||||
</bean>
|
||||
<bean id="webScriptExceptionResolver" class="org.alfresco.rest.framework.core.exceptions.WebScriptExceptionResolver">
|
||||
</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">
|
||||
<property name="exceptionMappings">
|
||||
<map>
|
||||
@@ -184,7 +182,6 @@
|
||||
<property name="resolver" ref="simpleMappingExceptionResolver" />
|
||||
<property name="webScriptExceptionResolver" ref="webScriptExceptionResolver" />
|
||||
<property name="restMetricsReporter" ref="restMetricsReporter"/>
|
||||
<property name="queryParserExceptionResolver" ref="queryParserExceptionResolver" />
|
||||
</bean>
|
||||
|
||||
<!-- Using annotation-config=false means AutowiredAnnotationBeanPostProcessor
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<#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 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 propValue p>
|
||||
<#attempt>
|
||||
@@ -25,52 +25,50 @@
|
||||
</#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>
|
||||
<@compress single_line=true>
|
||||
{
|
||||
<#assign first = true />
|
||||
<#list v?keys as key>
|
||||
<#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 />
|
||||
<#attempt>
|
||||
<#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>
|
||||
<@compress single_line=true>
|
||||
[
|
||||
<#list v as item>
|
||||
<#if first = false>,</#if>
|
||||
<@convertToJSON item />
|
||||
<#assign first = false/>
|
||||
{
|
||||
<#assign first = true />
|
||||
<#list v?keys as key>
|
||||
<#if first = false>,</#if>
|
||||
"${key}":
|
||||
<#if v[key]??>
|
||||
<@convertToJSON v[key] />
|
||||
<#else>
|
||||
${null}
|
||||
</#if>
|
||||
<#assign first = false/>
|
||||
</#list>
|
||||
]
|
||||
}
|
||||
</@compress>
|
||||
<#elseif v?is_enumerable>
|
||||
<#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>
|
||||
<#else>
|
||||
${null}
|
||||
</#if>
|
||||
<#recover>
|
||||
<span style="color:red">${.error}</span>
|
||||
</#attempt>
|
||||
</#macro>
|
||||
<#macro contentUrl nodeRef prop>
|
||||
${url.serviceContext}/api/node/${nodeRef?replace("://","/")}/content;${prop?url}
|
||||
|
@@ -23,46 +23,45 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.framework.tests.core;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.alfresco.repo.forms.FormNotFoundException;
|
||||
package org.alfresco.rest.framework.tests.core;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.alfresco.repo.forms.FormNotFoundException;
|
||||
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.ConstraintViolatedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.DeletedResourceException;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.ErrorResponse;
|
||||
import org.alfresco.rest.framework.core.exceptions.ApiException;
|
||||
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.DeletedResourceException;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.ErrorResponse;
|
||||
import org.alfresco.rest.framework.core.exceptions.InsufficientStorageException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.core.exceptions.NotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.StaleEntityException;
|
||||
import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException;
|
||||
import org.alfresco.rest.framework.resource.parameters.where.InvalidQueryException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.core.exceptions.NotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.StaleEntityException;
|
||||
import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationException;
|
||||
import org.alfresco.rest.framework.resource.parameters.where.InvalidQueryException;
|
||||
import org.alfresco.rest.framework.tools.ApiAssistant;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:test-rest-context.xml" })
|
||||
public class ExceptionResolverTests
|
||||
{
|
||||
@Autowired
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:test-rest-context.xml" })
|
||||
public class ExceptionResolverTests
|
||||
{
|
||||
@Autowired
|
||||
ApiAssistant assistant;
|
||||
|
||||
@Test
|
||||
@Test
|
||||
public void testWebscriptException()
|
||||
{
|
||||
ErrorResponse response = assistant.resolveException(new WebScriptException(null));
|
||||
@@ -76,43 +75,43 @@ public class ExceptionResolverTests
|
||||
|
||||
//04180006 Authentication failed for Web Script org/alfresco/api/ResourceWebScript.get
|
||||
@Test
|
||||
public void testMatchException()
|
||||
{
|
||||
public void testMatchException()
|
||||
{
|
||||
ErrorResponse response = assistant.resolveException(new ApiException(null));
|
||||
assertNotNull(response);
|
||||
assertEquals(500, response.getStatusCode()); //default to INTERNAL_SERVER_ERROR
|
||||
|
||||
assertNotNull(response);
|
||||
assertEquals(500, response.getStatusCode()); //default to INTERNAL_SERVER_ERROR
|
||||
|
||||
response = assistant.resolveException(new InvalidArgumentException(null));
|
||||
assertEquals(400, response.getStatusCode()); //default to STATUS_BAD_REQUEST
|
||||
|
||||
assertEquals(400, response.getStatusCode()); //default to STATUS_BAD_REQUEST
|
||||
|
||||
response = assistant.resolveException(new InvalidQueryException(null));
|
||||
assertEquals(400, response.getStatusCode()); //default to STATUS_BAD_REQUEST
|
||||
|
||||
assertEquals(400, response.getStatusCode()); //default to STATUS_BAD_REQUEST
|
||||
|
||||
response = assistant.resolveException(new NotFoundException(null));
|
||||
assertEquals(404, response.getStatusCode()); //default to STATUS_NOT_FOUND
|
||||
|
||||
assertEquals(404, response.getStatusCode()); //default to STATUS_NOT_FOUND
|
||||
|
||||
response = assistant.resolveException(new EntityNotFoundException(null));
|
||||
assertEquals(404, response.getStatusCode()); //default to STATUS_NOT_FOUND
|
||||
|
||||
assertEquals(404, response.getStatusCode()); //default to STATUS_NOT_FOUND
|
||||
|
||||
response = assistant.resolveException(new RelationshipResourceNotFoundException(null, null));
|
||||
assertEquals(404, response.getStatusCode()); //default to STATUS_NOT_FOUND
|
||||
|
||||
assertEquals(404, response.getStatusCode()); //default to STATUS_NOT_FOUND
|
||||
|
||||
response = assistant.resolveException(new PermissionDeniedException(null));
|
||||
assertEquals(403, response.getStatusCode()); //default to STATUS_FORBIDDEN
|
||||
|
||||
assertEquals(403, response.getStatusCode()); //default to STATUS_FORBIDDEN
|
||||
|
||||
response = assistant.resolveException(new UnsupportedResourceOperationException(null));
|
||||
assertEquals(405, response.getStatusCode()); //default to STATUS_METHOD_NOT_ALLOWED
|
||||
|
||||
assertEquals(405, response.getStatusCode()); //default to STATUS_METHOD_NOT_ALLOWED
|
||||
|
||||
response = assistant.resolveException(new DeletedResourceException(null));
|
||||
assertEquals(405, response.getStatusCode()); //default to STATUS_METHOD_NOT_ALLOWED
|
||||
|
||||
assertEquals(405, response.getStatusCode()); //default to STATUS_METHOD_NOT_ALLOWED
|
||||
|
||||
response = assistant.resolveException(new ConstraintViolatedException(null));
|
||||
assertEquals(409, response.getStatusCode()); //default to STATUS_CONFLICT
|
||||
|
||||
assertEquals(409, response.getStatusCode()); //default to STATUS_CONFLICT
|
||||
|
||||
response = assistant.resolveException(new StaleEntityException(null));
|
||||
assertEquals(409, response.getStatusCode()); //default to STATUS_CONFLICT
|
||||
assertEquals(409, response.getStatusCode()); //default to STATUS_CONFLICT
|
||||
|
||||
//Try a random exception
|
||||
//Try a random exception
|
||||
response = assistant.resolveException(new FormNotFoundException(null));
|
||||
assertEquals(500, response.getStatusCode()); //default to INTERNAL_SERVER_ERROR
|
||||
|
||||
@@ -121,15 +120,6 @@ public class ExceptionResolverTests
|
||||
|
||||
response = assistant.resolveException(new IntegrityException(null));
|
||||
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,12 +33,10 @@
|
||||
</bean>
|
||||
<bean id="webScriptExceptionResolver" class="org.alfresco.rest.framework.core.exceptions.WebScriptExceptionResolver">
|
||||
</bean>
|
||||
<bean id="queryParserExceptionResolver" class="org.alfresco.rest.framework.core.exceptions.QueryParserExceptionResolver" />
|
||||
<bean id="apiAssistant" class="org.alfresco.rest.framework.tools.ApiAssistant">
|
||||
<property name="jsonHelper" ref="jsonHelper" />
|
||||
<property name="resolver" ref="simpleMappingExceptionResolver" />
|
||||
<property name="webScriptExceptionResolver" ref="webScriptExceptionResolver" />
|
||||
<property name="queryParserExceptionResolver" ref="queryParserExceptionResolver" />
|
||||
</bean>
|
||||
<bean id="simpleMappingExceptionResolver" class="org.alfresco.rest.framework.core.exceptions.SimpleMappingExceptionResolver">
|
||||
<property name="exceptionMappings">
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>10.1</version>
|
||||
<version>11.9</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@@ -82,7 +82,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.11</version>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
@@ -191,7 +191,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-artifact</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<version>3.8.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.schlichtherle.truezip</groupId>
|
||||
@@ -383,7 +383,7 @@
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.woodstox</groupId>
|
||||
<artifactId>woodstox-core</artifactId>
|
||||
<version>6.2.6</version>
|
||||
<version>6.2.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- GData -->
|
||||
@@ -810,7 +810,7 @@
|
||||
<dependency>
|
||||
<groupId>commons-net</groupId>
|
||||
<artifactId>commons-net</artifactId>
|
||||
<version>3.7.2</version>
|
||||
<version>3.8.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -865,6 +865,12 @@
|
||||
<version>${dependency.awaitility.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@@ -32,8 +32,6 @@ import org.alfresco.sync.repo.Client;
|
||||
import org.alfresco.sync.repo.Client.ClientType;
|
||||
import org.alfresco.repo.activities.ActivityType;
|
||||
import org.alfresco.repo.model.filefolder.HiddenAspect;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.cmr.activities.ActivityInfo;
|
||||
import org.alfresco.service.cmr.activities.ActivityPoster;
|
||||
@@ -230,7 +228,7 @@ public class ActivityPosterImpl implements CmisActivityPoster, InitializingBean
|
||||
{
|
||||
if(activitiesEnabled && !hiddenAspect.hasHiddenAspect(nodeRef))
|
||||
{
|
||||
SiteInfo siteInfo = getSiteAsSystem(nodeRef);
|
||||
SiteInfo siteInfo = siteService.getSite(nodeRef);
|
||||
String siteId = (siteInfo != null ? siteInfo.getShortName() : null);
|
||||
if(siteId != null && !siteId.equals(""))
|
||||
{
|
||||
@@ -292,16 +290,5 @@ public class ActivityPosterImpl implements CmisActivityPoster, InitializingBean
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private SiteInfo getSiteAsSystem(NodeRef nodeRef)
|
||||
{
|
||||
return AuthenticationUtil.runAsSystem(new RunAsWork<SiteInfo>()
|
||||
{
|
||||
@Override
|
||||
public SiteInfo doWork() throws Exception
|
||||
{
|
||||
return siteService.getSite(nodeRef);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -35,6 +35,8 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.batch.BatchProcessWorkProvider;
|
||||
import org.alfresco.repo.batch.BatchProcessor;
|
||||
@@ -83,13 +85,16 @@ public class FixedAclUpdater extends TransactionListenerAdapter implements Appli
|
||||
|
||||
public static final String FIXED_ACL_ASYNC_REQUIRED_KEY = "FIXED_ACL_ASYNC_REQUIRED";
|
||||
public static final String FIXED_ACL_ASYNC_CALL_KEY = "FIXED_ACL_ASYNC_CALL";
|
||||
protected static final QName LOCK_Q_NAME = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "FixedAclUpdater");
|
||||
|
||||
/** A set of listeners to receive callback events whenever permissions are updated by this class. */
|
||||
private static Set<FixedAclUpdaterListener> listeners = Sets.newConcurrentHashSet();
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
private JobLockService jobLockService;
|
||||
private TransactionService transactionService;
|
||||
private AccessControlListDAO accessControlListDAO;
|
||||
private NodeDAO nodeDAO;
|
||||
private QName lockQName = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "FixedAclUpdater");
|
||||
private long lockTimeToLive = 10000;
|
||||
private long lockRefreshTime = lockTimeToLive / 2;
|
||||
|
||||
@@ -158,6 +163,12 @@ public class FixedAclUpdater extends TransactionListenerAdapter implements Appli
|
||||
this.policyIgnoreUtil = policyIgnoreUtil;
|
||||
}
|
||||
|
||||
/** Register a {@link FixedAclUpdaterListener} to be notified when a node is updated by an instance of this class. */
|
||||
public static void registerListener(FixedAclUpdaterListener listener)
|
||||
{
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
onInheritPermissionsDisabledDelegate = policyComponent
|
||||
@@ -241,7 +252,7 @@ public class FixedAclUpdater extends TransactionListenerAdapter implements Appli
|
||||
}
|
||||
}
|
||||
|
||||
private class AclWorker implements BatchProcessor.BatchProcessWorker<NodeRef>
|
||||
protected class AclWorker implements BatchProcessor.BatchProcessWorker<NodeRef>
|
||||
{
|
||||
private Set<QName> aspects = new HashSet<>(1);
|
||||
|
||||
@@ -315,6 +326,8 @@ public class FixedAclUpdater extends TransactionListenerAdapter implements Appli
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
listeners.forEach(listener -> listener.permissionsUpdatedAsynchronously(nodeRef));
|
||||
|
||||
if (log.isDebugEnabled())
|
||||
{
|
||||
log.debug(String.format("Node processed %s", nodeRef));
|
||||
@@ -330,7 +343,13 @@ public class FixedAclUpdater extends TransactionListenerAdapter implements Appli
|
||||
};
|
||||
|
||||
|
||||
private class GetNodesWithAspectCallback implements NodeRefQueryCallback
|
||||
/** Create a new AclWorker. */
|
||||
protected AclWorker createAclWorker()
|
||||
{
|
||||
return new AclWorker();
|
||||
}
|
||||
|
||||
class GetNodesWithAspectCallback implements NodeRefQueryCallback
|
||||
{
|
||||
private List<NodeRef> nodes = new ArrayList<>();
|
||||
private long minNodeId;
|
||||
@@ -421,11 +440,11 @@ public class FixedAclUpdater extends TransactionListenerAdapter implements Appli
|
||||
|
||||
try
|
||||
{
|
||||
lockToken = jobLockService.getLock(lockQName, lockTimeToLive, 0, 1);
|
||||
jobLockService.refreshLock(lockToken, lockQName, lockRefreshTime, jobLockRefreshCallback);
|
||||
lockToken = jobLockService.getLock(LOCK_Q_NAME, lockTimeToLive, 0, 1);
|
||||
jobLockService.refreshLock(lockToken, LOCK_Q_NAME, lockRefreshTime, jobLockRefreshCallback);
|
||||
|
||||
AclWorkProvider provider = new AclWorkProvider();
|
||||
AclWorker worker = new AclWorker();
|
||||
AclWorker worker = createAclWorker();
|
||||
BatchProcessor<NodeRef> bp = new BatchProcessor<>("FixedAclUpdater",
|
||||
transactionService.getRetryingTransactionHelper(), provider, numThreads, maxItemBatchSize, applicationContext,
|
||||
log, 100);
|
||||
@@ -442,7 +461,7 @@ public class FixedAclUpdater extends TransactionListenerAdapter implements Appli
|
||||
jobLockRefreshCallback.isActive.set(false);
|
||||
if (lockToken != null)
|
||||
{
|
||||
jobLockService.releaseLock(lockToken, lockQName);
|
||||
jobLockService.releaseLock(lockToken, LOCK_Q_NAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,48 +1,35 @@
|
||||
/*
|
||||
* #%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);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* #%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.domain.permissions;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/** Listener to receive callback events when permissions are asynchronously updated with the {@link FixedAclUpdater}. */
|
||||
public interface FixedAclUpdaterListener
|
||||
{
|
||||
/** Callback method for when permissions have been updated by the FixedAclUpdater. */
|
||||
void permissionsUpdatedAsynchronously(NodeRef nodeRef);
|
||||
}
|
@@ -25,6 +25,8 @@
|
||||
*/
|
||||
package org.alfresco.repo.domain.schema.script;
|
||||
|
||||
import org.alfresco.repo.domain.dialect.Dialect;
|
||||
import org.alfresco.repo.domain.dialect.MySQLInnoDBDialect;
|
||||
import org.alfresco.util.LogUtil;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
@@ -69,27 +71,34 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
public static final String PROPERTY_READ_ONLY = "system.delete_not_exists.read_only";
|
||||
public static final String PROPERTY_TIMEOUT_SECONDS = "system.delete_not_exists.timeout_seconds";
|
||||
|
||||
protected Connection connection;
|
||||
private Connection connection;
|
||||
private String sql;
|
||||
private int line;
|
||||
private File scriptFile;
|
||||
private Properties globalProperties;
|
||||
private Dialect dialect;
|
||||
|
||||
protected boolean readOnly;
|
||||
protected int deleteBatchSize;
|
||||
protected int batchSize;
|
||||
private boolean readOnly;
|
||||
private int deleteBatchSize;
|
||||
private int batchSize;
|
||||
private long timeoutSec;
|
||||
|
||||
protected long deletedCount;
|
||||
protected Date startTime;
|
||||
private long deletedCount;
|
||||
private Date startTime;
|
||||
|
||||
public DeleteNotExistsExecutor(Connection connection, String sql, int line, File scriptFile, Properties globalProperties)
|
||||
{
|
||||
this(connection, sql, line, scriptFile, globalProperties, null);
|
||||
}
|
||||
|
||||
public DeleteNotExistsExecutor(Connection connection, String sql, int line, File scriptFile, Properties globalProperties, Dialect dialect)
|
||||
{
|
||||
this.connection = connection;
|
||||
this.sql = sql;
|
||||
this.line = line;
|
||||
this.scriptFile = scriptFile;
|
||||
this.globalProperties = globalProperties;
|
||||
this.dialect = dialect;
|
||||
}
|
||||
|
||||
public void checkProperties()
|
||||
@@ -164,7 +173,22 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
}
|
||||
}
|
||||
|
||||
protected void process(Pair<String, String>[] tableColumn, Long[] tableUpperLimits, String[] optionalWhereClauses) throws SQLException
|
||||
/**
|
||||
* @return Integer.MIN_VALUE in case of MySQL otherwise the batch size.
|
||||
*/
|
||||
private int computeFetchSize()
|
||||
{
|
||||
if (this.dialect instanceof MySQLInnoDBDialect)
|
||||
{
|
||||
// Note the MySQL specific fetch size limitation (Integer.MIN_VALUE). fetchSize
|
||||
// activates result set streaming.
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
return batchSize;
|
||||
}
|
||||
|
||||
private void process(Pair<String, String>[] tableColumn, Long[] tableUpperLimits, String[] optionalWhereClauses) throws SQLException
|
||||
{
|
||||
// The approach is to fetch ordered row ids from all referencer/secondary (e.g.
|
||||
// alf_audit_app, alf_audit_entry, alf_prop_unique_ctx) tables and
|
||||
@@ -184,15 +208,15 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
PreparedStatement[] secondaryPrepStmts = null;
|
||||
PreparedStatement deletePrepStmt = null;
|
||||
Set<Long> deleteIds = new HashSet<>();
|
||||
int fetchSize = computeFetchSize();
|
||||
|
||||
deletedCount = 0L;
|
||||
startTime = new Date();
|
||||
try
|
||||
{
|
||||
connection.setAutoCommit(false);
|
||||
|
||||
primaryPrepStmt = connection.prepareStatement(createPreparedSelectStatement(primaryTableName, primaryColumnName, primaryWhereClause));
|
||||
primaryPrepStmt.setFetchSize(batchSize);
|
||||
primaryPrepStmt.setFetchSize(fetchSize);
|
||||
primaryPrepStmt.setLong(1, primaryId);
|
||||
primaryPrepStmt.setLong(2, tableUpperLimits[0]);
|
||||
|
||||
@@ -205,7 +229,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
for (int i = 1; i < tableColumn.length; i++)
|
||||
{
|
||||
PreparedStatement secStmt = connection.prepareStatement(createPreparedSelectStatement(tableColumn[i].getFirst(), tableColumn[i].getSecond(), optionalWhereClauses[i]));
|
||||
secStmt.setFetchSize(batchSize);
|
||||
secStmt.setFetchSize(fetchSize);
|
||||
secStmt.setLong(1, primaryId);
|
||||
secStmt.setLong(2, tableUpperLimits[i]);
|
||||
|
||||
@@ -265,7 +289,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isTimeoutExceeded()
|
||||
private boolean isTimeoutExceeded()
|
||||
{
|
||||
if (timeoutSec <= 0)
|
||||
{
|
||||
@@ -276,7 +300,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
return (now.getTime() > startTime.getTime() + (timeoutSec * 1000));
|
||||
}
|
||||
|
||||
protected Long processPrimaryTableResultSet(PreparedStatement primaryPrepStmt, PreparedStatement[] secondaryPrepStmts, PreparedStatement deletePrepStmt, Set<Long> deleteIds, String primaryTableName,
|
||||
private Long processPrimaryTableResultSet(PreparedStatement primaryPrepStmt, PreparedStatement[] secondaryPrepStmts, PreparedStatement deletePrepStmt, Set<Long> deleteIds, String primaryTableName,
|
||||
String primaryColumnName, Pair<String, String>[] tableColumn) throws SQLException
|
||||
{
|
||||
int rowsProcessed = 0;
|
||||
@@ -337,7 +361,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
return primaryId;
|
||||
}
|
||||
|
||||
protected void deleteFromPrimaryTable(PreparedStatement deletePrepStmt, Set<Long> deleteIds, String primaryTableName) throws SQLException
|
||||
private void deleteFromPrimaryTable(PreparedStatement deletePrepStmt, Set<Long> deleteIds, String primaryTableName) throws SQLException
|
||||
{
|
||||
int deletedBatchCount = deleteIds.size();
|
||||
if (!readOnly && !deleteIds.isEmpty())
|
||||
@@ -426,7 +450,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
return batchUpperLimit;
|
||||
}
|
||||
|
||||
protected boolean isLess(Long primaryId, Long[] secondaryIds)
|
||||
private boolean isLess(Long primaryId, Long[] secondaryIds)
|
||||
{
|
||||
for (Long secondaryId : secondaryIds)
|
||||
{
|
||||
@@ -448,8 +472,8 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
|
||||
return quotedString.replace("\"", "");
|
||||
}
|
||||
|
||||
protected String createPreparedSelectStatement(String tableName, String columnName, String whereClause)
|
||||
|
||||
private String createPreparedSelectStatement(String tableName, String columnName, String whereClause)
|
||||
{
|
||||
StringBuilder sqlBuilder = new StringBuilder("SELECT " + columnName + " FROM " + tableName + " WHERE ");
|
||||
|
||||
@@ -462,7 +486,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
return sqlBuilder.toString();
|
||||
}
|
||||
|
||||
protected String createPreparedDeleteStatement(String tableName, String idColumnName, int deleteBatchSize, String whereClause)
|
||||
private String createPreparedDeleteStatement(String tableName, String idColumnName, int deleteBatchSize, String whereClause)
|
||||
{
|
||||
StringBuilder stmtBuilder = new StringBuilder("DELETE FROM " + tableName + " WHERE ");
|
||||
|
||||
@@ -516,7 +540,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
}
|
||||
}
|
||||
|
||||
protected Long getColumnValueById(ResultSet resultSet, String columnId) throws SQLException
|
||||
private Long getColumnValueById(ResultSet resultSet, String columnId) throws SQLException
|
||||
{
|
||||
Long columnValue = null;
|
||||
if (resultSet != null && resultSet.next())
|
||||
@@ -527,7 +551,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
return columnValue;
|
||||
}
|
||||
|
||||
protected ResultSet[] getSecondaryResultSets(PreparedStatement[] preparedStatements) throws SQLException
|
||||
private ResultSet[] getSecondaryResultSets(PreparedStatement[] preparedStatements) throws SQLException
|
||||
{
|
||||
ResultSet[] secondaryResultSets = new ResultSet[preparedStatements.length];
|
||||
for (int i = 1; i < preparedStatements.length; i++)
|
||||
@@ -541,7 +565,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
return secondaryResultSets;
|
||||
}
|
||||
|
||||
protected Long[] getSecondaryIds(ResultSet[] secondaryResultSets, Pair<String, String>[] tableColumn) throws SQLException
|
||||
private Long[] getSecondaryIds(ResultSet[] secondaryResultSets, Pair<String, String>[] tableColumn) throws SQLException
|
||||
{
|
||||
Long[] secondaryIds = new Long[tableColumn.length];
|
||||
|
||||
@@ -572,7 +596,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
}
|
||||
}
|
||||
|
||||
protected void closeQuietly(Statement statement)
|
||||
private void closeQuietly(Statement statement)
|
||||
{
|
||||
if (statement != null)
|
||||
{
|
||||
@@ -587,7 +611,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
}
|
||||
}
|
||||
|
||||
protected void closeQuietly(Statement[] statements)
|
||||
private void closeQuietly(Statement[] statements)
|
||||
{
|
||||
if (statements != null)
|
||||
{
|
||||
@@ -598,7 +622,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
}
|
||||
}
|
||||
|
||||
protected void closeQuietly(ResultSet resultSet)
|
||||
private void closeQuietly(ResultSet resultSet)
|
||||
{
|
||||
if (resultSet != null)
|
||||
{
|
||||
@@ -613,7 +637,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
}
|
||||
}
|
||||
|
||||
protected void closeQuietly(ResultSet[] resultSets)
|
||||
private void closeQuietly(ResultSet[] resultSets)
|
||||
{
|
||||
if (resultSets != null)
|
||||
{
|
||||
|
@@ -1,278 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2020 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.domain.schema.script;
|
||||
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Extends <code>{@link DeleteNotExistsExecutor}</code> to cope with MySQL
|
||||
* specific fetch size limitation and restrictions.
|
||||
*/
|
||||
public class MySQLDeleteNotExistsExecutor extends DeleteNotExistsExecutor
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(MySQLDeleteNotExistsExecutor.class);
|
||||
|
||||
private final DataSource dataSource;
|
||||
|
||||
public MySQLDeleteNotExistsExecutor(Connection connection, String sql, int line, File scriptFile, Properties globalProperties, DataSource dataSource)
|
||||
{
|
||||
super(connection, sql, line, scriptFile, globalProperties);
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void process(Pair<String, String>[] tableColumn, Long[] tableUpperLimits, String[] optionalWhereClauses) throws SQLException
|
||||
{
|
||||
// The approach is to fetch ordered row ids from all referencer/secondary (e.g.
|
||||
// alf_audit_app, alf_audit_entry, alf_prop_unique_ctx) tables and
|
||||
// referenced/primary table (e.g. alf_prop_root) concurrently, so that it is
|
||||
// possible skip over id gaps efficiently while at the same time being able to
|
||||
// work out which ids are obsolete and delete them in batches.
|
||||
|
||||
// The algorithm can be further improved by iterating over the rows in descending order.
|
||||
// This is due to the fact that older data should be more stable in time.
|
||||
|
||||
String primaryTableName = tableColumn[0].getFirst();
|
||||
String primaryColumnName = tableColumn[0].getSecond();
|
||||
String primaryWhereClause = optionalWhereClauses[0];
|
||||
|
||||
Long primaryId = 0L;
|
||||
|
||||
PreparedStatement primaryPrepStmt = null;
|
||||
PreparedStatement[] secondaryPrepStmts = null;
|
||||
PreparedStatement deletePrepStmt = null;
|
||||
Set<Long> deleteIds = new HashSet<>();
|
||||
|
||||
deletedCount = 0L;
|
||||
startTime = new Date();
|
||||
|
||||
long defaultOffset = 0L;
|
||||
try
|
||||
{
|
||||
connection.setAutoCommit(false);
|
||||
|
||||
primaryPrepStmt = connection.prepareStatement(createLimitPreparedSelectStatement(primaryTableName, primaryColumnName, primaryWhereClause));
|
||||
primaryPrepStmt.setLong(1, primaryId);
|
||||
primaryPrepStmt.setLong(2, tableUpperLimits[0]);
|
||||
primaryPrepStmt.setInt(3, batchSize);
|
||||
primaryPrepStmt.setLong(4, defaultOffset);
|
||||
|
||||
boolean hasResults = primaryPrepStmt.execute();
|
||||
|
||||
if (hasResults)
|
||||
{
|
||||
secondaryPrepStmts = new PreparedStatement[tableColumn.length];
|
||||
for (int i = 1; i < tableColumn.length; i++)
|
||||
{
|
||||
PreparedStatement secStmt = connection.prepareStatement(createLimitPreparedSelectStatement(tableColumn[i].getFirst(), tableColumn[i].getSecond(), optionalWhereClauses[i]));
|
||||
secStmt.setLong(1, primaryId);
|
||||
secStmt.setLong(2, tableUpperLimits[i]);
|
||||
secStmt.setInt(3, batchSize);
|
||||
secStmt.setLong(4, defaultOffset);
|
||||
|
||||
secondaryPrepStmts[i] = secStmt;
|
||||
}
|
||||
|
||||
deletePrepStmt = connection.prepareStatement(createPreparedDeleteStatement(primaryTableName, primaryColumnName, deleteBatchSize, primaryWhereClause));
|
||||
|
||||
// Timeout is only checked at each bach start.
|
||||
// It can be further refined by being verified at each primary row processing.
|
||||
while (hasResults && !isTimeoutExceeded())
|
||||
{
|
||||
// Process batch
|
||||
primaryId = processPrimaryTableResultSet(primaryPrepStmt, secondaryPrepStmts, deletePrepStmt, deleteIds, primaryTableName, primaryColumnName, tableColumn);
|
||||
connection.commit();
|
||||
|
||||
if (primaryId == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// Prepare for next batch
|
||||
primaryPrepStmt.setLong(1, primaryId);
|
||||
primaryPrepStmt.setLong(2, tableUpperLimits[0]);
|
||||
primaryPrepStmt.setInt(3, batchSize);
|
||||
primaryPrepStmt.setLong(4, defaultOffset);
|
||||
|
||||
for (int i = 1; i < tableColumn.length; i++)
|
||||
{
|
||||
PreparedStatement secStmt = secondaryPrepStmts[i];
|
||||
secStmt.setLong(1, primaryId);
|
||||
secStmt.setLong(2, tableUpperLimits[i]);
|
||||
secStmt.setInt(3, batchSize);
|
||||
secStmt.setLong(4, defaultOffset);
|
||||
}
|
||||
|
||||
hasResults = primaryPrepStmt.execute();
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we have any more ids to delete
|
||||
if (!deleteIds.isEmpty())
|
||||
{
|
||||
deleteFromPrimaryTable(deletePrepStmt, deleteIds, primaryTableName);
|
||||
connection.commit();
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
String msg = ((readOnly) ? "Script would have" : "Script") + " deleted a total of " + deletedCount + " items from table " + primaryTableName + ".";
|
||||
logger.debug(msg);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly(deletePrepStmt);
|
||||
closeQuietly(secondaryPrepStmts);
|
||||
closeQuietly(primaryPrepStmt);
|
||||
|
||||
connection.setAutoCommit(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected Long processPrimaryTableResultSet(PreparedStatement primaryPrepStmt, PreparedStatement[] secondaryPrepStmts, PreparedStatement deletePrepStmt, Set<Long> deleteIds,
|
||||
String primaryTableName, String primaryColumnName, Pair<String, String>[] tableColumn) throws SQLException
|
||||
{
|
||||
int rowsProcessed = 0;
|
||||
Long primaryId = null;
|
||||
ResultSet[] secondaryResultSets = null;
|
||||
try (ResultSet resultSet = primaryPrepStmt.getResultSet())
|
||||
{
|
||||
secondaryResultSets = getSecondaryResultSets(secondaryPrepStmts);
|
||||
Long[] secondaryIds = getSecondaryIds(secondaryResultSets, tableColumn);
|
||||
|
||||
// Create and populate secondary tables offsets
|
||||
Long[] secondaryOffsets = new Long[tableColumn.length];
|
||||
for (int i = 1; i < tableColumn.length; i++)
|
||||
{
|
||||
secondaryOffsets[i] = 0L;
|
||||
}
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
++rowsProcessed;
|
||||
primaryId = resultSet.getLong(primaryColumnName);
|
||||
|
||||
while (isLess(primaryId, secondaryIds))
|
||||
{
|
||||
deleteIds.add(primaryId);
|
||||
|
||||
if (deleteIds.size() == deleteBatchSize)
|
||||
{
|
||||
deleteFromPrimaryTable(deletePrepStmt, deleteIds, primaryTableName);
|
||||
connection.commit();
|
||||
}
|
||||
|
||||
if (!resultSet.next())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
++rowsProcessed;
|
||||
primaryId = resultSet.getLong(primaryColumnName);
|
||||
}
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("RowsProcessed " + rowsProcessed + " from primary table " + primaryTableName);
|
||||
}
|
||||
|
||||
updateSecondaryIds(primaryId, secondaryIds, secondaryPrepStmts, secondaryOffsets, secondaryResultSets, tableColumn);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
closeQuietly(secondaryResultSets);
|
||||
}
|
||||
|
||||
return primaryId;
|
||||
}
|
||||
|
||||
private void updateSecondaryIds(Long primaryId, Long[] secondaryIds, PreparedStatement[] secondaryPrepStmts, Long[] secondaryOffsets, ResultSet[] secondaryResultSets,
|
||||
Pair<String, String>[] tableColumn) throws SQLException
|
||||
{
|
||||
for (int i = 1; i < tableColumn.length; i++)
|
||||
{
|
||||
Long secondaryId = secondaryIds[i];
|
||||
while (secondaryId != null && primaryId >= secondaryId)
|
||||
{
|
||||
ResultSet resultSet = secondaryResultSets[i];
|
||||
String columnId = tableColumn[i].getSecond();
|
||||
|
||||
secondaryId = getColumnValueById(resultSet, columnId);
|
||||
|
||||
// Check if we reach the end of the first page
|
||||
if (secondaryId == null)
|
||||
{
|
||||
// Close the previous result set
|
||||
closeQuietly(resultSet);
|
||||
|
||||
// Set to use the next page
|
||||
long offset = secondaryOffsets[i] + batchSize;
|
||||
secondaryOffsets[i] = offset;
|
||||
|
||||
PreparedStatement secStmt = secondaryPrepStmts[i];
|
||||
secStmt.setLong(4, offset);
|
||||
|
||||
// Check if any results were found
|
||||
boolean secHasResults = secStmt.execute();
|
||||
secondaryResultSets[i] = secHasResults ? secStmt.getResultSet() : null;
|
||||
|
||||
// Try again to get the next secondary id
|
||||
secondaryId = getColumnValueById(secondaryResultSets[i], columnId);
|
||||
}
|
||||
|
||||
secondaryIds[i] = secondaryId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String createLimitPreparedSelectStatement(String tableName, String columnName, String whereClause)
|
||||
{
|
||||
StringBuilder sqlBuilder = new StringBuilder("SELECT " + columnName + " FROM " + tableName + " WHERE ");
|
||||
|
||||
if (whereClause != null && !whereClause.isEmpty())
|
||||
{
|
||||
sqlBuilder.append(whereClause + " AND ");
|
||||
}
|
||||
|
||||
sqlBuilder.append(columnName + " > ? AND " + columnName + " <= ? ORDER BY " + columnName + " ASC LIMIT ? OFFSET ?");
|
||||
return sqlBuilder.toString();
|
||||
}
|
||||
}
|
@@ -350,7 +350,7 @@ public class ScriptExecutorImpl implements ScriptExecutor
|
||||
}
|
||||
else if (sql.startsWith("--DELETE_NOT_EXISTS"))
|
||||
{
|
||||
DeleteNotExistsExecutor deleteNotExists = createDeleteNotExistsExecutor(dialect, connection, sql, line, scriptFile);
|
||||
DeleteNotExistsExecutor deleteNotExists = new DeleteNotExistsExecutor(connection, sql, line, scriptFile, globalProperties, dialect);
|
||||
deleteNotExists.execute();
|
||||
|
||||
// Reset
|
||||
@@ -537,17 +537,7 @@ public class ScriptExecutorImpl implements ScriptExecutor
|
||||
try { scriptInputStream.close(); } catch (Throwable e) {}
|
||||
}
|
||||
}
|
||||
|
||||
private DeleteNotExistsExecutor createDeleteNotExistsExecutor(Dialect dialect, Connection connection, String sql, int line, File scriptFile)
|
||||
{
|
||||
if (dialect instanceof MySQLInnoDBDialect)
|
||||
{
|
||||
return new MySQLDeleteNotExistsExecutor(connection, sql, line, scriptFile, globalProperties, dataSource);
|
||||
}
|
||||
|
||||
return new DeleteNotExistsExecutor(connection, sql, line, scriptFile, globalProperties);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute the given SQL statement, absorbing exceptions that we expect during
|
||||
* schema creation or upgrade.
|
||||
|
@@ -0,0 +1,538 @@
|
||||
/*
|
||||
* #%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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -52,7 +52,6 @@ import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import static org.alfresco.repo.content.MimetypeMap.MIMETYPE_PDF;
|
||||
import static org.alfresco.repo.content.transform.magick.ImageTransformationOptions.OPT_COMMAND_OPTIONS;
|
||||
import static org.alfresco.repo.rendition2.RenditionDefinition2.ALLOW_ENLARGEMENT;
|
||||
import static org.alfresco.repo.rendition2.RenditionDefinition2.ALLOW_PDF_ENLARGEMENT;
|
||||
import static org.alfresco.repo.rendition2.RenditionDefinition2.ALPHA_REMOVE;
|
||||
@@ -123,7 +122,6 @@ public class TransformationOptionsConverter implements InitializingBean
|
||||
IMAGE_OPTIONS.addAll(RESIZE_OPTIONS);
|
||||
IMAGE_OPTIONS.add(AUTO_ORIENT);
|
||||
IMAGE_OPTIONS.add(ALPHA_REMOVE);
|
||||
IMAGE_OPTIONS.add(OPT_COMMAND_OPTIONS);
|
||||
}
|
||||
|
||||
private static Set<String> PDF_OPTIONS = new HashSet<>(Arrays.asList(new String[]
|
||||
@@ -286,8 +284,6 @@ public class TransformationOptionsConverter implements InitializingBean
|
||||
}
|
||||
opts.setSourceOptionsList(sourceOptionsList);
|
||||
}
|
||||
|
||||
ifSet(options, OPT_COMMAND_OPTIONS, (v) -> opts.setCommandOptions(v));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -365,11 +361,13 @@ public class TransformationOptionsConverter implements InitializingBean
|
||||
{
|
||||
ImageTransformationOptions opts = (ImageTransformationOptions) options;
|
||||
|
||||
// From a security viewpoint it would be better not to support the option of passing anything to
|
||||
// ImageMagick. It might be possible to extract some of the well know values and add them to the
|
||||
// T-Engine engine_config.
|
||||
// TODO We don't support this any more for security reasons, however it might be possible to
|
||||
// extract some of the well know values and add them to the newer ImageMagick transform options.
|
||||
String commandOptions = opts.getCommandOptions();
|
||||
ifSet(commandOptions != null && !commandOptions.isBlank(), map, OPT_COMMAND_OPTIONS, commandOptions);
|
||||
if (commandOptions != null && !commandOptions.isBlank())
|
||||
{
|
||||
logger.error("ImageMagick commandOptions are no longer supported for security reasons: " + commandOptions);
|
||||
}
|
||||
|
||||
ImageResizeOptions imageResizeOptions = opts.getResizeOptions();
|
||||
if (imageResizeOptions != null)
|
||||
|
@@ -26,9 +26,6 @@
|
||||
package org.alfresco.repo.search;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.apache.http.HttpStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Andy
|
||||
@@ -36,10 +33,11 @@ import java.util.List;
|
||||
*/
|
||||
public class QueryParserException extends AlfrescoRuntimeException
|
||||
{
|
||||
/** Serial version UUID. */
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4886993838297301968L;
|
||||
/** Http Status Code that should be returned by Remote API. */
|
||||
private int httpStatusCode;
|
||||
|
||||
/**
|
||||
* @param msgId
|
||||
@@ -47,6 +45,7 @@ public class QueryParserException extends AlfrescoRuntimeException
|
||||
public QueryParserException(String msgId)
|
||||
{
|
||||
super(msgId);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,6 +55,7 @@ public class QueryParserException extends AlfrescoRuntimeException
|
||||
public QueryParserException(String msgId, Object[] msgParams)
|
||||
{
|
||||
super(msgId, msgParams);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,6 +65,7 @@ public class QueryParserException extends AlfrescoRuntimeException
|
||||
public QueryParserException(String msgId, Throwable cause)
|
||||
{
|
||||
super(msgId, cause);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,22 +76,7 @@ public class QueryParserException extends AlfrescoRuntimeException
|
||||
public QueryParserException(String msgId, Object[] msgParams, Throwable 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;
|
||||
}
|
||||
}
|
@@ -1,505 +1,460 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.repo.search.impl.querymodel.impl.db;
|
||||
|
||||
import static org.alfresco.repo.domain.node.AbstractNodeDAOImpl.CACHE_REGION_NODES;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.concurrent.NotThreadSafe;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.admin.patch.OptionalPatchApplicationCheckBootstrapBean;
|
||||
import org.alfresco.repo.cache.SimpleCache;
|
||||
import org.alfresco.repo.cache.lookup.EntityLookupCache;
|
||||
import org.alfresco.repo.cache.lookup.EntityLookupCache.EntityLookupCallbackDAOAdaptor;
|
||||
import org.alfresco.repo.domain.node.Node;
|
||||
import org.alfresco.repo.domain.node.NodeDAO;
|
||||
import org.alfresco.repo.domain.node.StoreEntity;
|
||||
import org.alfresco.repo.domain.permissions.AclCrudDAO;
|
||||
import org.alfresco.repo.domain.permissions.Authority;
|
||||
import org.alfresco.repo.domain.qname.QNameDAO;
|
||||
import org.alfresco.repo.search.SimpleResultSetMetaData;
|
||||
import org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet;
|
||||
import org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext;
|
||||
import org.alfresco.repo.search.impl.querymodel.Query;
|
||||
import org.alfresco.repo.search.impl.querymodel.QueryEngine;
|
||||
import org.alfresco.repo.search.impl.querymodel.QueryEngineResults;
|
||||
import org.alfresco.repo.search.impl.querymodel.QueryModelException;
|
||||
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory;
|
||||
import org.alfresco.repo.search.impl.querymodel.QueryOptions;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.permissions.impl.acegi.FilteringResultSet;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.LimitBy;
|
||||
import org.alfresco.service.cmr.search.PermissionEvaluationMode;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.ibatis.session.ResultContext;
|
||||
import org.apache.ibatis.session.ResultHandler;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
|
||||
/**
|
||||
* @author Andy
|
||||
*/
|
||||
@NotThreadSafe
|
||||
public class DBQueryEngine implements QueryEngine
|
||||
{
|
||||
protected static final Log logger = LogFactory.getLog(DBQueryEngine.class);
|
||||
|
||||
protected static final String SELECT_BY_DYNAMIC_QUERY = "alfresco.metadata.query.select_byDynamicQuery";
|
||||
|
||||
protected SqlSessionTemplate template;
|
||||
|
||||
protected QNameDAO qnameDAO;
|
||||
|
||||
private NodeDAO nodeDAO;
|
||||
|
||||
protected DictionaryService dictionaryService;
|
||||
|
||||
protected NamespaceService namespaceService;
|
||||
|
||||
protected NodeService nodeService;
|
||||
|
||||
private TenantService tenantService;
|
||||
|
||||
private OptionalPatchApplicationCheckBootstrapBean metadataIndexCheck2;
|
||||
|
||||
protected PermissionService permissionService;
|
||||
|
||||
private int maxPermissionChecks;
|
||||
|
||||
private long maxPermissionCheckTimeMillis;
|
||||
|
||||
private boolean maxPermissionCheckEnabled;
|
||||
|
||||
protected EntityLookupCache<Long, Node, NodeRef> nodesCache;
|
||||
|
||||
private List<Pair<Long, StoreRef>> stores;
|
||||
|
||||
AclCrudDAO aclCrudDAO;
|
||||
|
||||
public void setAclCrudDAO(AclCrudDAO aclCrudDAO)
|
||||
{
|
||||
this.aclCrudDAO = aclCrudDAO;
|
||||
}
|
||||
|
||||
public void setMaxPermissionChecks(int maxPermissionChecks)
|
||||
{
|
||||
this.maxPermissionChecks = maxPermissionChecks;
|
||||
}
|
||||
|
||||
public void setMaxPermissionCheckTimeMillis(long maxPermissionCheckTimeMillis)
|
||||
{
|
||||
this.maxPermissionCheckTimeMillis = maxPermissionCheckTimeMillis;
|
||||
}
|
||||
|
||||
public void setMaxPermissionCheckEnabled(boolean maxPermissionCheckEnabled)
|
||||
{
|
||||
this.maxPermissionCheckEnabled = maxPermissionCheckEnabled;
|
||||
}
|
||||
|
||||
public void setTemplate(SqlSessionTemplate template)
|
||||
{
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
public void setMetadataIndexCheck2(OptionalPatchApplicationCheckBootstrapBean metadataIndexCheck2)
|
||||
{
|
||||
this.metadataIndexCheck2 = metadataIndexCheck2;
|
||||
}
|
||||
|
||||
public void setTenantService(TenantService tenantService)
|
||||
{
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
|
||||
public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate)
|
||||
{
|
||||
this.template = sqlSessionTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param qnameDAO
|
||||
* the qnameDAO to set
|
||||
*/
|
||||
public void setQnameDAO(QNameDAO qnameDAO)
|
||||
{
|
||||
this.qnameDAO = qnameDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dictionaryService
|
||||
* the dictionaryService to set
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namespaceService
|
||||
* the namespaceService to set
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService the nodeService to set
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeDAO the nodeDAO to set
|
||||
*/
|
||||
public void setNodeDAO(NodeDAO nodeDAO)
|
||||
{
|
||||
this.nodeDAO = nodeDAO;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* org.alfresco.repo.search.impl.querymodel.QueryEngine#executeQuery(org.alfresco.repo.search.impl.querymodel.Query,
|
||||
* org.alfresco.repo.search.impl.querymodel.QueryOptions,
|
||||
* org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext)
|
||||
*/
|
||||
@Override
|
||||
public QueryEngineResults executeQuery(Query query, QueryOptions options, FunctionEvaluationContext functionContext)
|
||||
{
|
||||
long start = 0;
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
start = System.currentTimeMillis();
|
||||
logger.debug("Query request received");
|
||||
}
|
||||
|
||||
Set<String> selectorGroup = null;
|
||||
if (query.getSource() != null)
|
||||
{
|
||||
List<Set<String>> selectorGroups = query.getSource().getSelectorGroups(functionContext);
|
||||
|
||||
if (selectorGroups.size() == 0)
|
||||
{
|
||||
throw new QueryModelException("No selectors");
|
||||
}
|
||||
|
||||
if (selectorGroups.size() > 1)
|
||||
{
|
||||
throw new QueryModelException("Advanced join is not supported");
|
||||
}
|
||||
|
||||
selectorGroup = selectorGroups.get(0);
|
||||
}
|
||||
|
||||
DBQuery dbQuery = (DBQuery)query;
|
||||
|
||||
if (options.getStores().size() > 1)
|
||||
{
|
||||
throw new QueryModelException("Multi-store queries are not supported");
|
||||
}
|
||||
|
||||
// MT
|
||||
StoreRef storeRef = options.getStores().get(0);
|
||||
storeRef = storeRef != null ? tenantService.getName(storeRef) : null;
|
||||
|
||||
Pair<Long, StoreRef> store = nodeDAO.getStore(storeRef);
|
||||
if (store == null)
|
||||
{
|
||||
throw new QueryModelException("Unknown store: "+storeRef);
|
||||
}
|
||||
dbQuery.setStoreId(store.getFirst());
|
||||
Pair<Long, QName> sysDeletedType = qnameDAO.getQName(ContentModel.TYPE_DELETED);
|
||||
if (sysDeletedType == null)
|
||||
{
|
||||
dbQuery.setSysDeletedType(-1L);
|
||||
}
|
||||
else
|
||||
{
|
||||
dbQuery.setSysDeletedType(sysDeletedType.getFirst());
|
||||
}
|
||||
|
||||
Long sinceTxId = options.getSinceTxId();
|
||||
if (sinceTxId == null)
|
||||
{
|
||||
// By default, return search results for all transactions.
|
||||
sinceTxId = -1L;
|
||||
}
|
||||
dbQuery.setSinceTxId(sinceTxId);
|
||||
|
||||
logger.debug("- query is being prepared");
|
||||
dbQuery.prepare(namespaceService, dictionaryService, qnameDAO, nodeDAO, tenantService, selectorGroup,
|
||||
null, functionContext, metadataIndexCheck2.getPatchApplied());
|
||||
|
||||
ResultSet resultSet;
|
||||
resultSet = selectNodesWithPermissions(options, dbQuery);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
long ms = System.currentTimeMillis() - start;
|
||||
logger.debug("Selected " + resultSet.length() + " nodes with permission resolution in "+ms+" ms");
|
||||
}
|
||||
return asQueryEngineResults(resultSet);
|
||||
}
|
||||
|
||||
protected String pickQueryTemplate(QueryOptions options, DBQuery dbQuery)
|
||||
{
|
||||
logger.debug("- using standard table for the query");
|
||||
return SELECT_BY_DYNAMIC_QUERY;
|
||||
}
|
||||
|
||||
private ResultSet selectNodesWithPermissions(QueryOptions options, DBQuery dbQuery)
|
||||
{
|
||||
Authority authority = aclCrudDAO.getAuthority(AuthenticationUtil.getRunAsUser());
|
||||
|
||||
NodePermissionAssessor permissionAssessor = createAssessor(authority);
|
||||
int maxPermsChecks = options.getMaxPermissionChecks() < 0 ? maxPermissionChecks : options.getMaxPermissionChecks();
|
||||
long maxPermCheckTimeMillis = options.getMaxPermissionCheckTimeMillis() < 0
|
||||
? maxPermissionCheckTimeMillis
|
||||
: options.getMaxPermissionCheckTimeMillis();
|
||||
permissionAssessor.setMaxPermissionChecks(maxPermsChecks);
|
||||
permissionAssessor.setMaxPermissionCheckTimeMillis(maxPermCheckTimeMillis);
|
||||
|
||||
FilteringResultSet resultSet = acceleratedNodeSelection(options, dbQuery, permissionAssessor);
|
||||
|
||||
PagingLuceneResultSet plrs = new PagingLuceneResultSet(resultSet, options.getAsSearchParmeters(), nodeService);
|
||||
plrs.setTrimmedResultSet(true);
|
||||
return plrs;
|
||||
}
|
||||
|
||||
protected NodePermissionAssessor createAssessor(Authority authority)
|
||||
{
|
||||
return new NodePermissionAssessor(nodeService, permissionService, authority, nodesCache);
|
||||
}
|
||||
|
||||
FilteringResultSet acceleratedNodeSelection(QueryOptions options, DBQuery dbQuery, NodePermissionAssessor permissionAssessor)
|
||||
{
|
||||
// get list of stores from database
|
||||
stores = nodeDAO.getStores();
|
||||
|
||||
List<Node> nodes = new ArrayList<>();
|
||||
int requiredNodes = computeRequiredNodesCount(options);
|
||||
|
||||
logger.debug("- query sent to the database");
|
||||
template.select(pickQueryTemplate(options, dbQuery), dbQuery, new ResultHandler<Node>()
|
||||
{
|
||||
@Override
|
||||
public void handleResult(ResultContext<? extends Node> context)
|
||||
{
|
||||
if (!maxPermissionCheckEnabled && nodes.size() >= requiredNodes)
|
||||
{
|
||||
context.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
Node node = context.getResultObject();
|
||||
addStoreInfo(node);
|
||||
|
||||
boolean shouldCache = shouldCache(options, nodes, requiredNodes);
|
||||
if(shouldCache)
|
||||
{
|
||||
logger.debug("- selected node "+nodes.size()+": "+node.getUuid()+" "+node.getId());
|
||||
nodesCache.setValue(node.getId(), node);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug("- skipped node "+nodes.size()+": "+node.getUuid()+" "+node.getId());
|
||||
}
|
||||
|
||||
if (permissionAssessor.isIncluded(node))
|
||||
{
|
||||
if (nodes.size() > requiredNodes)
|
||||
{
|
||||
nodes.add(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
nodes.add(shouldCache ? node : null);
|
||||
}
|
||||
}
|
||||
|
||||
if (permissionAssessor.shouldQuitChecks())
|
||||
{
|
||||
context.stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldCache(QueryOptions options, List<Node> nodes, int requiredNodes)
|
||||
{
|
||||
if (nodes.size() > requiredNodes)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nodes.size() >= options.getSkipCount();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
int numberFound = nodes.size();
|
||||
nodes.removeAll(Collections.singleton(null));
|
||||
|
||||
DBResultSet rs = createResultSet(options, nodes, numberFound);
|
||||
FilteringResultSet frs = new FilteringResultSet(rs, formInclusionMask(nodes));
|
||||
frs.setResultSetMetaData(new SimpleResultSetMetaData(LimitBy.UNLIMITED, PermissionEvaluationMode.EAGER, rs.getResultSetMetaData().getSearchParameters()));
|
||||
|
||||
logger.debug("- query is completed, "+nodes.size()+" nodes loaded");
|
||||
return frs;
|
||||
}
|
||||
|
||||
private DBResultSet createResultSet(QueryOptions options, List<Node> nodes, int numberFound)
|
||||
{
|
||||
DBResultSet dbResultSet = new DBResultSet(options.getAsSearchParmeters(), nodes, nodeDAO, nodeService, tenantService, Integer.MAX_VALUE);
|
||||
dbResultSet.setNumberFound(numberFound);
|
||||
return dbResultSet;
|
||||
}
|
||||
|
||||
private int computeRequiredNodesCount(QueryOptions options)
|
||||
{
|
||||
int maxItems = options.getMaxItems();
|
||||
if (maxItems == -1 || maxItems == Integer.MAX_VALUE)
|
||||
{
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
return maxItems + options.getSkipCount() + 1;
|
||||
}
|
||||
|
||||
private BitSet formInclusionMask(List<Node> nodes)
|
||||
{
|
||||
BitSet inclusionMask = new BitSet(nodes.size());
|
||||
for (int i=0; i < nodes.size(); i++)
|
||||
{
|
||||
inclusionMask.set(i, true);
|
||||
}
|
||||
return inclusionMask;
|
||||
}
|
||||
|
||||
|
||||
private QueryEngineResults asQueryEngineResults(ResultSet paged)
|
||||
{
|
||||
HashSet<String> key = new HashSet<>();
|
||||
key.add("");
|
||||
Map<Set<String>, ResultSet> answer = new HashMap<>();
|
||||
answer.put(key, paged);
|
||||
|
||||
return new QueryEngineResults(answer);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.search.impl.querymodel.QueryEngine#getQueryModelFactory()
|
||||
*/
|
||||
@Override
|
||||
public QueryModelFactory getQueryModelFactory()
|
||||
{
|
||||
return new DBQueryModelFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection of nodes cache for clean-up and warm up when required
|
||||
* @param cache The node cache to set
|
||||
*/
|
||||
public void setNodesCache(SimpleCache<Serializable, Serializable> cache)
|
||||
{
|
||||
this.nodesCache = new EntityLookupCache<>(
|
||||
cache,
|
||||
CACHE_REGION_NODES,
|
||||
new ReadonlyLocalCallbackDAO());
|
||||
}
|
||||
|
||||
void setNodesCache(EntityLookupCache<Long, Node, NodeRef> nodesCache)
|
||||
{
|
||||
this.nodesCache = nodesCache;
|
||||
}
|
||||
|
||||
private class ReadonlyLocalCallbackDAO extends EntityLookupCallbackDAOAdaptor<Long, Node, NodeRef>
|
||||
{
|
||||
@Override
|
||||
public Pair<Long, Node> createValue(Node value)
|
||||
{
|
||||
throw new UnsupportedOperationException("Node creation is done externally: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Long, Node> findByKey(Long nodeId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeRef getValueKey(Node value)
|
||||
{
|
||||
return value.getNodeRef();
|
||||
}
|
||||
}
|
||||
|
||||
private void addStoreInfo(Node node)
|
||||
{
|
||||
StoreEntity storeEntity = node.getStore();
|
||||
logger.debug("Adding store info for store id " + storeEntity.getId());
|
||||
for (Pair<Long, StoreRef> storeRefPair : stores)
|
||||
{
|
||||
if (Objects.equals(storeEntity.getId(), storeRefPair.getFirst()))
|
||||
{
|
||||
StoreRef storeRef = storeRefPair.getSecond();
|
||||
storeEntity.setIdentifier(storeRef.getIdentifier());
|
||||
storeEntity.setProtocol(storeRef.getProtocol());
|
||||
logger.debug("Added store info" + storeEntity.toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.repo.search.impl.querymodel.impl.db;
|
||||
|
||||
import static org.alfresco.repo.domain.node.AbstractNodeDAOImpl.CACHE_REGION_NODES;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.concurrent.NotThreadSafe;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.admin.patch.OptionalPatchApplicationCheckBootstrapBean;
|
||||
import org.alfresco.repo.cache.SimpleCache;
|
||||
import org.alfresco.repo.cache.lookup.EntityLookupCache;
|
||||
import org.alfresco.repo.cache.lookup.EntityLookupCache.EntityLookupCallbackDAOAdaptor;
|
||||
import org.alfresco.repo.domain.node.Node;
|
||||
import org.alfresco.repo.domain.node.NodeDAO;
|
||||
import org.alfresco.repo.domain.permissions.AclCrudDAO;
|
||||
import org.alfresco.repo.domain.permissions.Authority;
|
||||
import org.alfresco.repo.domain.qname.QNameDAO;
|
||||
import org.alfresco.repo.search.SimpleResultSetMetaData;
|
||||
import org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet;
|
||||
import org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext;
|
||||
import org.alfresco.repo.search.impl.querymodel.Query;
|
||||
import org.alfresco.repo.search.impl.querymodel.QueryEngine;
|
||||
import org.alfresco.repo.search.impl.querymodel.QueryEngineResults;
|
||||
import org.alfresco.repo.search.impl.querymodel.QueryModelException;
|
||||
import org.alfresco.repo.search.impl.querymodel.QueryModelFactory;
|
||||
import org.alfresco.repo.search.impl.querymodel.QueryOptions;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.permissions.impl.acegi.FilteringResultSet;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.LimitBy;
|
||||
import org.alfresco.service.cmr.search.PermissionEvaluationMode;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.ibatis.session.ResultContext;
|
||||
import org.apache.ibatis.session.ResultHandler;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
|
||||
/**
|
||||
* @author Andy
|
||||
*/
|
||||
@NotThreadSafe
|
||||
public class DBQueryEngine implements QueryEngine
|
||||
{
|
||||
protected static final Log logger = LogFactory.getLog(DBQueryEngine.class);
|
||||
|
||||
protected static final String SELECT_BY_DYNAMIC_QUERY = "alfresco.metadata.query.select_byDynamicQuery";
|
||||
|
||||
protected SqlSessionTemplate template;
|
||||
|
||||
protected QNameDAO qnameDAO;
|
||||
|
||||
private NodeDAO nodeDAO;
|
||||
|
||||
protected DictionaryService dictionaryService;
|
||||
|
||||
protected NamespaceService namespaceService;
|
||||
|
||||
protected NodeService nodeService;
|
||||
|
||||
private TenantService tenantService;
|
||||
|
||||
private OptionalPatchApplicationCheckBootstrapBean metadataIndexCheck2;
|
||||
|
||||
protected PermissionService permissionService;
|
||||
|
||||
private int maxPermissionChecks;
|
||||
|
||||
private long maxPermissionCheckTimeMillis;
|
||||
|
||||
protected EntityLookupCache<Long, Node, NodeRef> nodesCache;
|
||||
|
||||
AclCrudDAO aclCrudDAO;
|
||||
|
||||
public void setAclCrudDAO(AclCrudDAO aclCrudDAO)
|
||||
{
|
||||
this.aclCrudDAO = aclCrudDAO;
|
||||
}
|
||||
|
||||
public void setMaxPermissionChecks(int maxPermissionChecks)
|
||||
{
|
||||
this.maxPermissionChecks = maxPermissionChecks;
|
||||
}
|
||||
|
||||
public void setMaxPermissionCheckTimeMillis(long maxPermissionCheckTimeMillis)
|
||||
{
|
||||
this.maxPermissionCheckTimeMillis = maxPermissionCheckTimeMillis;
|
||||
}
|
||||
|
||||
public void setTemplate(SqlSessionTemplate template)
|
||||
{
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
public void setMetadataIndexCheck2(OptionalPatchApplicationCheckBootstrapBean metadataIndexCheck2)
|
||||
{
|
||||
this.metadataIndexCheck2 = metadataIndexCheck2;
|
||||
}
|
||||
|
||||
public void setTenantService(TenantService tenantService)
|
||||
{
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
|
||||
public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate)
|
||||
{
|
||||
this.template = sqlSessionTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param qnameDAO
|
||||
* the qnameDAO to set
|
||||
*/
|
||||
public void setQnameDAO(QNameDAO qnameDAO)
|
||||
{
|
||||
this.qnameDAO = qnameDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dictionaryService
|
||||
* the dictionaryService to set
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namespaceService
|
||||
* the namespaceService to set
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService the nodeService to set
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeDAO the nodeDAO to set
|
||||
*/
|
||||
public void setNodeDAO(NodeDAO nodeDAO)
|
||||
{
|
||||
this.nodeDAO = nodeDAO;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* org.alfresco.repo.search.impl.querymodel.QueryEngine#executeQuery(org.alfresco.repo.search.impl.querymodel.Query,
|
||||
* org.alfresco.repo.search.impl.querymodel.QueryOptions,
|
||||
* org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext)
|
||||
*/
|
||||
@Override
|
||||
public QueryEngineResults executeQuery(Query query, QueryOptions options, FunctionEvaluationContext functionContext)
|
||||
{
|
||||
long start = 0;
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
start = System.currentTimeMillis();
|
||||
logger.debug("Query request received");
|
||||
}
|
||||
|
||||
Set<String> selectorGroup = null;
|
||||
if (query.getSource() != null)
|
||||
{
|
||||
List<Set<String>> selectorGroups = query.getSource().getSelectorGroups(functionContext);
|
||||
|
||||
if (selectorGroups.size() == 0)
|
||||
{
|
||||
throw new QueryModelException("No selectors");
|
||||
}
|
||||
|
||||
if (selectorGroups.size() > 1)
|
||||
{
|
||||
throw new QueryModelException("Advanced join is not supported");
|
||||
}
|
||||
|
||||
selectorGroup = selectorGroups.get(0);
|
||||
}
|
||||
|
||||
DBQuery dbQuery = (DBQuery)query;
|
||||
|
||||
if (options.getStores().size() > 1)
|
||||
{
|
||||
throw new QueryModelException("Multi-store queries are not supported");
|
||||
}
|
||||
|
||||
// MT
|
||||
StoreRef storeRef = options.getStores().get(0);
|
||||
storeRef = storeRef != null ? tenantService.getName(storeRef) : null;
|
||||
|
||||
Pair<Long, StoreRef> store = nodeDAO.getStore(storeRef);
|
||||
if (store == null)
|
||||
{
|
||||
throw new QueryModelException("Unknown store: "+storeRef);
|
||||
}
|
||||
dbQuery.setStoreId(store.getFirst());
|
||||
Pair<Long, QName> sysDeletedType = qnameDAO.getQName(ContentModel.TYPE_DELETED);
|
||||
if (sysDeletedType == null)
|
||||
{
|
||||
dbQuery.setSysDeletedType(-1L);
|
||||
}
|
||||
else
|
||||
{
|
||||
dbQuery.setSysDeletedType(sysDeletedType.getFirst());
|
||||
}
|
||||
|
||||
Long sinceTxId = options.getSinceTxId();
|
||||
if (sinceTxId == null)
|
||||
{
|
||||
// By default, return search results for all transactions.
|
||||
sinceTxId = -1L;
|
||||
}
|
||||
dbQuery.setSinceTxId(sinceTxId);
|
||||
|
||||
logger.debug("- query is being prepared");
|
||||
dbQuery.prepare(namespaceService, dictionaryService, qnameDAO, nodeDAO, tenantService, selectorGroup,
|
||||
null, functionContext, metadataIndexCheck2.getPatchApplied());
|
||||
|
||||
ResultSet resultSet;
|
||||
resultSet = selectNodesWithPermissions(options, dbQuery);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
long ms = System.currentTimeMillis() - start;
|
||||
logger.debug("Selected " + resultSet.length() + " nodes with permission resolution in "+ms+" ms");
|
||||
}
|
||||
return asQueryEngineResults(resultSet);
|
||||
}
|
||||
|
||||
protected String pickQueryTemplate(QueryOptions options, DBQuery dbQuery)
|
||||
{
|
||||
logger.debug("- using standard table for the query");
|
||||
return SELECT_BY_DYNAMIC_QUERY;
|
||||
}
|
||||
|
||||
private ResultSet selectNodesWithPermissions(QueryOptions options, DBQuery dbQuery)
|
||||
{
|
||||
Authority authority = aclCrudDAO.getAuthority(AuthenticationUtil.getRunAsUser());
|
||||
|
||||
NodePermissionAssessor permissionAssessor = createAssessor(authority);
|
||||
int maxPermsChecks = options.getMaxPermissionChecks() < 0 ? maxPermissionChecks : options.getMaxPermissionChecks();
|
||||
long maxPermCheckTimeMillis = options.getMaxPermissionCheckTimeMillis() < 0
|
||||
? maxPermissionCheckTimeMillis
|
||||
: options.getMaxPermissionCheckTimeMillis();
|
||||
permissionAssessor.setMaxPermissionChecks(maxPermsChecks);
|
||||
permissionAssessor.setMaxPermissionCheckTimeMillis(maxPermCheckTimeMillis);
|
||||
|
||||
FilteringResultSet resultSet = acceleratedNodeSelection(options, dbQuery, permissionAssessor);
|
||||
|
||||
PagingLuceneResultSet plrs = new PagingLuceneResultSet(resultSet, options.getAsSearchParmeters(), nodeService);
|
||||
plrs.setTrimmedResultSet(true);
|
||||
return plrs;
|
||||
}
|
||||
|
||||
protected NodePermissionAssessor createAssessor(Authority authority)
|
||||
{
|
||||
return new NodePermissionAssessor(nodeService, permissionService, authority, nodesCache);
|
||||
}
|
||||
|
||||
FilteringResultSet acceleratedNodeSelection(QueryOptions options, DBQuery dbQuery, NodePermissionAssessor permissionAssessor)
|
||||
{
|
||||
List<Node> nodes = new ArrayList<>();
|
||||
int requiredNodes = computeRequiredNodesCount(options);
|
||||
|
||||
logger.debug("- query sent to the database");
|
||||
template.select(pickQueryTemplate(options, dbQuery), dbQuery, new ResultHandler<Node>()
|
||||
{
|
||||
@Override
|
||||
public void handleResult(ResultContext<? extends Node> context)
|
||||
{
|
||||
doHandleResult(permissionAssessor, nodes, requiredNodes, context);
|
||||
}
|
||||
|
||||
private void doHandleResult(NodePermissionAssessor permissionAssessor, List<Node> nodes,
|
||||
int requiredNodes, ResultContext<? extends Node> context)
|
||||
{
|
||||
if (nodes.size() >= requiredNodes)
|
||||
{
|
||||
context.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
Node node = context.getResultObject();
|
||||
|
||||
boolean shouldCache = nodes.size() >= options.getSkipCount();
|
||||
if(shouldCache)
|
||||
{
|
||||
logger.debug("- selected node "+nodes.size()+": "+node.getUuid()+" "+node.getId());
|
||||
nodesCache.setValue(node.getId(), node);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug("- skipped node "+nodes.size()+": "+node.getUuid()+" "+node.getId());
|
||||
}
|
||||
|
||||
if (permissionAssessor.isIncluded(node))
|
||||
{
|
||||
nodes.add(shouldCache ? node : null);
|
||||
}
|
||||
|
||||
if (permissionAssessor.shouldQuitChecks())
|
||||
{
|
||||
context.stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
int numberFound = nodes.size();
|
||||
nodes.removeAll(Collections.singleton(null));
|
||||
|
||||
DBResultSet rs = createResultSet(options, nodes, numberFound);
|
||||
FilteringResultSet frs = new FilteringResultSet(rs, formInclusionMask(nodes));
|
||||
frs.setResultSetMetaData(new SimpleResultSetMetaData(LimitBy.UNLIMITED, PermissionEvaluationMode.EAGER, rs.getResultSetMetaData().getSearchParameters()));
|
||||
|
||||
logger.debug("- query is completed, "+nodes.size()+" nodes loaded");
|
||||
return frs;
|
||||
}
|
||||
|
||||
private DBResultSet createResultSet(QueryOptions options, List<Node> nodes, int numberFound)
|
||||
{
|
||||
DBResultSet dbResultSet = new DBResultSet(options.getAsSearchParmeters(), nodes, nodeDAO, nodeService, tenantService, Integer.MAX_VALUE);
|
||||
dbResultSet.setNumberFound(numberFound);
|
||||
return dbResultSet;
|
||||
}
|
||||
|
||||
private int computeRequiredNodesCount(QueryOptions options)
|
||||
{
|
||||
int maxItems = options.getMaxItems();
|
||||
if (maxItems == -1 || maxItems == Integer.MAX_VALUE)
|
||||
{
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
return maxItems + options.getSkipCount() + 1;
|
||||
}
|
||||
|
||||
private BitSet formInclusionMask(List<Node> nodes)
|
||||
{
|
||||
BitSet inclusionMask = new BitSet(nodes.size());
|
||||
for (int i=0; i < nodes.size(); i++)
|
||||
{
|
||||
inclusionMask.set(i, true);
|
||||
}
|
||||
return inclusionMask;
|
||||
}
|
||||
|
||||
|
||||
private QueryEngineResults asQueryEngineResults(ResultSet paged)
|
||||
{
|
||||
HashSet<String> key = new HashSet<>();
|
||||
key.add("");
|
||||
Map<Set<String>, ResultSet> answer = new HashMap<>();
|
||||
answer.put(key, paged);
|
||||
|
||||
return new QueryEngineResults(answer);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.search.impl.querymodel.QueryEngine#getQueryModelFactory()
|
||||
*/
|
||||
@Override
|
||||
public QueryModelFactory getQueryModelFactory()
|
||||
{
|
||||
return new DBQueryModelFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection of nodes cache for clean-up and warm up when required
|
||||
* @param cache The node cache to set
|
||||
*/
|
||||
public void setNodesCache(SimpleCache<Serializable, Serializable> cache)
|
||||
{
|
||||
this.nodesCache = new EntityLookupCache<>(
|
||||
cache,
|
||||
CACHE_REGION_NODES,
|
||||
new ReadonlyLocalCallbackDAO());
|
||||
}
|
||||
|
||||
void setNodesCache(EntityLookupCache<Long, Node, NodeRef> nodesCache)
|
||||
{
|
||||
this.nodesCache = nodesCache;
|
||||
}
|
||||
|
||||
private class ReadonlyLocalCallbackDAO extends EntityLookupCallbackDAOAdaptor<Long, Node, NodeRef>
|
||||
{
|
||||
@Override
|
||||
public Pair<Long, Node> createValue(Node value)
|
||||
{
|
||||
throw new UnsupportedOperationException("Node creation is done externally: " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Long, Node> findByKey(Long nodeId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeRef getValueKey(Node value)
|
||||
{
|
||||
return value.getNodeRef();
|
||||
}
|
||||
}
|
||||
}
|
@@ -41,13 +41,9 @@ import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
public class NodePermissionAssessor
|
||||
{
|
||||
protected static final Log logger = LogFactory.getLog(NodePermissionAssessor.class);
|
||||
|
||||
private final boolean isSystemReading;
|
||||
private final boolean isAdminReading;
|
||||
private final boolean isNullReading;
|
||||
@@ -142,31 +138,24 @@ public class NodePermissionAssessor
|
||||
|
||||
public void setMaxPermissionChecks(int maxPermissionChecks)
|
||||
{
|
||||
if (maxPermissionChecks == Integer.MAX_VALUE)
|
||||
{
|
||||
this.maxPermissionChecks = maxPermissionChecks;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.maxPermissionChecks = maxPermissionChecks + 1;
|
||||
}
|
||||
this.maxPermissionChecks = maxPermissionChecks;
|
||||
}
|
||||
|
||||
public boolean shouldQuitChecks()
|
||||
{
|
||||
boolean result = false;
|
||||
|
||||
if (checksPerformed >= maxPermissionChecks)
|
||||
{
|
||||
logger.warn("Maximum permission checks exceeded (" + maxPermissionChecks + ")");
|
||||
return true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
|
||||
if ((System.currentTimeMillis() - startTime) >= maxPermissionCheckTimeMillis)
|
||||
{
|
||||
logger.warn("Maximum permission checks time exceeded (" + maxPermissionCheckTimeMillis + ")");
|
||||
return true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setMaxPermissionCheckTimeMillis(long maxPermissionCheckTimeMillis)
|
||||
|
@@ -29,29 +29,26 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.repo.search.QueryParserException;
|
||||
import org.apache.commons.httpclient.Header;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
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.StringRequestEntity;
|
||||
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.JSONObject;
|
||||
import org.json.JSONTokener;
|
||||
|
||||
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;
|
||||
|
||||
// Constants copied from org.apache.solr.common.params.HighlightParams (solr-solrj:1.4.1)
|
||||
@@ -82,13 +79,11 @@ public abstract class AbstractSolrQueryHTTPClient
|
||||
public static final String HIGHLIGHT_PARAMS_SLOP = HIGHLIGHT_PARAMS_HIGHLIGHT + "." + HIGHLIGHT_PARAMS_REGEX + ".slop";
|
||||
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";
|
||||
|
||||
/** List of SOLR Exceptions that should be returning HTTP 501 status code in Remote API. */
|
||||
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
|
||||
protected JSONObject postQuery(HttpClient httpClient, String url, JSONObject body) throws UnsupportedEncodingException,
|
||||
IOException, HttpException, URIException, JSONException
|
||||
{
|
||||
PostMethod post = createNewPostMethod(url);
|
||||
PostMethod post = new PostMethod(url);
|
||||
if (body.toString().length() > DEFAULT_SAVEPOST_BUFFER)
|
||||
{
|
||||
post.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, true);
|
||||
@@ -108,33 +103,9 @@ public abstract class AbstractSolrQueryHTTPClient
|
||||
httpClient.executeMethod(post);
|
||||
}
|
||||
}
|
||||
String responseBodyStr = post.getResponseBodyAsString();
|
||||
if (post.getStatusCode() != HttpServletResponse.SC_OK)
|
||||
{
|
||||
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);
|
||||
throw new QueryParserException("Request failed " + post.getStatusCode() + " " + url.toString());
|
||||
}
|
||||
|
||||
Reader reader = new BufferedReader(new InputStreamReader(post.getResponseBodyAsStream(), post.getResponseCharSet()));
|
||||
@@ -147,10 +118,4 @@ public abstract class AbstractSolrQueryHTTPClient
|
||||
post.releaseConnection();
|
||||
}
|
||||
}
|
||||
|
||||
/** Helper method that can be overridden by unit tests. */
|
||||
protected PostMethod createNewPostMethod(String url)
|
||||
{
|
||||
return new PostMethod(url);
|
||||
}
|
||||
}
|
||||
|
@@ -456,20 +456,12 @@ public class RepoUsageComponentImpl implements RepoUsageComponent
|
||||
}
|
||||
}
|
||||
|
||||
// Check the license expiration
|
||||
// Check the license expiry
|
||||
Long licenseExpiryDate = restrictions.getLicenseExpiryDate();
|
||||
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 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)
|
||||
if (remainingDays <= 0)
|
||||
{
|
||||
errors.add(I18NUtil.getMessage("system.usage.err.limit_license_expired"));
|
||||
level = RepoUsageLevel.LOCKED_DOWN;
|
||||
|
@@ -322,7 +322,7 @@ public class CombinedConfig
|
||||
{
|
||||
combinedTransformers.remove(indexToRemove);
|
||||
// this may also require the current index i to be changed so we don't skip one.
|
||||
if (i >= indexToRemove)
|
||||
if (i <= indexToRemove)
|
||||
{
|
||||
i--;
|
||||
}
|
||||
|
@@ -71,34 +71,4 @@ public class DateUtil
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -266,4 +266,4 @@
|
||||
<property name="registry" ref="auditModel.extractorRegistry" />
|
||||
<property name="cmisConnector" ref="CMISConnector" />
|
||||
</bean>
|
||||
</beans>
|
||||
</beans>
|
@@ -178,6 +178,14 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="htmlRenderingEngine"
|
||||
class="org.alfresco.repo.rendition.executer.HTMLRenderingEngine"
|
||||
parent="baseRenderingAction">
|
||||
<property name="tikaConfig">
|
||||
<ref bean="tikaConfig"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="compositeRenderingEngine"
|
||||
class="org.alfresco.repo.rendition.executer.CompositeRenderingEngine"
|
||||
parent="baseRenderingAction">
|
||||
|
@@ -9,9 +9,7 @@
|
||||
{"name": "allowEnlargement", "value": true},
|
||||
{"name": "maintainAspectRatio", "value": true},
|
||||
{"name": "autoOrient", "value": true},
|
||||
{"name": "thumbnail", "value": true},
|
||||
{"name": "startPage", "value": "0"},
|
||||
{"name": "endPage", "value": "0"}
|
||||
{"name": "thumbnail", "value": true}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -23,9 +21,7 @@
|
||||
{"name": "allowEnlargement", "value": false},
|
||||
{"name": "maintainAspectRatio", "value": true},
|
||||
{"name": "autoOrient", "value": true},
|
||||
{"name": "thumbnail", "value": true},
|
||||
{"name": "startPage", "value": "0"},
|
||||
{"name": "endPage", "value": "0"}
|
||||
{"name": "thumbnail", "value": true}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -37,9 +33,7 @@
|
||||
{"name": "allowEnlargement", "value": false},
|
||||
{"name": "maintainAspectRatio", "value": true},
|
||||
{"name": "autoOrient", "value": true},
|
||||
{"name": "thumbnail", "value": true},
|
||||
{"name": "startPage", "value": "0"},
|
||||
{"name": "endPage", "value": "0"}
|
||||
{"name": "thumbnail", "value": true}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -51,9 +45,7 @@
|
||||
{"name": "allowEnlargement", "value": false},
|
||||
{"name": "maintainAspectRatio", "value": true},
|
||||
{"name": "autoOrient", "value": true},
|
||||
{"name": "thumbnail", "value": true},
|
||||
{"name": "startPage", "value": "0"},
|
||||
{"name": "endPage", "value": "0"}
|
||||
{"name": "thumbnail", "value": true}
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -65,9 +57,7 @@
|
||||
{"name": "allowEnlargement", "value": false},
|
||||
{"name": "maintainAspectRatio", "value": true},
|
||||
{"name": "autoOrient", "value": true},
|
||||
{"name": "thumbnail", "value": true},
|
||||
{"name": "startPage", "value": "0"},
|
||||
{"name": "endPage", "value": "0"}
|
||||
{"name": "thumbnail", "value": true}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@@ -3,7 +3,7 @@
|
||||
repository.name=Main Repository
|
||||
|
||||
# Schema number
|
||||
version.schema=14200
|
||||
version.schema=15000
|
||||
|
||||
# Directory configuration
|
||||
|
||||
@@ -153,7 +153,6 @@ system.cache.parentAssocs.limitFactor=8
|
||||
system.acl.maxPermissionCheckTimeMillis=10000
|
||||
# The maximum number of search results to perform permission checks against
|
||||
system.acl.maxPermissionChecks=1000
|
||||
system.acl.maxPermissionCheckEnabled=false
|
||||
|
||||
# The maximum number of filefolder list results
|
||||
system.filefolderservice.defaultListMaxResults=5000
|
||||
@@ -221,6 +220,8 @@ system.content.deletionFailureAction=IGNORE
|
||||
# The CRON expression to trigger the deletion of resources associated with orphaned content.
|
||||
system.content.orphanCleanup.cronExpression=0 0 4 * * ?
|
||||
|
||||
# The CRON expression to trigger the cleanup of deleted nodes and dangling transactions that are old enough
|
||||
system.nodeServiceCleanup.cronExpression=0 0 21 * * ?
|
||||
|
||||
# When transforming archive files (.zip etc) into text representations (such as
|
||||
# for full text indexing), should the files within the archive be processed too?
|
||||
@@ -481,7 +482,7 @@ system.thumbnail.definition.default.timeoutMs=-1
|
||||
system.thumbnail.definition.default.readLimitTimeMs=-1
|
||||
system.thumbnail.definition.default.maxSourceSizeKBytes=-1
|
||||
system.thumbnail.definition.default.readLimitKBytes=-1
|
||||
system.thumbnail.definition.default.pageLimit=-1
|
||||
system.thumbnail.definition.default.pageLimit=1
|
||||
system.thumbnail.definition.default.maxPages=-1
|
||||
|
||||
# Max mimetype sizes to create thumbnail icons
|
||||
@@ -1207,7 +1208,7 @@ repo.event2.filter.nodeAspects=sys:*
|
||||
repo.event2.filter.childAssocTypes=rn:rendition
|
||||
# Comma separated list of users which should be excluded
|
||||
# Note: username's case-sensitivity depends on the {user.name.caseSensitive} setting
|
||||
repo.event2.filter.users=System, null
|
||||
repo.event2.filter.users=
|
||||
# Topic name
|
||||
repo.event2.topic.endpoint=amqp:topic:alfresco.repo.event2
|
||||
# Thread pool for async enqueue of repo events
|
||||
@@ -1237,4 +1238,4 @@ system.new-node-transaction-indexes.ignored=true
|
||||
|
||||
# Allows the configuration of maximum limits of the temp files to be deleted or the maximum time allowed to run for the job
|
||||
system.tempFileCleaner.maxFilesToDelete=
|
||||
system.tempFileCleaner.maxTimeToRun=
|
||||
system.tempFileCleaner.maxTimeToRun=
|
||||
|
@@ -107,7 +107,7 @@
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="nodeServiceCleanupTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
|
||||
<property name="cronExpression" value="0 0 21 * * ?"/>
|
||||
<property name="cronExpression" value="${system.nodeServiceCleanup.cronExpression}"/>
|
||||
<property name="startDelay" value="${system.cronJob.startDelayMilliseconds}"/>
|
||||
<property name="jobDetail">
|
||||
<bean class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
|
||||
|
@@ -126,9 +126,6 @@
|
||||
<property name="maxPermissionCheckTimeMillis">
|
||||
<value>${system.acl.maxPermissionCheckTimeMillis}</value>
|
||||
</property>
|
||||
<property name="maxPermissionCheckEnabled">
|
||||
<value>${system.acl.maxPermissionCheckEnabled}</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="search.dbQueryEngine" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
|
@@ -117,6 +117,31 @@
|
||||
"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",
|
||||
"transformerPipeline" : [
|
||||
@@ -173,66 +198,42 @@
|
||||
"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",
|
||||
"transformerPipeline" : [
|
||||
{"transformerName": "libreoffice", "targetMediaType": "application/pdf"},
|
||||
{"transformerName": "libreofficeToPdf", "targetMediaType": "application/pdf"},
|
||||
{"transformerName": "PdfBox"}
|
||||
],
|
||||
"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": [
|
||||
"pdfboxOptions"
|
||||
@@ -262,32 +263,6 @@
|
||||
"transformOptions": [
|
||||
"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"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@@ -82,9 +82,7 @@ import org.junit.runners.Suite;
|
||||
org.alfresco.repo.node.db.DbNodeServiceImplTest.class,
|
||||
|
||||
org.alfresco.repo.node.cleanup.TransactionCleanupTest.class,
|
||||
org.alfresco.repo.security.person.GetPeopleCannedQueryTest.class,
|
||||
|
||||
org.alfresco.repo.domain.schema.script.DeleteNotExistsExecutorTest.class
|
||||
org.alfresco.repo.security.person.GetPeopleCannedQueryTest.class
|
||||
})
|
||||
public class AllDBTestsTestSuite
|
||||
{
|
||||
|
@@ -43,10 +43,14 @@ import org.junit.runners.Suite;
|
||||
org.alfresco.encryption.KeyStoreKeyProviderTest.class,
|
||||
org.alfresco.filesys.config.ServerConfigurationBeanTest.class,
|
||||
org.alfresco.filesys.repo.rules.ShuffleTest.class,
|
||||
org.alfresco.opencmis.AlfrescoCmisExceptionInterceptorTest.class,
|
||||
org.alfresco.repo.admin.Log4JHierarchyInitTest.class,
|
||||
org.alfresco.repo.attributes.PropTablesCleanupJobTest.class,
|
||||
org.alfresco.repo.cache.AbstractCacheFactoryTest.class,
|
||||
org.alfresco.repo.cache.DefaultCacheFactoryTest.class,
|
||||
org.alfresco.repo.cache.DefaultSimpleCacheTest.class,
|
||||
org.alfresco.repo.cache.InMemoryCacheStatisticsTest.class,
|
||||
org.alfresco.repo.cache.TransactionStatsTest.class,
|
||||
org.alfresco.repo.cache.lookup.EntityLookupCacheTest.class,
|
||||
org.alfresco.repo.calendar.CalendarHelpersTest.class,
|
||||
org.alfresco.repo.copy.CopyServiceImplUnitTest.class,
|
||||
@@ -56,13 +60,16 @@ import org.junit.runners.Suite;
|
||||
org.alfresco.repo.forms.processor.workflow.WorkflowFormProcessorTest.class,
|
||||
org.alfresco.repo.invitation.site.InviteSenderTest.class,
|
||||
org.alfresco.repo.invitation.site.InviteModeratedSenderTest.class,
|
||||
org.alfresco.repo.jscript.ScriptSearchTest.class,
|
||||
org.alfresco.repo.lock.LockUtilsTest.class,
|
||||
org.alfresco.repo.lock.mem.LockStoreImplTest.class,
|
||||
org.alfresco.repo.management.subsystems.CryptodocSwitchableApplicationContextFactoryTest.class,
|
||||
org.alfresco.repo.module.ModuleDetailsImplTest.class,
|
||||
org.alfresco.repo.module.ModuleVersionNumberTest.class,
|
||||
org.alfresco.repo.module.tool.ModuleManagementToolTest.class,
|
||||
org.alfresco.repo.module.tool.WarHelperImplTest.class,
|
||||
org.alfresco.repo.module.tool.ModuleServiceImplTest.class,
|
||||
org.alfresco.repo.node.integrity.IntegrityEventTest.class,
|
||||
org.alfresco.repo.policy.MTPolicyComponentTest.class,
|
||||
org.alfresco.repo.policy.PolicyComponentTest.class,
|
||||
org.alfresco.repo.rendition.RenditionNodeManagerTest.class,
|
||||
@@ -70,6 +77,7 @@ import org.junit.runners.Suite;
|
||||
org.alfresco.repo.replication.ReplicationServiceImplTest.class,
|
||||
org.alfresco.repo.service.StoreRedirectorProxyFactoryTest.class,
|
||||
org.alfresco.repo.site.RoleComparatorImplTest.class,
|
||||
org.alfresco.repo.tenant.MultiTAdminServiceImplTest.class,
|
||||
org.alfresco.repo.thumbnail.ThumbnailServiceImplParameterTest.class,
|
||||
org.alfresco.repo.transfer.ContentChunkerImplTest.class,
|
||||
org.alfresco.repo.transfer.HttpClientTransmitterImplTest.class,
|
||||
@@ -110,18 +118,27 @@ import org.junit.runners.Suite;
|
||||
org.alfresco.util.schemacomp.validator.NameValidatorTest.class,
|
||||
org.alfresco.util.schemacomp.validator.SchemaVersionValidatorTest.class,
|
||||
org.alfresco.util.schemacomp.validator.TypeNameOnlyValidatorTest.class,
|
||||
org.alfresco.util.test.OmittedTestClassFinderUnitTest.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.querymodel.impl.db.DBQueryEngineTest.class,
|
||||
org.alfresco.repo.search.impl.querymodel.impl.db.NodePermissionAssessorLimitsTest.class,
|
||||
org.alfresco.repo.search.impl.querymodel.impl.db.NodePermissionAssessorPermissionsTest.class,
|
||||
org.alfresco.repo.search.impl.solr.DbOrIndexSwitchingQueryLanguageTest.class,
|
||||
org.alfresco.repo.search.impl.solr.SolrQueryHTTPClientTest.class,
|
||||
org.alfresco.repo.search.impl.solr.SolrSQLHttpClientTest.class,
|
||||
org.alfresco.repo.search.impl.solr.SolrStatsResultTest.class,
|
||||
org.alfresco.repo.search.impl.solr.SolrSQLJSONResultMetadataSetTest.class,
|
||||
org.alfresco.repo.search.impl.solr.facet.SolrFacetComparatorTest.class,
|
||||
org.alfresco.repo.search.impl.solr.facet.FacetQNameUtilsTest.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.solr.SOLRTrackingComponentUnitTest.class,
|
||||
org.alfresco.repo.security.authentication.CompositePasswordEncoderTest.class,
|
||||
org.alfresco.repo.security.authentication.PasswordHashingTest.class,
|
||||
org.alfresco.repo.security.authority.script.ScriptAuthorityService_RegExTest.class,
|
||||
org.alfresco.repo.security.permissions.PermissionCheckCollectionTest.class,
|
||||
org.alfresco.repo.security.sync.LDAPUserRegistryTest.class,
|
||||
org.alfresco.traitextender.TraitExtenderIntegrationTest.class,
|
||||
org.alfresco.traitextender.AJExtensionsCompileTest.class,
|
||||
|
||||
@@ -158,8 +175,12 @@ import org.junit.runners.Suite;
|
||||
org.alfresco.repo.action.ActionConditionImplTest.class,
|
||||
org.alfresco.repo.action.CompositeActionImplTest.class,
|
||||
org.alfresco.repo.action.CompositeActionConditionImplTest.class,
|
||||
org.alfresco.repo.action.executer.TransformActionExecuterTest.class,
|
||||
org.alfresco.repo.audit.AuditableAnnotationTest.class,
|
||||
org.alfresco.repo.audit.PropertyAuditFilterTest.class,
|
||||
org.alfresco.repo.audit.access.NodeChangeTest.class,
|
||||
org.alfresco.repo.content.LimitedStreamCopierTest.class,
|
||||
org.alfresco.repo.content.filestore.FileIOTest.class,
|
||||
org.alfresco.repo.content.filestore.SpoofedTextContentReaderTest.class,
|
||||
org.alfresco.repo.content.ContentDataTest.class,
|
||||
org.alfresco.service.cmr.repository.TransformationOptionLimitsTest.class,
|
||||
@@ -171,7 +192,9 @@ import org.junit.runners.Suite;
|
||||
org.alfresco.repo.content.caching.quota.UnlimitedQuotaStrategyTest.class,
|
||||
org.alfresco.repo.content.caching.CachingContentStoreTest.class,
|
||||
org.alfresco.repo.content.caching.ContentCacheImplTest.class,
|
||||
org.alfresco.repo.domain.permissions.FixedAclUpdaterUnitTest.class,
|
||||
org.alfresco.repo.domain.propval.PropertyTypeConverterTest.class,
|
||||
org.alfresco.repo.domain.schema.script.ScriptBundleExecutorImplTest.class,
|
||||
org.alfresco.repo.search.MLAnaysisModeExpansionTest.class,
|
||||
org.alfresco.repo.search.DocumentNavigatorTest.class,
|
||||
org.alfresco.util.NumericEncodingTest.class,
|
||||
@@ -180,6 +203,7 @@ import org.junit.runners.Suite;
|
||||
org.alfresco.repo.search.impl.parsers.FTSTest.class,
|
||||
org.alfresco.repo.security.authentication.AlfrescoSSLSocketFactoryTest.class,
|
||||
org.alfresco.repo.security.authentication.AuthorizationTest.class,
|
||||
org.alfresco.repo.security.permissions.PermissionCheckedCollectionTest.class,
|
||||
org.alfresco.repo.security.permissions.impl.acegi.FilteringResultSetTest.class,
|
||||
org.alfresco.repo.security.authentication.ChainingAuthenticationServiceTest.class,
|
||||
org.alfresco.repo.security.authentication.NameBasedUserNameGeneratorTest.class,
|
||||
@@ -187,9 +211,10 @@ import org.junit.runners.Suite;
|
||||
org.alfresco.repo.version.common.VersionHistoryImplTest.class,
|
||||
org.alfresco.repo.version.common.versionlabel.SerialVersionLabelPolicyTest.class,
|
||||
org.alfresco.repo.workflow.activiti.WorklfowObjectFactoryTest.class,
|
||||
org.alfresco.repo.workflow.activiti.properties.ActivitiPriorityPropertyHandlerTest.class,
|
||||
org.alfresco.repo.workflow.WorkflowSuiteContextShutdownTest.class,
|
||||
org.alfresco.repo.search.LuceneUtilsTest.class,
|
||||
|
||||
|
||||
org.alfresco.heartbeat.HBDataCollectorServiceImplTest.class,
|
||||
org.alfresco.heartbeat.jobs.LockingJobTest.class,
|
||||
org.alfresco.heartbeat.jobs.QuartzJobSchedulerTest.class,
|
||||
@@ -197,6 +222,7 @@ import org.junit.runners.Suite;
|
||||
org.alfresco.heartbeat.ConfigurationDataCollectorTest.class,
|
||||
org.alfresco.heartbeat.InfoDataCollectorTest.class,
|
||||
org.alfresco.heartbeat.ModelUsageDataCollectorTest.class,
|
||||
org.alfresco.heartbeat.SessionsUsageDataCollectorTest.class,
|
||||
org.alfresco.heartbeat.SystemUsageDataCollectorTest.class,
|
||||
|
||||
org.alfresco.util.BeanExtenderUnitTest.class,
|
||||
@@ -204,6 +230,7 @@ import org.junit.runners.Suite;
|
||||
org.alfresco.util.resource.HierarchicalResourceLoaderTest.class,
|
||||
org.alfresco.repo.events.ClientUtilTest.class,
|
||||
org.alfresco.repo.rendition2.RenditionService2Test.class,
|
||||
org.alfresco.repo.rendition2.TransformationOptionsConverterTest.class,
|
||||
org.alfresco.transform.client.registry.TransformServiceRegistryConfigTest.class,
|
||||
|
||||
org.alfresco.repo.event2.RepoEvent2UnitSuite.class
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -39,7 +39,7 @@ import org.junit.runners.Suite;
|
||||
@RunWith(Categories.class)
|
||||
@Categories.ExcludeCategory({DBTests.class, NonBuildTests.class})
|
||||
@Suite.SuiteClasses({
|
||||
|
||||
|
||||
// there is a test that runs for 184s and another one that runs for 40s
|
||||
org.alfresco.repo.attributes.AttributeServiceTest.class,
|
||||
|
||||
@@ -66,9 +66,7 @@ import org.junit.runners.Suite;
|
||||
org.alfresco.repo.content.RoutingContentStoreTest.class,
|
||||
|
||||
org.alfresco.encryption.EncryptionTests.class,
|
||||
org.alfresco.encryption.KeyStoreTests.class,
|
||||
|
||||
org.alfresco.repo.content.MimetypeMapContentTest.class
|
||||
org.alfresco.encryption.KeyStoreTests.class
|
||||
|
||||
// TODO REPO-2791 org.alfresco.repo.content.routing.StoreSelectorAspectContentStoreTest.class,
|
||||
})
|
||||
|
@@ -56,6 +56,7 @@ import org.junit.runners.Suite;
|
||||
// This test opens, closes and again opens the alfresco application context.
|
||||
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.XSLTRenderingEngineTest.class,
|
||||
org.alfresco.repo.replication.ReplicationServiceIntegrationTest.class,
|
||||
|
@@ -75,6 +75,7 @@ import org.junit.runners.Suite;
|
||||
org.alfresco.repo.site.SiteServiceImplTest.class,
|
||||
|
||||
// [classpath:alfresco/application-context.xml, classpath:scriptexec/script-exec-test.xml]
|
||||
org.alfresco.repo.domain.schema.script.DeleteNotExistsExecutorTest.class,
|
||||
org.alfresco.repo.domain.schema.script.ScriptExecutorImplIntegrationTest.class,
|
||||
org.alfresco.repo.domain.schema.script.ScriptBundleExecutorImplIntegrationTest.class,
|
||||
|
||||
|
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2018 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.messaging.camel;
|
||||
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.Produce;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests Camel components defined in the application's Spring context
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@Category(NeverRunsTests.class)
|
||||
@ContextConfiguration(locations = "/test-messaging-context.xml")
|
||||
public class CamelComponentsTest {
|
||||
@Autowired
|
||||
protected CamelContext camelContext;
|
||||
|
||||
@Produce("activemq:queue:alfresco.test")
|
||||
protected ProducerTemplate activemqTemplate;
|
||||
|
||||
@Produce("amqp:queue:alfresco.test")
|
||||
protected ProducerTemplate amqpTemplate;
|
||||
|
||||
@Produce("jms:queue:alfresco.test")
|
||||
protected ProducerTemplate jmsTemplate;
|
||||
|
||||
|
||||
@Test
|
||||
public void testActivemqComponent()
|
||||
{
|
||||
final String msg = "ping <activemq>";
|
||||
|
||||
activemqTemplate.sendBody(msg);
|
||||
|
||||
final Object reply = camelContext
|
||||
.createConsumerTemplate()
|
||||
.receiveBody("activemq:queue:alfresco.test", 2000);
|
||||
|
||||
assertEquals(msg, reply);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAmqpComponent()
|
||||
{
|
||||
final String msg = "ping <amqp>";
|
||||
|
||||
amqpTemplate.sendBody(msg);
|
||||
|
||||
final Object reply = camelContext
|
||||
.createConsumerTemplate()
|
||||
.receiveBody("amqp:queue:alfresco.test", 2000);
|
||||
|
||||
assertEquals(msg, reply);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJmsComponent()
|
||||
{
|
||||
final String msg = "ping <jms>";
|
||||
|
||||
jmsTemplate.sendBody(msg);
|
||||
|
||||
final Object reply = camelContext
|
||||
.createConsumerTemplate()
|
||||
.receiveBody("jms:queue:alfresco.test", 2000);
|
||||
|
||||
assertEquals(msg, reply);
|
||||
}
|
||||
}
|
@@ -27,12 +27,14 @@ package org.alfresco.messaging.camel;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.EndpointInject;
|
||||
import org.apache.camel.Produce;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
import org.apache.camel.component.mock.MockEndpoint;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -44,6 +46,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Ray Gauss II
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@Category(NeverRunsTests.class)
|
||||
@ContextConfiguration(locations = "/test-messaging-context.xml")
|
||||
public class CamelRoutesTest
|
||||
{
|
||||
@@ -61,76 +64,76 @@ public class CamelRoutesTest
|
||||
|
||||
@Produce("direct-vm:alfresco.test.1")
|
||||
protected ProducerTemplate template1;
|
||||
|
||||
|
||||
@Produce("direct-vm:alfresco.test.2")
|
||||
protected ProducerTemplate template2;
|
||||
|
||||
|
||||
@Produce("direct-vm:alfresco.default")
|
||||
protected ProducerTemplate template3;
|
||||
|
||||
|
||||
@Produce("direct-vm:alfresco.test.transacted")
|
||||
protected ProducerTemplate template4;
|
||||
|
||||
|
||||
@Autowired
|
||||
protected MockExceptionProcessor messagingExceptionProcessor;
|
||||
|
||||
|
||||
@Autowired
|
||||
protected MockConsumer mockConsumer;
|
||||
|
||||
|
||||
@Autowired
|
||||
protected MockExceptionThrowingConsumer mockExceptionThrowingConsumer;
|
||||
|
||||
@Test
|
||||
public void testMessageRouteXmlDefined() throws Exception {
|
||||
String expectedBody = "<matched.>";
|
||||
|
||||
|
||||
resultEndpoint1.expectedBodiesReceived(expectedBody);
|
||||
|
||||
|
||||
template1.sendBody(expectedBody);
|
||||
|
||||
|
||||
resultEndpoint1.assertIsSatisfied();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMessageRoutePackageDefined() throws Exception {
|
||||
String expectedBody = "<matched.>";
|
||||
|
||||
|
||||
resultEndpoint2.expectedBodiesReceived(expectedBody);
|
||||
|
||||
|
||||
template2.sendBody(expectedBody);
|
||||
|
||||
|
||||
resultEndpoint2.assertIsSatisfied();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMessageRouteXmlOverride() throws Exception {
|
||||
String expectedBody = "<matched.>";
|
||||
|
||||
|
||||
dlqEndpoint.expectedBodiesReceived(expectedBody);
|
||||
|
||||
|
||||
template3.sendBody(expectedBody);
|
||||
|
||||
|
||||
dlqEndpoint.assertIsSatisfied();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testTransactedRoute() throws Exception {
|
||||
String expectedBody = "<matched.>";
|
||||
|
||||
|
||||
template4.sendBody(expectedBody);
|
||||
|
||||
|
||||
// Wait for Camel and ActiveMQ to process
|
||||
Thread.sleep(2000);
|
||||
|
||||
|
||||
// Test that our exception processor received the error
|
||||
assertNotNull(messagingExceptionProcessor.getLastError());
|
||||
assertTrue(messagingExceptionProcessor.getLastError().getClass().equals(
|
||||
IllegalArgumentException.class));
|
||||
|
||||
|
||||
// Check that an error was thrown the first time
|
||||
assertTrue(mockExceptionThrowingConsumer.isErrorThrown());
|
||||
assertNull(mockExceptionThrowingConsumer.getLastMessage());
|
||||
|
||||
|
||||
// Check that the message was re-delivered to a second consumer
|
||||
assertEquals(expectedBody, mockConsumer.getLastMessage());
|
||||
}
|
||||
|
@@ -78,7 +78,6 @@ import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationContext;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.site.SiteModel;
|
||||
import org.alfresco.repo.tenant.TenantAdminService;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.repo.tenant.TenantUtil;
|
||||
@@ -108,13 +107,7 @@ import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.AuthorityType;
|
||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.cmr.security.PersonService.PersonInfo;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||
import org.alfresco.service.cmr.tagging.TaggingService;
|
||||
import org.alfresco.service.cmr.version.Version;
|
||||
import org.alfresco.service.cmr.version.VersionService;
|
||||
@@ -128,6 +121,7 @@ import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.testing.category.FrequentlyFailingTests;
|
||||
import org.alfresco.util.testing.category.LuceneTests;
|
||||
import org.alfresco.util.testing.category.PerformanceTests;
|
||||
import org.alfresco.util.testing.category.RedundantTests;
|
||||
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
import org.apache.chemistry.opencmis.commons.data.Ace;
|
||||
@@ -219,9 +213,6 @@ public class CMISTest
|
||||
private SearchService searchService;
|
||||
private java.util.Properties globalProperties;
|
||||
private AuditComponentImpl auditComponent;
|
||||
private PersonService personService;
|
||||
private SiteService siteService;
|
||||
private MutableAuthenticationService authenticationService;
|
||||
|
||||
private AlfrescoCmisServiceFactory factory;
|
||||
|
||||
@@ -347,9 +338,6 @@ public class CMISTest
|
||||
this.tenantService = (TenantService) ctx.getBean("tenantService");
|
||||
this.searchService = (SearchService) ctx.getBean("SearchService");
|
||||
this.auditComponent = (AuditComponentImpl) ctx.getBean("auditComponent");
|
||||
this.personService = (PersonService) ctx.getBean("personService");
|
||||
this.siteService = (SiteService) ctx.getBean("siteService");
|
||||
this.authenticationService = (MutableAuthenticationService) ctx.getBean("AuthenticationService");
|
||||
|
||||
this.globalProperties = (java.util.Properties) ctx.getBean("global-properties");
|
||||
this.globalProperties.setProperty(VersionableAspectTest.AUTO_VERSION_PROPS_KEY, "true");
|
||||
@@ -731,17 +719,12 @@ public class CMISTest
|
||||
}
|
||||
|
||||
private <T extends Object> T withCmisService(CmisServiceCallback<T> callback, CmisVersion cmisVersion)
|
||||
{
|
||||
return withCmisService("admin", "admin", callback, cmisVersion);
|
||||
}
|
||||
|
||||
private <T extends Object> T withCmisService(String username, String password, CmisServiceCallback<T> callback, CmisVersion cmisVersion)
|
||||
{
|
||||
CmisService cmisService = null;
|
||||
|
||||
try
|
||||
{
|
||||
CallContext context = new SimpleCallContext(username, password, cmisVersion);
|
||||
CallContext context = new SimpleCallContext("admin", "admin", cmisVersion);
|
||||
cmisService = factory.getService(context);
|
||||
T ret = callback.execute(cmisService);
|
||||
return ret;
|
||||
@@ -4118,108 +4101,6 @@ public class CMISTest
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This test ensures that a non member user of a private site, can edit metadata on a document (where the non member user
|
||||
* has "SiteCollaborator" role) placed on the site.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testMNT20006() throws Exception
|
||||
{
|
||||
AuthenticationUtil.pushAuthentication();
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||
|
||||
final String nonMemberUsername = "user" + System.currentTimeMillis();
|
||||
final String nonMemberPassword = "pass" + System.currentTimeMillis();
|
||||
final String siteId = "site" + System.currentTimeMillis();
|
||||
final String originalDescription = "my description";
|
||||
|
||||
NodeRef fileNode;
|
||||
|
||||
try
|
||||
{
|
||||
fileNode = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<NodeRef>()
|
||||
{
|
||||
public NodeRef execute() throws Throwable
|
||||
{
|
||||
// Create user
|
||||
authenticationService.createAuthentication(nonMemberUsername, nonMemberPassword.toCharArray());
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
|
||||
String email = nonMemberUsername + "@testcmis.com";
|
||||
props.put(ContentModel.PROP_USERNAME, nonMemberUsername);
|
||||
props.put(ContentModel.PROP_FIRSTNAME, nonMemberUsername);
|
||||
props.put(ContentModel.PROP_LASTNAME, nonMemberUsername);
|
||||
props.put(ContentModel.PROP_EMAIL, email);
|
||||
PersonInfo personInfo = personService.getPerson(personService.createPerson(props));
|
||||
assertNotNull("Null person info", personInfo);
|
||||
|
||||
// Create site
|
||||
SiteInfo siteInfo = siteService.createSite("myPreset", siteId, "myTitle", "myDescription", SiteVisibility.PRIVATE);
|
||||
assertNotNull("Null site info", siteInfo);
|
||||
NodeRef siteDocLib = siteService.createContainer(siteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null);
|
||||
assertNotNull("Null site doclib", siteDocLib);
|
||||
|
||||
// Create node in site
|
||||
String nodeName = "node" + System.currentTimeMillis() + ".txt";
|
||||
NodeRef fileNode = nodeService.createNode(siteDocLib, ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS, ContentModel.TYPE_CONTENT).getChildRef();
|
||||
ContentWriter writer = contentService.getWriter(fileNode, ContentModel.PROP_CONTENT, true);
|
||||
writer.putContent("my node content");
|
||||
nodeService.setProperty(fileNode, ContentModel.PROP_TITLE, nodeName);
|
||||
nodeService.setProperty(fileNode, ContentModel.PROP_DESCRIPTION, originalDescription);
|
||||
assertNotNull("Null file node", fileNode);
|
||||
assertTrue(nodeService.exists(fileNode));
|
||||
|
||||
// Sets node permissions to the user who is not member of the site and get site activities
|
||||
permissionService.setPermission(fileNode, nonMemberUsername, SiteModel.SITE_COLLABORATOR, true);
|
||||
|
||||
return fileNode;
|
||||
}
|
||||
});
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
|
||||
// Edit metadata
|
||||
final String newDescription = "new node description";
|
||||
|
||||
Boolean updated = withCmisService(nonMemberUsername, nonMemberPassword, new CmisServiceCallback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public Boolean execute(CmisService cmisService)
|
||||
{
|
||||
Boolean updated = true;
|
||||
|
||||
try
|
||||
{
|
||||
// Obtain repository id
|
||||
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
|
||||
assertTrue(repositories.size() > 0);
|
||||
RepositoryInfo repo = repositories.get(0);
|
||||
String repositoryId = repo.getId();
|
||||
|
||||
// Id holder
|
||||
Holder<String> objectIdHolder = new Holder<String>(fileNode.toString());
|
||||
|
||||
// New Properties
|
||||
PropertiesImpl newProperties = new PropertiesImpl();
|
||||
newProperties.addProperty(new PropertyStringImpl(PropertyIds.DESCRIPTION, newDescription));
|
||||
cmisService.updateProperties(repositoryId, objectIdHolder, null, newProperties, null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
updated = false;
|
||||
}
|
||||
|
||||
return updated;
|
||||
};
|
||||
}, CmisVersion.CMIS_1_1);
|
||||
|
||||
assertTrue("Document metadata not updated", updated);
|
||||
}
|
||||
|
||||
private NodeRef createFolder(NodeRef parentNodeRef, String folderName, QName folderType) throws IOException
|
||||
{
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||
|
@@ -32,13 +32,16 @@ import org.alfresco.repo.action.evaluator.compare.ComparePropertyValueOperation;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.action.ParameterConstraint;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
/**
|
||||
* Action parameter constraint unit test
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
@Category(NeverRunsTests.class)
|
||||
public class ActionParameterConstraintTest extends BaseSpringTest
|
||||
{
|
||||
private static final String COMPARE_OP = "ac-compare-operations";
|
||||
|
@@ -34,7 +34,9 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
@@ -44,6 +46,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @since 3.4
|
||||
*/
|
||||
@Transactional
|
||||
@Category(NeverRunsTests.class)
|
||||
public class HasChildEvaluatorTest extends BaseSpringTest
|
||||
{
|
||||
private NodeService nodeService;
|
||||
|
@@ -36,7 +36,9 @@ import org.alfresco.service.cmr.tagging.TaggingService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
@@ -45,6 +47,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
@Transactional
|
||||
@Category(NeverRunsTests.class)
|
||||
public class HasTagEvaluatorTest extends BaseSpringTest
|
||||
{
|
||||
private NodeService nodeService;
|
||||
|
@@ -36,6 +36,7 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.test_category.BaseSpringTestsCategory;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -43,7 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
/**
|
||||
* Tests checkout using action executer
|
||||
*/
|
||||
@Category(BaseSpringTestsCategory.class)
|
||||
@Category({BaseSpringTestsCategory.class, NeverRunsTests.class})
|
||||
@Transactional
|
||||
public class CheckOutActionExecuterTest extends BaseSpringTest
|
||||
{
|
||||
|
@@ -51,6 +51,7 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.test_category.BaseSpringTestsCategory;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
@@ -68,7 +69,7 @@ import static org.alfresco.repo.rule.RuleModel.ASPECT_IGNORE_INHERITED_RULES;
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
@Category(BaseSpringTestsCategory.class)
|
||||
@Category({BaseSpringTestsCategory.class, NeverRunsTests.class})
|
||||
@Transactional
|
||||
public class ExecuteAllRulesActionExecuterTest extends BaseSpringTest
|
||||
{
|
||||
|
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* #%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%
|
||||
*/
|
||||
/*
|
||||
* #%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.action.executer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -43,6 +43,7 @@ import org.alfresco.util.test.junitrules.RunAsFullyAuthenticatedRule;
|
||||
import org.alfresco.util.test.junitrules.TemporaryNodes;
|
||||
import org.alfresco.util.test.junitrules.TemporarySites;
|
||||
import org.alfresco.util.test.junitrules.TemporarySites.TestSiteAndMemberInfo;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
@@ -51,7 +52,7 @@ import org.junit.experimental.categories.Category;
|
||||
import org.junit.rules.RuleChain;
|
||||
|
||||
/** Tests for {@link TakeOwnershipActionExecuter}. */
|
||||
@Category(OwnJVMTestsCategory.class)
|
||||
@Category({OwnJVMTestsCategory.class, NeverRunsTests.class})
|
||||
public class TakeOwnershipActionExecuterTest
|
||||
{
|
||||
// Rule to initialise the default Alfresco spring configuration
|
||||
|
@@ -38,6 +38,7 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.test_category.BaseSpringTestsCategory;
|
||||
import org.alfresco.util.BaseAlfrescoSpringTest;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
@@ -46,7 +47,7 @@ import org.junit.experimental.categories.Category;
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
@Category(BaseSpringTestsCategory.class)
|
||||
@Category({BaseSpringTestsCategory.class, NeverRunsTests.class})
|
||||
public class TransitionSimpleWorkflowActionExecuterTest extends BaseAlfrescoSpringTest
|
||||
{
|
||||
private FileFolderService fileFolderService;
|
||||
|
@@ -41,6 +41,7 @@ import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.testing.category.LuceneTests;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.extensions.surf.util.ISO8601DateFormat;
|
||||
@@ -50,7 +51,7 @@ import org.springframework.extensions.surf.util.ISO8601DateFormat;
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
@Category({OwnJVMTestsCategory.class, LuceneTests.class})
|
||||
@Category({OwnJVMTestsCategory.class, LuceneTests.class, NeverRunsTests.class})
|
||||
public class FreeMarkerModelLuceneFunctionTest extends TestCase
|
||||
{
|
||||
//private static SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sssZ");
|
||||
|
@@ -77,7 +77,7 @@ import static org.junit.Assert.fail;
|
||||
* @since 4.0
|
||||
*/
|
||||
@Category(LuceneTests.class)
|
||||
public class AbstractBulkImportTests
|
||||
public abstract class AbstractBulkImportTests
|
||||
{
|
||||
protected static ApplicationContext ctx;
|
||||
|
||||
|
@@ -1,160 +1,148 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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.repo.content;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.repo.content.filestore.FileContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* Content specific tests for MimeTypeMap
|
||||
*
|
||||
* @see org.alfresco.repo.content.MimetypeMap
|
||||
* @see org.alfresco.repo.content.MimetypeMapTest
|
||||
*/
|
||||
@Category({OwnJVMTestsCategory.class})
|
||||
public class MimetypeMapContentTest extends TestCase
|
||||
{
|
||||
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||
|
||||
private MimetypeService mimetypeService;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
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
|
||||
{
|
||||
// Correct ones
|
||||
assertEquals(
|
||||
"application/msword",
|
||||
mimetypeService.guessMimetype("something.doc", openQuickTestFile("quick.doc"))
|
||||
);
|
||||
assertEquals(
|
||||
"application/msword",
|
||||
mimetypeService.guessMimetype("SOMETHING.DOC", openQuickTestFile("quick.doc"))
|
||||
);
|
||||
|
||||
// Incorrect ones, Tika spots the mistake
|
||||
assertEquals(
|
||||
"application/msword",
|
||||
mimetypeService.guessMimetype("something.pdf", openQuickTestFile("quick.doc"))
|
||||
);
|
||||
|
||||
// Ones where we use a different mimetype to the canonical one
|
||||
assertEquals(
|
||||
"image/bmp", // Officially image/x-ms-bmp
|
||||
mimetypeService.guessMimetype("image.bmp", openQuickTestFile("quick.bmp"))
|
||||
);
|
||||
|
||||
// Ones where we know about the parent, and Tika knows about the details
|
||||
assertEquals(
|
||||
"application/dita+xml", // Full version: application/dita+xml;format=concept
|
||||
mimetypeService.guessMimetype("concept.dita", openQuickTestFile("quickConcept.dita"))
|
||||
);
|
||||
|
||||
// Commented out when the test class was reintroduced after many years of not being run. Failed as the type was
|
||||
// identified as a zip. Reintroduced to check guessMimetype works without pdfbox libraries.
|
||||
//
|
||||
// // Alfresco Specific ones, that Tika doesn't know about
|
||||
// assertEquals(
|
||||
// "application/acp",
|
||||
// mimetypeService.guessMimetype("something.acp", openQuickTestFile("quick.acp"))
|
||||
// );
|
||||
|
||||
// Where the file is corrupted
|
||||
File tmp = File.createTempFile("alfresco", ".tmp");
|
||||
ContentReader reader = openQuickTestFile("quick.doc");
|
||||
InputStream inp = reader.getContentInputStream();
|
||||
byte[] trunc = new byte[512+256];
|
||||
IOUtils.readFully(inp, trunc);
|
||||
inp.close();
|
||||
FileOutputStream out = new FileOutputStream(tmp);
|
||||
out.write(trunc);
|
||||
out.close();
|
||||
ContentReader truncReader = new FileContentReader(tmp);
|
||||
|
||||
// Because the file is truncated, Tika won't be able to process the contents
|
||||
// of the OLE2 structure
|
||||
// So, it'll fall back to just OLE2, but it won't fail
|
||||
assertEquals(
|
||||
"application/x-tika-msoffice",
|
||||
mimetypeService.guessMimetype(null, truncReader)
|
||||
);
|
||||
// Commented out when the test class was reintroduced after many years of not being run. Failed to open a
|
||||
// stream onto the channel. Reintroduced to check guessMimetype works without pdfbox libraries.
|
||||
//
|
||||
// // But with the filename it'll be able to use the .doc extension
|
||||
// // to guess at it being a .Doc file
|
||||
// assertEquals(
|
||||
// "application/msword",
|
||||
// mimetypeService.guessMimetype("something.doc", truncReader)
|
||||
// );
|
||||
|
||||
// Lotus notes EML files (ALF-16381 / TIKA-1042)
|
||||
assertEquals(
|
||||
"message/rfc822",
|
||||
mimetypeService.guessMimetype("something.eml", openQuickTestFile("quickLotus.eml"))
|
||||
);
|
||||
}
|
||||
|
||||
private ContentReader openQuickTestFile(String filename)
|
||||
{
|
||||
URL url = getClass().getClassLoader().getResource("quick/" + filename);
|
||||
if(url == null)
|
||||
{
|
||||
fail("Quick test file \"" + filename + "\" wasn't found");
|
||||
}
|
||||
File file = new File(url.getFile());
|
||||
return new FileContentReader(file);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* #%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.content;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.repo.content.filestore.FileContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
import org.alfresco.util.DataModelTestApplicationContextHelper;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
* Content specific tests for MimeTypeMap
|
||||
*
|
||||
* @see org.alfresco.repo.content.MimetypeMap
|
||||
* @see org.alfresco.repo.content.MimetypeMapTest
|
||||
*/
|
||||
@Category({OwnJVMTestsCategory.class, NeverRunsTests.class})
|
||||
public class MimetypeMapContentTest extends TestCase
|
||||
{
|
||||
private static ApplicationContext ctx = DataModelTestApplicationContextHelper.getApplicationContext();
|
||||
|
||||
private MimetypeService mimetypeService;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
mimetypeService = (MimetypeService)ctx.getBean("mimetypeService");
|
||||
}
|
||||
|
||||
public void testGuessMimetypeForFile() throws Exception
|
||||
{
|
||||
// Correct ones
|
||||
assertEquals(
|
||||
"application/msword",
|
||||
mimetypeService.guessMimetype("something.doc", openQuickTestFile("quick.doc"))
|
||||
);
|
||||
assertEquals(
|
||||
"application/msword",
|
||||
mimetypeService.guessMimetype("SOMETHING.DOC", openQuickTestFile("quick.doc"))
|
||||
);
|
||||
|
||||
// Incorrect ones, Tika spots the mistake
|
||||
assertEquals(
|
||||
"application/msword",
|
||||
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
|
||||
assertEquals(
|
||||
"image/bmp", // Officially image/x-ms-bmp
|
||||
mimetypeService.guessMimetype("image.bmp", openQuickTestFile("quick.bmp"))
|
||||
);
|
||||
|
||||
// Ones where we know about the parent, and Tika knows about the details
|
||||
assertEquals(
|
||||
"application/dita+xml", // Full version: application/dita+xml;format=concept
|
||||
mimetypeService.guessMimetype("concept.dita", openQuickTestFile("quickConcept.dita"))
|
||||
);
|
||||
|
||||
// Alfresco Specific ones, that Tika doesn't know about
|
||||
assertEquals(
|
||||
"application/acp",
|
||||
mimetypeService.guessMimetype("something.acp", openQuickTestFile("quick.acp"))
|
||||
);
|
||||
|
||||
|
||||
// Where the file is corrupted
|
||||
File tmp = File.createTempFile("alfresco", ".tmp");
|
||||
ContentReader reader = openQuickTestFile("quick.doc");
|
||||
InputStream inp = reader.getContentInputStream();
|
||||
byte[] trunc = new byte[512+256];
|
||||
IOUtils.readFully(inp, trunc);
|
||||
inp.close();
|
||||
FileOutputStream out = new FileOutputStream(tmp);
|
||||
out.write(trunc);
|
||||
out.close();
|
||||
ContentReader truncReader = new FileContentReader(tmp);
|
||||
|
||||
// Because the file is truncated, Tika won't be able to process the contents
|
||||
// of the OLE2 structure
|
||||
// So, it'll fall back to just OLE2, but it won't fail
|
||||
assertEquals(
|
||||
"application/x-tika-msoffice",
|
||||
mimetypeService.guessMimetype(null, truncReader)
|
||||
);
|
||||
// But with the filename it'll be able to use the .doc extension
|
||||
// to guess at it being a .Doc file
|
||||
assertEquals(
|
||||
"application/msword",
|
||||
mimetypeService.guessMimetype("something.doc", truncReader)
|
||||
);
|
||||
|
||||
// Lotus notes EML files (ALF-16381 / TIKA-1042)
|
||||
assertEquals(
|
||||
"message/rfc822",
|
||||
mimetypeService.guessMimetype("something.eml", openQuickTestFile("quickLotus.eml"))
|
||||
);
|
||||
}
|
||||
|
||||
private ContentReader openQuickTestFile(String filename)
|
||||
{
|
||||
URL url = getClass().getClassLoader().getResource("quick/" + filename);
|
||||
if(url == null)
|
||||
{
|
||||
fail("Quick test file \"" + filename + "\" wasn't found");
|
||||
}
|
||||
File file = new File(url.getFile());
|
||||
return new FileContentReader(file);
|
||||
}
|
||||
}
|
||||
|
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* #%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%
|
||||
*/
|
||||
/*
|
||||
* #%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.content.caching;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -46,6 +46,7 @@ import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.internal.runners.JUnit38ClassRunner;
|
||||
@@ -58,7 +59,7 @@ import org.junit.runner.RunWith;
|
||||
* @author Matt Ward
|
||||
*/
|
||||
@RunWith(JUnit38ClassRunner.class)
|
||||
@Category(OwnJVMTestsCategory.class)
|
||||
@Category({OwnJVMTestsCategory.class, NeverRunsTests.class})
|
||||
public class CachingContentStoreSpringTest extends AbstractWritableContentStoreTest
|
||||
{
|
||||
private CachingContentStore store;
|
||||
|
@@ -29,6 +29,7 @@ package org.alfresco.repo.content.filestore;
|
||||
import java.io.File;
|
||||
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
@@ -43,7 +44,7 @@ import static org.junit.Assert.assertTrue;
|
||||
* @author Andreea Dragoi
|
||||
*
|
||||
*/
|
||||
@Category(OwnJVMTestsCategory.class)
|
||||
@Category({OwnJVMTestsCategory.class, NeverRunsTests.class})
|
||||
public class BucketAwareFileContentStoreTest extends FileContentStoreTest
|
||||
{
|
||||
private static final int BUCKETS_PER_MINUTE = 20;
|
||||
|
@@ -29,6 +29,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
@@ -39,7 +40,7 @@ import static org.junit.Assert.assertTrue;
|
||||
* to route content from a store to a selection of filesystem volumes
|
||||
* @author Andreea Dragoi
|
||||
*/
|
||||
@Category(OwnJVMTestsCategory.class)
|
||||
@Category({OwnJVMTestsCategory.class, NeverRunsTests.class})
|
||||
public class VolumeAwareFileContentStoreTest extends FileContentStoreTest{
|
||||
|
||||
private static final String VOLUMES = "volumeA,volumeB,volumeC";
|
||||
|
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* #%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%
|
||||
*/
|
||||
/*
|
||||
* #%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.content.metadata.xml;
|
||||
|
||||
import static org.alfresco.repo.content.metadata.AbstractMetadataExtracterTest.QUICK_DESCRIPTION;
|
||||
@@ -33,7 +33,6 @@ import java.io.FileNotFoundException;
|
||||
import java.net.URL;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.action.ActionImpl;
|
||||
import org.alfresco.repo.action.executer.ActionExecuter;
|
||||
@@ -59,6 +58,8 @@ import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.PropertyMap;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
@@ -69,6 +70,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
*
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
@Category(NeverRunsTests.class)
|
||||
public class XmlMetadataExtracterTest extends TestCase
|
||||
{
|
||||
private static final String FILE_ALFRESCO_MODEL = "xml-metadata/alfresco-model-sample.xml";
|
||||
|
@@ -40,6 +40,7 @@ import org.alfresco.service.cmr.repository.DirectAccessUrl;
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -69,7 +70,7 @@ import static org.mockito.Mockito.when;
|
||||
* @author Derek Hulley
|
||||
* @author Mark Rogers
|
||||
*/
|
||||
@Category(OwnJVMTestsCategory.class)
|
||||
@Category({OwnJVMTestsCategory.class, NeverRunsTests.class})
|
||||
public class AggregatingContentStoreTest extends AbstractWritableContentStoreTest
|
||||
{
|
||||
private static final String SOME_CONTENT = "The No. 1 Ladies' Detective Agency";
|
||||
|
@@ -28,6 +28,7 @@ package org.alfresco.repo.content.transform;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpEntity;
|
||||
@@ -37,6 +38,7 @@ import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.Spy;
|
||||
@@ -61,6 +63,7 @@ import static org.springframework.test.util.AssertionErrors.assertTrue;
|
||||
* @deprecated The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
|
||||
*/
|
||||
@Deprecated
|
||||
@Category(NeverRunsTests.class)
|
||||
public class RemoteTransformerClientTest
|
||||
{
|
||||
public static final int STARTUP_RETRY_PERIOD_SECONDS = 2;
|
||||
|
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* #%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%
|
||||
*/
|
||||
/*
|
||||
* #%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.dictionary;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -45,8 +45,10 @@ import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ThreadPoolExecutorFactoryBean;
|
||||
import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
@@ -54,6 +56,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
* @author sglover
|
||||
*
|
||||
*/
|
||||
@Category(NeverRunsTests.class)
|
||||
public class DictionaryDAOTest
|
||||
{
|
||||
public static final String TEST_RESOURCE_MESSAGES = "alfresco/messages/dictionary-messages";
|
||||
|
@@ -39,8 +39,10 @@ import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
|
||||
import org.alfresco.util.DynamicallySizedThreadPoolExecutor;
|
||||
import org.alfresco.util.TraceableThreadFactory;
|
||||
import org.alfresco.util.cache.DefaultAsynchronouslyRefreshedCacheRegistry;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
@@ -48,6 +50,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
* @author sglover
|
||||
*
|
||||
*/
|
||||
@Category (NeverRunsTests.class)
|
||||
public class DictionaryLoadDAOTest
|
||||
{
|
||||
public static final String TEST_RESOURCE_MESSAGES = "alfresco/messages/dictionary-messages";
|
||||
|
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* #%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%
|
||||
*/
|
||||
/*
|
||||
* #%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.domain.node;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -50,6 +50,8 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
@@ -60,6 +62,7 @@ import org.springframework.context.ApplicationContext;
|
||||
* @author Derek Hulley
|
||||
* @since 3.4
|
||||
*/
|
||||
@Category (NeverRunsTests.class)
|
||||
public class NodePropertyHelperTest extends TestCase
|
||||
{
|
||||
private static final QName QN_BOOLEAN = createQName("boolean");
|
||||
|
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* #%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.domain.permissions;
|
||||
|
||||
import static org.alfresco.model.ContentModel.TYPE_BASE;
|
||||
import static org.alfresco.service.cmr.repository.StoreRef.STORE_REF_ARCHIVE_SPACESSTORE;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.MockitoAnnotations.openMocks;
|
||||
|
||||
import org.alfresco.repo.domain.node.NodeDAO;
|
||||
import org.alfresco.repo.domain.permissions.FixedAclUpdater.AclWorker;
|
||||
import org.alfresco.repo.policy.ClassPolicyDelegate;
|
||||
import org.alfresco.repo.security.permissions.PermissionServicePolicies.OnInheritPermissionsDisabled;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.PolicyIgnoreUtil;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
|
||||
/** Mock-based unit tests for {@link FixedAclUpdater}. */
|
||||
public class FixedAclUpdaterUnitTest
|
||||
{
|
||||
private static final NodeRef NODE_REF = new NodeRef("test://node/ref");
|
||||
private static final long NODE_ID = 123L;
|
||||
private static final NodeRef ARCHIVED_NODE = new NodeRef(STORE_REF_ARCHIVE_SPACESSTORE, "archived");
|
||||
|
||||
@InjectMocks
|
||||
private FixedAclUpdater fixedAclUpdater = new FixedAclUpdater();
|
||||
/** The inner class under test. */
|
||||
private AclWorker aclWorker = fixedAclUpdater.createAclWorker();
|
||||
@Mock
|
||||
private NodeDAO nodeDAO;
|
||||
@Mock
|
||||
private AccessControlListDAO accessControlListDAO;
|
||||
@Mock
|
||||
private PolicyIgnoreUtil policyIgnoreUtil;
|
||||
@Mock
|
||||
private ClassPolicyDelegate<OnInheritPermissionsDisabled> onInheritPermissionsDisabledDelegate;
|
||||
@Mock
|
||||
private OnInheritPermissionsDisabled onInheritPermissionsDisabled;
|
||||
/** A pair of mock listeners. */
|
||||
@Mock
|
||||
private FixedAclUpdaterListener listenerA, listenerB;
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
openMocks(this);
|
||||
|
||||
fixedAclUpdater.registerListener(listenerA);
|
||||
fixedAclUpdater.registerListener(listenerB);
|
||||
}
|
||||
|
||||
/** Check that when the AclWorker successfully processes a node then the listeners are notified. */
|
||||
@Test
|
||||
public void testListenersNotifiedAboutUpdate() throws Throwable
|
||||
{
|
||||
when(nodeDAO.getNodePair(NODE_REF)).thenReturn(new Pair<>(NODE_ID, NODE_REF));
|
||||
when(onInheritPermissionsDisabledDelegate.get(TYPE_BASE)).thenReturn(onInheritPermissionsDisabled);
|
||||
|
||||
aclWorker.process(NODE_REF);
|
||||
|
||||
verify(listenerA).permissionsUpdatedAsynchronously(NODE_REF);
|
||||
verify(listenerB).permissionsUpdatedAsynchronously(NODE_REF);
|
||||
}
|
||||
|
||||
/** Check that archived nodes get the "Pending ACL" aspect removed without further updates, and the listeners are not notified. */
|
||||
@Test
|
||||
public void testListenersNotNotifiedAboutArchivedNode() throws Throwable
|
||||
{
|
||||
when(nodeDAO.getNodePair(ARCHIVED_NODE)).thenReturn(new Pair<>(NODE_ID, ARCHIVED_NODE));
|
||||
when(onInheritPermissionsDisabledDelegate.get(TYPE_BASE)).thenReturn(onInheritPermissionsDisabled);
|
||||
|
||||
aclWorker.process(ARCHIVED_NODE);
|
||||
|
||||
verify(accessControlListDAO).removePendingAclAspect(NODE_ID);
|
||||
verify(listenerA, never()).permissionsUpdatedAsynchronously(any(NodeRef.class));
|
||||
verify(listenerB, never()).permissionsUpdatedAsynchronously(any(NodeRef.class));
|
||||
}
|
||||
}
|
@@ -35,14 +35,10 @@ import java.util.Properties;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.alfresco.repo.domain.dialect.Dialect;
|
||||
import org.alfresco.repo.domain.dialect.MySQLInnoDBDialect;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.testing.category.DBTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@@ -52,13 +48,11 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
*
|
||||
* @author Cristian Turlica
|
||||
*/
|
||||
@Category({DBTests.class})
|
||||
public class DeleteNotExistsExecutorTest
|
||||
{
|
||||
private static ApplicationContext ctx;
|
||||
private ScriptExecutor scriptExecutor;
|
||||
private DataSource dataSource;
|
||||
private Dialect dialect;
|
||||
private JdbcTemplate jdbcTmpl;
|
||||
|
||||
@BeforeClass
|
||||
@@ -73,20 +67,9 @@ public class DeleteNotExistsExecutorTest
|
||||
{
|
||||
scriptExecutor = ctx.getBean("simpleScriptExecutor", ScriptExecutorImpl.class);
|
||||
dataSource = ctx.getBean("dataSource", DataSource.class);
|
||||
dialect = ctx.getBean("dialect", Dialect.class);
|
||||
jdbcTmpl = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
private DeleteNotExistsExecutor createDeleteNotExistsExecutor(Connection connection, String sql, int line, File scriptFile, Properties properties)
|
||||
{
|
||||
if (dialect instanceof MySQLInnoDBDialect)
|
||||
{
|
||||
return new MySQLDeleteNotExistsExecutor(connection, sql, line, scriptFile, properties, dataSource);
|
||||
}
|
||||
|
||||
return new DeleteNotExistsExecutor(connection, sql, line, scriptFile, properties);
|
||||
}
|
||||
|
||||
@Test()
|
||||
public void testDefaultBehaviour() throws Exception
|
||||
{
|
||||
@@ -107,7 +90,7 @@ public class DeleteNotExistsExecutorTest
|
||||
{
|
||||
when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_READ_ONLY)).thenReturn("true");
|
||||
when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_TIMEOUT_SECONDS)).thenReturn("-1");
|
||||
DeleteNotExistsExecutor deleteNotExistsExecutor = createDeleteNotExistsExecutor(connection, sql, line, scriptFile, properties);
|
||||
DeleteNotExistsExecutor deleteNotExistsExecutor = new DeleteNotExistsExecutor(connection, sql, line, scriptFile, properties, null);
|
||||
deleteNotExistsExecutor.execute();
|
||||
|
||||
List<String> res = jdbcTmpl.queryForList(select, String.class);
|
||||
@@ -117,7 +100,7 @@ public class DeleteNotExistsExecutorTest
|
||||
{
|
||||
when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_READ_ONLY)).thenReturn("false");
|
||||
when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_TIMEOUT_SECONDS)).thenReturn("-1");
|
||||
DeleteNotExistsExecutor deleteNotExistsExecutor = createDeleteNotExistsExecutor(connection, sql, line, scriptFile, properties);
|
||||
DeleteNotExistsExecutor deleteNotExistsExecutor = new DeleteNotExistsExecutor(connection, sql, line, scriptFile, properties, null);
|
||||
deleteNotExistsExecutor.execute();
|
||||
|
||||
List<String> res = jdbcTmpl.queryForList(select, String.class);
|
||||
@@ -150,7 +133,7 @@ public class DeleteNotExistsExecutorTest
|
||||
{
|
||||
when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_DELETE_BATCH_SIZE)).thenReturn("1");
|
||||
when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_READ_ONLY)).thenReturn("false");
|
||||
DeleteNotExistsExecutor deleteNotExistsExecutor = createDeleteNotExistsExecutor(connection, sql, line, scriptFile, properties);
|
||||
DeleteNotExistsExecutor deleteNotExistsExecutor = new DeleteNotExistsExecutor(connection, sql, line, scriptFile, properties, null);
|
||||
deleteNotExistsExecutor.execute();
|
||||
|
||||
List<String> res = jdbcTmpl.queryForList(select, String.class);
|
||||
@@ -184,7 +167,7 @@ public class DeleteNotExistsExecutorTest
|
||||
when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_BATCH_SIZE)).thenReturn("2");
|
||||
when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_READ_ONLY)).thenReturn("false");
|
||||
when(properties.getProperty(DeleteNotExistsExecutor.PROPERTY_TIMEOUT_SECONDS)).thenReturn("-1");
|
||||
DeleteNotExistsExecutor deleteNotExistsExecutor = createDeleteNotExistsExecutor(connection, sql, line, scriptFile, properties);
|
||||
DeleteNotExistsExecutor deleteNotExistsExecutor = new DeleteNotExistsExecutor(connection, sql, line, scriptFile, properties, null);
|
||||
deleteNotExistsExecutor.execute();
|
||||
|
||||
List<String> res = jdbcTmpl.queryForList(select, String.class);
|
||||
|
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* #%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%
|
||||
*/
|
||||
/*
|
||||
* #%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.domain.subscriptions;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
@@ -41,10 +41,11 @@ import org.alfresco.service.cmr.subscriptions.SubscriptionItemTypeEnum;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
@Category(OwnJVMTestsCategory.class)
|
||||
@Category({OwnJVMTestsCategory.class, NeverRunsTests.class})
|
||||
public class SubscriptionDAOTest extends TestCase
|
||||
{
|
||||
private ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||
|
@@ -1,40 +1,40 @@
|
||||
/*
|
||||
* #%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%
|
||||
*/
|
||||
/*
|
||||
* #%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.imap;
|
||||
|
||||
import javax.mail.Flags;
|
||||
import javax.transaction.UserTransaction;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.mail.Flags;
|
||||
import javax.transaction.UserTransaction;
|
||||
import com.icegreen.greenmail.store.SimpleStoredMessage;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.importer.ACPImportPackageHandler;
|
||||
import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory;
|
||||
@@ -55,13 +55,14 @@ import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.PropertyMap;
|
||||
import org.alfresco.util.config.RepositoryFolderConfigBean;
|
||||
import org.alfresco.util.testing.category.PerformanceTests;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import com.icegreen.greenmail.store.SimpleStoredMessage;
|
||||
|
||||
@Category(PerformanceTests.class)
|
||||
public class LoadTester extends TestCase
|
||||
{
|
||||
private Log logger = LogFactory.getLog(LoadTester.class);
|
||||
@@ -218,7 +219,7 @@ public class LoadTester extends TestCase
|
||||
|
||||
private void reauthenticate(String name, String password)
|
||||
{
|
||||
authenticationService.invalidateTicket(authenticationService.getCurrentTicket());
|
||||
authenticationService.invalidateTicket(authenticationService.getCurrentTicket());
|
||||
authenticationService.clearCurrentSecurityContext();
|
||||
authenticationService.authenticate(name, password.toCharArray());
|
||||
}
|
||||
|
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* #%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%
|
||||
*/
|
||||
/*
|
||||
* #%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.imap;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
@@ -41,11 +41,14 @@ import javax.mail.Store;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.alfresco.util.testing.category.PerformanceTests;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
import com.sun.mail.util.BASE64DecoderStream;
|
||||
|
||||
@Category(PerformanceTests.class)
|
||||
public class RemoteLoadTester extends TestCase
|
||||
{
|
||||
|
||||
|
@@ -23,16 +23,20 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
|
||||
package org.alfresco.repo.invitation;
|
||||
|
||||
/**
|
||||
* Test InvitationService with both engines enabled.
|
||||
*
|
||||
* @author Nick Smith
|
||||
* @since 4.0
|
||||
*/
|
||||
public class FullInvitationServiceImplTests extends AbstractInvitationServiceImplTest
|
||||
{
|
||||
// See inherited tests.
|
||||
}
|
||||
|
||||
package org.alfresco.repo.invitation;
|
||||
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
/**
|
||||
* Test InvitationService with both engines enabled.
|
||||
*
|
||||
* @author Nick Smith
|
||||
* @since 4.0
|
||||
*/
|
||||
@Category(NeverRunsTests.class)
|
||||
public class FullInvitationServiceImplTests extends AbstractInvitationServiceImplTest
|
||||
{
|
||||
// See inherited tests.
|
||||
}
|
||||
|
@@ -231,7 +231,7 @@ public class ModuleVersionNumberTest extends TestCase
|
||||
return (ModuleVersionNumber) objectInputStream.readObject();
|
||||
}
|
||||
|
||||
// Tests that we can strip the suffixes such as "-M2", "-A12" or "-RC2" from versions "7.0.0-M2", "6.2.2-A12", "7.0.1-RC2"
|
||||
// Tests that we can strip the suffixes such as "-M2", "-A12" or "-RC2" from versions "7.0.0-M2", "6.2.2-A12", "7.1.0-RC2"
|
||||
// The main version may contain 3 or 4 digit parts.
|
||||
public void testGetVersionWithoutSuffix()
|
||||
{
|
||||
|
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* #%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%
|
||||
*/
|
||||
/*
|
||||
* #%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.node;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -50,11 +50,14 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.PropertyMap;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
@Category(NeverRunsTests.class)
|
||||
public class MetadataEncryptorTests extends TestCase
|
||||
{
|
||||
private static final String TEST_MODEL = "org/alfresco/repo/node/encrypted_prop_model.xml";
|
||||
|
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* #%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%
|
||||
*/
|
||||
/*
|
||||
* #%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.notification;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -32,8 +32,8 @@ import java.util.Map;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.model.Repository;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.notification.NotificationContext;
|
||||
@@ -47,6 +47,7 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
import org.alfresco.util.BaseAlfrescoTestCase;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.experimental.categories.Category;
|
||||
@@ -57,7 +58,7 @@ import org.junit.experimental.categories.Category;
|
||||
* @author Roy Wetherall
|
||||
* @since 4.0
|
||||
*/
|
||||
@Category(OwnJVMTestsCategory.class)
|
||||
@Category({OwnJVMTestsCategory.class, NeverRunsTests.class})
|
||||
public class NotificationServiceImplSystemTest extends BaseAlfrescoTestCase
|
||||
{
|
||||
private static final String FROM_USER = "fromUser" + GUID.generate();
|
||||
@@ -196,33 +197,33 @@ public class NotificationServiceImplSystemTest extends BaseAlfrescoTestCase
|
||||
protected boolean useSpacesStore()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void testSimpleEmailNotificationSystem()
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork()
|
||||
{
|
||||
NotificationContext context = new NotificationContext();
|
||||
|
||||
context.setFrom(FROM_EMAIL);
|
||||
context.addTo(TO_USER1);
|
||||
context.setSubject(SUBJECT);
|
||||
context.setBodyTemplate(template.toString());
|
||||
|
||||
Map<String, Serializable> templateArgs = new HashMap<String, Serializable>(1);
|
||||
templateArgs.put("template", template);
|
||||
context.setTemplateArgs(templateArgs);
|
||||
|
||||
notificationService.sendNotification(EMailNotificationProvider.NAME, context);
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void testSimpleEmailNotificationSystem()
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork()
|
||||
{
|
||||
NotificationContext context = new NotificationContext();
|
||||
|
||||
context.setFrom(FROM_EMAIL);
|
||||
context.addTo(TO_USER1);
|
||||
context.setSubject(SUBJECT);
|
||||
context.setBodyTemplate(template.toString());
|
||||
|
||||
Map<String, Serializable> templateArgs = new HashMap<String, Serializable>(1);
|
||||
templateArgs.put("template", template);
|
||||
context.setTemplateArgs(templateArgs);
|
||||
|
||||
notificationService.sendNotification(EMailNotificationProvider.NAME, context);
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testTemplateEmailNotification()
|
||||
|
@@ -1,30 +1,31 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* 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%
|
||||
*/
|
||||
/*
|
||||
* #%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;
|
||||
|
||||
import org.alfresco.repo.rendition.executer.HTMLRenderingEngineTest;
|
||||
import org.alfresco.repo.thumbnail.ThumbnailServiceImplParameterTest;
|
||||
import org.alfresco.repo.thumbnail.ThumbnailServiceImplTest;
|
||||
import org.alfresco.repo.thumbnail.conditions.NodeEligibleForRethumbnailingEvaluatorTest;
|
||||
@@ -48,6 +49,7 @@ import org.junit.runners.Suite;
|
||||
RenditionServiceIntegrationTest.class,
|
||||
RenditionServicePermissionsTest.class,
|
||||
RenditionNodeManagerTest.class,
|
||||
HTMLRenderingEngineTest.class,
|
||||
MultiUserRenditionTest.class
|
||||
})
|
||||
public class AllRenditionTests
|
||||
|
@@ -51,6 +51,8 @@ import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
/**
|
||||
@@ -59,6 +61,7 @@ import org.mockito.ArgumentCaptor;
|
||||
* @deprecated We are introducing the new async RenditionService2.
|
||||
*/
|
||||
@Deprecated
|
||||
@Category(NeverRunsTests.class)
|
||||
public class AbstractRenderingEngineTest extends TestCase
|
||||
{
|
||||
private final NodeRef source = new NodeRef("http://test/sourceId");
|
||||
|
@@ -0,0 +1,543 @@
|
||||
/*
|
||||
* #%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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -31,10 +31,12 @@ import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -50,6 +52,7 @@ import static org.alfresco.model.ContentModel.PROP_CONTENT;
|
||||
/**
|
||||
* Integration tests for {@link LocalSynchronousTransformClient}
|
||||
*/
|
||||
@Category(NeverRunsTests.class)
|
||||
public class LocalSynchronousTransformClientIntegrationTest extends AbstractRenditionIntegrationTest
|
||||
{
|
||||
@Autowired
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -32,13 +32,10 @@ import org.alfresco.repo.thumbnail.ThumbnailDefinition;
|
||||
import org.alfresco.repo.thumbnail.ThumbnailRenditionConvertor;
|
||||
import org.alfresco.service.cmr.rendition.RenditionDefinition;
|
||||
import org.alfresco.service.cmr.rendition.RenditionService;
|
||||
import org.alfresco.service.cmr.repository.PagedSourceOptions;
|
||||
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||
import org.alfresco.service.cmr.repository.TransformationSourceOptions;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -129,27 +126,6 @@ public class RenditionDefinitionTest extends BaseSpringTest
|
||||
// than checking transformationOptions is equal to transformationOptions2.
|
||||
if (!renditionName.equals("pdf") && !renditionName.equals("webpreview"))
|
||||
{
|
||||
// MNT-22409: We no longer have system.thumbnail.definition.default.pageLimit=1 as a default.
|
||||
// It is -1 (unlimited), but to compensate for that the new OOTB renditions defined in
|
||||
// 0100-baseRenditions now have startPage and endPage transform options. The following code modifies
|
||||
// the transformationOptions so that they will be the same if there are no bugs.
|
||||
Collection<TransformationSourceOptions> sourceOptionsList = transformationOptions2.getSourceOptionsList();
|
||||
if (sourceOptionsList != null && sourceOptionsList.size() == 1)
|
||||
{
|
||||
TransformationSourceOptions sourceOptions = sourceOptionsList.iterator().next();
|
||||
if (sourceOptions instanceof PagedSourceOptions)
|
||||
{
|
||||
PagedSourceOptions pagedSourceOptions = (PagedSourceOptions)sourceOptions;
|
||||
if (pagedSourceOptions.getStartPageNumber() == 1 && pagedSourceOptions.getEndPageNumber() == 1)
|
||||
{
|
||||
if (transformationOptions.getSourceOptionsList() == null)
|
||||
{
|
||||
transformationOptions.setSourceOptionsList(sourceOptionsList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals("The TransformationOptions used in transforms for " + renditionName + " should be the same",
|
||||
transformationOptions.toStringAll(), transformationOptions2.toStringAll());
|
||||
assertEquals("The transformationOptionsConverter back to the newer format was not the same for " +
|
||||
|
@@ -32,6 +32,7 @@ import org.alfresco.repo.rawevents.types.OnContentUpdatePolicyEvent;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.Message;
|
||||
@@ -39,6 +40,7 @@ import org.apache.camel.support.DefaultExchange;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.rules.TestName;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
@@ -53,6 +55,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
*
|
||||
* @author Cristian Turlica
|
||||
*/
|
||||
@Category(NeverRunsTests.class)
|
||||
public class RenditionEventProcessorTest
|
||||
{
|
||||
private RenditionEventProcessor renditionEventProcessor;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2021 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
@@ -565,18 +565,4 @@ public class TransformationOptionsConverterTest
|
||||
"timeout=-1 "
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommandOptionsFromOldOptions()
|
||||
{
|
||||
ImageTransformationOptions oldOptions = new ImageTransformationOptions();
|
||||
oldOptions.setCommandOptions("-resize 350x50> -background none -gravity center");
|
||||
|
||||
assertConverterToMapAndBack(oldOptions, MIMETYPE_IMAGE_JPEG, MIMETYPE_IMAGE_PNG,
|
||||
"ImageTransformationOptions [commandOptions=-resize 350x50> -background none -gravity center, " +
|
||||
"resizeOptions=null, autoOrient=true]]",
|
||||
"autoOrient=true " + // this is a default - so is also set when uploading a logo
|
||||
"commandOptions=-resize 350x50> -background none -gravity center " +
|
||||
"timeout=-1 ");
|
||||
}
|
||||
}
|
@@ -62,7 +62,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
@Transactional
|
||||
public class BaseRuleTest extends BaseSpringTest
|
||||
public abstract class BaseRuleTest extends BaseSpringTest
|
||||
{
|
||||
/**
|
||||
* Data used in the tests
|
||||
|
@@ -158,20 +158,7 @@ public class DBQueryEngineTest
|
||||
assertNodePresent(6, result);
|
||||
assertNodePresent(7, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldResultSetLengthMatchTheAmountOfAllAccessibleNodesWhenMaxPermissionCheckEnabled()
|
||||
{
|
||||
withMaxItems(5);
|
||||
prepareTemplate(dbQuery, createNodes(10));
|
||||
when(assessor.isIncluded(any(Node.class))).thenReturn(true);
|
||||
|
||||
engine.setMaxPermissionCheckEnabled(true);
|
||||
FilteringResultSet result = engine.acceleratedNodeSelection(options, dbQuery, assessor);
|
||||
|
||||
assertEquals(10, result.length());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void shouldNotConsiderInaccessibleNodesInResultSetWhenSkippingNodes()
|
||||
{
|
||||
|
@@ -77,6 +77,7 @@ import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.CachingDateFormat;
|
||||
import org.alfresco.util.testing.category.LuceneTests;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
@@ -90,7 +91,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
* @author Andy
|
||||
*
|
||||
*/
|
||||
@Category(LuceneTests.class)
|
||||
@Category({LuceneTests.class, NeverRunsTests.class})
|
||||
public class DBQueryTest implements DictionaryListener
|
||||
{
|
||||
protected static ApplicationContext ctx = null;
|
||||
|
@@ -1,155 +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.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());
|
||||
}
|
||||
}
|
@@ -59,6 +59,7 @@ import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.ScriptPagingDetails;
|
||||
import org.alfresco.util.testing.category.LuceneTests;
|
||||
import org.alfresco.util.testing.category.NeverRunsTests;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
@@ -66,7 +67,7 @@ import org.springframework.context.ApplicationContext;
|
||||
* Tests for the Script wrapper for the Authority Service,
|
||||
* ScriptAuthorityService
|
||||
*/
|
||||
@Category(LuceneTests.class)
|
||||
@Category({LuceneTests.class, NeverRunsTests.class})
|
||||
public class ScriptAuthorityServiceTest extends TestCase
|
||||
{
|
||||
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user