Compare commits

...

65 Commits
20.155 ... 22.1

Author SHA1 Message Date
alfresco-build
8175bbfb43 [maven-release-plugin][skip ci] prepare release 22.1 2023-08-16 19:45:52 +00:00
tiagosalvado10
5b4823c7a2 [MNT-23509] Add lock callback to refreshLock method (#2030) (#2140)
* [MNT-23509] Add lock callback to refreshLock method

* [MNT-23509] Added unit test

* [MNT-23509] PMD scan improvements

(cherry picked from commit 27186a56b8)
2023-08-16 19:55:57 +01:00
tiagosalvado10
a0ac6e54ed [MNT-23816] Prevent rules aspect removal when there are existing rules (#2114) (#2139)
* [MNT-23816] Prevent rules aspect removal when there are existing rules

(cherry picked from commit 1d56eb1dd1)
2023-08-16 19:06:57 +01:00
mpichura
7a3b2f66ea Update ServicePack branch to 7.4.2 2023-08-09 13:19:25 +02:00
alfresco-build
c93e239c85 [maven-release-plugin][skip ci] prepare for next development iteration 2023-08-07 22:05:40 +00:00
alfresco-build
604369fd2a [maven-release-plugin][skip ci] prepare release 21.14 2023-08-07 22:05:37 +00:00
mstrankowski
647e17e4a0 [skip tests] bring back old properties and skip tests 2023-08-08 00:02:09 +02:00
alfresco-build
397d6fdaee [maven-release-plugin][skip ci] prepare for next development iteration 2023-08-07 18:37:25 +00:00
alfresco-build
35052404fe [maven-release-plugin][skip ci] prepare release 21.13 2023-08-07 18:37:22 +00:00
Marcin Strankowski
6ba66513f2 There was no override of properties related to HttpClientConfig, whic… (#2120)
* There was no override of properties related to HttpClientConfig, which meant that if a property wasn't present in global-properties files, it wouldn't be registered and couldn't be provided through command line. I've amended that here
2023-08-07 19:43:38 +02:00
alfresco-build
e5886e2104 [maven-release-plugin][skip ci] prepare for next development iteration 2023-08-07 11:14:18 +00:00
alfresco-build
5ad1d9752c [maven-release-plugin][skip ci] prepare release 21.12 2023-08-07 11:14:15 +00:00
Marcin Strankowski
67deb82f06 MNT-23878: By default there was no timeout set for HttpClients, we've… (#2118)
* MNT-23878: By default there was no timeout set for HttpClients, we've wrongly directed ourselfes with the values of currently existing mTLS (Solr/Elasticsearch) for Transform that used default http clients with infinite timeouts
2023-08-07 09:49:10 +02:00
alfresco-build
a067b1dba5 [maven-release-plugin][skip ci] prepare for next development iteration 2023-08-01 10:29:03 +00:00
alfresco-build
55f9c9d46d [maven-release-plugin][skip ci] prepare release 21.11 2023-08-01 10:28:59 +00:00
Maciej Pichura
f070ed46a7 ACS-5698: Update api-explorer version 2023-08-01 11:41:58 +02:00
alfresco-build
c9636c84a2 [maven-release-plugin][skip ci] prepare for next development iteration 2023-07-28 15:03:25 +00:00
alfresco-build
4e764a3106 [maven-release-plugin][skip ci] prepare release 21.10 2023-07-28 15:03:22 +00:00
Tom Page
bbb668b446 [force 7.4.1-A2] ACS-5696 Release 7.4.1-A2. 2023-07-28 15:56:59 +01:00
alfresco-build
c9b9a9b239 [maven-release-plugin][skip ci] prepare for next development iteration 2023-07-28 12:55:37 +00:00
alfresco-build
01fb7f45a3 [maven-release-plugin][skip ci] prepare release 21.9 2023-07-28 12:55:33 +00:00
Tom Page
41c4b34d8d ACS-5698 Allow specifying version when performing force release. (#2089)
(cherry picked from commit 0b6b405c5f)
2023-07-26 15:53:01 +01:00
alfresco-build
36bf081b59 [maven-release-plugin][skip ci] prepare for next development iteration 2023-07-26 13:16:58 +00:00
alfresco-build
2a5892de78 [maven-release-plugin][skip ci] prepare release 21.8 2023-07-26 13:16:55 +00:00
Tom Page
d302606318 Merge pull request #2085 from Alfresco/feature/MNT-23763_ImagePreviewWebscript (#2088)
MNT-23763 Fix image preview webscript for use with ES.

(cherry picked from commit fcf3e005e4)
2023-07-26 13:27:21 +01:00
alfresco-build
7ebad61406 [maven-release-plugin][skip ci] prepare for next development iteration 2023-07-07 16:23:49 +00:00
alfresco-build
587087389e [maven-release-plugin][skip ci] prepare release 21.7 2023-07-07 16:23:47 +00:00
evasques
57c3605d63 ACS-5487 - Track Total Hits on ES (#2041) (#2049)
SearchParameters - added trackTotalHits (int) attribute
SearchRequest - Added trackTotalHitsLimit (int) to the Limits attribute and mapped it to the SearchParameters
Changed the SearchRequest model in TAS to include a new RestRequestLimitsModel that has the new trackTotalHitsLimit attribute
SearchMapperTests to test the changes in the SearchParameters

(cherry picked from commit a1faf97fc5)
2023-07-07 16:38:05 +01:00
alfresco-build
2cb318a18e [maven-release-plugin][skip ci] prepare for next development iteration 2023-07-03 14:11:08 +00:00
alfresco-build
bd7af1f39c [maven-release-plugin][skip ci] prepare release 21.6 2023-07-03 14:10:59 +00:00
tiagosalvado10
7885c6a78b MNT-23451 filterQuery for facet Null (#1764) (#2033)
After MNT-23276, a "Null" value was introduced but the facetQuery does not reflect how to query nodes with that facet

(cherry picked from commit d46ae1634f)

Co-authored-by: Nicolas Barithel <nicolas.barithel@hyland.com>
2023-07-03 14:22:43 +01:00
alfresco-build
d42e9ef993 [maven-release-plugin][skip ci] prepare for next development iteration 2023-06-29 15:54:37 +00:00
alfresco-build
197590eef4 [maven-release-plugin][skip ci] prepare release 21.5 2023-06-29 15:54:33 +00:00
tiagosalvado10
102f59cde1 [MNT-23748] Bump surf webscripts (#2026)
* [MNT-23748] Bump surf-webscripts to 8.44 (#2023)

(cherry picked from commit 51fe0275df)
2023-06-29 14:26:27 +01:00
alfresco-build
529699b5e1 [maven-release-plugin][skip ci] prepare for next development iteration 2023-06-28 23:54:50 +00:00
alfresco-build
96456ec719 [maven-release-plugin][skip ci] prepare release 21.4 2023-06-28 23:54:47 +00:00
tiagosalvado10
71bbb579e6 [MNT-23642] Add error messages (#2019) (#2024)
(cherry picked from commit 689e6a23fa)
2023-06-29 00:08:56 +01:00
alfresco-build
51dcf28756 [maven-release-plugin][skip ci] prepare for next development iteration 2023-06-21 10:25:52 +00:00
alfresco-build
1639a17451 [maven-release-plugin][skip ci] prepare release 21.3 2023-06-21 10:25:49 +00:00
rrajoria
585e6042cb Fix/MNT-23612 Fix to allow only valid task status. (#1954)
* Update WorkflowServiceImpl.java

* Update WorkflowServiceImpl.java

(cherry picked from commit 4c256ab546)
2023-06-21 14:16:59 +05:30
alfresco-build
8364211384 [maven-release-plugin][skip ci] prepare for next development iteration 2023-06-20 07:05:59 +00:00
alfresco-build
f68d304d57 [maven-release-plugin][skip ci] prepare release 21.2 2023-06-20 07:05:55 +00:00
rrajoria
b55e1114e6 MNT-23724: Fix for Downloading a folder as zip with correct Name
Cherrypicked from master
2023-06-20 11:14:17 +05:30
alfresco-build
0e23ba37c6 [maven-release-plugin][skip ci] prepare for next development iteration 2023-05-30 23:52:54 +00:00
alfresco-build
38a4d378d9 [maven-release-plugin][skip ci] prepare release 21.1 2023-05-30 23:52:51 +00:00
tiagosalvado10
65a562cd73 [MNT-23665] Removed search controls count limit (#1936) (#1968)
(cherry picked from commit 07c7342032)
2023-05-30 21:42:47 +01:00
kmagdziarz
8eab098317 Create ServicePack branch release/7.4.N 2023-05-05 12:39:50 +02:00
alfresco-build
25f3f33594 [maven-release-plugin][skip ci] prepare release 20.161 2023-05-03 20:54:45 +00:00
tiagosalvado10
f83328f7b0 [MNT-23550] Always disable behaviours to prevent unexpected modifier changes (#1898) 2023-05-03 20:34:37 +01:00
alfresco-build
a177f391db [maven-release-plugin][skip ci] prepare for next development iteration 2023-05-02 05:22:45 +00:00
alfresco-build
784557afcd [maven-release-plugin][skip ci] prepare release 20.160 2023-05-02 05:22:41 +00:00
MohinishSah
8fb7b0d224 Update G-drive and AOS final version 2023-05-01 12:24:30 +05:30
alfresco-build
011ec9d7e6 [maven-release-plugin][skip ci] prepare for next development iteration 2023-04-30 00:06:05 +00:00
alfresco-build
3900f589d9 [maven-release-plugin][skip ci] prepare release 20.159 2023-04-30 00:06:02 +00:00
Alfresco CI User
def7a0d432 [force] Force release for 2023-04-30. 2023-04-30 00:02:53 +00:00
alfresco-build
7371c5d7ff [maven-release-plugin][skip ci] prepare for next development iteration 2023-04-28 16:36:05 +00:00
alfresco-build
90406cef03 [maven-release-plugin][skip ci] prepare release 20.158 2023-04-28 16:36:01 +00:00
Sara
862e6d5596 ACS-5075 and ACS-4832 Bump t-core and t-service to 3.1.0 and 2.1.0 (#1906) 2023-04-28 16:05:00 +01:00
alfresco-build
27be717df5 [maven-release-plugin][skip ci] prepare for next development iteration 2023-04-26 12:50:39 +00:00
alfresco-build
28ad071daf [maven-release-plugin][skip ci] prepare release 20.157 2023-04-26 12:50:36 +00:00
dependabot[bot]
06cc5e3499 Bump spring-security-bom from 5.8.2 to 5.8.3 (#1884)
* Bump spring-security-bom from 5.8.2 to 6.0.3

Bumps [spring-security-bom](https://github.com/spring-projects/spring-security) from 5.8.2 to 6.0.3.
- [Release notes](https://github.com/spring-projects/spring-security/releases)
- [Changelog](https://github.com/spring-projects/spring-security/blob/main/RELEASE.adoc)
- [Commits](https://github.com/spring-projects/spring-security/compare/5.8.2...6.0.3)

---
updated-dependencies:
- dependency-name: org.springframework.security:spring-security-bom
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump Spring Security BOM to 5.8.3

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Domenico Sibilio <domenicosibilio@gmail.com>
2023-04-26 14:05:37 +02:00
alfresco-build
df8b36350d [maven-release-plugin][skip ci] prepare for next development iteration 2023-04-23 00:08:06 +00:00
alfresco-build
552abc9bd4 [maven-release-plugin][skip ci] prepare release 20.156 2023-04-23 00:08:03 +00:00
Alfresco CI User
00cab8e6b5 [force] Force release for 2023-04-23. 2023-04-23 00:03:14 +00:00
alfresco-build
6f4069790c [maven-release-plugin][skip ci] prepare for next development iteration 2023-04-21 14:50:56 +00:00
54 changed files with 952 additions and 187 deletions

View File

@@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-latest
if: >
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
@@ -52,7 +52,7 @@ jobs:
if: >
((github.ref_name == 'master' || startsWith(github.ref_name, 'release/')) && github.event_name != 'pull_request') &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
@@ -73,7 +73,7 @@ jobs:
if: >
!contains(github.event.head_commit.message, '[skip repo]') &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
@@ -94,7 +94,7 @@ jobs:
if: >
!contains(github.event.head_commit.message, '[skip repo]') &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
strategy:
fail-fast: false
matrix:
@@ -139,7 +139,7 @@ jobs:
!contains(github.event.head_commit.message, '[skip db]')) ||
contains(github.event.head_commit.message, '[db]')) &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
strategy:
fail-fast: false
matrix:
@@ -169,7 +169,7 @@ jobs:
contains(github.event.head_commit.message, '[latest db]') ||
contains(github.event.head_commit.message, '[db]')) &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
@@ -195,7 +195,7 @@ jobs:
contains(github.event.head_commit.message, '[latest db]') ||
contains(github.event.head_commit.message, '[db]')) &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
@@ -220,7 +220,7 @@ jobs:
!contains(github.event.head_commit.message, '[skip db]')) ||
contains(github.event.head_commit.message, '[db]')) &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
@@ -245,7 +245,7 @@ jobs:
contains(github.event.head_commit.message, '[latest db]') ||
contains(github.event.head_commit.message, '[db]')) &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
@@ -268,7 +268,7 @@ jobs:
if: >
!contains(github.event.head_commit.message, '[skip repo]') &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
@@ -289,7 +289,7 @@ jobs:
if: >
!contains(github.event.head_commit.message, '[skip repo]') &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
strategy:
fail-fast: false
matrix:
@@ -358,7 +358,7 @@ jobs:
!contains(github.event.head_commit.message, '[skip tas]')) ||
contains(github.event.head_commit.message, '[tas]')) &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
strategy:
fail-fast: false
matrix:
@@ -425,7 +425,7 @@ jobs:
if: >
!contains(github.event.head_commit.message, '[skip repo]') &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
steps:
- uses: actions/checkout@v3
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
@@ -448,7 +448,7 @@ jobs:
!contains(github.event.head_commit.message, '[skip ags]')) ||
contains(github.event.head_commit.message, '[ags]')) &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
strategy:
fail-fast: false
matrix:
@@ -479,7 +479,7 @@ jobs:
!contains(github.event.head_commit.message, '[skip ags]')) ||
contains(github.event.head_commit.message, '[ags on MySQL]')) &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
strategy:
fail-fast: false
matrix:
@@ -510,7 +510,7 @@ jobs:
!contains(github.event.head_commit.message, '[skip ags]') && !contains(github.event.head_commit.message, '[skip tas]')) ||
(contains(github.event.head_commit.message, '[ags]') && contains(github.event.head_commit.message, '[tas]'))) &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[force]')
!contains(github.event.head_commit.message, '[force')
env:
REQUIRES_LOCAL_IMAGES: true
steps:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -5,7 +5,7 @@
# Version label
version.major=7
version.minor=4
version.revision=0
version.revision=2
version.label=
# Edition label

View File

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

View File

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

View File

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

View File

@@ -48,7 +48,7 @@ function tagQuery()
}
query += "ASPECT:\"{http://www.alfresco.org/model/content/1.0}taggable\"";
//MNT-2118 Share inconsistencies when displaying locked files with tags
query += " -ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\"";
query += " AND -ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\"";
// MNT-20091 check to prevent cm:taggable with NULL
query += " AND ISNOTNULL:\"{http://www.alfresco.org/model/content/1.0}taggable\"";
@@ -60,7 +60,7 @@ function tagQuery()
query: query,
language: "lucene",
page: {
// query minimum rows because all usefull info will come with facets
// query minimum rows because all useful info will come with facets
maxItems: 1,
skipCount: 0
},

View File

@@ -24,7 +24,7 @@ function getCategoryNode()
else
{
var queryPath = "/" + catAspect + "/" + encodePath(path);
categoryResults = search.luceneSearch("+PATH:\"" + queryPath + "/*\" -PATH:\"" + queryPath + "/member\"");
categoryResults = search.luceneSearch("+PATH:\"" + queryPath + "/*\" AND -PATH:\"" + queryPath + "/member\"");
}
// make each result an object and indicate it is selectable in the UI
@@ -71,4 +71,4 @@ function encodePath(path)
function sortByName(a, b)
{
return (b.node.name.toLowerCase() > a.node.name.toLowerCase() ? -1 : 1);
}
}

View File

@@ -29,7 +29,7 @@ function main()
{
query = "+PATH:\"" + parsedArgs.pathNode.qnamePath + "//*\" ";
}
query += "+TYPE:\"cm:content\" +@cm\\:content.mimetype:image/*";
query += "AND +TYPE:\"cm:content\" AND +@cm\\:content.mimetype:\"image/*\"";
// Sort the list before trimming to page chunks
assets = search.query(
@@ -52,4 +52,4 @@ function main()
/**
* Images List Component: images
*/
model.images = main();
model.images = main();

View File

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

View File

@@ -92,15 +92,16 @@ public class HttpClient4Factory
else
{
//Setting a connectionManager overrides these properties
clientBuilder.setMaxConnTotal(config.getMaxTotalConnections());
clientBuilder.setMaxConnPerRoute(config.getMaxHostConnections());
config.getMaxTotalConnections().ifPresent(v -> clientBuilder.setMaxConnTotal(v));
config.getMaxHostConnections().ifPresent(v -> clientBuilder.setMaxConnPerRoute(v));
}
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(config.getConnectionTimeout())
.setSocketTimeout(config.getSocketTimeout())
.setConnectionRequestTimeout(config.getConnectionRequestTimeout())
.build();
RequestConfig.Builder requestConfigBuilder = RequestConfig.custom();
config.getConnectionTimeout().ifPresent(v -> requestConfigBuilder.setConnectTimeout(v));
config.getConnectionRequestTimeout().ifPresent(v -> requestConfigBuilder.setConnectionRequestTimeout(v));
config.getSocketTimeout().ifPresent(v -> requestConfigBuilder.setSocketTimeout(v));
RequestConfig requestConfig = requestConfigBuilder.build();
clientBuilder.setDefaultRequestConfig(requestConfig);
@@ -135,8 +136,8 @@ public class HttpClient4Factory
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.build());
}
poolingHttpClientConnectionManager.setMaxTotal(config.getMaxTotalConnections());
poolingHttpClientConnectionManager.setDefaultMaxPerRoute(config.getMaxHostConnections());
config.getMaxTotalConnections().ifPresent(v -> poolingHttpClientConnectionManager.setMaxTotal(v));
config.getMaxHostConnections().ifPresent(v -> poolingHttpClientConnectionManager.setDefaultMaxPerRoute(v));
return poolingHttpClientConnectionManager;
}

View File

@@ -85,17 +85,27 @@ public class HttpClientConfig
this.keyStore = new AlfrescoKeyStoreImpl(sslEncryptionParameters.getKeyStoreParameters(), keyResourceLoader);
this.trustStore = new AlfrescoKeyStoreImpl(sslEncryptionParameters.getTrustStoreParameters(), keyResourceLoader);
config = retrieveConfig(serviceName);
config = retrieveConfig();
checkUnsupportedProperties(config);
}
/**
* Method used for retrieving HttpClient config from Global Properties
* @param serviceName name of used service
* that can also have values provided/overridden through System Properties
*
* @return map of properties
*/
private Map<String, String> retrieveConfig(String serviceName)
private Map<String, String> retrieveConfig()
{
Map<String, String> resultProperties = getHttpClientPropertiesForService(properties);
Map<String, String> systemProperties = getHttpClientPropertiesForService(System.getProperties());
systemProperties.forEach((k, v) -> resultProperties.put(k, v)); //Override/Add to Global Properties results with values from System Properties
return resultProperties;
}
private Map<String, String> getHttpClientPropertiesForService(Properties properties) {
return properties.keySet().stream()
.filter(key -> key instanceof String)
.map(Object::toString)
@@ -112,79 +122,75 @@ public class HttpClientConfig
.forEach(propertyName -> LOGGER.warn(String.format("For service [%s], an unsupported property [%s] is set", serviceName, propertyName)));
}
private Integer getIntegerProperty(HttpClientPropertiesEnum property)
private Optional<Integer> getIntegerProperty(HttpClientPropertiesEnum property)
{
return Integer.parseInt(extractValueFromConfig(property).orElse("0"));
Optional<String> optionalProperty = extractValueFromConfig(property);
return optionalProperty.isPresent() ? Optional.of(Integer.parseInt(optionalProperty.get())) : Optional.empty();
}
private Boolean getBooleanProperty(HttpClientPropertiesEnum property)
private Optional<Boolean> getBooleanProperty(HttpClientPropertiesEnum property)
{
return Boolean.parseBoolean(extractValueFromConfig(property).orElse("false"));
Optional<String> optionalProperty = extractValueFromConfig(property);
return optionalProperty.isPresent() ? Optional.of(Boolean.parseBoolean(optionalProperty.get())) : Optional.empty();
}
private Optional<String> extractValueFromConfig(HttpClientPropertiesEnum property)
{
Optional<String> optionalProperty = Optional.ofNullable(config.get(property.name));
if(property.isRequired && optionalProperty.isEmpty())
{
String msg = String.format("Required property: '%s' is empty.", property.name);
throw new HttpClientException(msg);
}
return optionalProperty;
return Optional.ofNullable(config.get(property.name));
}
public Integer getConnectionTimeout()
public Optional<Integer> getConnectionTimeout()
{
return getIntegerProperty(HttpClientPropertiesEnum.CONNECTION_REQUEST_TIMEOUT);
}
public Integer getSocketTimeout()
public Optional<Integer> getSocketTimeout()
{
return getIntegerProperty(HttpClientPropertiesEnum.SOCKET_TIMEOUT);
}
public Integer getConnectionRequestTimeout()
public Optional<Integer> getConnectionRequestTimeout()
{
return getIntegerProperty(HttpClientPropertiesEnum.CONNECTION_REQUEST_TIMEOUT);
}
public Integer getMaxTotalConnections()
public Optional<Integer> getMaxTotalConnections()
{
return getIntegerProperty(HttpClientPropertiesEnum.MAX_TOTAL_CONNECTIONS);
}
public Integer getMaxHostConnections()
public Optional<Integer> getMaxHostConnections()
{
return getIntegerProperty(HttpClientPropertiesEnum.MAX_HOST_CONNECTIONS);
}
public Boolean isMTLSEnabled()
public boolean isMTLSEnabled()
{
return getBooleanProperty(HttpClientPropertiesEnum.MTLS_ENABLED);
return getBooleanProperty(HttpClientPropertiesEnum.MTLS_ENABLED).orElse(Boolean.FALSE);
}
public boolean isHostnameVerificationDisabled()
{
return getBooleanProperty(HttpClientPropertiesEnum.HOSTNAME_VERIFICATION_DISABLED);
return getBooleanProperty(HttpClientPropertiesEnum.HOSTNAME_VERIFICATION_DISABLED).orElse(Boolean.FALSE);
}
private enum HttpClientPropertiesEnum
{
CONNECTION_TIMEOUT("connectionTimeout", true),
SOCKET_TIMEOUT("socketTimeout", true),
CONNECTION_REQUEST_TIMEOUT("connectionRequestTimeout", true),
MAX_TOTAL_CONNECTIONS("maxTotalConnections", true),
MAX_HOST_CONNECTIONS("maxHostConnections", true),
HOSTNAME_VERIFICATION_DISABLED("hostnameVerificationDisabled", false),
MTLS_ENABLED("mTLSEnabled", true);
CONNECTION_TIMEOUT("connectionTimeout"),
SOCKET_TIMEOUT("socketTimeout"),
CONNECTION_REQUEST_TIMEOUT("connectionRequestTimeout"),
MAX_TOTAL_CONNECTIONS("maxTotalConnections"),
MAX_HOST_CONNECTIONS("maxHostConnections"),
HOSTNAME_VERIFICATION_DISABLED("hostnameVerificationDisabled"),
MTLS_ENABLED("mTLSEnabled");
private final String name;
private final Boolean isRequired;
HttpClientPropertiesEnum(String propertyName, Boolean isRequired)
HttpClientPropertiesEnum(String propertyName)
{
this.name = propertyName;
this.isRequired = isRequired;
}
private static final List<String> supportedProperties = new ArrayList<>();

View File

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

View File

@@ -201,6 +201,11 @@ public class SearchParameters implements BasicSearchParameters
private String timezone;
/**
* Configure the limit to track the total hits on search results
*/
private int trackTotalHits;
/**
* Default constructor
*/
@@ -251,6 +256,7 @@ public class SearchParameters implements BasicSearchParameters
sp.stats = this.stats;
sp.ranges = this.ranges;
sp.timezone = this.timezone;
sp.trackTotalHits = this.trackTotalHits;
return sp;
}
@@ -1641,6 +1647,21 @@ public class SearchParameters implements BasicSearchParameters
{
this.includeMetadata = includeMetadata;
}
public int getTrackTotalHits()
{
return trackTotalHits;
}
/**
* Set a maximum value for the report of total hits. The reported number of hits will never exceed this limit even
* if more are found. If unset, the engines default tracking limit is applied. To remove any limit, set to -1.
*
* @param trackTotalHits int
*/
public void setTrackTotalHits(int trackTotalHits)
{
this.trackTotalHits = trackTotalHits;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>20.155</version>
<version>22.1</version>
</parent>
<organization>

View File

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

View File

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

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>20.155</version>
<version>22.1</version>
</parent>
<properties>

View File

@@ -0,0 +1,82 @@
/*-
* #%L
* alfresco-tas-restapi
* %%
* Copyright (C) 2005 - 2023 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.search;
import org.alfresco.rest.core.IRestModel;
import org.alfresco.utility.model.TestModel;
import com.fasterxml.jackson.annotation.JsonProperty;
public class RestRequestLimitsModel extends TestModel implements IRestModel<RestRequestLimitsModel>
{
@JsonProperty
RestRequestLimitsModel model;
private Integer permissionEvaluationTime;
private Integer permissionEvaluationCount;
private Integer trackTotalHitsLimit;
@Override
public RestRequestLimitsModel onModel()
{
return model;
}
public RestRequestLimitsModel(Integer permissionEvaluationTime, Integer permissionEvaluationCount,
Integer trackTotalHitsLimit)
{
super();
this.permissionEvaluationTime = permissionEvaluationTime;
this.permissionEvaluationCount = permissionEvaluationCount;
this.trackTotalHitsLimit = trackTotalHitsLimit;
}
public Integer getPermissionEvaluationTime()
{
return permissionEvaluationTime;
}
public void setPermissionEvaluationTime(Integer permissionEvaluationTime)
{
this.permissionEvaluationTime = permissionEvaluationTime;
}
public Integer getPermissionEvaluationCount()
{
return permissionEvaluationCount;
}
public void setPermissionEvaluationCount(Integer permissionEvaluationCount)
{
this.permissionEvaluationCount = permissionEvaluationCount;
}
public Integer getTrackTotalHitsLimit()
{
return trackTotalHitsLimit;
}
public void setTrackTotalHitsLimit(Integer trackTotalHitsLimit)
{
this.trackTotalHitsLimit = trackTotalHitsLimit;
}
}

View File

@@ -76,6 +76,7 @@ public class SearchRequest extends TestModel
String facetFormat;
List<String> include;
List<SortClause> sort;
RestRequestLimitsModel limits;
public SearchRequest()
{
@@ -279,4 +280,15 @@ public class SearchRequest extends TestModel
return this;
}
public RestRequestLimitsModel getLimits()
{
return limits;
}
public void setLimits(RestRequestLimitsModel limits)
{
this.limits = limits;
}
}

View File

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

View File

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

20
pom.xml
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>20.155</version>
<version>22.1</version>
<packaging>pom</packaging>
<name>Alfresco Community Repo Parent</name>
@@ -25,7 +25,7 @@
<properties>
<acs.version.major>7</acs.version.major>
<acs.version.minor>4</acs.version.minor>
<acs.version.revision>0</acs.version.revision>
<acs.version.revision>2</acs.version.revision>
<acs.version.label />
<amp.min.version>${acs.version.major}.0.0</amp.min.version>
@@ -52,8 +52,8 @@
<dependency.alfresco-messaging-repo.version>1.2.20</dependency.alfresco-messaging-repo.version>
<dependency.activiti-engine.version>5.23.0</dependency.activiti-engine.version>
<dependency.activiti.version>5.23.0</dependency.activiti.version>
<dependency.alfresco-transform-service.version>2.1.0-A9</dependency.alfresco-transform-service.version>
<dependency.alfresco-transform-core.version>3.1.0-A12</dependency.alfresco-transform-core.version>
<dependency.alfresco-transform-service.version>2.1.0</dependency.alfresco-transform-service.version>
<dependency.alfresco-transform-core.version>3.1.0</dependency.alfresco-transform-core.version>
<dependency.alfresco-greenmail.version>6.5</dependency.alfresco-greenmail.version>
<dependency.acs-event-model.version>0.0.18</dependency.acs-event-model.version>
@@ -62,7 +62,7 @@
<dependency.jackson.version>2.15.0-rc1</dependency.jackson.version>
<dependency.cxf.version>3.5.5</dependency.cxf.version>
<dependency.opencmis.version>1.0.0</dependency.opencmis.version>
<dependency.webscripts.version>8.40</dependency.webscripts.version>
<dependency.webscripts.version>8.44</dependency.webscripts.version>
<dependency.bouncycastle.version>1.70</dependency.bouncycastle.version>
<dependency.mockito-core.version>4.9.0</dependency.mockito-core.version>
<dependency.assertj.version>3.24.2</dependency.assertj.version>
@@ -79,7 +79,7 @@
<dependency.gytheio.version>0.18</dependency.gytheio.version>
<dependency.groovy.version>3.0.16</dependency.groovy.version>
<dependency.tika.version>2.4.1</dependency.tika.version>
<dependency.spring-security.version>5.8.2</dependency.spring-security.version>
<dependency.spring-security.version>5.8.3</dependency.spring-security.version>
<dependency.truezip.version>7.7.10</dependency.truezip.version>
<dependency.poi.version>5.2.2</dependency.poi.version>
<dependency.poi-ooxml-lite.version>5.2.3</dependency.poi-ooxml-lite.version>
@@ -111,9 +111,9 @@
<dependency.json-smart.version>2.4.10</dependency.json-smart.version>
<dependency.jakarta-rpc-api.version>1.1.4</dependency.jakarta-rpc-api.version>
<alfresco.googledrive.version>3.4.0-A4</alfresco.googledrive.version>
<alfresco.aos-module.version>1.6.0-A5</alfresco.aos-module.version>
<alfresco.api-explorer.version>7.3.0</alfresco.api-explorer.version> <!-- Also in alfresco-enterprise-share -->
<alfresco.googledrive.version>3.4.0</alfresco.googledrive.version>
<alfresco.aos-module.version>1.6.0</alfresco.aos-module.version>
<alfresco.api-explorer.version>7.4.0</alfresco.api-explorer.version> <!-- Also in alfresco-enterprise-share -->
<alfresco.maven-plugin.version>2.2.0</alfresco.maven-plugin.version>
<license-maven-plugin.version>2.0.1.alfresco-2</license-maven-plugin.version>
@@ -150,7 +150,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>20.155</tag>
<tag>22.1</tag>
</scm>
<distributionManagement>

View File

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

View File

@@ -68,6 +68,7 @@ import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.rendition2.RenditionDefinition2;
import org.alfresco.repo.rendition2.RenditionDefinitionRegistry2;
import org.alfresco.repo.rendition2.RenditionService2;
import org.alfresco.repo.rule.RuleModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.security.permissions.AccessDeniedException;
@@ -148,6 +149,7 @@ import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.Path;
import org.alfresco.service.cmr.repository.Path.Element;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.service.cmr.security.AccessPermission;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.AuthorityService;
@@ -216,6 +218,7 @@ public class NodesImpl implements Nodes
private LockService lockService;
private VirtualStore smartStore; // note: remove as part of REPO-1173
private ClassDefinitionMapper classDefinitionMapper;
private RuleService ruleService;
private enum Activity_Type
{
@@ -338,6 +341,11 @@ public class NodesImpl implements Nodes
this.classDefinitionMapper = classDefinitionMapper;
}
public void setRuleService(RuleService ruleService)
{
this.ruleService = ruleService;
}
// excluded namespaces (aspects, properties, assoc types)
private static final List<String> EXCLUDED_NS = Arrays.asList(NamespaceService.SYSTEM_MODEL_1_0_URI);
@@ -2543,6 +2551,8 @@ public class NodesImpl implements Nodes
Set<QName> aspectsToAdd = new HashSet<>(3);
Set<QName> aspectsToRemove = new HashSet<>(3);
boolean hasRules = ruleService.hasRules(nodeRef);
for (QName aspectQName : aspectQNames)
{
if (EXCLUDED_NS.contains(aspectQName.getNamespaceURI()) || excludedAspects.contains(aspectQName) || aspectQName.equals(ContentModel.ASPECT_AUDITABLE))
@@ -2558,7 +2568,7 @@ public class NodesImpl implements Nodes
for (QName existingAspect : existingAspects)
{
if (EXCLUDED_NS.contains(existingAspect.getNamespaceURI()) || excludedAspects.contains(existingAspect) || existingAspect.equals(ContentModel.ASPECT_AUDITABLE))
if (EXCLUDED_NS.contains(existingAspect.getNamespaceURI()) || excludedAspects.contains(existingAspect) || existingAspect.equals(ContentModel.ASPECT_AUDITABLE) || existingAspect.equals(RuleModel.ASPECT_RULES) && hasRules)
{
continue; // ignore
}

View File

@@ -823,6 +823,11 @@ public class SearchMapper
sp.setLimitBy(LimitBy.NUMBER_OF_PERMISSION_EVALUATIONS);
sp.setMaxPermissionCheckTimeMillis(limits.getPermissionEvaluationTime());
}
if(limits.getTrackTotalHitsLimit() != null)
{
sp.setTrackTotalHits(limits.getTrackTotalHitsLimit());
}
}
}

View File

@@ -93,7 +93,7 @@ public class FacetField
public String toFilterQuery(String value)
{
return field+":\""+value+"\"";
return ("Null".equals(value)) ? "ISNULL:\"" + field + "\"" : field + ":\"" + value + "\"";
}
public String getPrefix()

View File

@@ -37,13 +37,16 @@ public class Limits
private final Integer permissionEvaluationTime;
private final Integer permissionEvaluationCount;
private final Integer trackTotalHitsLimit;
@JsonCreator
public Limits(@JsonProperty("permissionEvaluationTime") Integer permissionEvaluationTime,
@JsonProperty("permissionEvaluationCount") Integer permissionEvaluationCount)
@JsonProperty("permissionEvaluationCount") Integer permissionEvaluationCount,
@JsonProperty("trackTotalHitsLimit") Integer trackTotalHitsLimit)
{
this.permissionEvaluationTime = permissionEvaluationTime;
this.permissionEvaluationCount = permissionEvaluationCount;
this.trackTotalHitsLimit = trackTotalHitsLimit;
}
public Integer getPermissionEvaluationTime()
@@ -55,4 +58,9 @@ public class Limits
{
return permissionEvaluationCount;
}
public Integer getTrackTotalHitsLimit()
{
return trackTotalHitsLimit;
}
}

View File

@@ -537,6 +537,7 @@
<property name="poster" ref="activitiesPoster" />
<property name="smartStore" ref="smartStore"/>
<property name="classDefinitionMapper" ref="classDefinitionMapper" />
<property name="ruleService" ref="RuleService" />
</bean>
<bean id="Nodes" class="org.springframework.aop.framework.ProxyFactoryBean">

View File

@@ -745,33 +745,56 @@ public class SearchMapperTests
}
@Test
public void fromLimits() throws Exception
public void fromLimits_setNull() throws Exception
{
SearchParameters searchParameters = new SearchParameters();
searchMapper.setDefaults(searchParameters);
//Doesn't error
searchMapper.fromLimits(searchParameters, null);
assertEquals(500, searchParameters.getLimit());
assertEquals(LimitBy.UNLIMITED, searchParameters.getLimitBy());
assertEquals("LimitBy default value should be unlimited", LimitBy.UNLIMITED, searchParameters.getLimitBy());
assertEquals("Limit default value should be 500", 500, searchParameters.getLimit());
}
searchMapper.fromLimits(searchParameters, new Limits(null, null));
assertEquals(LimitBy.UNLIMITED, searchParameters.getLimitBy());
assertEquals(500, searchParameters.getLimit());
searchMapper.fromLimits(searchParameters, new Limits(null, 34));
assertEquals(LimitBy.NUMBER_OF_PERMISSION_EVALUATIONS, searchParameters.getLimitBy());
assertEquals(34, searchParameters.getMaxPermissionChecks());
assertEquals(-1, searchParameters.getLimit());
assertEquals(-1, searchParameters.getMaxPermissionCheckTimeMillis());
searchParameters = new SearchParameters();
@Test
public void fromLimits_setAllLimitsAsNull() throws Exception
{
SearchParameters searchParameters = new SearchParameters();
searchMapper.setDefaults(searchParameters);
searchMapper.fromLimits(searchParameters, new Limits(1000, null));
searchMapper.fromLimits(searchParameters, new Limits(null, null, null));
assertEquals("LimitBy default value should be unlimited", LimitBy.UNLIMITED, searchParameters.getLimitBy());
assertEquals("Limit default value should be 500", 500, searchParameters.getLimit());
}
@Test
public void fromLimits_setPermissionEvaluationCount() throws Exception
{
SearchParameters searchParameters = new SearchParameters();
searchMapper.setDefaults(searchParameters);
searchMapper.fromLimits(searchParameters, new Limits(null, 34, null));
assertEquals(LimitBy.NUMBER_OF_PERMISSION_EVALUATIONS, searchParameters.getLimitBy());
assertEquals(1000, searchParameters.getMaxPermissionCheckTimeMillis());
assertEquals(-1, searchParameters.getLimit());
assertEquals(-1, searchParameters.getMaxPermissionChecks());
assertEquals("MaxPermissionChecks should be set", 34, searchParameters.getMaxPermissionChecks());
assertEquals("Limit should be -1", -1, searchParameters.getLimit());
assertEquals("MaxPermissionCheckTimeMillis should be -1", -1, searchParameters.getMaxPermissionCheckTimeMillis());
}
@Test
public void fromLimits_setPermissionEvaluationTime() throws Exception
{
SearchParameters searchParameters = new SearchParameters();
searchMapper.setDefaults(searchParameters);
searchMapper.fromLimits(searchParameters, new Limits(1000, null, null));
assertEquals(LimitBy.NUMBER_OF_PERMISSION_EVALUATIONS, searchParameters.getLimitBy());
assertEquals("MaxPermissionCheckTimeMillis should be set", 1000, searchParameters.getMaxPermissionCheckTimeMillis());
assertEquals("Limit should be -1", -1, searchParameters.getLimit());
assertEquals("MaxPermissionChecks should be -1", -1, searchParameters.getMaxPermissionChecks());
}
@Test
public void fromLimits_setTrackTotalHitsLimit() throws Exception
{
SearchParameters searchParameters = new SearchParameters();
searchMapper.setDefaults(searchParameters);
searchMapper.fromLimits(searchParameters, new Limits(null, null, 10));
assertEquals("TrackTotalHits should be set", 10, searchParameters.getTrackTotalHits());
}
@Test

View File

@@ -49,8 +49,10 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
import org.alfresco.repo.content.ContentLimitProvider.SimpleFixedLimitProvider;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.rule.RuleModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.repo.tenant.TenantUtil;
@@ -83,11 +85,16 @@ import org.alfresco.rest.api.tests.util.MultiPartBuilder;
import org.alfresco.rest.api.tests.util.MultiPartBuilder.FileData;
import org.alfresco.rest.api.tests.util.MultiPartBuilder.MultiPartRequest;
import org.alfresco.rest.api.tests.util.RestApiUtil;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.lock.LockType;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.Path;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.rule.Rule;
import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.service.cmr.rule.RuleType;
import org.alfresco.service.cmr.security.AccessPermission;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.AuthorityService;
@@ -130,7 +137,8 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
protected AuthorityService authorityService;
private NodeService nodeService;
private NamespaceService namespaceService;
private RuleService ruleService;
private ActionService actionService;
private String rootGroupName = null;
private String groupA = null;
@@ -145,6 +153,8 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
authorityService = (AuthorityService) applicationContext.getBean("AuthorityService");
nodeService = applicationContext.getBean("NodeService", NodeService.class);
namespaceService= (NamespaceService) applicationContext.getBean("NamespaceService");
ruleService = (RuleService) applicationContext.getBean("RuleService", RuleService.class);
actionService = (ActionService) applicationContext.getBean("ActionService", ActionService.class);
}
@After
@@ -6398,5 +6408,42 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
setRequestContext(user1);
deleteSite(site1Id, true, 204);
}
@Test
public void testRuleAspectAfterUpdate() throws Exception
{
// Change to User1 context
setRequestContext(networkOne.getId(), user1, null);
AuthenticationUtil.setFullyAuthenticatedUser(user1);
// Create folder
String folderId = createUniqueFolder(getMyNodeId());
NodeRef folderNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, folderId);
assertFalse("Folder shouldn't have the rule aspect", nodeService.hasAspect(folderNodeRef, RuleModel.ASPECT_RULES));
// Create Rule
Rule rule = new Rule();
rule.setTitle("My Rule");
rule.setRuleType(RuleType.INBOUND);
Action action = this.actionService.createAction(AddFeaturesActionExecuter.NAME);
action.setParameterValue(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_CLASSIFIABLE);
rule.setAction(action);
this.ruleService.saveRule(folderNodeRef, rule);
assertTrue("Folder should have the rule aspect", nodeService.hasAspect(folderNodeRef, RuleModel.ASPECT_RULES));
// Update folder with empty aspectNames
Folder folderUpdate = new Folder();
folderUpdate.setAspectNames(Arrays.asList());
put(URL_NODES, folderId, toJsonAsStringNonNull(folderUpdate), null, 200);
assertTrue("Folder should have the rule aspect", nodeService.hasAspect(folderNodeRef, RuleModel.ASPECT_RULES));
assertEquals("Folder should have 1 rule.", 1, ruleService.countRules(folderNodeRef));
// Cleanup
delete(URL_NODES, folderId, 204);
}
}

View File

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

View File

@@ -251,15 +251,16 @@ public class TransactionBehaviourQueue implements TransactionListener
}
catch (IllegalArgumentException e)
{
throw new AlfrescoRuntimeException("Failed to execute transaction-level behaviour " + context.method + " in transaction " + AlfrescoTransactionSupport.getTransactionId(), e);
throw new AlfrescoRuntimeException("Failed to execute transaction-level behaviour " + context.method + " in transaction " + AlfrescoTransactionSupport.getTransactionId() + " : " + e.getMessage(), e);
}
catch (IllegalAccessException e)
{
throw new AlfrescoRuntimeException("Failed to execute transaction-level behaviour " + context.method + " in transaction " + AlfrescoTransactionSupport.getTransactionId(), e);
throw new AlfrescoRuntimeException("Failed to execute transaction-level behaviour " + context.method + " in transaction " + AlfrescoTransactionSupport.getTransactionId() + " : " + e.getMessage(), e);
}
catch (InvocationTargetException e)
{
throw new AlfrescoRuntimeException("Failed to execute transaction-level behaviour " + context.method + " in transaction " + AlfrescoTransactionSupport.getTransactionId(), e.getTargetException());
String msg = e.getMessage() + (e.getTargetException() != null ? "(" + e.getTargetException().getMessage() + ")" : "");
throw new AlfrescoRuntimeException("Failed to execute transaction-level behaviour " + context.method + " in transaction " + AlfrescoTransactionSupport.getTransactionId() + " : " + msg, e.getTargetException());
}
}

View File

@@ -514,15 +514,11 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
NodeRef renditionNode = getRenditionNode(sourceNodeRef, renditionName);
boolean createRenditionNode = renditionNode == null;
boolean sourceHasAspectRenditioned = nodeService.hasAspect(sourceNodeRef, RenditionModel.ASPECT_RENDITIONED);
boolean sourceChanges = !sourceHasAspectRenditioned || createRenditionNode || transformInputStream == null;
try
{
if (sourceChanges)
{
ruleService.disableRuleType(RuleType.UPDATE);
behaviourFilter.disableBehaviour(sourceNodeRef, ContentModel.ASPECT_AUDITABLE);
behaviourFilter.disableBehaviour(sourceNodeRef, ContentModel.ASPECT_VERSIONABLE);
}
ruleService.disableRuleType(RuleType.UPDATE);
behaviourFilter.disableBehaviour(sourceNodeRef, ContentModel.ASPECT_AUDITABLE);
behaviourFilter.disableBehaviour(sourceNodeRef, ContentModel.ASPECT_VERSIONABLE);
// If they do not exist create the rendition association and the rendition node.
if (createRenditionNode)
@@ -592,12 +588,9 @@ public class RenditionService2Impl implements RenditionService2, InitializingBea
}
finally
{
if (sourceChanges)
{
behaviourFilter.enableBehaviour(sourceNodeRef, ContentModel.ASPECT_AUDITABLE);
behaviourFilter.enableBehaviour(sourceNodeRef, ContentModel.ASPECT_VERSIONABLE);
ruleService.enableRuleType(RuleType.UPDATE);
}
behaviourFilter.enableBehaviour(sourceNodeRef, ContentModel.ASPECT_AUDITABLE);
behaviourFilter.enableBehaviour(sourceNodeRef, ContentModel.ASPECT_VERSIONABLE);
ruleService.enableRuleType(RuleType.UPDATE);
}
return null;
}, false, true));

View File

@@ -1605,8 +1605,6 @@ public class LDAPUserRegistry implements UserRegistry, LDAPNameResolver, Initial
this.userSearchCtls = new SearchControls();
this.userSearchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
this.userSearchCtls.setReturningAttributes(LDAPUserRegistry.this.userKeys.getFirst());
// MNT-14001 fix, set search limit to ensure that server will not return more search results then provided by paged result control
this.userSearchCtls.setCountLimit(LDAPUserRegistry.this.queryBatchSize > 0 ? LDAPUserRegistry.this.queryBatchSize : 0);
this.next = fetchNext();
}

View File

@@ -997,6 +997,20 @@ public class WorkflowServiceImpl implements WorkflowService
public WorkflowTask updateTask(String taskId, Map<QName, Serializable> properties, Map<QName, List<NodeRef>> add,
Map<QName, List<NodeRef>> remove)
{
if(properties.containsKey(WorkflowModel.PROP_STATUS)) {
LinkedList<String> validTaskStatus = new LinkedList<>();
validTaskStatus.add("Not Yet Started");
validTaskStatus.add("In Progress");
validTaskStatus.add("On Hold");
validTaskStatus.add("Cancelled");
validTaskStatus.add("Completed");
if (!validTaskStatus.contains(properties.get(WorkflowModel.PROP_STATUS))) {
throw new WorkflowException("Invalid Value is Passed for Task Status.");
}
}
String engineId = BPMEngineRegistry.getEngineId(taskId);
TaskComponent component = getTaskComponent(engineId);
// get the current assignee before updating the task

View File

@@ -25,16 +25,19 @@
*/
package org.alfresco.schedule;
import org.alfresco.repo.lock.JobLockService;
import org.alfresco.repo.lock.LockAcquisitionException;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
import org.alfresco.util.VmShutdownListener.VmShutdownException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import org.alfresco.repo.lock.JobLockService;
import org.alfresco.repo.lock.JobLockService.JobLockRefreshCallback;
import org.alfresco.repo.lock.LockAcquisitionException;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
import org.alfresco.util.VmShutdownListener.VmShutdownException;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This class encapsulates the {@link org.alfresco.repo.lock.JobLockService JobLockService}
@@ -56,7 +59,7 @@ public class ScheduledJobLockExecuter
{
private static final long LOCK_TTL = 30000L;
private static Log logger = LogFactory.getLog(ScheduledJobLockExecuter.class.getName());
private static final Logger LOGGER = LoggerFactory.getLogger(ScheduledJobLockExecuter.class);
private static ThreadLocal<Pair<Long, String>> lockThreadLocal = new ThreadLocal<Pair<Long, String>>();
private final JobLockService jobLockService;
@@ -83,52 +86,43 @@ public class ScheduledJobLockExecuter
* @throws JobExecutionException thrown if the job fails to execute
*/
public void execute(JobExecutionContext jobContext) throws JobExecutionException
{
{
LockCallback lockCallback = new LockCallback();
String lockName = lockQName.getLocalName();
try
{
if (logger.isDebugEnabled())
{
logger.debug(String.format(" Job %s started.", lockQName.getLocalName()));
}
refreshLock();
LOGGER.debug(" Job {} started.", lockName);
refreshLock(lockCallback);
job.executeJob(jobContext);
if (logger.isDebugEnabled())
{
logger.debug(String.format(" Job %s completed.", lockQName.getLocalName()));
}
LOGGER.debug(" Job {} completed.", lockName);
}
catch (LockAcquisitionException e)
{
// Job being done by another process
if (logger.isDebugEnabled())
{
logger.debug(String.format(" Job %s already underway.", lockQName.getLocalName()));
}
// Job being done by another process
LOGGER.debug(" Job {} already underway.", lockName);
}
catch (VmShutdownException e)
{
// Aborted
if (logger.isDebugEnabled())
{
logger.debug(String.format(" Job %s aborted.", lockQName.getLocalName()));
}
LOGGER.debug(" Job {} aborted.", lockName);
}
finally
{
releaseLock();
releaseLock(lockCallback);
}
}
/**
* Lazily update the job lock
*/
private void refreshLock()
private void refreshLock(LockCallback lockCallback)
{
Pair<Long, String> lockPair = lockThreadLocal.get();
if (lockPair == null)
{
String lockToken = jobLockService.getLock(lockQName, LOCK_TTL);
Long lastLock = new Long(System.currentTimeMillis());
String lockToken = jobLockService.getLock(lockQName, LOCK_TTL);
jobLockService.refreshLock(lockToken, lockQName, LOCK_TTL, lockCallback);
Long lastLock = Long.valueOf(System.currentTimeMillis());
// We have not locked before
lockPair = new Pair<Long, String>(lastLock, lockToken);
lockThreadLocal.set(lockPair);
@@ -141,7 +135,7 @@ public class ScheduledJobLockExecuter
// Only refresh the lock if we are past a threshold
if (now - lastLock > (long) (LOCK_TTL / 2L))
{
jobLockService.refreshLock(lockToken, lockQName, LOCK_TTL);
jobLockService.refreshLock(lockToken, lockQName, LOCK_TTL, lockCallback);
lastLock = System.currentTimeMillis();
lockPair = new Pair<Long, String>(lastLock, lockToken);
lockThreadLocal.set(lockPair);
@@ -152,8 +146,13 @@ public class ScheduledJobLockExecuter
/**
* Release the lock after the job completes
*/
private void releaseLock()
{
private void releaseLock(LockCallback lockCallback)
{
if (lockCallback != null)
{
lockCallback.running.set(false);
}
Pair<Long, String> lockPair = lockThreadLocal.get();
if (lockPair != null)
{
@@ -169,5 +168,23 @@ public class ScheduledJobLockExecuter
}
}
// else: We can't release without a token
}
private class LockCallback implements JobLockRefreshCallback
{
final AtomicBoolean running = new AtomicBoolean(true);
@Override
public boolean isActive()
{
return running.get();
}
@Override
public void lockReleased()
{
running.set(false);
LOGGER.debug("Lock release notification: {}", lockQName);
}
}
}

View File

@@ -3,7 +3,7 @@
repository.name=Main Repository
# Schema number
version.schema=18000
version.schema=18200
# Directory configuration
@@ -754,13 +754,6 @@ encryption.ssl.truststore.keyMetaData.location=
httpclient.config.transform.mTLSEnabled=false
httpclient.config.transform.maxTotalConnections=20
httpclient.config.transform.maxHostConnections=20
httpclient.config.transform.socketTimeout=5000
httpclient.config.transform.connectionRequestTimeout=5000
httpclient.config.transform.connectionTimeout=5000
# Property is disabled by default for security reasons, never enable it on for production environments.
# It will stop verification of hostnames placed in certificates returned with server responses to Repository requests towards transform services
httpclient.config.transform.hostnameVerificationDisabled=false
# Re-encryptor properties
encryption.reencryptor.chunkSize=100
@@ -1349,7 +1342,7 @@ system.remove-alf_server-table-from-db.ignored=true
allow.unsecure.callback.jsonp=false
# pre-configured allow list of media/mime types to allow inline instead of attachment (via Content-Disposition response header)
content.nonAttach.mimetypes=application/pdf,image/jpeg,image/gif,image/png,image/tiff,image/bmp
content.nonAttach.mimetypes=application/pdf,image/jpeg,image/gif,image/png,image/tiff,image/bmp,application/octet-stream
# Zip file compression ratio threshold as a percentage, above which the zip file will be considered a "zip bomb" and the
# import extraction process cancelled.

View File

@@ -38,6 +38,15 @@ import org.junit.runners.Suite;
@RunWith(Categories.class)
@Categories.ExcludeCategory({DBTests.class, NonBuildTests.class})
@Suite.SuiteClasses({
// ----------------------------------------------------------------------
// testScheduleContext [classpath:alfresco/application-context.xml, classpath:alfresco/schedule/test-schedule-context.xml]
//
// This test needs to be first as it will clean nodes from trashcan, if order is changed, then it will take lot of time
// to remove all the nodes from previous tests
// ----------------------------------------------------------------------
org.alfresco.schedule.AbstractScheduledLockedJobTest.class,
// ----------------------------------------------------------------------
// globalIntegrationTestContext [classpath:alfresco/application-context.xml, classpath:alfresco/test/global-integration-test-context.xml]
// ----------------------------------------------------------------------

View File

@@ -30,6 +30,7 @@ import static org.junit.Assert.assertNotEquals;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.model.ContentModel;
@@ -419,6 +420,65 @@ public class RenditionService2IntegrationTest extends AbstractRenditionIntegrati
assertTrue("New rendition content hash code was not generated", isValidRenditionContentHashCode(contentHashCode3));
}
@Test
public void testModifierAfterMultipleRenditionRequests() throws InterruptedException
{
String user1 = createRandomUser();
String user2 = createRandomUser();
List<NodeRef> nodes = new ArrayList<NodeRef>();
final int TOTAL_NODES = 10;
// Create nodes
for (int i = 0; i < TOTAL_NODES; i++)
{
NodeRef n = createSource(user1, "quick.jpg");
render(user1, n, DOC_LIB);
nodes.add(n);
}
// Ask rendition multiple times with 'user2'
for (int j = 0; j < 10; j++)
{
for (int i = 0; i < TOTAL_NODES; i++)
{
render(user2, nodes.get(i), DOC_LIB);
}
}
for (int i = 0; i < TOTAL_NODES; i++)
{
waitForRendition(user1, nodes.get(i), DOC_LIB, true);
}
// Check the modifier is still user1
assertEquals(TOTAL_NODES, countModifier(nodes, user1));
}
private int countModifier(List<NodeRef> nodes, String user)
{
int count = 0;
for (int i = 0; i < nodes.size(); i++)
{
count += compareModifier(nodes.get(i), user);
}
return count;
}
private int compareModifier(NodeRef nodeRef, String user)
{
int res = 0;
if (nodeRef != null && user != null)
{
String modifier = nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIER).toString();
if (user.equals(modifier))
{
res = 1;
}
}
return res;
}
/**
* @deprecated can be removed when we remove the original RenditionService
*/
@@ -622,4 +682,4 @@ public class RenditionService2IntegrationTest extends AbstractRenditionIntegrati
renditionService2.setEnabled(true);
}
}
}
}

View File

@@ -0,0 +1,209 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2023 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.schedule;
import java.util.UUID;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.model.Repository;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
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.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.BaseSpringTest;
import org.junit.Before;
import org.junit.Test;
import org.quartz.JobDetail;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.quartz.SchedulerAccessorBean;
import org.springframework.test.context.ContextConfiguration;
import com.google.common.collect.ImmutableMap;
/**
*
* @author Tiago Salvado
*/
@ContextConfiguration({"classpath:alfresco/application-context.xml", "classpath:alfresco/schedule/test-schedule-context.xml"})
public class AbstractScheduledLockedJobTest extends BaseSpringTest
{
private static final int TOTAL_NODES = 9;
private static final int NUM_THREADS = 2;
private static final long JOB_EXECUTER_LOCK_TTL = 30000L;
private static final String ARCHIVE_STORE_URL = "archive://SpacesStore";
private NodeService nodeService;
private TransactionService transactionService;
private Repository repository;
private SchedulerAccessorBean testCleanerAccessor;
private JobDetail testCleanerJobDetail;
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractScheduledLockedJobTest.class);
/**
* Sets services and job beans
*/
@Before
public void setUp()
{
nodeService = (NodeService) applicationContext.getBean("nodeService");
transactionService = (TransactionService) applicationContext.getBean("transactionComponent");
repository = (Repository) applicationContext.getBean("repositoryHelper");
}
@Test
public void test() throws SchedulerException, InterruptedException
{
createAndDeleteNodes(TOTAL_NODES);
assertTrue("Expected nodes haven't been created", getNumberOfNodesInTrashcan() >= TOTAL_NODES);
CleanerThread[] threads = new CleanerThread[NUM_THREADS];
for (int i = 0; i < NUM_THREADS; i++)
{
CleanerThread t = new CleanerThread(i);
threads[i] = t;
t.start();
Thread.sleep(JOB_EXECUTER_LOCK_TTL);
}
for (Thread t : threads)
{
t.join();
}
while (getNumberOfNodesInTrashcan() > 0)
{
Thread.sleep(2000);
}
for (CleanerThread t : threads)
{
if (t.hasErrors())
{
fail("An error has occurred when executing multiple cleaner jobs at the same time");
}
}
}
/**
* Creates and deletes the specified number of nodes.
*
* @param archivedNodes
* Number of nodes to be created and added to trashcan
*/
private void createAndDeleteNodes(int archivedNodes)
{
AuthenticationUtil.runAsSystem(() -> {
RetryingTransactionHelper.RetryingTransactionCallback<Void> txnWork = () -> {
for (int i = 0; i < archivedNodes; i++)
{
addNodeToTrashcan();
}
return null;
};
return transactionService.getRetryingTransactionHelper().doInTransaction(txnWork);
});
}
/**
* Creates and deletes nodes
*/
private void addNodeToTrashcan()
{
NodeRef companyHome = repository.getCompanyHome();
String name = "Sample (" + UUID.randomUUID().toString() + ")";
ChildAssociationRef association = nodeService.createNode(companyHome, ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, name), ContentModel.TYPE_CONTENT,
ImmutableMap.of(ContentModel.PROP_NAME, name));
NodeRef parent = association.getChildRef();
nodeService.deleteNode(parent);
}
/**
* It returns the number of nodes present on trashcan.
*
* @return
*/
private long getNumberOfNodesInTrashcan()
{
StoreRef storeRef = new StoreRef(ARCHIVE_STORE_URL);
NodeRef archiveRoot = nodeService.getRootNode(storeRef);
return nodeService.getChildAssocs(archiveRoot, ContentModel.ASSOC_CHILDREN, RegexQNamePattern.MATCH_ALL).size();
}
/**
* Thread to start the cleaner job for the test.
*/
private class CleanerThread extends Thread
{
private int threadNum;
private boolean started;
private Cleaner testCleaner;
CleanerThread(int threadNum)
{
super(CleanerThread.class.getSimpleName() + "-" + threadNum);
this.threadNum = threadNum;
}
@Override
public void run()
{
try
{
testCleanerAccessor = (SchedulerAccessorBean) applicationContext.getBean("testSchedulerAccessor");
testCleanerJobDetail = (JobDetail) applicationContext.getBean("testCleanerJobDetail");
testCleaner = (Cleaner) testCleanerJobDetail.getJobDataMap().get("testCleaner");
testCleanerAccessor.getScheduler().triggerJob(testCleanerJobDetail.getKey());
LOGGER.info("Thread {} has started", this.threadNum);
this.started = true;
}
catch (SchedulerException e)
{
this.started = false;
}
}
public boolean hasErrors()
{
return !started || testCleaner != null && testCleaner.hasErrors();
}
}
}

View File

@@ -0,0 +1,174 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2023 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.schedule;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
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.namespace.RegexQNamePattern;
import org.alfresco.service.transaction.TransactionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A test implementation similar to the trash can cleaner job implementation that will be used in
* {@link AbstractScheduledLockedJobTest}
*
* @author Tiago Salvado
*/
public class Cleaner
{
private static final Logger LOGGER = LoggerFactory.getLogger(Cleaner.class);
private final NodeService nodeService;
private final TransactionService transactionService;
private static final String ARCHIVE_STORE_URL = "archive://SpacesStore";
private final int deleteBatchCount;
private List<NodeRef> nodesToClean;
private int numErrors;
private static final int REMOVAL_WAIT_TIME_MS = 5000;
/**
*
* @param nodeService
* @param transactionService
* @param deleteBatchCount
*/
public Cleaner(NodeService nodeService, TransactionService transactionService, int deleteBatchCount)
{
this.nodeService = nodeService;
this.transactionService = transactionService;
this.deleteBatchCount = deleteBatchCount;
}
/**
*
* It deletes the {@link java.util.List List} of {@link org.alfresco.service.cmr.repository.NodeRef NodeRef}
* received as argument.
*
* @param nodes
*
* return The number of deleted nodes
*/
private int deleteNodes(List<NodeRef> nodes)
{
AtomicInteger deletedNodes = new AtomicInteger();
for (NodeRef nodeRef : nodes)
{
// create a new transaction for each deletion so the transactions are smaller and the progress of the
// cleaner is not lost in case of any problems encountered during the job execution
AuthenticationUtil.runAsSystem(() -> {
RetryingTransactionCallback<Void> txnWork = () -> {
try
{
nodeService.deleteNode(nodeRef);
}
catch (InvalidNodeRefException inre)
{
numErrors++;
}
deletedNodes.getAndIncrement();
// Waiting REMOVAL_WAIT_TIME_MS seconds for next deletion so we don't need to have many nodes on the trash can
Thread.sleep(REMOVAL_WAIT_TIME_MS);
return null;
};
return transactionService.getRetryingTransactionHelper().doInTransaction(txnWork, false, true);
});
}
return deletedNodes.get();
}
/**
*
* It returns the {@link java.util.List List} of {@link org.alfresco.service.cmr.repository.NodeRef NodeRef} of the
* archive store set to be deleted according to configuration for <b>deleteBatchCount</b>.
*
* @return
*/
private List<NodeRef> getBatchToDelete()
{
return getChildAssocs().stream().map(ChildAssociationRef::getChildRef).collect(Collectors.toList());
}
/**
*
* It will return the first {@link #deleteBatchCount}
* {@link org.alfresco.service.cmr.repository.ChildAssociationRef}s of type {@link ContentModel}.ASSOC_CHILDREN from
* the archive store set.
*
* @return
*/
private List<ChildAssociationRef> getChildAssocs()
{
StoreRef archiveStore = new StoreRef(ARCHIVE_STORE_URL);
NodeRef archiveRoot = nodeService.getRootNode(archiveStore);
return nodeService.getChildAssocs(archiveRoot, ContentModel.ASSOC_CHILDREN, RegexQNamePattern.MATCH_ALL, deleteBatchCount,
false);
}
/**
*
* The method that will clean the specified <b>archiveStoreUrl</b> to the limits defined by the values set for
* <b>deleteBatchCount</b>.
*/
public void clean()
{
LOGGER.info("Running TestCleaner");
// Retrieve in a new read-only transaction the list of nodes to be deleted by the TestCleaner
AuthenticationUtil.runAsSystem(() -> {
RetryingTransactionCallback<Void> txnWork = () -> {
nodesToClean = getBatchToDelete();
LOGGER.info(String.format("Number of nodes to delete: %s", nodesToClean.size()));
return null;
};
return transactionService.getRetryingTransactionHelper().doInTransaction(txnWork, true, true);
});
int deletedNodes = deleteNodes(nodesToClean);
LOGGER.info("TestCleaner finished. Number of deleted nodes: {}", deletedNodes);
}
public boolean hasErrors()
{
return numErrors > 0;
}
}

View File

@@ -0,0 +1,45 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2023 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.schedule;
import org.quartz.JobExecutionContext;
/**
* Test job that will execute {@link Cleaner}
*
* @author Tiago Salvado
*
* @see AbstractScheduledLockedJob
*/
public class CleanerJob extends AbstractScheduledLockedJob
{
@Override
public void executeJob(JobExecutionContext jobContext)
{
Cleaner testCleaner = (Cleaner) jobContext.getJobDetail().getJobDataMap().get("testCleaner");
testCleaner.clean();
}
}

View File

@@ -0,0 +1,36 @@
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="testCleaner" class="org.alfresco.schedule.Cleaner">
<constructor-arg ref="nodeService" />
<constructor-arg ref="transactionService" />
<constructor-arg value="100" />
</bean>
<bean id="testSchedulerAccessor" class="org.springframework.scheduling.quartz.SchedulerAccessorBean">
<property name="scheduler" ref="schedulerFactory"/>
<property name="triggers">
<list>
<ref bean="testCleanerTrigger"/>
</list>
</property>
</bean>
<bean id="testCleanerTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="cronExpression" value="* * * * * ? 2099"/>
<property name="jobDetail" ref="testCleanerJobDetail"/>
</bean>
<bean id="testCleanerJobDetail" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<property name="jobClass" value="org.alfresco.schedule.CleanerJob"/>
<property name="jobDataAsMap">
<map>
<entry key="testCleaner" value-ref="testCleaner" />
<entry key="jobLockService" value-ref="jobLockService" />
</map>
</property>
</bean>
</beans>