Compare commits

...

42 Commits

Author SHA1 Message Date
Travis CI User
1f608b1eb5 [maven-release-plugin][skip ci] prepare release 11.125 2021-08-27 10:31:23 +00:00
Ayman Harake
8652c9d644 ATS-956: Bump T-core to use 2.5.3 (#683) 2021-08-27 10:43:59 +01:00
Travis CI User
57e8ee2c76 [maven-release-plugin][skip ci] prepare for next development iteration 2021-08-26 15:04:19 +00:00
Travis CI User
6cb00d8e3b [maven-release-plugin][skip ci] prepare release 11.124 2021-08-26 15:04:17 +00:00
alandavis
bb58c4a2d9 "ACS-1907 TMDQ against MySql throws SQLException in certain situations (#679)"
This reverts commit 83097d452b.
2021-08-26 14:26:01 +01:00
Travis CI User
1766ce6e31 [maven-release-plugin][skip ci] prepare for next development iteration 2021-08-26 12:08:32 +00:00
Travis CI User
0c5498fba0 [maven-release-plugin][skip ci] prepare release 11.123 2021-08-26 12:08:30 +00:00
Sara
48045c8c38 ACS-1788 Implement RestApi endpoint for deleted renditions (#681)
* ACS-1788 deleted renditions

* ACS-1913 Fix endpoint operation labels

* ACS-1788 Updates from review
2021-08-26 12:20:08 +01:00
Travis CI User
89adfacca6 [maven-release-plugin][skip ci] prepare for next development iteration 2021-08-26 08:45:09 +00:00
Travis CI User
6159bee521 [maven-release-plugin][skip ci] prepare release 11.122 2021-08-26 08:45:06 +00:00
Davide
a8a06f4b1f SEARCH-2833 Add field for association Qname in NodeResource and ChildAssociationResource (#678) 2021-08-26 09:59:06 +02:00
Travis CI User
279ff3a0d8 [maven-release-plugin][skip ci] prepare for next development iteration 2021-08-26 06:35:05 +00:00
Travis CI User
b6a50ae6e1 [maven-release-plugin][skip ci] prepare release 11.121 2021-08-26 06:35:01 +00:00
alandavis
83097d452b Revert "ACS-1907 TMDQ against MySql throws SQLException in certain situations (#679)"
Kept the travis changes.

This reverts commit 85fa4b5a93.
2021-08-26 01:18:19 +01:00
Travis CI User
b26d03cc0c [maven-release-plugin][skip ci] prepare for next development iteration 2021-08-25 22:17:37 +00:00
Travis CI User
af24fef02b [maven-release-plugin][skip ci] prepare release 11.120 2021-08-25 22:17:34 +00:00
Stefan Kopf
85fa4b5a93 ACS-1907 TMDQ against MySql throws SQLException in certain situations (#679)
* Added alternative approach for DBQueryEngine to page through the entire query using "LIMIT" requests instead of result set streaming
* Use the alternative approach for MySql
2021-08-25 22:05:33 +01:00
Travis CI User
01b5fb5593 [maven-release-plugin][skip ci] prepare for next development iteration 2021-08-25 20:01:30 +00:00
Travis CI User
09f8d7a806 [maven-release-plugin][skip ci] prepare release 11.119 2021-08-25 20:01:27 +00:00
Sara
77691ec5fd ACS-1913 Fix endpoint operation labels (#682)
* ACS-1913 Fix endpoint operation labels

* ACS-1913 Update tests

* ACS-1913 Update tests
2021-08-25 20:14:16 +01:00
Travis CI User
472710ffd4 [maven-release-plugin][skip ci] prepare for next development iteration 2021-08-25 17:12:43 +00:00
Travis CI User
16f0714e99 [maven-release-plugin][skip ci] prepare release 11.118 2021-08-25 17:12:41 +00:00
Sara
c7c40b06e1 Feature/acs 1904 fix node ref vs content url (#680)
* ACS-1904 Fix NodeRef vs ContentUrl and remove deprecated methods

* ACS-1904 remove unused imports
2021-08-25 17:22:59 +01:00
alandavis
439a9254a3 Remove double spaces in log messages [skip ci] 2021-08-25 11:46:25 +01:00
Travis CI User
a9f19de31c [maven-release-plugin][skip ci] prepare for next development iteration 2021-08-24 15:11:35 +00:00
Travis CI User
d237e51bb2 [maven-release-plugin][skip ci] prepare release 11.117 2021-08-24 15:11:32 +00:00
Sara Aspery
d7758d5509 update api-explorer version to 7.1.0-A1 in community-repo pom 2021-08-24 15:24:02 +01:00
Sara
f8b40d3cc0 ACS-566 Fix Poms (#677) 2021-08-24 09:13:03 +01:00
Travis CI User
6d48c0979e [maven-release-plugin][skip ci] prepare for next development iteration 2021-08-24 07:14:21 +00:00
Travis CI User
1b7bada294 [maven-release-plugin][skip ci] prepare release 11.116 2021-08-24 07:14:18 +00:00
Rodica Sutu
924f64409e end to end tests for APPS-1004 and APPS-1005 (#674)
* end to end tests for governance service issues APPS-1004 and APPS-1005
2021-08-24 09:25:04 +03:00
Travis CI User
7267ea5846 [maven-release-plugin][skip ci] prepare for next development iteration 2021-08-23 11:02:06 +00:00
Travis CI User
c86d82e9cd [maven-release-plugin][skip ci] prepare release 11.115 2021-08-23 11:02:03 +00:00
mikolajbrzezinski
f7e6320a83 Feature/acs 1787 endpoint for deleted nodes (#672)
* Deleted Nodes DAU Skeleton

* Copyright Dates Update

* Spring Wiring and Default Method

* Operation Name Change

* Removal of unnecesary Method Calls and JavaDoc update

* Updates from Review
2021-08-23 12:15:40 +02:00
Travis CI User
cff733bbdf [maven-release-plugin][skip ci] prepare for next development iteration 2021-08-23 09:00:57 +00:00
Travis CI User
57942cd43b [maven-release-plugin][skip ci] prepare release 11.114 2021-08-23 09:00:54 +00:00
Iulian Aftene
4aaae012c5 ACS-1833 - Test requestContentDirectUrl for Versions Renditions REST API endpoint (#675)
-add requestContentDirectUrl test for versions renditions
2021-08-23 11:14:33 +03:00
Travis CI User
1c387add9d [maven-release-plugin][skip ci] prepare for next development iteration 2021-08-22 22:34:52 +00:00
Travis CI User
d3ab782b57 [maven-release-plugin][skip ci] prepare release 11.113 2021-08-22 22:34:50 +00:00
Stefan Kopf
b3d43b0500 ACS-1907: Fix typo in test case 2021-08-22 23:50:36 +02:00
Stefan Kopf
a8e1ce909e ACS-1907: Added test case to reproduce error situation 2021-08-22 23:47:26 +02:00
Travis CI User
76e815f9c5 [maven-release-plugin][skip ci] prepare for next development iteration 2021-08-20 16:38:27 +00:00
62 changed files with 1063 additions and 176 deletions

View File

@@ -55,7 +55,7 @@ jobs:
before_script:
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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.5.2
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.5.3
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"
@@ -70,7 +70,7 @@ jobs:
before_script:
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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.5.2
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.5.3
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"
@@ -78,7 +78,7 @@ jobs:
before_script:
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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.5.2
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.5.3
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"
@@ -97,7 +97,7 @@ jobs:
before_script:
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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.5.2
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.5.3
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"
@@ -105,7 +105,7 @@ jobs:
before_script:
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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.5.2
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.5.3
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"
@@ -113,7 +113,7 @@ jobs:
before_script:
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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.5.2
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.5.3
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"
@@ -145,7 +145,7 @@ jobs:
script: travis_wait 20 mvn -B test -pl repository -Dtest=AllDBTestsTestSuite -Ddb.name=alfresco -Ddb.url=jdbc:mariadb://localhost:3307/alfresco?useUnicode=yes\&characterEncoding=UTF-8 -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.driver=org.mariadb.jdbc.Driver
- name: "Repository - MariaDB 10.6 tests"
if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/
if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ OR commit_message =~ /\[latest db\]/
before_script:
- docker run -d -p 3307:3306 --name mariadb -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mariadb:10.6 --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
@@ -159,7 +159,7 @@ jobs:
script: travis_wait 20 mvn -B test -pl repository -Dtest=AllDBTestsTestSuite -Ddb.driver=com.mysql.jdbc.Driver -Ddb.name=alfresco -Ddb.url=jdbc:mysql://localhost:3307/alfresco -Ddb.username=alfresco -Ddb.password=alfresco
- name: "Repository - MySQL 8 tests"
if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/
if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ OR commit_message =~ /\[latest db\]/
before_script:
- docker run -d -p 3307:3306 -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mysql:8 --transaction-isolation='READ-COMMITTED'
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
@@ -210,7 +210,7 @@ jobs:
- name: "Repository - PostgreSQL 13.3 tests"
# We only run DB tests on the latest version of PostgreSQL on feature branches
if: commit_message !~ /\[skip db\]/
if: commit_message !~ /\[skip db\]/ OR commit_message =~ /\[latest db\]/
before_script:
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 postgres -c 'max_connections=300'
- docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1
@@ -234,7 +234,7 @@ jobs:
before_script:
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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.5.2
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.5.3
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"
@@ -242,7 +242,7 @@ jobs:
before_script:
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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.5.2
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.5.3
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"
@@ -250,7 +250,7 @@ jobs:
before_script:
- docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.3 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.5.2
- docker run -d -p 8090:8090 -e JAVA_OPTS=" -Xms256m -Xmx256m" alfresco/alfresco-transform-core-aio:2.5.3
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"

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-amps</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<modules>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-parent</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<modules>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>

View File

@@ -55,6 +55,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_AS_OF;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_NAME;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS_ELIGIBLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD;
@@ -248,6 +249,9 @@ public class RecordProperties extends TestModel
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS_ELIGIBLE)
private Boolean recordSearchDispositionEventsEligible;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS)
private List<String> recordSearchDispositionEvents;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS)
private String recordSearchDispositionInstructions;

View File

@@ -47,6 +47,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@@ -134,7 +135,7 @@ public class RecordCategoryChildProperties extends TestModel
private String recordSearchDispositionInstructions;
@JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS)
private Boolean recordSearchDispositionEvents;
private List<String> recordSearchDispositionEvents;
@JsonProperty (PROPERTIES_OWNER)
private Owner owner;

View File

@@ -0,0 +1,268 @@
/*-
* #%L
* Alfresco Records Management Module
* %%
* 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.rm.community.recordcategories;
import static org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty.CREATED_DATE;
import static org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty.CUT_OFF_DATE;
import static org.alfresco.rest.rm.community.model.recordcategory.RetentionPeriodProperty.DATE_FILED;
import static org.alfresco.rest.rm.community.utils.CoreUtil.createBodyForMoveCopy;
import static org.alfresco.rest.rm.community.utils.CoreUtil.toContentModel;
import static org.alfresco.utility.data.RandomData.getRandomName;
import static org.alfresco.utility.report.log.Step.STEP;
import static org.springframework.http.HttpStatus.OK;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import org.alfresco.rest.core.v0.BaseAPI.RM_ACTIONS;
import org.alfresco.rest.core.v0.RMEvents;
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
import org.alfresco.rest.rm.community.model.record.Record;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
import org.alfresco.rest.v0.service.DispositionScheduleService;
import org.alfresco.test.AlfrescoTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* Tests for moving record categories between record categories with different retention schedule
*/
public class MoveRecCategoriesWithRSTests extends BaseRMRestTest
{
private RecordCategory rootCategory, rootCategory2;
private Record elRecord, nonElRecord;
@Autowired
private DispositionScheduleService dispositionScheduleService;
/**
* Create two root categories with some retention schedules on record level
*/
@BeforeMethod
private void setUpMoveRecCategoriesWithRSTests()
{
STEP("Create record category with retention schedule and apply it to records.");
rootCategory = createRootCategory(getRandomName("rootCategory1"));
dispositionScheduleService.createCategoryRetentionSchedule(rootCategory.getName(), true);
STEP("Create record category with retention schedule and apply it to records.");
rootCategory2 = createRootCategory(getRandomName("rootCategory2"));
dispositionScheduleService.createCategoryRetentionSchedule(rootCategory2.getName(), true);
}
/**
* Given following structure is created:
* rootCategory1 with RS applied on record level with cut off and destroy after 1 day
* - subCategory1 without RS
* - recFolder
* - incomplete electronic record
* - complete non-electronic record
* rootCategory2 with RS with retain and destroy both after 2 day
* When moving subcategory1 within rootCategory2
* Then the records will inherit the RS from rootCategory2
*/
@Test
@AlfrescoTest (jira = "APPS-1005")
public void testInheritWhenMoveToDifferentRSStep() throws Exception
{
STEP("Add retention schedule cut off step after 1 day period.");
dispositionScheduleService.addCutOffAfterPeriodStep(rootCategory.getName(), "day|1", CREATED_DATE);
STEP("Add retention schedule destroy step after 1 Day period.");
dispositionScheduleService.addDestroyWithGhostingAfterPeriodStep(rootCategory.getName(), "day|1", CUT_OFF_DATE);
STEP("Create a subcategory with a record folder and records.");
RecordCategoryChild subCategory = createSubCategoryWithRecords();
STEP("Add retention schedule retain step after 2 day period.");
dispositionScheduleService.addRetainAfterPeriodStep(rootCategory2.getName(), "day|2");
STEP("Add retention schedule destroy step after 2 Day period.");
dispositionScheduleService.addDestroyWithGhostingAfterPeriodStep(rootCategory2.getName(), "day|2", DATE_FILED);
STEP("Move the subcategory within the rootCategory2.");
getRestAPIFactory().getNodeAPI(toContentModel(subCategory.getId())).move(createBodyForMoveCopy(rootCategory2.getId()));
assertStatusCode(OK);
STEP("Check that both records inherit rootCategory2 retention schedule");
elRecord = getRestAPIFactory().getRecordsAPI().getRecord(elRecord.getId());
nonElRecord = getRestAPIFactory().getRecordsAPI().getRecord(nonElRecord.getId());
assertTrue(elRecord.getProperties().getRecordSearchDispositionActionName().equalsIgnoreCase(RM_ACTIONS.END_RETENTION.getAction()),
"Disposition action should be retain");
assertTrue(elRecord.getProperties().getRecordSearchDispositionPeriod().equalsIgnoreCase("day"),
"Disposition period property should be day");
assertTrue(elRecord.getProperties().getRecordSearchDispositionPeriodExpression().equalsIgnoreCase("2"),
"Disposition period expression should be 2");
assertTrue(nonElRecord.getProperties().getRecordSearchDispositionActionName().equalsIgnoreCase(RM_ACTIONS.END_RETENTION.getAction()),
"Disposition action should be retain");
assertTrue(nonElRecord.getProperties().getRecordSearchDispositionPeriod().equalsIgnoreCase("day"),
"Disposition period property should be day");
assertTrue(nonElRecord.getProperties().getRecordSearchDispositionPeriodExpression().equalsIgnoreCase("2"),
"Disposition period expression should be 2");
}
/**
* Given following structure is created:
* rootCategory1 with RS applied on record level with retain and destroy after 1 day
* - subCategory without RS
* - recFolder
* - incomplete electronic record
* - complete non-electronic record
* rootCategory2 with RS with cut off on event case closed and destroy both after 2 day
* When moving subcategory within rootCategory2
* Then the records will inherit the RS from rootCategory2
*/
@Test
@AlfrescoTest (jira = "APPS-1004")
public void testInheritWhenMoveToDifferentRSStepOnEventBase() throws Exception
{
STEP("Add retention schedule retain step after 1 day period.");
dispositionScheduleService.addRetainAfterPeriodStep(rootCategory.getName(), "day|1");
STEP("Add retention schedule destroy step after 1 Day period.");
dispositionScheduleService.addDestroyWithGhostingAfterPeriodStep(rootCategory.getName(), "day|1", CUT_OFF_DATE);
STEP("Create a subcategory with a record folder and records.");
RecordCategoryChild subCategory = createSubCategoryWithRecords();
STEP("Add retention schedule cut off step on event case closed.");
dispositionScheduleService.addCutOffAfterEventStep(rootCategory2.getName(), RMEvents.CASE_CLOSED.getEventName());
STEP("Add retention schedule destroy step after 1 Day period.");
dispositionScheduleService.addDestroyWithGhostingAfterPeriodStep(rootCategory2.getName(), "day|2", DATE_FILED);
STEP("Move the subcategory within the rootCategory2.");
getRestAPIFactory().getNodeAPI(toContentModel(subCategory.getId())).move(createBodyForMoveCopy(rootCategory2.getId()));
assertStatusCode(OK);
STEP("Check that both records inherit rootCategory2 retention schedule");
elRecord = getRestAPIFactory().getRecordsAPI().getRecord(elRecord.getId());
nonElRecord = getRestAPIFactory().getRecordsAPI().getRecord(nonElRecord.getId());
assertTrue(elRecord.getProperties().getRecordSearchDispositionActionName().equalsIgnoreCase(RM_ACTIONS.CUT_OFF.getAction()),
"Disposition action should be cut off");
assertTrue(elRecord.getProperties().getRecordSearchDispositionPeriod().equalsIgnoreCase("none"),
"Disposition period property should none");
assertTrue(elRecord.getProperties().getRecordSearchDispositionPeriodExpression().equalsIgnoreCase("0"),
"Disposition period expression should be 0");
assertTrue(elRecord.getProperties().getRecordSearchDispositionEvents().contains(RMEvents.CASE_CLOSED.getEventName()),
"Disposition event list doesn't contain case closed event");
assertTrue(nonElRecord.getProperties().getRecordSearchDispositionActionName().equalsIgnoreCase(RM_ACTIONS.CUT_OFF.getAction()),
"Disposition action should be cut off");
assertTrue(nonElRecord.getProperties().getRecordSearchDispositionPeriod().equalsIgnoreCase("none"),
"Disposition period property should be none");
assertTrue(nonElRecord.getProperties().getRecordSearchDispositionPeriodExpression().equalsIgnoreCase("0"),
"Disposition period expression should be 0");
assertTrue(nonElRecord.getProperties().getRecordSearchDispositionEvents().contains(RMEvents.CASE_CLOSED.getEventName()),
"Disposition event list doesn't contain case closed event");
}
/**
* Given following structure is created:
* rootCategory1 with RS applied on record level with cut off on event case closed and destroy after 1 day
* - subCategory2 without RS
* - recFolder
* - incomplete electronic record
* - complete non-electronic record
* rootCategory2 with cut off on event Obsolete and destroy both after 2 day
* When moving subcategory2 within rootCategory2
* Then the records will inherit the RS from rootCategory2
*/
@Test
@AlfrescoTest (jira = "APPS-1004")
public void testInheritWhenMoveToSameStepDifferentEvent() throws Exception
{
STEP("Add retention schedule cut off on case closed.");
dispositionScheduleService.addCutOffAfterEventStep(rootCategory.getName(), RMEvents.CASE_CLOSED.getEventName());
STEP("Add retention schedule destroy step after 1 Day period.");
dispositionScheduleService.addDestroyWithGhostingAfterPeriodStep(rootCategory.getName(), "day|1", CUT_OFF_DATE);
STEP("Create a subcategory with a record folder and records.");
RecordCategoryChild subCategory = createSubCategoryWithRecords();
STEP("Add retention schedule cut off step on event separation.");
dispositionScheduleService.addCutOffAfterEventStep(rootCategory2.getName(), RMEvents.OBSOLETE.getEventName());
STEP("Add retention schedule destroy step after 2 Day period.");
dispositionScheduleService.addDestroyWithGhostingAfterPeriodStep(rootCategory2.getName(), "day|2", DATE_FILED);
STEP("Move the subcategory within the rootCategory2.");
getRestAPIFactory().getNodeAPI(toContentModel(subCategory.getId())).move(createBodyForMoveCopy(rootCategory2.getId()));
assertStatusCode(OK);
STEP("Check that both records inherit rootCategory2 retention schedule");
elRecord = getRestAPIFactory().getRecordsAPI().getRecord(elRecord.getId());
nonElRecord = getRestAPIFactory().getRecordsAPI().getRecord(nonElRecord.getId());
assertTrue(elRecord.getProperties().getRecordSearchDispositionActionName().equalsIgnoreCase(RM_ACTIONS.CUT_OFF.getAction()),
"Disposition action should be cut off");
assertTrue(elRecord.getProperties().getRecordSearchDispositionPeriod().equalsIgnoreCase("none"),
"Disposition period property should be none");
assertTrue(elRecord.getProperties().getRecordSearchDispositionPeriodExpression().equalsIgnoreCase("0"),
"Disposition period expression should be 0");
assertFalse(elRecord.getProperties().getRecordSearchDispositionEvents().contains(RMEvents.CASE_CLOSED.getEventName()),
"Event list contain the event from the previous RS ");
assertTrue(elRecord.getProperties().getRecordSearchDispositionEvents().contains(RMEvents.OBSOLETE.getEventName()),
"Event list doesn't contain the event from the current RS ");
assertTrue(nonElRecord.getProperties().getRecordSearchDispositionActionName().equalsIgnoreCase(RM_ACTIONS.CUT_OFF.getAction()),
"Disposition action should be cut off");
assertTrue(nonElRecord.getProperties().getRecordSearchDispositionPeriod().equalsIgnoreCase("none"),
"Disposition period property should be none");
assertTrue(nonElRecord.getProperties().getRecordSearchDispositionPeriodExpression().equalsIgnoreCase("0"),
"Disposition period expression should be 0");
assertFalse(nonElRecord.getProperties().getRecordSearchDispositionEvents().contains(RMEvents.CASE_CLOSED.getEventName()),
"Event list contain the event from the previous RS ");
assertTrue(nonElRecord.getProperties().getRecordSearchDispositionEvents().contains(RMEvents.OBSOLETE.getEventName()),
"Event list doesn't contain the event from the current RS ");
}
@AfterMethod (alwaysRun = true)
public void cleanupMoveRecCategoriesWithRSTests()
{
getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(rootCategory.getId());
getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(rootCategory2.getId());
}
/**
* Helper method to create a sub-category with a folder, an incomplete electronic record and a complete
* electronic record
* @return
*/
private RecordCategoryChild createSubCategoryWithRecords()
{
STEP("Create a subcategory with a record folder");
RecordCategoryChild subCategory = createRecordCategory(rootCategory.getId(), getRandomName("subCategory"));
RecordCategoryChild recFolder = createFolder(subCategory.getId(), getRandomName("recFolder"));
STEP("Create 2 records in the record folder. Complete one of them.");
elRecord = createElectronicRecord(recFolder.getId(), getRandomName("elRecord"));
nonElRecord = createNonElectronicRecord(recFolder.getId(), getRandomName("nonElRecord"));
getRestAPIFactory().getRecordsAPI().completeRecord(nonElRecord.getId());
return subCategory;
}
}

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-parent</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<modules>

View File

@@ -1,4 +1,4 @@
TRANSFORMERS_TAG=2.5.2
TRANSFORMERS_TAG=2.5.3
SOLR6_TAG=2.0.2-RC1
POSTGRES_TAG=13.3
ACTIVEMQ_TAG=5.16.1

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<properties>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<build>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<modules>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-amps</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<properties>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<dependencies>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<properties>

View File

@@ -25,8 +25,6 @@
*/
package org.alfresco.repo.content;
import java.util.Date;
import org.alfresco.api.AlfrescoPublicApi;
import org.alfresco.service.cmr.repository.ContentAccessor;
import org.alfresco.service.cmr.repository.ContentIOException;
@@ -34,7 +32,6 @@ import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentStreamListener;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.DirectAccessUrl;
import org.alfresco.service.cmr.repository.NodeRef;
/**
@@ -254,9 +251,10 @@ public interface ContentStore
/**
* Checks if the store supports the retrieving of a direct access URL for the given node.
*
* @param contentUrl the {@code URL} of the content for which to request a direct access {@code URL}
* @return {@code true} if direct access URLs retrieving is supported for the node, {@code false} otherwise
*/
default boolean isContentDirectUrlEnabled(NodeRef nodeRef)
default boolean isContentDirectUrlEnabled(String contentUrl)
{
return false;
}
@@ -292,31 +290,4 @@ public interface ContentStore
throw new UnsupportedOperationException(
"Retrieving direct access URLs is not supported by this content store.");
}
/**
* Gets a presigned URL to directly access a binary content. It is up to the actual store
* implementation if it can fulfil this request with an expiry time or not.
*
* @param contentUrl A content store URL
* @param expiresAt An optional expiry date, so the direct access url would become invalid when the expiry date is reached
* @return A direct access URL object for a binary content
* @throws UnsupportedOperationException if the store is unable to provide the information
*/
@Deprecated
default DirectAccessUrl getDirectAccessUrl(String contentUrl, Date expiresAt)
{
throw new UnsupportedOperationException(
"Retrieving direct access URLs is not supported by this content store.");
}
/**
* Checks if the store supports the retrieving of direct access URLs.
*
* @return true if direct access URLs retrieving is supported, false otherwise
*/
@Deprecated
default boolean isDirectAccessSupported()
{
return false;
}
}

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Data model classes
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* 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

View File

@@ -9,6 +9,6 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
</project>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<properties>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<modules>

View File

@@ -1,4 +1,4 @@
TRANSFORMERS_TAG=2.5.2
TRANSFORMERS_TAG=2.5.3
SOLR6_TAG=2.0.2
POSTGRES_TAG=13.3
ACTIVEMQ_TAG=5.16.1

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<modules>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<developers>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<developers>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<developers>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<developers>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<developers>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<properties>

View File

@@ -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>11.112</version>
<version>11.125</version>
<packaging>pom</packaging>
<name>Alfresco Community Repo Parent</name>
@@ -53,7 +53,7 @@
<dependency.activiti.version>5.23.0</dependency.activiti.version>
<dependency.alfresco-transform-model.version>1.4.0</dependency.alfresco-transform-model.version>
<dependency.alfresco-greenmail.version>6.2</dependency.alfresco-greenmail.version>
<dependency.acs-event-model.version>0.0.12</dependency.acs-event-model.version>
<dependency.acs-event-model.version>0.0.13</dependency.acs-event-model.version>
<dependency.spring.version>5.3.9</dependency.spring.version>
<dependency.antlr.version>3.5.2</dependency.antlr.version>
@@ -105,7 +105,7 @@
<alfresco.googledrive.version>3.2.1.3</alfresco.googledrive.version>
<alfresco.aos-module.version>1.4.0.1</alfresco.aos-module.version>
<alfresco.api-explorer.version>7.0.0</alfresco.api-explorer.version>
<alfresco.api-explorer.version>7.1.0-A1</alfresco.api-explorer.version>
<alfresco.maven-plugin.version>2.2.0</alfresco.maven-plugin.version>
<dependency.postgresql.version>42.2.20</dependency.postgresql.version>
@@ -142,7 +142,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>11.112</tag>
<tag>11.125</tag>
</scm>
<distributionManagement>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<dependencies>

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* 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
@@ -34,6 +34,7 @@ import org.alfresco.rest.api.model.UserInfo;
import org.alfresco.rest.framework.resource.content.BinaryResource;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.service.cmr.repository.DirectAccessUrl;
/**
* Handles trashcan / deleted nodes
@@ -99,4 +100,29 @@ public interface DeletedNodes
* @return
*/
CollectionWithPagingInfo<Rendition> getRenditions(String archivedId, Parameters parameters);
/**
* Gets a presigned URL to directly access content.
*
* @param archivedId The node id for which to obtain the direct access {@code URL}
* @param renditionId The rendition id for which to obtain the direct access {@code URL}
* @param attachment {@code true} if an attachment {@code URL} is requested, {@code false} for an embedded {@code URL}, {@code true} by default.
* @return A direct access {@code URL} object for the content.
*/
default DirectAccessUrl requestContentDirectUrl(String archivedId, String renditionId, boolean attachment)
{
return requestContentDirectUrl(archivedId, renditionId, attachment, null);
}
/**
* Gets a presigned URL to directly access content.
*
* @param archivedId The node id for which to obtain the direct access {@code URL}
* @param renditionId The rendition id for which to obtain the direct access {@code URL}
* @param attachment {@code true} if an attachment {@code URL} is requested, {@code false} for an embedded {@code URL}, {@code true} by default.
* @param validFor The time at which the direct access {@code URL} will expire.
* @return A direct access {@code URL} object for the content.
*/
DirectAccessUrl requestContentDirectUrl(String archivedId, String renditionId, boolean attachment, Long validFor);
}

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* 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
@@ -55,6 +55,7 @@ import org.alfresco.rest.framework.resource.content.BinaryResource;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.rest.framework.tools.RecognizedParamsExtractor;
import org.alfresco.service.cmr.repository.DirectAccessUrl;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
@@ -244,4 +245,23 @@ public class DeletedNodesImpl implements DeletedNodes, RecognizedParamsExtractor
NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, archivedId);
return renditions.getRenditions(nodeRef, parameters);
}
/**
* {@inheritDoc}
*/
@Override
public DirectAccessUrl requestContentDirectUrl(String originalNodeId, String renditionId, boolean attachment, Long validFor)
{
//First check the node is valid and has been archived.
NodeRef validatedNodeRef = nodes.validateNode(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, originalNodeId);
if (renditionId != null)
{
return renditions.requestContentDirectUrl(validatedNodeRef, null, renditionId, attachment, validFor);
}
else
{
return nodes.requestContentDirectUrl(validatedNodeRef, attachment, validFor);
}
}
}

View File

@@ -119,7 +119,7 @@ public class NodeRenditionsRelation implements RelationshipResourceAction.Read<R
return renditions.getContent(nodeRef, renditionId, parameters);
}
@Operation ("requestRenditionDirectAccessUrl")
@Operation("request-direct-access-url")
@WebApiParam (name = "requestRenditionDirectAccessUrl", title = "Request direct access url", description = "Request direct access url", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT)
@WebApiDescription(title = "Request content url",
description="Generates a direct access URL.",

View File

@@ -132,7 +132,7 @@ public class NodeVersionRenditionsRelation implements RelationshipResourceAction
return renditions.getContent(nodeRef, versionId, renditionId, parameters);
}
@Operation ("requestVersionRenditionDirectAccessUrl")
@Operation ("request-direct-access-url")
@WebApiParam (name = "requestVersionRenditionDirectAccessUrl", title = "Request direct access url", description = "Request direct access url", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT)
@WebApiDescription(title = "Request content url",
description="Generates a direct access URL.",

View File

@@ -302,7 +302,7 @@ public class NodeVersionsRelation extends AbstractNodeRelation implements
return null;
}
@Operation("requestVersionDirectAccessUrl")
@Operation("request-direct-access-url")
@WebApiParam (name = "requestVersionDirectAccessUrl", title = "Request direct access url", description = "Request direct access url", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT)
@WebApiDescription(title = "Request content url",
description="Generates a direct access URL.",

View File

@@ -202,7 +202,7 @@ public class NodesEntityResource implements
return nodes.unlock(nodeId, parameters);
}
@Operation("requestNodeDirectAccessUrl")
@Operation("request-direct-access-url")
@WebApiParam(name = "requestNodeDirectAccessUrl", title = "Request direct access url", description = "Request direct access url", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT)
@WebApiDescription(title = "Request content url",
description="Generates a direct access URL.",

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* 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
@@ -28,7 +28,10 @@ package org.alfresco.rest.api.trashcan;
import javax.servlet.http.HttpServletResponse;
import org.alfresco.repo.content.directurl.DirectAccessUrlDisabledException;
import org.alfresco.rest.api.DeletedNodes;
import org.alfresco.rest.api.DirectAccessUrlHelper;
import org.alfresco.rest.api.model.DirectAccessUrlRequest;
import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.api.model.NodeTargetAssoc;
import org.alfresco.rest.framework.BinaryProperties;
@@ -36,6 +39,7 @@ import org.alfresco.rest.framework.Operation;
import org.alfresco.rest.framework.WebApiDescription;
import org.alfresco.rest.framework.WebApiParam;
import org.alfresco.rest.framework.core.ResourceParameter;
import org.alfresco.rest.framework.core.exceptions.DisabledServiceException;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.resource.EntityResource;
import org.alfresco.rest.framework.resource.actions.interfaces.BinaryResourceAction;
@@ -44,6 +48,7 @@ import org.alfresco.rest.framework.resource.content.BinaryResource;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.rest.framework.webscripts.WithResponse;
import org.alfresco.service.cmr.repository.DirectAccessUrl;
/**
* An implementation of an Entity Resource for handling archived content
@@ -55,12 +60,18 @@ public class TrashcanEntityResource implements
EntityResourceAction.ReadById<Node>, EntityResourceAction.Read<Node>, EntityResourceAction.Delete, BinaryResourceAction.Read
{
private DeletedNodes deletedNodes;
private DirectAccessUrlHelper directAccessUrlHelper;
public void setDeletedNodes(DeletedNodes deletedNodes)
{
this.deletedNodes = deletedNodes;
}
public void setDirectAccessUrlHelper(DirectAccessUrlHelper directAccessUrlHelper)
{
this.directAccessUrlHelper = directAccessUrlHelper;
}
@Override
public CollectionWithPagingInfo<Node> readAll(Parameters params)
{
@@ -89,6 +100,27 @@ public class TrashcanEntityResource implements
return deletedNodes.getContent(nodeId, null, parameters);
}
@Operation("request-direct-access-url")
@WebApiParam(name = "requestDeletedNodeDirectAccessUrl", title = "Request direct access url", description = "Request direct access url", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT)
@WebApiDescription(title = "Request content url",
description="Generates a direct access URL.",
successStatus = HttpServletResponse.SC_OK)
public DirectAccessUrl requestContentDirectUrl(String originalNodeId, DirectAccessUrlRequest directAccessUrlRequest, Parameters parameters, WithResponse withResponse)
{
boolean attachment = directAccessUrlHelper.getAttachment(directAccessUrlRequest);
Long validFor = directAccessUrlHelper.getDefaultExpiryTimeInSec();
DirectAccessUrl directAccessUrl;
try
{
directAccessUrl = deletedNodes.requestContentDirectUrl(originalNodeId, null, attachment, validFor);
}
catch (DirectAccessUrlDisabledException ex)
{
throw new DisabledServiceException(ex.getMessage());
}
return directAccessUrl;
}
@Override
public void delete(String nodeId, Parameters parameters)
{

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* 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
@@ -25,18 +25,27 @@
*/
package org.alfresco.rest.api.trashcan;
import javax.servlet.http.HttpServletResponse;
import org.alfresco.repo.content.directurl.DirectAccessUrlDisabledException;
import org.alfresco.rest.api.DeletedNodes;
import org.alfresco.rest.api.DirectAccessUrlHelper;
import org.alfresco.rest.api.model.DirectAccessUrlRequest;
import org.alfresco.rest.api.model.Rendition;
import org.alfresco.rest.framework.BinaryProperties;
import org.alfresco.rest.framework.Operation;
import org.alfresco.rest.framework.WebApiDescription;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
import org.alfresco.rest.framework.WebApiParam;
import org.alfresco.rest.framework.core.ResourceParameter;
import org.alfresco.rest.framework.core.exceptions.DisabledServiceException;
import org.alfresco.rest.framework.resource.RelationshipResource;
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceBinaryAction;
import org.alfresco.rest.framework.resource.content.BinaryResource;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.rest.framework.webscripts.WithResponse;
import org.alfresco.service.cmr.repository.DirectAccessUrl;
import org.alfresco.util.ParameterCheck;
import org.springframework.beans.factory.InitializingBean;
@@ -46,12 +55,18 @@ public class TrashcanRenditionsRelation
{
private DeletedNodes deletedNodes;
private DirectAccessUrlHelper directAccessUrlHelper;
public void setDeletedNodes(DeletedNodes deletedNodes)
{
this.deletedNodes = deletedNodes;
}
public void setDirectAccessUrlHelper(DirectAccessUrlHelper directAccessUrlHelper)
{
this.directAccessUrlHelper = directAccessUrlHelper;
}
@WebApiDescription(title = "List renditions", description = "List available (created) renditions")
@Override
public CollectionWithPagingInfo<Rendition> readAll(String nodeId, Parameters parameters)
@@ -74,6 +89,27 @@ public class TrashcanRenditionsRelation
return deletedNodes.getContent(nodeId, renditionId, parameters);
}
@Operation ("request-direct-access-url")
@WebApiParam (name = "requestArchivedNodeRenditionDirectAccessUrl", title = "Request direct access url", description = "Request direct access url", kind = ResourceParameter.KIND.HTTP_BODY_OBJECT)
@WebApiDescription(title = "Request content url",
description="Generates a direct access URL.",
successStatus = HttpServletResponse.SC_OK)
public DirectAccessUrl requestContentDirectUrl(String originalNodeId, String renditionId, DirectAccessUrlRequest directAccessUrlRequest, Parameters parameters, WithResponse withResponse)
{
boolean attachment = directAccessUrlHelper.getAttachment(directAccessUrlRequest);
Long validFor = directAccessUrlHelper.getDefaultExpiryTimeInSec();
DirectAccessUrl directAccessUrl;
try
{
directAccessUrl = deletedNodes.requestContentDirectUrl(originalNodeId, renditionId, attachment, validFor);
}
catch (DirectAccessUrlDisabledException ex)
{
throw new DisabledServiceException(ex.getMessage());
}
return directAccessUrl;
}
@Override
public void afterPropertiesSet() throws Exception
{

View File

@@ -995,9 +995,9 @@
<bean class="org.alfresco.rest.api.trashcan.TrashcanEntityResource">
<property name="deletedNodes" ref="DeletedNodes" />
<property name="directAccessUrlHelper" ref="directAccessUrlHelper" />
</bean>
<bean class="org.alfresco.rest.api.quicksharelinks.QuickShareLinkEntityResource">
<property name="quickShareLinks" ref="QuickShareLinks" />
</bean>
@@ -1438,6 +1438,7 @@
<bean class="org.alfresco.rest.api.trashcan.TrashcanRenditionsRelation">
<property name="deletedNodes" ref="DeletedNodes"/>
<property name="directAccessUrlHelper" ref="directAccessUrlHelper" />
</bean>
<!-- HeartBeat rest api renditions data collector -->

View File

@@ -138,7 +138,7 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
protected final String RUNID = System.currentTimeMillis()+"";
private static final String REQUEST_NODE_DIRECT_ACCESS_URL = "requestNodeDirectAccessUrl";
private static final String REQUEST_DIRECT_ACCESS_URL = "request-direct-access-url";
@Override
@Before
@@ -216,7 +216,7 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
protected String getRequestContentDirectUrl(String nodeId)
{
return URL_NODES + "/" + nodeId + "/" + REQUEST_NODE_DIRECT_ACCESS_URL;
return URL_NODES + "/" + nodeId + "/" + REQUEST_DIRECT_ACCESS_URL;
}
/**

View File

@@ -141,6 +141,8 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
private String groupA = null;
private String groupB = null;
private final static long DELAY_IN_MS = 500;
@Before
public void setup() throws Exception
{
@@ -6275,8 +6277,7 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
assertNotNull(contentInfo);
assertEquals(MimetypeMap.MIMETYPE_TEXT_PLAIN, contentInfo.getMimeType());
getSingle(getRequestContentDirectUrl(contentNodeId), null, null, null, 405);
HttpResponse dauResponse = post(getRequestContentDirectUrl(contentNodeId), null, null, null, null, 501);
}
@Test
@@ -6320,7 +6321,7 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
assertNotNull(contentInfo);
assertEquals(MimetypeMap.MIMETYPE_TEXT_PLAIN, contentInfo.getMimeType());
getSingle(getRequestContentDirectUrl(contentNodeId), null, null, null, 405);
HttpResponse dauResponse = post(getRequestContentDirectUrl(contentNodeId), null, null, null, null, 501);
}
@Test
@@ -6365,7 +6366,114 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
assertNotNull(rendition);
assertEquals(Rendition.RenditionStatus.CREATED, rendition.getStatus());
getSingle(getRequestContentDirectUrl(contentNodeId), null, null, null, 405);
HttpResponse dauResponse = post(getRequestContentDirectUrl(contentNodeId), null, null, null, null, 501);
}
@Test
public void testCreateRenditionForNewVersion() throws Exception
{
setRequestContext(user1);
RepoService.TestNetwork networkN1;
RepoService.TestPerson userOneN1;
Site userOneN1Site;
networkN1 = repoService.createNetworkWithAlias("ping", true);
networkN1.create();
userOneN1 = networkN1.createUser();
setRequestContext(networkN1.getId(), userOneN1.getId(), null);
String siteTitle = "RandomSite" + System.currentTimeMillis();
userOneN1Site = createSite(siteTitle, SiteVisibility.PRIVATE);
String PROP_LTM = "cm:lastThumbnailModification";
String RENDITION_NAME = "imgpreview";
String userId = userOneN1.getId();
setRequestContext(networkN1.getId(), userOneN1.getId(), null);
// Create a folder within the site document's library
String folderName = "folder" + System.currentTimeMillis();
String parentId = getSiteContainerNodeId(userOneN1Site.getId(), "documentLibrary");
String folder_Id = createNode(parentId, folderName, TYPE_CM_FOLDER, null).getId();
// Create multipart request - pdf file
String fileName = "quick.pdf";
File file = getResourceFile(fileName);
MultiPartRequest reqBody = MultiPartBuilder.create()
.setFileData(new FileData(fileName, file))
.build();
Map<String, String> params = Collections.singletonMap("include", "properties");
// Upload quick.pdf file into 'folder' - do not include request to create 'doclib' thumbnail
HttpResponse response = post(getNodeChildrenUrl(folder_Id), reqBody.getBody(), params, null, "alfresco", reqBody.getContentType(), 201);
Document document1 = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
String contentNodeId = document1.getId();
assertNotNull(document1.getProperties());
// pause briefly
Thread.sleep(DELAY_IN_MS);
// Get rendition (not created yet) information for node
response = getSingle(getNodeRenditionsUrl(contentNodeId), RENDITION_NAME, 200);
Rendition rendition = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Rendition.class);
assertNotNull(rendition);
assertEquals(Rendition.RenditionStatus.NOT_CREATED, rendition.getStatus());
params = new HashMap<>();
params.put("placeholder", "false");
getSingle(getNodeRenditionsUrl(contentNodeId), (RENDITION_NAME+"/content"), params, 404);
// Create and get 'imgpreview' rendition
rendition = createAndGetRendition(contentNodeId, RENDITION_NAME);
assertNotNull(rendition);
params = new HashMap<>();
params.put("placeholder", "false");
response = getSingle(getNodeRenditionsUrl(contentNodeId), (RENDITION_NAME+"/content"), params, 200);
byte[] renditionBytes1 = response.getResponseAsBytes();
assertNotNull(renditionBytes1);
// check node details ...
params = Collections.singletonMap("include", "properties");
response = getSingle(NodesEntityResource.class, contentNodeId, params, 200);
Document document1b = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
assertEquals(document1b.getModifiedByUser().getId(), document1.getModifiedByUser().getId());
// upload another version of "quick.pdf" and check again
fileName = "quick-2.pdf";
file = getResourceFile(fileName);
reqBody = MultiPartBuilder.create()
.setFileData(new FileData("quick.pdf", file))
.setOverwrite(true)
.build();
response = post(getNodeChildrenUrl(folder_Id), reqBody.getBody(), null, null, "alfresco", reqBody.getContentType(), 201);
Document document2 = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
assertEquals(contentNodeId, document2.getId());
// wait to allow new version of the rendition to be created ...
Thread.sleep(DELAY_IN_MS * 4);
params = new HashMap<>();
params.put("placeholder", "false");
response = getSingle(getNodeRenditionsUrl(contentNodeId), (RENDITION_NAME+"/content"), params, 200);
assertNotNull(response.getResponseAsBytes());
// check rendition binary has changed
assertNotEquals(renditionBytes1, response.getResponseAsBytes());
params = Collections.singletonMap("include", "properties");
response = getSingle(NodesEntityResource.class, contentNodeId, params, 200);
Document document2b = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
String contentNodeId2b = document2b.getId();
HttpResponse dauResponse = post(getRequestContentDirectUrl(contentNodeId2b), null, null, null, null, 501);
}
}

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>11.112</version>
<version>11.125</version>
</parent>
<dependencies>

View File

@@ -27,7 +27,6 @@ package org.alfresco.repo.content;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -520,12 +519,6 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa
return tempStore.getWriter(ContentContext.NULL_CONTEXT);
}
@Deprecated
public DirectAccessUrl getDirectAccessUrl(NodeRef nodeRef, Date expiresAt)
{
return requestContentDirectUrl(nodeRef, true, null);
}
/**
* Ensures that, upon closure of the output stream, the node is updated with
* the latest URL of the content to which it refers.
@@ -612,7 +605,7 @@ public class ContentServiceImpl implements ContentService, ApplicationContextAwa
throw new IllegalArgumentException("The supplied nodeRef " + nodeRef + " has no content.");
}
contentDirectUrlEnabled = (store.isContentDirectUrlEnabled(nodeRef));
contentDirectUrlEnabled = (store.isContentDirectUrlEnabled(getContentUrl(nodeRef)));
}
return contentDirectUrlEnabled;

View File

@@ -489,9 +489,9 @@ public class CachingContentStore implements ContentStore, ApplicationEventPublis
/**
* {@inheritDoc}
*/
public boolean isContentDirectUrlEnabled(NodeRef nodeRef)
public boolean isContentDirectUrlEnabled(String contentUrl)
{
return backingStore.isContentDirectUrlEnabled(nodeRef);
return backingStore.isContentDirectUrlEnabled(contentUrl);
}
/**

View File

@@ -294,10 +294,10 @@ public class AggregatingContentStore extends AbstractContentStore
/**
* @return Returns {@code true} if at least one store supports direct access URL for node
*/
public boolean isContentDirectUrlEnabled(NodeRef nodeRef)
public boolean isContentDirectUrlEnabled(String contentUrl)
{
// Check the primary store
boolean isContentDirectUrlEnabled = primaryStore.isContentDirectUrlEnabled(nodeRef);
boolean isContentDirectUrlEnabled = primaryStore.isContentDirectUrlEnabled(contentUrl);
if (!isContentDirectUrlEnabled)
{
@@ -305,7 +305,7 @@ public class AggregatingContentStore extends AbstractContentStore
// other stores
for (ContentStore store : secondaryStores)
{
isContentDirectUrlEnabled = store.isContentDirectUrlEnabled(nodeRef);
isContentDirectUrlEnabled = store.isContentDirectUrlEnabled(contentUrl);
if (isContentDirectUrlEnabled)
{

View File

@@ -27,7 +27,6 @@ package org.alfresco.repo.event2;
import java.util.ArrayDeque;
import java.util.Deque;
import org.alfresco.repo.event.v1.model.ChildAssociationResource;
import org.alfresco.repo.event.v1.model.DataAttributes;
import org.alfresco.repo.event.v1.model.EventData;
@@ -117,8 +116,9 @@ public class ChildAssociationEventConsolidator implements ChildAssociationEventS
{
String parentId = childAssociationRef.getParentRef().getId();
String childId = childAssociationRef.getChildRef().getId();
String assocQName = helper.getQNamePrefixString(childAssociationRef.getQName());
String assocType = helper.getQNamePrefixString(childAssociationRef.getTypeQName());
return new ChildAssociationResource(parentId, childId, assocType);
return new ChildAssociationResource(parentId, childId, assocType, assocQName);
}
/**

View File

@@ -46,6 +46,7 @@ import org.alfresco.repo.event2.filter.NodePropertyFilter;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.MLText;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -148,6 +149,7 @@ public class NodeResourceHelper implements InitializingBean
.setModifiedByUser(getUserInfo((String) properties.get(ContentModel.PROP_MODIFIER), mapUserCache))
.setModifiedAt(getZonedDateTime((Date)properties.get(ContentModel.PROP_MODIFIED)))
.setContent(getContentInfo(properties))
.setPrimaryAssocQName(getPrimaryAssocQName(nodeRef))
.setPrimaryHierarchy(PathUtil.getNodeIdsInReverse(path, false))
.setProperties(mapToNodeProperties(properties))
.setAspectNames(getMappedAspects(nodeRef));
@@ -158,6 +160,23 @@ public class NodeResourceHelper implements InitializingBean
return dictionaryService.isSubClass(className, ofClassQName);
}
private String getPrimaryAssocQName(NodeRef nodeRef)
{
String result = null;
try
{
ChildAssociationRef primaryParent = nodeService.getPrimaryParent(nodeRef);
if(primaryParent != null && primaryParent.getQName() != null)
{
result = primaryParent.getQName().getPrefixedQName(namespaceService).getPrefixString();
}
} catch (NamespaceException namespaceException)
{
LOGGER.error("Cannot return a valid primary association QName: " + namespaceException.getMessage());
}
return result;
}
private UserInfo getUserInfo(String userName, Map<String, UserInfo> mapUserCache)
{
UserInfo userInfo = mapUserCache.get(userName);

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2019 Alfresco Software Limited
* Copyright (C) 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
@@ -120,21 +120,21 @@ public class LocalSynchronousTransformClient implements SynchronousTransformClie
if (logger.isDebugEnabled())
{
logger.debug(TRANSFORM + " requested " + renditionName);
logger.debug(TRANSFORM + "requested " + renditionName);
}
transform.transform(reader, writer, actualOptions, renditionName, sourceNodeRef);
if (logger.isDebugEnabled())
{
logger.debug(TRANSFORM + " created " + renditionName);
logger.debug(TRANSFORM + "created " + renditionName);
}
}
catch (Exception e)
{
if (logger.isDebugEnabled())
{
logger.debug(TRANSFORM + " failed " + renditionName, e);
logger.debug(TRANSFORM + "failed " + renditionName, e);
}
throw e;
}

View 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.search.impl.querymodel.impl.db;
import java.util.ArrayList;
@@ -74,6 +74,10 @@ public class DBQuery extends BaseQuery implements DBQueryBuilderComponent
Set<String> selectorGroup;
private int limit = 0;
private int offset = 0;
/**
* @param source Source
* @param constraint Constraint
@@ -133,6 +137,22 @@ public class DBQuery extends BaseQuery implements DBQueryBuilderComponent
this.sinceTxId = sinceTxId;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public int getOffset() {
return offset;
}
public void setOffset(int offset) {
this.offset = offset;
}
public List<DBQueryBuilderJoinCommand> getJoins()
{
HashMap<QName, DBQueryBuilderJoinCommand> singleJoins = new HashMap<QName, DBQueryBuilderJoinCommand>();

View File

@@ -76,8 +76,10 @@ 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.executor.result.DefaultResultContext;
import org.apache.ibatis.session.ResultContext;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.mybatis.spring.SqlSessionTemplate;
/**
@@ -89,7 +91,11 @@ 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";
private static final int DEFAULT_MIN_PAGING_BATCH_SIZE = 2500;
private static final int DEFAULT_MAX_PAGING_BATCH_SIZE = 10000;
protected SqlSessionTemplate template;
protected QNameDAO qnameDAO;
@@ -114,6 +120,12 @@ public class DBQueryEngine implements QueryEngine
private boolean maxPermissionCheckEnabled;
private boolean usePagingQuery = false;
private int minPagingBatchSize = DEFAULT_MIN_PAGING_BATCH_SIZE;
private int maxPagingBatchSize = DEFAULT_MAX_PAGING_BATCH_SIZE;
protected EntityLookupCache<Long, Node, NodeRef> nodesCache;
private List<Pair<Long, StoreRef>> stores;
@@ -149,7 +161,31 @@ public class DBQueryEngine implements QueryEngine
{
this.permissionService = permissionService;
}
public boolean isUsePagingQuery() {
return usePagingQuery;
}
public void setUsePagingQuery(boolean usePagingQuery) {
this.usePagingQuery = usePagingQuery;
}
public int getMinPagingBatchSize() {
return minPagingBatchSize;
}
public void setMinPagingBatchSize(int minPagingBatchSize) {
this.minPagingBatchSize = minPagingBatchSize;
}
public int getMaxPagingBatchSize() {
return maxPagingBatchSize;
}
public void setMaxPagingBatchSize(int maxPagingBatchSize) {
this.maxPagingBatchSize = maxPagingBatchSize;
}
public void setMetadataIndexCheck2(OptionalPatchApplicationCheckBootstrapBean metadataIndexCheck2)
{
this.metadataIndexCheck2 = metadataIndexCheck2;
@@ -331,7 +367,7 @@ public class DBQueryEngine implements QueryEngine
int requiredNodes = computeRequiredNodesCount(options);
logger.debug("- query sent to the database");
template.select(pickQueryTemplate(options, dbQuery), dbQuery, new ResultHandler<Node>()
performTmdqSelect(pickQueryTemplate(options, dbQuery), dbQuery, requiredNodes, new ResultHandler<Node>()
{
@Override
public void handleResult(ResultContext<? extends Node> context)
@@ -399,6 +435,54 @@ public class DBQueryEngine implements QueryEngine
return frs;
}
private void performTmdqSelect(String statement, DBQuery dbQuery, int requiredNodes, ResultHandler<Node> handler)
{
if (usePagingQuery)
{
performTmdqSelectPaging(statement, dbQuery, requiredNodes, handler);
}
else
{
performTmdqSelectStreaming(statement, dbQuery, handler);
}
}
private void performTmdqSelectStreaming(String statement, DBQuery dbQuery, ResultHandler<Node> handler)
{
template.select(statement, dbQuery, handler);
}
private void performTmdqSelectPaging(String statement, DBQuery dbQuery, int requiredNodes, ResultHandler<Node> handler)
{
int batchStart = 0;
int batchSize = requiredNodes * 2;
batchSize = Math.min(Math.max(batchSize, minPagingBatchSize), maxPagingBatchSize);
DefaultResultContext<Node> resultCtx = new DefaultResultContext<>();
while (!resultCtx.isStopped())
{
dbQuery.setOffset(batchStart);
dbQuery.setLimit(batchSize);
List<Node> batch = template.selectList(statement, dbQuery);
for (Node node : batch)
{
resultCtx.nextResultObject(node);
handler.handleResult(resultCtx);
if (resultCtx.isStopped())
{
break;
}
}
if (batch.size() < batchSize)
{
resultCtx.stop();
}
else
{
batchStart += batchSize;
}
}
}
private DBResultSet createResultSet(QueryOptions options, List<Node> nodes, int numberFound)
{
DBResultSet dbResultSet = new DBResultSet(options.getAsSearchParmeters(), nodes, nodeDAO, nodeService, tenantService, Integer.MAX_VALUE);

View File

@@ -25,7 +25,6 @@
*/
package org.alfresco.service.cmr.repository;
import java.util.Date;
import org.alfresco.api.AlfrescoPublicApi;
import org.alfresco.service.Auditable;
@@ -155,23 +154,6 @@ public interface ContentService
@Auditable
public ContentWriter getTempWriter();
/**
* Gets a presigned URL to directly access a binary content. It is up to the
* content store if it can fulfil this request with an expiry time (in
* milliseconds) or not.
*
* @param nodeRef
* a reference to a node having a content property
* @param expiresAt
* an optional expiry date, so the direct access url would become
* invalid when the expiry date is reached
* @return A direct access URL object for a binary content or returns null if not supported
* @throws IllegalArgumentException if there is no binary content for the node
*/
@Deprecated
@Auditable(parameters = {"nodeRef", "expiresAt"})
public DirectAccessUrl getDirectAccessUrl(NodeRef nodeRef, Date expiresAt);
/**
* Checks if the system and at least one store supports the retrieving of direct access URLs.
*

View File

@@ -177,7 +177,8 @@
</choose>
</foreach>
</if>
</if>
</sql>
</if>
<if test="limit != 0">limit #{offset}, #{limit}</if>
</sql>
</mapper>

View File

@@ -105,8 +105,35 @@
<ref bean="metadataQueryIndexesCheck2" />
</property>
</bean>
<bean id="search.dbQueryEngineImpl" class="org.alfresco.repo.search.impl.querymodel.impl.db.DBQueryEngine" >
<bean id="search.dbQueryEngineImpl" class="org.alfresco.util.bean.HierarchicalBeanLoader">
<property name="targetBeanName">
<value>search.dbQueryEngineImpl.#bean.dialect#</value>
</property>
<property name="targetClass">
<value>org.alfresco.repo.search.impl.querymodel.QueryEngine</value>
</property>
<property name="dialectBaseClass">
<value>org.alfresco.repo.domain.dialect.Dialect</value>
</property>
<property name="dialectClass">
<bean class="org.springframework.beans.factory.config.PropertyPathFactoryBean">
<property name="targetBeanName" value="dialect" />
<property name="propertyPath" value="class.name" />
</bean>
</property>
</bean>
<bean id="search.dbQueryEngineImpl.org.alfresco.repo.domain.dialect.Dialect"
parent="search.baseDbQueryEngineImpl">
<property name="usePagingQuery" value="false"/>
</bean>
<bean id="search.dbQueryEngineImpl.org.alfresco.repo.domain.dialect.MySQLInnoDBDialect"
parent="search.baseDbQueryEngineImpl">
<property name="usePagingQuery" value="true"/>
</bean>
<bean id="search.baseDbQueryEngineImpl" class="org.alfresco.repo.search.impl.querymodel.impl.db.DBQueryEngine" abstract="true">
<property name="permissionService" ref="permissionService"/>
<property name="dictionaryService" ref="dictionaryService" />
<property name="namespaceService" ref="namespaceService" />

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2017 Alfresco Software Limited
* 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
@@ -77,7 +77,10 @@ import org.junit.runners.Suite;
// From MiscContextTestSuite
org.alfresco.repo.domain.query.CannedQueryDAOTest.class,
// REPO-2963 : Tests causing a cascade of failures in AllDBTestsTestSuite on PostgreSQL/MySQL
// ACS-1907
org.alfresco.repo.search.impl.querymodel.impl.db.ACS1907Test.class,
// REPO-2963 : Tests causing a cascade of failures in AllDBTestsTestSuite on PostgreSQL/MySQL
// Moved at the bottom of the suite because DbNodeServiceImplTest.testNodeCleanupRegistry() takes a long time on a clean DB.
org.alfresco.repo.node.db.DbNodeServiceImplTest.class,

View File

@@ -492,7 +492,7 @@ public class CachingContentStoreTest
}
@Test
public void isDirectAccessSupported()
public void isContentDirectUrlSupported()
{
assertFalse(cachingStore.isContentDirectUrlEnabled());
@@ -501,7 +501,7 @@ public class CachingContentStoreTest
}
@Test
public void getDirectAccessUrlUnsupported()
public void getRequestContentDirectUrlUnsupported()
{
try
{
@@ -516,7 +516,7 @@ public class CachingContentStoreTest
}
@Test
public void getDirectAccessUrl()
public void getRequestContentDirectUrl()
{
when(backingStore.requestContentDirectUrl(anyString(), eq(true), anyString(), anyLong())).thenReturn(new DirectAccessUrl());
cachingStore.requestContentDirectUrl("url", true,"someFile", 30L);

View File

@@ -216,7 +216,7 @@ public class AggregatingContentStoreTest extends AbstractWritableContentStoreTes
}
@Test
public void testGetDirectAccessUrl()
public void testRequestContentDirectUrl()
{
// Create the aggregating store
AggregatingContentStore aggStore = new AggregatingContentStore();

View File

@@ -36,6 +36,7 @@ import java.util.List;
import javax.jms.ConnectionFactory;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.dictionary.NamespaceDAO;
import org.alfresco.repo.event.v1.model.ChildAssociationResource;
import org.alfresco.repo.event.v1.model.DataAttributes;
import org.alfresco.repo.event.v1.model.EventType;
@@ -114,6 +115,9 @@ public abstract class AbstractContextAwareRepoEvent extends BaseSpringTest
@Qualifier("eventGeneratorQueue")
protected EventGeneratorQueue eventQueue;
@Autowired
private NamespaceDAO namespaceDAO;
protected NodeRef rootNodeRef;
@BeforeClass
@@ -152,9 +156,19 @@ public abstract class AbstractContextAwareRepoEvent extends BaseSpringTest
return nodeService.getRootNode(storeRef);
});
initTestNamespacePrefixMapping();
flushSpuriousEvents();
}
protected void initTestNamespacePrefixMapping() {
if(namespaceDAO.getNamespaceURI("ce") == null)
{
namespaceDAO.addURI(TEST_NAMESPACE);
namespaceDAO.addPrefix("ce", TEST_NAMESPACE);
}
}
/*
* When running with an empty database some events related to the creation may
* creep up here making the test fails. After attempting several other
@@ -207,11 +221,16 @@ public abstract class AbstractContextAwareRepoEvent extends BaseSpringTest
}
protected NodeRef createNode(QName contentType, PropertyMap propertyMap)
{
return createNode(contentType, GUID.generate(), propertyMap);
}
protected NodeRef createNode(QName contentType, String localName, PropertyMap propertyMap)
{
return retryingTransactionHelper.doInTransaction(() -> nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(TEST_NAMESPACE, GUID.generate()),
QName.createQName(TEST_NAMESPACE, localName),
contentType,
propertyMap).getChildRef());
}

View File

@@ -50,6 +50,7 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
@Test
public void testAddChildAssociation()
{
String assocLocalName = GUID.generate();
final NodeRef parentNodeRef = createNode(ContentModel.TYPE_FOLDER);
final NodeRef childNodeRef = createNode(ContentModel.TYPE_CONTENT);
@@ -64,11 +65,11 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
resultRepoEvent.getType());
retryingTransactionHelper.doInTransaction(() ->
nodeService.addChild(
parentNodeRef,
childNodeRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName(TEST_NAMESPACE, GUID.generate())));
nodeService.addChild(
parentNodeRef,
childNodeRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName(TEST_NAMESPACE, assocLocalName)));
List<ChildAssociationRef> childAssociationRefs = retryingTransactionHelper.doInTransaction(() ->
nodeService.getChildAssocs(parentNodeRef));
@@ -101,6 +102,7 @@ public class ChildAssociationRepoEventIT extends AbstractContextAwareRepoEvent
assertEquals("Wrong parent", parentNodeRef.getId(), childAssociationResource.getParent().getId());
assertEquals("Wrong child", childNodeRef.getId(), childAssociationResource.getChild().getId());
assertEquals("Wrong assoc type", "cm:contains", childAssociationResource.getAssocType());
assertEquals("Wrong assoc name", "ce:" + assocLocalName, childAssociationResource.getAssocQName());
}
@Test

View File

@@ -53,16 +53,17 @@ public class CreateRepoEventIT extends AbstractContextAwareRepoEvent
@Autowired
private NodeDAO nodeDAO;
@Test
public void testCreateEvent()
{
// Create a node without content
final String name = "TestFile-" + System.currentTimeMillis() + ".txt";
String localName = GUID.generate();
PropertyMap propertyMap = new PropertyMap();
propertyMap.put(ContentModel.PROP_TITLE, "test title");
propertyMap.put(ContentModel.PROP_NAME, name);
final NodeRef nodeRef = createNode(ContentModel.TYPE_CONTENT, propertyMap);
final NodeRef nodeRef = createNode(ContentModel.TYPE_CONTENT, localName, propertyMap);
final RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEvent(1);
// Repo event attributes
@@ -103,6 +104,7 @@ public class CreateRepoEventIT extends AbstractContextAwareRepoEvent
assertEquals("Wrong node modifier display name.", "Administrator",
nodeResource.getModifiedByUser().getDisplayName());
assertNotNull("Missing modifiedAt property.", nodeResource.getModifiedAt());
assertEquals("Wrong primaryAssocQName prefix.", "ce:" + localName, nodeResource.getPrimaryAssocQName());
}
@Test

View File

@@ -45,9 +45,10 @@ public class DeleteRepoEventIT extends AbstractContextAwareRepoEvent
@Test
public void testDeleteContent()
{
String localName = GUID.generate();
PropertyMap propertyMap = new PropertyMap();
propertyMap.put(ContentModel.PROP_TITLE, "test title");
NodeRef nodeRef = createNode(ContentModel.TYPE_CONTENT, propertyMap);
NodeRef nodeRef = createNode(ContentModel.TYPE_CONTENT, localName, propertyMap);
NodeResource createdResource = getNodeResource(1);
@@ -64,6 +65,7 @@ public class DeleteRepoEventIT extends AbstractContextAwareRepoEvent
assertEquals("Repo event type:", EventType.NODE_DELETED.getType(), resultRepoEvent.getType());
assertEquals(createdResource.getId(), getNodeResource(resultRepoEvent).getId());
assertEquals("Wrong primaryAssocQName prefix.", "ce:" + localName, createdResource.getPrimaryAssocQName());
// There should be no resourceBefore
EventData<NodeResource> eventData = getEventData(resultRepoEvent);

View File

@@ -33,7 +33,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.dictionary.M2Model;
@@ -59,6 +58,7 @@ import org.junit.Test;
*/
public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
{
@Test
public void testUpdateNodeResourceContent()
{
@@ -138,6 +138,7 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
assertNull(resourceBefore.getProperties());
assertNull(resourceBefore.getAspectNames());
assertNull(resourceBefore.getPrimaryHierarchy());
assertNull(resourceBefore.getPrimaryAssocQName());
}
@Test
@@ -198,6 +199,7 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
assertNull(resourceBefore.getProperties());
assertNull(resourceBefore.getAspectNames());
assertNull(resourceBefore.getPrimaryHierarchy());
assertNull(resourceBefore.getPrimaryAssocQName());
}
@Test
@@ -274,6 +276,7 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
assertNull(resourceBefore.getProperties());
assertNull(resourceBefore.getAspectNames());
assertNull(resourceBefore.getPrimaryHierarchy());
assertNull(resourceBefore.getPrimaryAssocQName());
}
@Test
@@ -539,6 +542,7 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
assertNull(resourceBefore.getProperties());
assertNull(resourceBefore.getAspectNames());
assertNull(resourceBefore.getPrimaryHierarchy());
assertNull(resourceBefore.getPrimaryAssocQName());
}
@Test
@@ -574,6 +578,7 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
NodeResource nodeResource = getNodeResource(resultRepoEvent);
assertEquals("Incorrect node type was found", "cm:dictionaryModel", nodeResource.getNodeType());
initTestNamespacePrefixMapping();
final NodeRef nodeRef = createNode(ContentModel.TYPE_CONTENT);
// old node's type
assertEquals(ContentModel.TYPE_CONTENT, nodeService.getType(nodeRef));
@@ -613,7 +618,7 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
assertNull(resourceBefore.getProperties());
assertNull(resourceBefore.getAspectNames());
assertNull(resourceBefore.getPrimaryHierarchy());
assertNull(resourceBefore.getPrimaryAssocQName());
}
@Test
@@ -660,6 +665,7 @@ public class UpdateRepoEventIT extends AbstractContextAwareRepoEvent
assertNull(resourceBefore.getProperties());
assertNull(resourceBefore.getAspectNames());
assertNull(resourceBefore.getPrimaryHierarchy());
assertNull(resourceBefore.getPrimaryAssocQName());
}
@Test

View File

@@ -0,0 +1,260 @@
/*
* #%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 junit.framework.TestCase;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.cache.TransactionalCache;
import org.alfresco.repo.management.subsystems.SwitchableApplicationContextFactory;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.repo.security.permissions.AccessControlList;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
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.*;
import org.alfresco.service.cmr.security.MutableAuthenticationService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.test_category.OwnJVMTestsCategory;
import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.testing.category.DBTests;
import org.junit.experimental.categories.Category;
import org.springframework.context.ApplicationContext;
import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@Category({OwnJVMTestsCategory.class, DBTests.class})
public class ACS1907Test extends TestCase
{
private ApplicationContext ctx;
private NodeService nodeService;
private AuthenticationComponent authenticationComponent;
private MutableAuthenticationService authenticationService;
private MutableAuthenticationDao authenticationDAO;
private SearchService pubSearchService;
private PermissionService pubPermissionService;
private TransactionService transactionService;
private RetryingTransactionHelper txnHelper;
private DBQueryEngine queryEngine;
private TransactionalCache<Serializable, AccessControlList> aclCache;
private TransactionalCache<Serializable, Object> aclEntityCache;
private TransactionalCache<Serializable, Object> permissionEntityCache;
private NodeRef rootNodeRef;
@Override
public void setUp() throws Exception
{
setupServices();
this.authenticationComponent.setSystemUserAsCurrentUser();
rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
setupTestUsers();
setupTestContent();
dropCaches();
}
@Override
protected void tearDown() throws Exception
{
authenticationComponent.clearCurrentSecurityContext();
}
private void setupServices()
{
ctx = ApplicationContextHelper.getApplicationContext();
nodeService = (NodeService) ctx.getBean("dbNodeService");
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService");
authenticationDAO = (MutableAuthenticationDao) ctx.getBean("authenticationDao");
pubSearchService = (SearchService) ctx.getBean("SearchService");
pubPermissionService = (PermissionService) ctx.getBean("PermissionService");
transactionService = (TransactionService) ctx.getBean("TransactionService");
aclCache = (TransactionalCache) ctx.getBean("aclCache");
aclEntityCache = (TransactionalCache) ctx.getBean("aclEntityCache");
permissionEntityCache = (TransactionalCache) ctx.getBean("permissionEntityCache");
SwitchableApplicationContextFactory searchContextFactory = (SwitchableApplicationContextFactory) ctx.getBean("Search");
ApplicationContext searchCtx = searchContextFactory.getApplicationContext();
queryEngine = (DBQueryEngine) searchCtx.getBean("search.dbQueryEngineImpl");
txnHelper = new RetryingTransactionHelper();
txnHelper.setTransactionService(transactionService);
txnHelper.setReadOnly(false);
txnHelper.setMaxRetries(1);
txnHelper.setMinRetryWaitMs(1);
txnHelper.setMaxRetryWaitMs(10);
txnHelper.setRetryWaitIncrementMs(1);
}
private void setupTestUser(String userName)
{
if (!authenticationDAO.userExists(userName))
{
authenticationService.createAuthentication(userName, userName.toCharArray());
}
}
private void setupTestUsers()
{
txnHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>() {
@Override
public Object execute() throws Throwable {
setupTestUser("userA");
setupTestUser("userB");
setupTestUser(AuthenticationUtil.getAdminUserName());
return null;
}
}, false, false);
}
private void setupTestContent()
{
for(int f = 0; f < 5; f++)
{
final int ff = f;
txnHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>() {
@Override
public Object execute() throws Throwable {
Map<QName, Serializable> testFolderProps = new HashMap<>();
testFolderProps.put(ContentModel.PROP_NAME, "folder"+ff);
NodeRef testFolder = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("https://example.com/test", "folder"+ff),
ContentModel.TYPE_FOLDER,
testFolderProps
).getChildRef();
for(int c = 0; c < 5; c++)
{
Map<QName, Serializable> testContentProps = new HashMap<>();
testContentProps.put(ContentModel.PROP_NAME, "content"+c);
NodeRef testContent = nodeService.createNode(
testFolder,
ContentModel.ASSOC_CONTAINS,
QName.createQName("https://example.com/test", "content"+c),
ContentModel.TYPE_CONTENT,
testContentProps
).getChildRef();
String user = c % 2 == 0 ? "userA" : "userB";
pubPermissionService.setPermission(testContent, user, "Read", true);
}
return null;
}
}, false, false);
}
}
private void dropCaches()
{
aclCache.clear();
aclEntityCache.clear();
permissionEntityCache.clear();
}
public void testACS1907()
{
txnHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>() {
@Override
public Object execute() throws Throwable {
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>() {
@Override
public Object doWork() throws Exception {
SearchParameters sp = new SearchParameters();
sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
sp.setQueryConsistency(QueryConsistency.TRANSACTIONAL);
sp.setQuery("TYPE:\"cm:content\"");
ResultSet rs = pubSearchService.query(sp);
int cnt = 0;
for (ResultSetRow row : rs)
{
assertNotNull(row.getValue(ContentModel.PROP_NAME));
cnt++;
}
return null;
}
}, "userA");
return null;
}
}, false, false);
}
public void testPaging()
{
HashSet<NodeRef> resultPageSize2 = queryNodes(2);
HashSet<NodeRef> resultPageSize5 = queryNodes(5);
HashSet<NodeRef> resultPageSize10 = queryNodes(10);
HashSet<NodeRef> resultPageSizeAll = queryNodes(10000);
// all result sets must be equal, independent of page size used to retrieve them
assertTrue(resultPageSize2.size() >= 25);
assertTrue(resultPageSize5.size() >= 25);
assertTrue(resultPageSize10.size() >= 25);
assertTrue(resultPageSizeAll.size() >= 25);
assertTrue(resultPageSize2.containsAll(resultPageSize5));
assertTrue(resultPageSize2.containsAll(resultPageSize10));
assertTrue(resultPageSize2.containsAll(resultPageSizeAll));
assertTrue(resultPageSize5.containsAll(resultPageSize2));
assertTrue(resultPageSize5.containsAll(resultPageSize10));
assertTrue(resultPageSize5.containsAll(resultPageSizeAll));
assertTrue(resultPageSize10.containsAll(resultPageSize2));
assertTrue(resultPageSize10.containsAll(resultPageSize5));
assertTrue(resultPageSize10.containsAll(resultPageSizeAll));
assertTrue(resultPageSizeAll.containsAll(resultPageSize2));
assertTrue(resultPageSizeAll.containsAll(resultPageSize5));
assertTrue(resultPageSizeAll.containsAll(resultPageSize10));
// reset
queryEngine.setMinPagingBatchSize(2500);
queryEngine.setMaxPagingBatchSize(10000);
}
HashSet<NodeRef> queryNodes(int pageSize)
{
queryEngine.setMinPagingBatchSize(pageSize);
queryEngine.setMaxPagingBatchSize(pageSize);
HashSet<NodeRef> result = new HashSet<>();
SearchParameters sp = new SearchParameters();
sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
sp.setQueryConsistency(QueryConsistency.TRANSACTIONAL);
sp.setQuery("TYPE:\"cm:content\"");
ResultSet rs = pubSearchService.query(sp);
int cnt = 0;
for (ResultSetRow row : rs)
{
result.add(row.getNodeRef());
}
return result;
}
}