mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-10 14:11:58 +00:00
Compare commits
108 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
146b59a4a8 | ||
|
2c3845bf9d | ||
|
dd05f3d338 | ||
|
c2338bdeb2 | ||
|
589e14a0b1 | ||
|
0f753c11c7 | ||
|
c8fea93298 | ||
|
d7f881ce0c | ||
|
b5fabb1290 | ||
|
f6d3ff4b15 | ||
|
2eb5bb7b7a | ||
|
53909dc086 | ||
|
4fedf0bada | ||
|
9f6edc648e | ||
|
22298eaa46 | ||
|
2e9db406d4 | ||
|
8565c9413e | ||
|
0d411cd759 | ||
|
ca3bbf5226 | ||
|
e83cd86c4d | ||
|
7da314cd97 | ||
|
d39401a7ec | ||
|
05df8a7582 | ||
|
85f22cb6e4 | ||
|
ce77b1ff42 | ||
|
29a7de55d2 | ||
|
cb3cb85694 | ||
|
2fcf1bd2d5 | ||
|
4c687f670e | ||
|
dad0094a46 | ||
|
06fdc4302e | ||
|
b1466915af | ||
|
6be773ba18 | ||
|
fbcfe68c99 | ||
|
e50118115e | ||
|
3a2136b886 | ||
|
86464427a0 | ||
|
7e9e0e1ad4 | ||
|
32c3a5ad90 | ||
|
e983e4ed22 | ||
|
ba197fcf70 | ||
|
18e6965a61 | ||
|
c0757f45a2 | ||
|
7bdbc3a91a | ||
|
25fa97bdd8 | ||
|
7592b637cc | ||
|
70c490f26c | ||
|
93f7d06cf0 | ||
|
657318c6ae | ||
|
4f4d8210ef | ||
|
14ba7f5d55 | ||
|
c4a4aedad7 | ||
|
be60d67377 | ||
|
806131c21c | ||
|
b0f767c1ae | ||
|
baccde2663 | ||
|
e048278a27 | ||
|
8586d22b95 | ||
|
3dec621b15 | ||
|
64202ee9d5 | ||
|
2b92022b5b | ||
|
9a56a052e8 | ||
|
1f38c24bbd | ||
|
0bcb96e51e | ||
|
df522a38b9 | ||
|
1458ef3311 | ||
|
2bdca1a4f5 | ||
|
07cc9aa86e | ||
|
7db550cee1 | ||
|
937d80327f | ||
|
8abff868cc | ||
|
ffae8a62a1 | ||
|
0350c966df | ||
|
833a7675bc | ||
|
8aa263f377 | ||
|
73f30b7ef2 | ||
|
4bf58cc99c | ||
|
d53881d87f | ||
|
937601020d | ||
|
429b389b08 | ||
|
c944f3560c | ||
|
40ff2558f5 | ||
|
4f69f28586 | ||
|
aa66dd748f | ||
|
bf9c8ab870 | ||
|
959cf8f13f | ||
|
8b4285afbd | ||
|
7143f5975f | ||
|
31944bfc0f | ||
|
c874fa4e51 | ||
|
5780871f0c | ||
|
85ef347dc3 | ||
|
0a76858778 | ||
|
6db6245e53 | ||
|
7b572a3e02 | ||
|
b1cbebacc3 | ||
|
0bbe73aee1 | ||
|
9135fdae8b | ||
|
0cb0cfa8f6 | ||
|
5a96cce5bb | ||
|
3c2643dbf2 | ||
|
0612d74c68 | ||
|
eb6157ed2a | ||
|
72a573c090 | ||
|
13e3369a7f | ||
|
444de08f91 | ||
|
5f5c377532 | ||
|
f1561504cd |
14
.github/workflows/ci.yml
vendored
14
.github/workflows/ci.yml
vendored
@@ -23,6 +23,7 @@ env:
|
||||
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
|
||||
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
|
||||
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
|
||||
CI_WORKSPACE: ${{ github.workspace }}
|
||||
TAS_ENVIRONMENT: ./packaging/tests/environment
|
||||
TAS_SCRIPTS: ../alfresco-community-repo/packaging/tests/scripts
|
||||
|
||||
@@ -316,7 +317,8 @@ jobs:
|
||||
- testSuite: MTLSTestSuite
|
||||
compose-profile: with-mtls-transform-core-aio
|
||||
mtls: true
|
||||
mvn-options: '-Dencryption.ssl.keystore.location=${GITHUB_WORKSPACE}/keystores/alfresco/alfresco.keystore -Dencryption.ssl.truststore.location=${GITHUB_WORKSPACE}/keystores/alfresco/alfresco.truststore'
|
||||
disabledHostnameVerification: false
|
||||
mvn-options: '-Dencryption.ssl.keystore.location=${CI_WORKSPACE}/keystores/alfresco/alfresco.keystore -Dencryption.ssl.truststore.location=${CI_WORKSPACE}/keystores/alfresco/alfresco.truststore'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
@@ -328,8 +330,14 @@ jobs:
|
||||
- name: "Generate Keystores and Truststores for Mutual TLS configuration"
|
||||
if: ${{ matrix.mtls }}
|
||||
run: |
|
||||
git clone -b "master" --depth=1 "https://${{ secrets.BOT_GITHUB_USERNAME }}:${{ secrets.BOT_GITHUB_TOKEN }}@github.com/Alfresco/alfresco-ssl-generator.git"
|
||||
bash ./scripts/ci/generate_keystores.sh
|
||||
git clone -b "master" --depth=1 "https://${{ secrets.BOT_GITHUB_USERNAME }}:${{ secrets.BOT_GITHUB_TOKEN }}@github.com/Alfresco/alfresco-ssl-generator.git"
|
||||
if ${{ matrix.disabledHostnameVerification }} ; then
|
||||
bash ${{ env.CI_WORKSPACE }}/alfresco-ssl-generator/scripts/ci/generate_keystores_wrong_hostnames.sh
|
||||
echo "HOSTNAME_VERIFICATION_DISABLED=true" >> "$GITHUB_ENV"
|
||||
else
|
||||
bash ${{ env.CI_WORKSPACE }}/alfresco-ssl-generator/scripts/ci/generate_keystores.sh
|
||||
echo "HOSTNAME_VERIFICATION_DISABLED=false" >> "$GITHUB_ENV"
|
||||
fi
|
||||
- name: "Set up the environment"
|
||||
run: |
|
||||
if [ -e ./scripts/ci/tests/${{ matrix.testSuite }}-setup.sh ]; then
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
@@ -50,6 +50,7 @@ import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Ignore;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.AssertJUnit;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
@@ -135,192 +136,195 @@ public class DispositionScheduleLinkedRecordsTest extends BaseRMRestTest {
|
||||
* <p>
|
||||
* <p/> TestRail Test C775<p/>
|
||||
**/
|
||||
@Test
|
||||
@AlfrescoTest(jira = "RM-1622")
|
||||
public void dispositionScheduleLinkedRecords() throws UnsupportedEncodingException {
|
||||
STEP("Create record category");
|
||||
Category1 = createRootCategory(categoryRM3077);
|
||||
// @Ignore("ACS-5020")
|
||||
// @Test
|
||||
// @AlfrescoTest(jira = "RM-1622")
|
||||
// public void dispositionScheduleLinkedRecords() throws UnsupportedEncodingException {
|
||||
// STEP("Create record category");
|
||||
// Category1 = createRootCategory(categoryRM3077);
|
||||
//
|
||||
// //create retention schedule
|
||||
// dispositionScheduleService.createCategoryRetentionSchedule(Category1.getName(), false);
|
||||
//
|
||||
// // add cut off step
|
||||
// dispositionScheduleService.addCutOffAfterPeriodStep(Category1.getName(), "day|2", CREATED_DATE);
|
||||
//
|
||||
// //create a copy of the category recordsCategory
|
||||
// String CopyCategoryId = copyCategory(getAdminUser(),Category1.getId(), copyCategoryRM3077);
|
||||
//
|
||||
// // create folders in both categories
|
||||
// CatFolder = createRecordFolder(Category1.getId(), folderRM3077);
|
||||
// CopyCatFolder = createRecordFolder(CopyCategoryId, copyFolderRM3077);
|
||||
//
|
||||
// // create record files
|
||||
// String electronicRecord = "RM-2801 electronic record";
|
||||
// Record elRecord = createElectronicRecord(CatFolder.getId(), electronicRecord);
|
||||
// String elRecordFullName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
// getDataUser().usingAdmin().getAdminUser().getPassword(), CatFolder.getName(), electronicRecord);
|
||||
//
|
||||
// String nonElectronicRecord = "RM-2801 non-electronic record";
|
||||
// Record nonElRecord = createNonElectronicRecord(CatFolder.getId(), nonElectronicRecord);
|
||||
// String nonElRecordFullName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
// getDataUser().usingAdmin().getAdminUser().getPassword(), CatFolder.getName(), nonElectronicRecord);
|
||||
//
|
||||
// // link the records to copy folder, then complete them
|
||||
// List<String> recordLists = new ArrayList<>();
|
||||
// recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + elRecord.getId());
|
||||
// recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + nonElRecord.getId());
|
||||
//
|
||||
// linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
||||
// getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK,copyCategoryRM3077 + "/" +
|
||||
// copyFolderRM3077, recordLists);
|
||||
// recordsAPI.completeRecord(rmAdmin.getUsername(), rmAdmin.getPassword(), elRecordFullName);
|
||||
// recordsAPI.completeRecord(rmAdmin.getUsername(), rmAdmin.getPassword(), nonElRecordFullName);
|
||||
//
|
||||
// // edit disposition date
|
||||
// recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),editDispositionDateJson(),CatFolder.getName());
|
||||
//
|
||||
// // cut off the Folder
|
||||
// recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),CatFolder.getName());
|
||||
//
|
||||
// // Verify the Content
|
||||
// Node electronicNode = getNode(elRecord.getId());
|
||||
// assertTrue("The content of " + electronicRecord + " is available",
|
||||
// StringUtils.isEmpty(electronicNode.getNodeContent().getResponse().getBody().asString()));
|
||||
//
|
||||
// // verify the Properties
|
||||
// AssertJUnit.assertNull("The properties are present even after cutting off the record.", elRecord.getProperties().getTitle());
|
||||
//
|
||||
// // delete precondition
|
||||
// deleteRecordCategory(Category1.getId());
|
||||
// deleteRecordCategory(CopyCategoryId);
|
||||
// }
|
||||
// /**
|
||||
// * Test covering RM-3060
|
||||
// * Check the disposition steps for a record can be executed
|
||||
// * When the record is linked to a folder with the same disposition schedule
|
||||
// * */
|
||||
// @Ignore("ACS-5020")
|
||||
//// @Test
|
||||
// @AlfrescoTest (jira = "RM-3060")
|
||||
// public void sameDispositionScheduleLinkedRecords() throws UnsupportedEncodingException {
|
||||
//
|
||||
// // create a category with retention applied on records level
|
||||
// RecordCategory recordCategory = getRestAPIFactory().getFilePlansAPI(rmAdmin)
|
||||
// .createRootRecordCategory(RecordCategory.builder().name(firstCategoryRM3060).build(),
|
||||
// RecordCategory.DEFAULT_FILE_PLAN_ALIAS);
|
||||
// dispositionScheduleService.createCategoryRetentionSchedule(firstCategoryRM3060, true);
|
||||
// dispositionScheduleService.addCutOffAfterPeriodStep(firstCategoryRM3060, "week|1", DATE_FILED);
|
||||
// dispositionScheduleService.addTransferAfterEventStep(firstCategoryRM3060, TRANSFER_LOCATION, RMEvents.CASE_CLOSED.getEventName());
|
||||
// dispositionScheduleService.addDestroyWithoutGhostingAfterPeriodStep(firstCategoryRM3060, "week|1", CUT_OFF_DATE);
|
||||
//
|
||||
// // make a copy of the category created
|
||||
// String categorySecondId = copyCategory(getAdminUser(), recordCategory.getId(), secondCategoryRM3060);
|
||||
//
|
||||
// // create a folder on the category firstCategoryRM3060 with a complete electronic record
|
||||
// RecordCategoryChild firstFolderRecordCategoryChild = createRecordFolder(recordCategory.getId(),firstFolderRM3060);
|
||||
// Record firstElectronicRecord = createElectronicRecord(firstFolderRecordCategoryChild.getId(),electronicRecordRM3060);
|
||||
//
|
||||
// String elRecordFullName = recordsAPI.getRecordFullName(getDataUser().getAdminUser().getUsername(),
|
||||
// getDataUser().getAdminUser().getPassword(),firstFolderRM3060, electronicRecordRM3060);
|
||||
// String elRecordNameNodeRef = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
// getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + firstCategoryRM3060 + "/" + firstFolderRM3060);
|
||||
//
|
||||
// recordsAPI.completeRecord(getDataUser().getAdminUser().getUsername(),
|
||||
// getDataUser().getAdminUser().getPassword(), elRecordFullName);
|
||||
//
|
||||
// // create a folder on the category secondCategoryRM3060 with a non electronic record
|
||||
// RecordCategoryChild secondFolderRecordCategoryChild = createRecordFolder(categorySecondId,secondFolderRM3060);
|
||||
// Record secondNonElectronicRecord = createNonElectronicRecord(secondFolderRecordCategoryChild.getId(),nonElectronicRecordRM3060);
|
||||
//
|
||||
// // link the nonElectronicRecordRM3060 to firstFolderRM3060
|
||||
// List<String> recordLists = new ArrayList<>();
|
||||
// recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + secondNonElectronicRecord.getId());
|
||||
//
|
||||
// linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
||||
// getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK,secondCategoryRM3060 + "/" +
|
||||
// secondFolderRM3060, recordLists);
|
||||
// String nonElRecordFullName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
// getDataUser().usingAdmin().getAdminUser().getPassword(), secondFolderRM3060, secondNonElectronicRecord.getName());
|
||||
// String nonElRecordNameNodeRef = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
// getDataUser().usingAdmin().getAdminUser().getPassword(), nonElRecordFullName, "/" + secondCategoryRM3060 + "/" + secondFolderRM3060);
|
||||
//
|
||||
// // complete records and cut them off
|
||||
// recordsAPI.completeRecord(getDataUser().getAdminUser().getUsername(),
|
||||
// getDataUser().getAdminUser().getPassword(), nonElRecordFullName);
|
||||
//
|
||||
// // edit the disposition date
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),editDispositionDateJson(),nonElRecordNameNodeRef);
|
||||
//
|
||||
// // cut off the record
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),nonElRecordNameNodeRef);
|
||||
//
|
||||
// //check the record is cut off
|
||||
// AssertJUnit.assertTrue("The file " + nonElectronicRecordRM3060 + " has not been successfully cut off.", getRestAPIFactory().getRecordsAPI().getRecord(secondNonElectronicRecord.getId()).getAspectNames().contains(CUT_OFF_ASPECT));
|
||||
//
|
||||
// // link the electronic record to secondFolderRM3060
|
||||
// recordLists.clear();
|
||||
// recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + secondNonElectronicRecord.getId());
|
||||
// linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
||||
// getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK,secondCategoryRM3060 + "/" +
|
||||
// secondFolderRM3060, recordLists);
|
||||
//
|
||||
// // edit the disposition date and cut off the record
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),editDispositionDateJson(),elRecordNameNodeRef);
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),elRecordNameNodeRef);
|
||||
//
|
||||
// AssertJUnit.assertTrue("The file " + electronicRecordRM3060 + " has not been successfully cut off.", getRestAPIFactory().getRecordsAPI().getRecord(firstElectronicRecord.getId()).getAspectNames().contains(CUT_OFF_ASPECT));
|
||||
//
|
||||
// // open the record and complete the disposition schedule event
|
||||
// rmRolesAndActionsAPI.completeEvent(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(), elRecordFullName, RMEvents.CASE_CLOSED, Instant.now());
|
||||
// rmRolesAndActionsAPI.completeEvent(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(), nonElRecordFullName, RMEvents.CASE_CLOSED, Instant.now());
|
||||
//
|
||||
// // transfer the files & complete transfers
|
||||
// HttpResponse nonElRecordNameHttpResponse = recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","transfer"),recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
// getDataUser().usingAdmin().getAdminUser().getPassword(), nonElRecordFullName, "/" + secondCategoryRM3060 + "/" + secondFolderRM3060));
|
||||
//
|
||||
// String nonElRecordNameTransferId = getTransferId(nonElRecordNameHttpResponse,nonElRecordNameNodeRef);
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","transferComplete"),nonElRecordNameTransferId);
|
||||
//
|
||||
// HttpResponse elRecordNameHttpResponse = recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","transfer"),recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
// getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + firstCategoryRM3060 + "/" + firstFolderRM3060));
|
||||
//
|
||||
// String elRecordNameTransferId = getTransferId(elRecordNameHttpResponse,elRecordNameNodeRef);
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","transferComplete"),elRecordNameTransferId);
|
||||
//
|
||||
// AssertJUnit.assertTrue("The file " + electronicRecordRM3060 + " has not been successfully transferred", getRestAPIFactory().getRecordsAPI().getRecord(firstElectronicRecord.getId()).getAspectNames().contains(TRANSFER_TYPE));
|
||||
// AssertJUnit.assertTrue("The file " + nonElectronicRecordRM3060 + " has not been successfully transferred.", getRestAPIFactory().getRecordsAPI().getRecord(secondNonElectronicRecord.getId()).getAspectNames().contains(TRANSFER_TYPE));
|
||||
//
|
||||
// // edit the disposition date for nonElectronicRecordRM3060 & electronicRecordRM3060
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),editDispositionDateJson(),nonElRecordNameNodeRef);
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),editDispositionDateJson(),elRecordNameNodeRef);
|
||||
//
|
||||
// // destroy nonElectronicRecordRM3060 & electronicRecordRM3060 records
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","destroy"),nonElRecordNameNodeRef);
|
||||
// recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
// getAdminUser().getPassword(),new JSONObject().put("name","destroy"),elRecordNameNodeRef);
|
||||
//
|
||||
// // check the file is not displayed
|
||||
// assertNull("The file " + nonElectronicRecordRM3060 + " has not been successfully destroyed.", secondNonElectronicRecord.getContent());
|
||||
// assertNull("The file " + electronicRecordRM3060 + " has not been successfully destroyed.", firstElectronicRecord.getContent());
|
||||
//
|
||||
// // delete precondition
|
||||
// deleteRecordCategory(recordCategory.getId());
|
||||
// deleteRecordCategory(categorySecondId);
|
||||
// }
|
||||
|
||||
//create retention schedule
|
||||
dispositionScheduleService.createCategoryRetentionSchedule(Category1.getName(), false);
|
||||
|
||||
// add cut off step
|
||||
dispositionScheduleService.addCutOffAfterPeriodStep(Category1.getName(), "day|2", CREATED_DATE);
|
||||
|
||||
//create a copy of the category recordsCategory
|
||||
String CopyCategoryId = copyCategory(getAdminUser(),Category1.getId(), copyCategoryRM3077);
|
||||
|
||||
// create folders in both categories
|
||||
CatFolder = createRecordFolder(Category1.getId(), folderRM3077);
|
||||
CopyCatFolder = createRecordFolder(CopyCategoryId, copyFolderRM3077);
|
||||
|
||||
// create record files
|
||||
String electronicRecord = "RM-2801 electronic record";
|
||||
Record elRecord = createElectronicRecord(CatFolder.getId(), electronicRecord);
|
||||
String elRecordFullName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), CatFolder.getName(), electronicRecord);
|
||||
|
||||
String nonElectronicRecord = "RM-2801 non-electronic record";
|
||||
Record nonElRecord = createNonElectronicRecord(CatFolder.getId(), nonElectronicRecord);
|
||||
String nonElRecordFullName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), CatFolder.getName(), nonElectronicRecord);
|
||||
|
||||
// link the records to copy folder, then complete them
|
||||
List<String> recordLists = new ArrayList<>();
|
||||
recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + elRecord.getId());
|
||||
recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + nonElRecord.getId());
|
||||
|
||||
linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
||||
getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK,copyCategoryRM3077 + "/" +
|
||||
copyFolderRM3077, recordLists);
|
||||
recordsAPI.completeRecord(rmAdmin.getUsername(), rmAdmin.getPassword(), elRecordFullName);
|
||||
recordsAPI.completeRecord(rmAdmin.getUsername(), rmAdmin.getPassword(), nonElRecordFullName);
|
||||
|
||||
// edit disposition date
|
||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),CatFolder.getName());
|
||||
|
||||
// cut off the Folder
|
||||
recordFoldersAPI.postFolderAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),CatFolder.getName());
|
||||
|
||||
// Verify the Content
|
||||
Node electronicNode = getNode(elRecord.getId());
|
||||
assertTrue("The content of " + electronicRecord + " is available",
|
||||
StringUtils.isEmpty(electronicNode.getNodeContent().getResponse().getBody().asString()));
|
||||
|
||||
// verify the Properties
|
||||
AssertJUnit.assertNull("The properties are present even after cutting off the record.", elRecord.getProperties().getTitle());
|
||||
|
||||
// delete precondition
|
||||
deleteRecordCategory(Category1.getId());
|
||||
deleteRecordCategory(CopyCategoryId);
|
||||
}
|
||||
/**
|
||||
* Test covering RM-3060
|
||||
* Check the disposition steps for a record can be executed
|
||||
* When the record is linked to a folder with the same disposition schedule
|
||||
* */
|
||||
@Test
|
||||
@AlfrescoTest (jira = "RM-3060")
|
||||
public void sameDispositionScheduleLinkedRecords() throws UnsupportedEncodingException {
|
||||
|
||||
// create a category with retention applied on records level
|
||||
RecordCategory recordCategory = getRestAPIFactory().getFilePlansAPI(rmAdmin)
|
||||
.createRootRecordCategory(RecordCategory.builder().name(firstCategoryRM3060).build(),
|
||||
RecordCategory.DEFAULT_FILE_PLAN_ALIAS);
|
||||
dispositionScheduleService.createCategoryRetentionSchedule(firstCategoryRM3060, true);
|
||||
dispositionScheduleService.addCutOffAfterPeriodStep(firstCategoryRM3060, "week|1", DATE_FILED);
|
||||
dispositionScheduleService.addTransferAfterEventStep(firstCategoryRM3060, TRANSFER_LOCATION, RMEvents.CASE_CLOSED.getEventName());
|
||||
dispositionScheduleService.addDestroyWithoutGhostingAfterPeriodStep(firstCategoryRM3060, "week|1", CUT_OFF_DATE);
|
||||
|
||||
// make a copy of the category created
|
||||
String categorySecondId = copyCategory(getAdminUser(), recordCategory.getId(), secondCategoryRM3060);
|
||||
|
||||
// create a folder on the category firstCategoryRM3060 with a complete electronic record
|
||||
RecordCategoryChild firstFolderRecordCategoryChild = createRecordFolder(recordCategory.getId(),firstFolderRM3060);
|
||||
Record firstElectronicRecord = createElectronicRecord(firstFolderRecordCategoryChild.getId(),electronicRecordRM3060);
|
||||
|
||||
String elRecordFullName = recordsAPI.getRecordFullName(getDataUser().getAdminUser().getUsername(),
|
||||
getDataUser().getAdminUser().getPassword(),firstFolderRM3060, electronicRecordRM3060);
|
||||
String elRecordNameNodeRef = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + firstCategoryRM3060 + "/" + firstFolderRM3060);
|
||||
|
||||
recordsAPI.completeRecord(getDataUser().getAdminUser().getUsername(),
|
||||
getDataUser().getAdminUser().getPassword(), elRecordFullName);
|
||||
|
||||
// create a folder on the category secondCategoryRM3060 with a non electronic record
|
||||
RecordCategoryChild secondFolderRecordCategoryChild = createRecordFolder(categorySecondId,secondFolderRM3060);
|
||||
Record secondNonElectronicRecord = createNonElectronicRecord(secondFolderRecordCategoryChild.getId(),nonElectronicRecordRM3060);
|
||||
|
||||
// link the nonElectronicRecordRM3060 to firstFolderRM3060
|
||||
List<String> recordLists = new ArrayList<>();
|
||||
recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + secondNonElectronicRecord.getId());
|
||||
|
||||
linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
||||
getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK,secondCategoryRM3060 + "/" +
|
||||
secondFolderRM3060, recordLists);
|
||||
String nonElRecordFullName = recordsAPI.getRecordFullName(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), secondFolderRM3060, secondNonElectronicRecord.getName());
|
||||
String nonElRecordNameNodeRef = recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), nonElRecordFullName, "/" + secondCategoryRM3060 + "/" + secondFolderRM3060);
|
||||
|
||||
// complete records and cut them off
|
||||
recordsAPI.completeRecord(getDataUser().getAdminUser().getUsername(),
|
||||
getDataUser().getAdminUser().getPassword(), nonElRecordFullName);
|
||||
|
||||
// edit the disposition date
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),nonElRecordNameNodeRef);
|
||||
|
||||
// cut off the record
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),nonElRecordNameNodeRef);
|
||||
|
||||
//check the record is cut off
|
||||
AssertJUnit.assertTrue("The file " + nonElectronicRecordRM3060 + " has not been successfully cut off.", getRestAPIFactory().getRecordsAPI().getRecord(secondNonElectronicRecord.getId()).getAspectNames().contains(CUT_OFF_ASPECT));
|
||||
|
||||
// link the electronic record to secondFolderRM3060
|
||||
recordLists.clear();
|
||||
recordLists.add(NODE_REF_WORKSPACE_SPACES_STORE + secondNonElectronicRecord.getId());
|
||||
linksAPI.linkRecord(getDataUser().getAdminUser().getUsername(),
|
||||
getDataUser().getAdminUser().getPassword(), HttpStatus.SC_OK,secondCategoryRM3060 + "/" +
|
||||
secondFolderRM3060, recordLists);
|
||||
|
||||
// edit the disposition date and cut off the record
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),elRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","cutoff"),elRecordNameNodeRef);
|
||||
|
||||
AssertJUnit.assertTrue("The file " + electronicRecordRM3060 + " has not been successfully cut off.", getRestAPIFactory().getRecordsAPI().getRecord(firstElectronicRecord.getId()).getAspectNames().contains(CUT_OFF_ASPECT));
|
||||
|
||||
// open the record and complete the disposition schedule event
|
||||
rmRolesAndActionsAPI.completeEvent(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(), elRecordFullName, RMEvents.CASE_CLOSED, Instant.now());
|
||||
rmRolesAndActionsAPI.completeEvent(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(), nonElRecordFullName, RMEvents.CASE_CLOSED, Instant.now());
|
||||
|
||||
// transfer the files & complete transfers
|
||||
HttpResponse nonElRecordNameHttpResponse = recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transfer"),recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), nonElRecordFullName, "/" + secondCategoryRM3060 + "/" + secondFolderRM3060));
|
||||
|
||||
String nonElRecordNameTransferId = getTransferId(nonElRecordNameHttpResponse,nonElRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transferComplete"),nonElRecordNameTransferId);
|
||||
|
||||
HttpResponse elRecordNameHttpResponse = recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transfer"),recordsAPI.getRecordNodeRef(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), elRecordFullName, "/" + firstCategoryRM3060 + "/" + firstFolderRM3060));
|
||||
|
||||
String elRecordNameTransferId = getTransferId(elRecordNameHttpResponse,elRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","transferComplete"),elRecordNameTransferId);
|
||||
|
||||
AssertJUnit.assertTrue("The file " + electronicRecordRM3060 + " has not been successfully transferred", getRestAPIFactory().getRecordsAPI().getRecord(firstElectronicRecord.getId()).getAspectNames().contains(TRANSFER_TYPE));
|
||||
AssertJUnit.assertTrue("The file " + nonElectronicRecordRM3060 + " has not been successfully transferred.", getRestAPIFactory().getRecordsAPI().getRecord(secondNonElectronicRecord.getId()).getAspectNames().contains(TRANSFER_TYPE));
|
||||
|
||||
// edit the disposition date for nonElectronicRecordRM3060 & electronicRecordRM3060
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),nonElRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),editDispositionDateJson(),elRecordNameNodeRef);
|
||||
|
||||
// destroy nonElectronicRecordRM3060 & electronicRecordRM3060 records
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","destroy"),nonElRecordNameNodeRef);
|
||||
recordFoldersAPI.postRecordAction(getAdminUser().getUsername(),
|
||||
getAdminUser().getPassword(),new JSONObject().put("name","destroy"),elRecordNameNodeRef);
|
||||
|
||||
// check the file is not displayed
|
||||
assertNull("The file " + nonElectronicRecordRM3060 + " has not been successfully destroyed.", secondNonElectronicRecord.getContent());
|
||||
assertNull("The file " + electronicRecordRM3060 + " has not been successfully destroyed.", firstElectronicRecord.getContent());
|
||||
|
||||
// delete precondition
|
||||
deleteRecordCategory(recordCategory.getId());
|
||||
deleteRecordCategory(categorySecondId);
|
||||
}
|
||||
private String copyCategory(UserModel user, String categoryId, String copyName) {
|
||||
RepoTestModel repoTestModel = new RepoTestModel() {};
|
||||
repoTestModel.setNodeRef(categoryId);
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -1,3 +1,3 @@
|
||||
SOLR6_TAG=2.0.7-A2
|
||||
SOLR6_TAG=2.0.7-A5
|
||||
POSTGRES_TAG=14.4
|
||||
ACTIVEMQ_TAG=5.17.1-jre11-rockylinux8
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
@@ -38,9 +38,7 @@ tags:
|
||||
description: Retrieve and manage unfiled records containers
|
||||
- name: unfiled-record-folders
|
||||
description: Retrieve and manage unfiled record folders
|
||||
- name: events
|
||||
description: Retrieve and manage retention events
|
||||
|
||||
|
||||
paths:
|
||||
## GS sites
|
||||
'/gs-sites':
|
||||
@@ -2094,172 +2092,8 @@ paths:
|
||||
description: Unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
'/events':
|
||||
get:
|
||||
tags:
|
||||
- events
|
||||
summary: List all available retention events
|
||||
description: |
|
||||
Gets the list of events that can be used by retention steps
|
||||
operationId: getAllEvents
|
||||
produces:
|
||||
- application/json
|
||||
parameters:
|
||||
- $ref: '#/parameters/skipCountParam'
|
||||
- $ref: '#/parameters/maxItemsParam'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/EventPaging'
|
||||
'400':
|
||||
description: |
|
||||
Invalid parameter: value of **maxItems** or **skipCount** is invalid
|
||||
'401':
|
||||
description: Authentication failed
|
||||
default:
|
||||
description: Unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
|
||||
post:
|
||||
tags:
|
||||
- events
|
||||
summary: Create a new retention event
|
||||
description: |
|
||||
Creates a new event that can be used by retention schedules.
|
||||
operationId: createEvent
|
||||
parameters:
|
||||
- in: body
|
||||
name: eventBodyCreate
|
||||
description: The new event.
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/EventBody'
|
||||
consumes:
|
||||
- application/json
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
'201':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/EventEntry'
|
||||
'400':
|
||||
description: |
|
||||
Invalid parameter: **name** or **type** is invalid
|
||||
'401':
|
||||
description: Authentication failed
|
||||
'403':
|
||||
description: Current user does not have permission to create event
|
||||
'409':
|
||||
description: Cannot create event. An event with the name **name** already exists
|
||||
default:
|
||||
description: Unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
|
||||
'/events/{eventId}':
|
||||
get:
|
||||
tags:
|
||||
- events
|
||||
summary: Return event for given eventId
|
||||
description: |
|
||||
Gets information about the retention event with id **eventId**.
|
||||
operationId: getEvent
|
||||
produces:
|
||||
- application/json
|
||||
parameters:
|
||||
- $ref: '#/parameters/eventIdParam'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/EventEntry'
|
||||
'400':
|
||||
description: |
|
||||
Invalid parameter: **eventId** is invalid
|
||||
'401':
|
||||
description: Authentication failed
|
||||
'404':
|
||||
description: "**eventId** does not exist"
|
||||
default:
|
||||
description: Unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
put:
|
||||
tags:
|
||||
- events
|
||||
summary: Update event for given eventId
|
||||
operationId: updateEvent
|
||||
description: |
|
||||
Updates retention event with id **eventId**.
|
||||
produces:
|
||||
- application/json
|
||||
parameters:
|
||||
- $ref: '#/parameters/eventIdParam'
|
||||
- in: body
|
||||
name: eventBodyUpdate
|
||||
description: The event information to update.
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/EventBody'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/EventEntry'
|
||||
'400':
|
||||
description: |
|
||||
Invalid parameter: The update request is invalid or **eventId** is not a valid format or **eventBodyUpdate** is invalid
|
||||
'401':
|
||||
description: Authentication failed
|
||||
'403':
|
||||
description: Current user does not have permission to update events
|
||||
'404':
|
||||
description: "**eventId** does not exist"
|
||||
'409':
|
||||
description: Cannot update event. An event with the name **name** already exists
|
||||
default:
|
||||
description: Unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
|
||||
'/event-types':
|
||||
get:
|
||||
tags:
|
||||
- events
|
||||
summary: List all the retention event types
|
||||
description: |
|
||||
Gets a list of all the retention event types.
|
||||
operationId: getAllEventTypes
|
||||
produces:
|
||||
- application/json
|
||||
parameters:
|
||||
- $ref: '#/parameters/skipCountParam'
|
||||
- $ref: '#/parameters/maxItemsParam'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful response
|
||||
schema:
|
||||
$ref: '#/definitions/EventTypePaging'
|
||||
'400':
|
||||
description: |
|
||||
Invalid parameter: value of **maxItems** or **skipCount** is invalid
|
||||
'401':
|
||||
description: Authentication failed
|
||||
default:
|
||||
description: Unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
parameters:
|
||||
## event
|
||||
eventIdParam:
|
||||
name: eventId
|
||||
in: path
|
||||
description: The identifier of an event.
|
||||
required: true
|
||||
type: string
|
||||
## File plans
|
||||
filePlanEntryIncludeParam:
|
||||
name: include
|
||||
@@ -3927,92 +3761,4 @@ definitions:
|
||||
- SiteConsumer
|
||||
- SiteCollaborator
|
||||
- SiteContributor
|
||||
- SiteManager
|
||||
EventPaging:
|
||||
type: object
|
||||
properties:
|
||||
list:
|
||||
type: object
|
||||
properties:
|
||||
pagination:
|
||||
$ref: '#/definitions/Pagination'
|
||||
entries:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/EventEntry'
|
||||
EventEntry:
|
||||
type: object
|
||||
required:
|
||||
- entry
|
||||
properties:
|
||||
entry:
|
||||
$ref: '#/definitions/Event'
|
||||
Event:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- type
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: this is the id of the event
|
||||
name:
|
||||
type: string
|
||||
description: This is the unique display label of the event
|
||||
type:
|
||||
type: string
|
||||
description: this is event type
|
||||
EventBody:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: This is the unique display label of the event
|
||||
type:
|
||||
type: string
|
||||
description: this is event type
|
||||
default: Simple
|
||||
EventTypePaging:
|
||||
type: object
|
||||
properties:
|
||||
list:
|
||||
type: object
|
||||
properties:
|
||||
pagination:
|
||||
$ref: '#/definitions/Pagination'
|
||||
entries:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/EventTypeEntry'
|
||||
EventTypeEntry:
|
||||
type: object
|
||||
required:
|
||||
- entry
|
||||
properties:
|
||||
entry:
|
||||
$ref: '#/definitions/EventType'
|
||||
EventType:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: this is the event type id
|
||||
name:
|
||||
type: string
|
||||
description: this is event type name
|
||||
isAutomatic:
|
||||
type: boolean
|
||||
description: Whether events of this type need completing manually or can be completed automatically
|
||||
default: true
|
||||
associationName:
|
||||
type: string
|
||||
description: The association used to determine whether automatic events of this type are complete
|
||||
actionOnAssociatedNode:
|
||||
type: string
|
||||
description: If an association name is set for this event type then it is possible to require an action to be completed on the associated node
|
||||
- SiteManager
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -22,18 +22,21 @@ package org.alfresco.httpclient;
|
||||
import javax.net.ssl.KeyManager;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.HttpRequestInterceptor;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.config.RegistryBuilder;
|
||||
import org.apache.http.conn.HttpClientConnectionManager;
|
||||
import org.apache.http.conn.socket.ConnectionSocketFactory;
|
||||
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
|
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.client.StandardHttpRequestRetryHandler;
|
||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||
|
||||
|
||||
public class HttpClient4Factory
|
||||
@@ -79,19 +82,19 @@ public class HttpClient4Factory
|
||||
throw new HttpClientException(msg);
|
||||
}
|
||||
});
|
||||
|
||||
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(
|
||||
createSSLContext(config),
|
||||
new String[] { TLS_V_1_2, TLS_V_1_3 },
|
||||
null,
|
||||
config.isHostnameVerificationDisabled() ? new NoopHostnameVerifier() : SSLConnectionSocketFactory.getDefaultHostnameVerifier());
|
||||
clientBuilder.setSSLSocketFactory(sslConnectionSocketFactory);
|
||||
clientBuilder.setSSLSocketFactory(getSslConnectionSocketFactory(config));
|
||||
}
|
||||
|
||||
if(connectionManager != null)
|
||||
if (connectionManager != null)
|
||||
{
|
||||
clientBuilder.setConnectionManager(connectionManager);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Setting a connectionManager overrides these properties
|
||||
clientBuilder.setMaxConnTotal(config.getMaxTotalConnections());
|
||||
clientBuilder.setMaxConnPerRoute(config.getMaxHostConnections());
|
||||
}
|
||||
|
||||
RequestConfig requestConfig = RequestConfig.custom()
|
||||
.setConnectTimeout(config.getConnectionTimeout())
|
||||
@@ -100,11 +103,41 @@ public class HttpClient4Factory
|
||||
.build();
|
||||
|
||||
clientBuilder.setDefaultRequestConfig(requestConfig);
|
||||
clientBuilder.setMaxConnTotal(config.getMaxTotalConnections());
|
||||
clientBuilder.setMaxConnPerRoute(config.getMaxHostConnections());
|
||||
|
||||
clientBuilder.setRetryHandler(new StandardHttpRequestRetryHandler(5, false));
|
||||
|
||||
return clientBuilder.build();
|
||||
}
|
||||
|
||||
private static SSLConnectionSocketFactory getSslConnectionSocketFactory(HttpClientConfig config)
|
||||
{
|
||||
return new SSLConnectionSocketFactory(
|
||||
createSSLContext(config),
|
||||
new String[] { TLS_V_1_2, TLS_V_1_3 },
|
||||
null,
|
||||
config.isHostnameVerificationDisabled() ? new NoopHostnameVerifier() : SSLConnectionSocketFactory.getDefaultHostnameVerifier());
|
||||
}
|
||||
|
||||
public static PoolingHttpClientConnectionManager createPoolingConnectionManager(HttpClientConfig config)
|
||||
{
|
||||
PoolingHttpClientConnectionManager poolingHttpClientConnectionManager;
|
||||
if(config.isMTLSEnabled())
|
||||
{
|
||||
poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager(
|
||||
RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("https", getSslConnectionSocketFactory(config))
|
||||
.build());
|
||||
}
|
||||
else
|
||||
{
|
||||
poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager(
|
||||
RegistryBuilder.<ConnectionSocketFactory>create()
|
||||
.register("http", PlainConnectionSocketFactory.getSocketFactory())
|
||||
.build());
|
||||
}
|
||||
poolingHttpClientConnectionManager.setMaxTotal(config.getMaxTotalConnections());
|
||||
poolingHttpClientConnectionManager.setDefaultMaxPerRoute(config.getMaxHostConnections());
|
||||
|
||||
return poolingHttpClientConnectionManager;
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -9,6 +9,6 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
</project>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -1,3 +1,3 @@
|
||||
SOLR6_TAG=2.0.7-A2
|
||||
SOLR6_TAG=2.0.7-A5
|
||||
POSTGRES_TAG=14.4
|
||||
ACTIVEMQ_TAG=5.17.1-jre11-rockylinux8
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<organization>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -680,17 +680,22 @@ public class RestWrapper extends DSLWrapper<RestWrapper>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (returnedResponse.getContentType().contains("image/png"))
|
||||
{
|
||||
LOG.info("On {} {}, received the response with an image and headers: \n{}", restRequest.getHttpMethod(), restRequest.getPath(),
|
||||
returnedResponse.getHeaders().toString());
|
||||
}
|
||||
else if (returnedResponse.getContentType().contains("application/json") && !returnedResponse.asString().isEmpty())
|
||||
if (returnedResponse.asString().isEmpty())
|
||||
{
|
||||
LOG.info("On {} {}, received the following response \n{}", restRequest.getHttpMethod(), restRequest.getPath(),
|
||||
Utility.prettyPrintJsonString(returnedResponse.asString()));
|
||||
returnedResponse.getStatusCode());
|
||||
}
|
||||
else if (returnedResponse.getContentType().contains("application/xml") && !returnedResponse.asString().isEmpty())
|
||||
else if (returnedResponse.getContentType().contains("image/png"))
|
||||
{
|
||||
LOG.info("On {} {}, received the response with an image and headers: \n{}", restRequest.getHttpMethod(), restRequest.getPath(),
|
||||
returnedResponse.getHeaders().toString());
|
||||
}
|
||||
else if (returnedResponse.getContentType().contains("application/json"))
|
||||
{
|
||||
LOG.info("On {} {}, received the following response \n{}", restRequest.getHttpMethod(), restRequest.getPath(),
|
||||
Utility.prettyPrintJsonString(returnedResponse.asString()));
|
||||
}
|
||||
else if (returnedResponse.getContentType().contains("application/xml"))
|
||||
{
|
||||
String response = parseXML(returnedResponse);
|
||||
LOG.info("On {} {}, received the following response \n{}", restRequest.getHttpMethod(), restRequest.getPath(), response);
|
||||
@@ -698,7 +703,7 @@ public class RestWrapper extends DSLWrapper<RestWrapper>
|
||||
else
|
||||
{
|
||||
LOG.info("On {} {}, received the following response \n{}", restRequest.getHttpMethod(), restRequest.getPath(),
|
||||
ToStringBuilder.reflectionToString(returnedResponse.asString(), ToStringStyle.MULTI_LINE_STYLE));
|
||||
ToStringBuilder.reflectionToString(returnedResponse.asString(), ToStringStyle.MULTI_LINE_STYLE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -52,6 +52,11 @@ This must be unique within the parent category.
|
||||
*/
|
||||
private long count;
|
||||
|
||||
/**
|
||||
The path to this category.
|
||||
*/
|
||||
private String path;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
@@ -102,6 +107,14 @@ This must be unique within the parent category.
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
@@ -126,6 +139,7 @@ This must be unique within the parent category.
|
||||
", parentId='" + parentId + '\'' +
|
||||
", hasChildren=" + hasChildren +
|
||||
", count=" + count +
|
||||
", path=" + path +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
@@ -60,7 +60,7 @@ public class RestErrorModel
|
||||
public static String INVALID_MAXITEMS = "Invalid paging parameter maxItems:%s";
|
||||
public static String INVALID_SKIPCOUNT = "Invalid paging parameter skipCount:%s";
|
||||
public static String INVALID_TAG = "Tag name must not contain %s char sequence";
|
||||
public static String EMPTY_TAG = "New tag cannot be null";
|
||||
public static String BLANK_TAG = "New tag cannot be blank";
|
||||
public static String UNKNOWN_ROLE = "Unknown role '%s'";
|
||||
public static String ALREADY_Site_MEMBER = "%s is already a member of site %s";
|
||||
public static String ALREADY_INVITED = "%s is already invited to site %s";
|
||||
|
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Remote API
|
||||
* %%
|
||||
* 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.categories;
|
||||
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.model.RestCategoryLinkBodyModel;
|
||||
import org.alfresco.rest.model.RestCategoryModel;
|
||||
import org.alfresco.rest.model.RestCategoryModelsCollection;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class CategoriesPathTests extends CategoriesRestTest
|
||||
{
|
||||
private FileModel file;
|
||||
private RestCategoryModel category;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
@Override
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
STEP("Create user and site");
|
||||
user = dataUser.createRandomTestUser();
|
||||
SiteModel site = dataSite.usingUser(user).createPublicRandomSite();
|
||||
|
||||
STEP("Create a folder, file in it and a category");
|
||||
FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
file = dataContent.usingUser(user).usingResource(folder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
category = prepareCategoryUnderRoot();
|
||||
|
||||
STEP("Wait for indexing to complete");
|
||||
Utility.sleep(1000, 60000, () -> restClient.authenticateUser(user)
|
||||
.withCoreAPI()
|
||||
.usingCategory(category)
|
||||
.include(INCLUDE_PATH_PARAM)
|
||||
.getCategory()
|
||||
.assertThat()
|
||||
.field(FIELD_PATH)
|
||||
.isNotNull());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify path for a category got by ID.
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API })
|
||||
public void testGetCategoryById_includePath()
|
||||
{
|
||||
STEP("Get category and verify if path is a general path for categories");
|
||||
final RestCategoryModel actualCategory = restClient.authenticateUser(user)
|
||||
.withCoreAPI()
|
||||
.usingCategory(category)
|
||||
.include(INCLUDE_PATH_PARAM)
|
||||
.getCategory();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
actualCategory.assertThat().field(FIELD_ID).is(category.getId());
|
||||
actualCategory.assertThat().field(FIELD_PATH).is("/categories/General");
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify path for category.
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API })
|
||||
public void testGetCategories_includePath()
|
||||
{
|
||||
STEP("Get few categories and verify its paths");
|
||||
final RestCategoryModel parentCategory = createCategoryModelWithId(ROOT_CATEGORY_ID);
|
||||
final RestCategoryModelsCollection actualCategories = restClient.authenticateUser(user)
|
||||
.withCoreAPI()
|
||||
.usingCategory(parentCategory)
|
||||
.include(INCLUDE_PATH_PARAM)
|
||||
.getCategoryChildren();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
assertTrue(actualCategories.getEntries().stream()
|
||||
.map(RestCategoryModel::onModel)
|
||||
.allMatch(cat -> cat.getPath().equals("/categories/General")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify path for child category.
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API })
|
||||
public void testGetChildCategory_includePath()
|
||||
{
|
||||
STEP("Create parent and child categories");
|
||||
final RestCategoryModel parentCategory = prepareCategoryUnderRoot();
|
||||
final RestCategoryModel childCategory = prepareCategoryUnder(parentCategory);
|
||||
|
||||
STEP("Verify path for created child categories");
|
||||
final RestCategoryModelsCollection actualCategories = restClient.authenticateUser(user)
|
||||
.withCoreAPI()
|
||||
.usingCategory(parentCategory)
|
||||
.include(INCLUDE_PATH_PARAM)
|
||||
.getCategoryChildren();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
actualCategories.getEntries().stream()
|
||||
.map(RestCategoryModel::onModel)
|
||||
.forEach(cat -> cat.assertThat().field(FIELD_PATH).is("/categories/General/" + parentCategory.getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create category and verify that it has a path.
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API })
|
||||
public void testCreateCategory_includingPath()
|
||||
{
|
||||
STEP("Create a category under root and verify if path is a general path for categories");
|
||||
final String categoryName = getRandomName("Category");
|
||||
final RestCategoryModel rootCategory = createCategoryModelWithId(ROOT_CATEGORY_ID);
|
||||
final RestCategoryModel aCategory = createCategoryModelWithName(categoryName);
|
||||
final RestCategoryModel createdCategory = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.include(INCLUDE_PATH_PARAM)
|
||||
.usingCategory(rootCategory)
|
||||
.createSingleCategory(aCategory);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
createdCategory.assertThat().field(FIELD_NAME).is(categoryName);
|
||||
createdCategory.assertThat().field(FIELD_PATH).is("/categories/General");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update category and verify that it has a path.
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API })
|
||||
public void testUpdateCategory_includePath()
|
||||
{
|
||||
STEP("Update linked category and verify if path is a general path for categories");
|
||||
final String categoryNewName = getRandomName("NewCategoryName");
|
||||
final RestCategoryModel fixedCategoryModel = createCategoryModelWithName(categoryNewName);
|
||||
final RestCategoryModel updatedCategory = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingCategory(category)
|
||||
.include(INCLUDE_PATH_PARAM)
|
||||
.updateCategory(fixedCategoryModel);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
updatedCategory.assertThat().field(FIELD_ID).is(category.getId());
|
||||
updatedCategory.assertThat().field(FIELD_PATH).is("/categories/General");
|
||||
}
|
||||
|
||||
/**
|
||||
* Link node to categories and verify that they have path.
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API })
|
||||
public void testLinkNodeToCategories_includePath()
|
||||
{
|
||||
STEP("Link node to categories and verify if path is a general path");
|
||||
final RestCategoryLinkBodyModel categoryLinkModel = createCategoryLinkModelWithId(category.getId());
|
||||
final RestCategoryModel linkedCategory = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingNode(file)
|
||||
.include(INCLUDE_PATH_PARAM)
|
||||
.linkToCategory(categoryLinkModel);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
linkedCategory.assertThat().field(FIELD_ID).is(category.getId());
|
||||
linkedCategory.assertThat().field(FIELD_PATH).is("/categories/General");
|
||||
}
|
||||
|
||||
/**
|
||||
* List categories for given node and verify that they have a path.
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API })
|
||||
public void testListCategoriesForNode_includePath()
|
||||
{
|
||||
STEP("Link file to category");
|
||||
final RestCategoryLinkBodyModel categoryLink = createCategoryLinkModelWithId(category.getId());
|
||||
final RestCategoryModel linkedCategory = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingNode(file)
|
||||
.include(INCLUDE_PATH_PARAM)
|
||||
.linkToCategory(categoryLink);
|
||||
|
||||
STEP("Get linked category and verify if path is a general path");
|
||||
final RestCategoryModelsCollection linkedCategories = restClient.authenticateUser(dataUser.getAdminUser())
|
||||
.withCoreAPI()
|
||||
.usingNode(file)
|
||||
.include(INCLUDE_PATH_PARAM)
|
||||
.getLinkedCategories();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
linkedCategories.assertThat().entriesListCountIs(1);
|
||||
linkedCategories.getEntries().get(0).onModel().assertThat().field(FIELD_ID).is(category.getId());
|
||||
linkedCategories.getEntries().get(0).onModel().assertThat().field(FIELD_PATH).is("/categories/General");
|
||||
}
|
||||
}
|
@@ -46,6 +46,7 @@ import org.testng.annotations.BeforeClass;
|
||||
abstract class CategoriesRestTest extends RestTest
|
||||
{
|
||||
protected static final String INCLUDE_COUNT_PARAM = "count";
|
||||
protected static final String INCLUDE_PATH_PARAM = "path";
|
||||
protected static final String ROOT_CATEGORY_ID = "-root-";
|
||||
protected static final String CATEGORY_NAME_PREFIX = "CategoryName";
|
||||
protected static final String FIELD_NAME = "name";
|
||||
@@ -53,6 +54,7 @@ abstract class CategoriesRestTest extends RestTest
|
||||
protected static final String FIELD_PARENT_ID = "parentId";
|
||||
protected static final String FIELD_HAS_CHILDREN = "hasChildren";
|
||||
protected static final String FIELD_COUNT = "count";
|
||||
protected static final String FIELD_PATH = "path";
|
||||
|
||||
protected UserModel user;
|
||||
|
||||
|
@@ -26,7 +26,7 @@ public class GetTagTests extends TagsDataPrep
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsAbleToGetTag() throws Exception
|
||||
public void adminIsAbleToGetTag()
|
||||
{
|
||||
RestTagModel returnedTag = restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(documentTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
@@ -35,7 +35,7 @@ public class GetTagTests extends TagsDataPrep
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void userWithManagerRoleIsAbleToGetTag() throws Exception
|
||||
public void userWithManagerRoleIsAbleToGetTag()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
|
||||
@@ -47,7 +47,7 @@ public class GetTagTests extends TagsDataPrep
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void userWithCollaboratorRoleIsAbleToGetTag() throws Exception
|
||||
public void userWithCollaboratorRoleIsAbleToGetTag()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag);
|
||||
@@ -57,7 +57,7 @@ public class GetTagTests extends TagsDataPrep
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void userWithContributorRoleIsAbleToGetTag() throws Exception
|
||||
public void userWithContributorRoleIsAbleToGetTag()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag);
|
||||
@@ -67,7 +67,7 @@ public class GetTagTests extends TagsDataPrep
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void userWithConsumerRoleIsAbleToGetTag() throws Exception
|
||||
public void userWithConsumerRoleIsAbleToGetTag()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
RestTagModel returnedTag = restClient.withCoreAPI().getTag(documentTag);
|
||||
@@ -78,7 +78,7 @@ public class GetTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void managerIsNotAbleToGetTagIfAuthenticationFails() throws Exception
|
||||
public void managerIsNotAbleToGetTagIfAuthenticationFails()
|
||||
{
|
||||
UserModel managerUser = dataUser.usingAdmin().createRandomTestUser();
|
||||
String managerPassword = managerUser.getPassword();
|
||||
@@ -92,7 +92,7 @@ public class GetTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if tag id is invalid status code returned is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void invalidTagIdTest() throws Exception
|
||||
public void invalidTagIdTest()
|
||||
{
|
||||
String tagId = documentTag.getId();
|
||||
documentTag.setId("random_tag_value");
|
||||
@@ -104,7 +104,7 @@ public class GetTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Check that properties filter is applied when getting tag using Manager user.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void checkPropertiesFilterIsApplied() throws Exception
|
||||
public void checkPropertiesFilterIsApplied()
|
||||
{
|
||||
RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("properties=id,tag").withCoreAPI().getTag(documentTag);
|
||||
@@ -117,7 +117,7 @@ public class GetTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Check that Manager user can get tag of a folder.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagOfAFolder() throws Exception
|
||||
public void getTagOfAFolder()
|
||||
{
|
||||
RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().getTag(folderTag);
|
||||
@@ -128,7 +128,7 @@ public class GetTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Check default error model schema. Use invalid skipCount parameter.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void checkDefaultErrorModelSchema() throws Exception
|
||||
public void checkDefaultErrorModelSchema()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("skipCount=abc").withCoreAPI().getTag(documentTag);
|
||||
@@ -140,13 +140,14 @@ public class GetTagTests extends TagsDataPrep
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that count field is not present for searched tag.
|
||||
* Verify that count field is not present for searched tag when not requested.
|
||||
*/
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void testGetTag_notIncludingCount()
|
||||
{
|
||||
STEP("Create single tag as admin");
|
||||
final RestTagModel tagModel = createTagModelWithName(getRandomName(TAG_NAME_PREFIX).toLowerCase());
|
||||
String tagName = getRandomName(TAG_NAME_PREFIX).toLowerCase();
|
||||
final RestTagModel tagModel = createTagModelWithName(tagName);
|
||||
final RestTagModel createdTag = restClient.authenticateUser(adminUserModel).withCoreAPI().createSingleTag(tagModel);
|
||||
|
||||
restClient.assertStatusCodeIs(CREATED);
|
||||
@@ -155,8 +156,26 @@ public class GetTagTests extends TagsDataPrep
|
||||
final RestTagModel searchedTag = restClient.withCoreAPI().getTag(createdTag);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
searchedTag.assertThat().field(FIELD_TAG).is(tagModel.getTag())
|
||||
.assertThat().field(FIELD_ID).isNotEmpty()
|
||||
.assertThat().field(FIELD_COUNT).isNull();
|
||||
RestTagModel expected = RestTagModel.builder().id(createdTag.getId()).tag(tagName).create();
|
||||
searchedTag.assertThat().isEqualTo(expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the count field can be included.
|
||||
*/
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void testGetTag_includeCount()
|
||||
{
|
||||
STEP("Create unused tag as admin");
|
||||
String tagName = getRandomName(TAG_NAME_PREFIX).toLowerCase();
|
||||
RestTagModel tagModel = createTagModelWithName(tagName);
|
||||
RestTagModel createdTag = restClient.authenticateUser(adminUserModel).withCoreAPI().createSingleTag(tagModel);
|
||||
|
||||
STEP("Get a single tag with the count field");
|
||||
RestTagModel searchedTag = restClient.withCoreAPI().include("count").getTag(createdTag);
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
RestTagModel expected = RestTagModel.builder().id(createdTag.getId()).tag(tagName).count(0).create();
|
||||
searchedTag.assertThat().isEqualTo(expected);
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package org.alfresco.rest.tags;
|
||||
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -16,6 +17,11 @@ import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
@Test(groups = {TestGroup.REQUIRE_SOLR})
|
||||
public class GetTagsTests extends TagsDataPrep
|
||||
{
|
||||
@@ -32,8 +38,8 @@ public class GetTagsTests extends TagsDataPrep
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", documentTagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", documentTagValue2.toLowerCase());
|
||||
.and().entriesListContains("tag", documentTagValue)
|
||||
.and().entriesListContains("tag", documentTagValue2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)")
|
||||
@@ -44,8 +50,8 @@ public class GetTagsTests extends TagsDataPrep
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", documentTagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", documentTagValue2.toLowerCase());
|
||||
.and().entriesListContains("tag", documentTagValue)
|
||||
.and().entriesListContains("tag", documentTagValue2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)")
|
||||
@@ -56,8 +62,8 @@ public class GetTagsTests extends TagsDataPrep
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", documentTagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", documentTagValue2.toLowerCase());
|
||||
.and().entriesListContains("tag", documentTagValue)
|
||||
.and().entriesListContains("tag", documentTagValue2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)")
|
||||
@@ -68,8 +74,140 @@ public class GetTagsTests extends TagsDataPrep
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", documentTagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", documentTagValue2.toLowerCase());
|
||||
.and().entriesListContains("tag", documentTagValue)
|
||||
.and().entriesListContains("tag", documentTagValue2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Include count in the query parameters and ensure count is as expected for returned tags.
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void testGetTags_withIncludeCount()
|
||||
{
|
||||
STEP("Get tags including count filter and ensure count is as expected for returned tags");
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("include=count")
|
||||
.withCoreAPI()
|
||||
.getTags();
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
|
||||
returnedCollection.getEntries().stream()
|
||||
.filter(e -> e.onModel().getTag().equals(folderTagValue) || e.onModel().getTag().equals(documentTagValue))
|
||||
.forEach(e -> e.onModel().assertThat().field("count").is(2));
|
||||
|
||||
returnedCollection.getEntries().stream()
|
||||
.filter(e -> e.onModel().getTag().equals(documentTagValue2))
|
||||
.forEach(e -> e.onModel().assertThat().field("count").is(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tags and order results by count. Default sort order should be ascending
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void testGetTags_withOrderByCountDefaultOrderShouldBeAsc()
|
||||
{
|
||||
STEP("Get tags and order results by count. Default sort order should be ascending");
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("include=count&orderBy=count")
|
||||
.withCoreAPI()
|
||||
.getTags();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
returnedCollection.assertThat().entriesListIsSortedAscBy("count");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tags and order results by count in ascending order
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void testGetTags_withOrderByCountAsc()
|
||||
{
|
||||
STEP("Get tags and order results by count in ascending order");
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("include=count&orderBy=count ASC")
|
||||
.withCoreAPI()
|
||||
.getTags();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
returnedCollection.assertThat().entriesListIsSortedAscBy("count");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tags and order results by count in descending order
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void testGetTags_withOrderByCountDesc()
|
||||
{
|
||||
STEP("Get tags and order results by count in descending order");
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("include=count&orderBy=count DESC")
|
||||
.withCoreAPI()
|
||||
.getTags();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
returnedCollection.assertThat().entriesListIsSortedDescBy("count");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tags and order results by tag name. Default sort order should be ascending
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void testGetTags_withOrderByTagDefaultOrderShouldBeAsc()
|
||||
{
|
||||
STEP("Get tags and order results by tag name. Default sort order should be ascending");
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("orderBy=tag")
|
||||
.withCoreAPI()
|
||||
.getTags();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
returnedCollection.assertThat().entriesListIsSortedAscBy("tag");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tags and order results by tag name in ascending order
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void testGetTags_withOrderByTagAsc()
|
||||
{
|
||||
STEP("Get tags and order results by tag name in ascending order");
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("orderBy=tag ASC")
|
||||
.withCoreAPI()
|
||||
.getTags();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
returnedCollection.assertThat().entriesListIsSortedAscBy("tag");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tags and order results by tag name in descending order
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void testGetTags_withOrderByTagDesc()
|
||||
{
|
||||
STEP("Get tags and order results by tag name in descending order");
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("orderBy=tag DESC")
|
||||
.withCoreAPI()
|
||||
.getTags();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
returnedCollection.assertThat().entriesListIsSortedDescBy("tag");
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that we get a 400 error when we request to order by count without also including the tag count.
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void testGetTags_orderByCountWithoutIncludeCount()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.withParams("orderBy=count")
|
||||
.withCoreAPI()
|
||||
.getTags();
|
||||
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role")
|
||||
@@ -113,8 +251,8 @@ public class GetTagsTests extends TagsDataPrep
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", documentTagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", documentTagValue2.toLowerCase());
|
||||
.and().entriesListContains("tag", documentTagValue)
|
||||
.and().entriesListContains("tag", documentTagValue2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
@@ -126,7 +264,7 @@ public class GetTagsTests extends TagsDataPrep
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", folderTagValue.toLowerCase());
|
||||
.and().entriesListContains("tag", folderTagValue);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
@@ -139,8 +277,8 @@ public class GetTagsTests extends TagsDataPrep
|
||||
.withParams("maxItems=5000&properties=tag").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", documentTagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", documentTagValue2.toLowerCase())
|
||||
.and().entriesListContains("tag", documentTagValue)
|
||||
.and().entriesListContains("tag", documentTagValue2)
|
||||
.and().entriesListDoesNotContain("id");
|
||||
}
|
||||
|
||||
@@ -193,8 +331,7 @@ public class GetTagsTests extends TagsDataPrep
|
||||
.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("count").is("0")
|
||||
.and().field("skipCount").is(20000)
|
||||
.and().field("totalItems").is(0);
|
||||
.and().field("skipCount").is(20000);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
@@ -226,7 +363,7 @@ public class GetTagsTests extends TagsDataPrep
|
||||
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListDoesNotContain("tag", removedTag.toLowerCase());
|
||||
.and().entriesListDoesNotContain("tag", removedTag);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,7 +380,7 @@ public class GetTagsTests extends TagsDataPrep
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entrySetMatches("tag", Set.of(documentTagValue.toLowerCase()));
|
||||
.entrySetMatches("tag", Set.of(documentTagValue));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,7 +397,7 @@ public class GetTagsTests extends TagsDataPrep
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entrySetMatches("tag", Set.of(documentTagValue.toLowerCase(), folderTagValue.toLowerCase()));
|
||||
.entrySetMatches("tag", Set.of(documentTagValue, folderTagValue));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,13 +408,13 @@ public class GetTagsTests extends TagsDataPrep
|
||||
{
|
||||
STEP("Get tags with names filter using MATCHES and expect one item in result");
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("where=(tag MATCHES ('orphan*'))")
|
||||
.withCoreAPI()
|
||||
.getTags();
|
||||
.withParams("where=(tag MATCHES ('orphan*'))", "maxItems=10000")
|
||||
.withCoreAPI()
|
||||
.getTags();
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entrySetContains("tag", orphanTag.getTag().toLowerCase());
|
||||
.entrySetContains("tag", orphanTag.getTag());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,13 +425,13 @@ public class GetTagsTests extends TagsDataPrep
|
||||
{
|
||||
STEP("Get tags with names filter using EQUALS and MATCHES and expect four items in result");
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("where=(tag='" + orphanTag.getTag() + "' OR tag MATCHES ('*tag*'))")
|
||||
.withParams("where=(tag MATCHES ('*tag*'))", "maxItems=10000")
|
||||
.withCoreAPI()
|
||||
.getTags();
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entrySetContains("tag", documentTagValue.toLowerCase(), documentTagValue2.toLowerCase(), folderTagValue.toLowerCase(), orphanTag.getTag().toLowerCase());
|
||||
.entrySetContains("tag", documentTagValue, documentTagValue2, folderTagValue, orphanTag.getTag());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -305,17 +442,17 @@ public class GetTagsTests extends TagsDataPrep
|
||||
{
|
||||
STEP("Get tags applying names filter using MATCHES twice and expect four items in result");
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("where=(tag MATCHES ('orphan*') OR tag MATCHES ('tag*'))")
|
||||
.withParams("where=(tag MATCHES ('orphan*') OR tag MATCHES ('tag*'))", "maxItems=10000")
|
||||
.withCoreAPI()
|
||||
.getTags();
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entrySetContains("tag", documentTagValue.toLowerCase(), documentTagValue2.toLowerCase(), folderTagValue.toLowerCase(), orphanTag.getTag().toLowerCase());
|
||||
.entrySetContains("tag", documentTagValue, documentTagValue2, folderTagValue, orphanTag.getTag());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that providing incorrect field name in where query will result with 400 (Bad Request).
|
||||
* Verify that providing incorrect field name in where query will result with 400 (Bad Request).
|
||||
*/
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void testGetTags_withWrongWherePropertyNameAndExpect400()
|
||||
|
@@ -22,7 +22,8 @@ public class TagsDataPrep extends RestTest
|
||||
protected static ListUserWithRoles usersWithRoles;
|
||||
protected static SiteModel siteModel;
|
||||
protected static FileModel document;
|
||||
protected static FolderModel folder;
|
||||
protected static FolderModel folder, folder2;
|
||||
protected static RestTagModelsCollection folder2tags;
|
||||
protected static String documentTagValue, documentTagValue2, folderTagValue;
|
||||
protected static RestTagModel documentTag, documentTag2, folderTag, orphanTag, returnedModel;
|
||||
protected static RestTagModelsCollection returnedCollection;
|
||||
@@ -38,25 +39,28 @@ public class TagsDataPrep extends RestTest
|
||||
usersWithRoles = dataUser.usingAdmin().addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
folder2 = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
documentTagValue = RandomData.getRandomName("tag");
|
||||
documentTagValue2 = RandomData.getRandomName("tag");
|
||||
folderTagValue = RandomData.getRandomName("tag");
|
||||
documentTagValue = RandomData.getRandomName("tag").toLowerCase();
|
||||
documentTagValue2 = RandomData.getRandomName("tag").toLowerCase();
|
||||
folderTagValue = RandomData.getRandomName("tag").toLowerCase();
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
documentTag = restClient.withCoreAPI().usingResource(document).addTag(documentTagValue);
|
||||
documentTag2 = restClient.withCoreAPI().usingResource(document).addTag(documentTagValue2);
|
||||
folderTag = restClient.withCoreAPI().usingResource(folder).addTag(folderTagValue);
|
||||
orphanTag = restClient.withCoreAPI().createSingleTag(RestTagModel.builder().tag(RandomData.getRandomName("orphan-tag")).create());
|
||||
orphanTag = restClient.withCoreAPI().createSingleTag(RestTagModel.builder().tag(RandomData.getRandomName("orphan-tag").toLowerCase()).create());
|
||||
folder2tags = restClient.withCoreAPI().usingResource(folder2).addTags(folderTagValue, documentTagValue);
|
||||
|
||||
// Allow indexing to complete.
|
||||
Utility.sleep(500, 60000, () ->
|
||||
{
|
||||
returnedCollection = restClient.withParams("maxItems=10000", "where=(tag MATCHES ('*tag*'))")
|
||||
.withCoreAPI().getTags();
|
||||
returnedCollection.assertThat().entriesListContains("tag", documentTagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", documentTagValue2.toLowerCase())
|
||||
.and().entriesListContains("tag", folderTagValue.toLowerCase());
|
||||
.withCoreAPI().getTags();
|
||||
returnedCollection.assertThat().entriesListContains("tag", documentTagValue)
|
||||
.and().entriesListContains("tag", documentTagValue2)
|
||||
.and().entriesListContains("tag", folderTagValue)
|
||||
.and().entriesListContains("tag", orphanTag.getTag());
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package org.alfresco.rest.tags;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
@@ -15,6 +16,7 @@ import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Ignore;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
@@ -27,17 +29,17 @@ public class UpdateTagTests extends TagsDataPrep
|
||||
private String randomTag = "";
|
||||
|
||||
@BeforeMethod(alwaysRun=true)
|
||||
public void addTagToDocument() throws Exception
|
||||
public void addTagToDocument()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old"));
|
||||
randomTag = RandomData.getRandomName("tag");
|
||||
oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old").toLowerCase());
|
||||
randomTag = RandomData.getRandomName("tag").toLowerCase();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200")
|
||||
@Bug(id="REPO-1828")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void adminIsAbleToUpdateTags() throws Exception
|
||||
public void adminIsAbleToUpdateTags()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
@@ -49,7 +51,7 @@ public class UpdateTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void managerIsNotAbleToUpdateTag() throws Exception
|
||||
public void managerIsNotAbleToUpdateTag()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
@@ -59,7 +61,7 @@ public class UpdateTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws Exception
|
||||
public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
@@ -72,7 +74,7 @@ public class UpdateTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Contributor user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsNotAbleToUpdateTag() throws Exception
|
||||
public void contributorIsNotAbleToUpdateTag()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
@@ -82,7 +84,7 @@ public class UpdateTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify Consumer user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void consumerIsNotAbleToUpdateTag() throws Exception
|
||||
public void consumerIsNotAbleToUpdateTag()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
@@ -93,7 +95,7 @@ public class UpdateTagTests extends TagsDataPrep
|
||||
executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToUpdateTagIfAuthenticationFails() throws Exception
|
||||
public void userIsNotAbleToUpdateTagIfAuthenticationFails()
|
||||
{
|
||||
UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager);
|
||||
String managerPassword = siteManager.getPassword();
|
||||
@@ -106,76 +108,93 @@ public class UpdateTagTests extends TagsDataPrep
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with invalid id")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsNotAbleToUpdateTagWithInvalidId() throws Exception
|
||||
public void adminIsNotAbleToUpdateTagWithInvalidId()
|
||||
{
|
||||
String invalidTagId = "invalid-id";
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag").toLowerCase());
|
||||
tag.setId(invalidTagId);
|
||||
restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag"));
|
||||
restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag").toLowerCase());
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidTagId));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with empty id")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsNotAbleToUpdateTagWithEmptyId() throws Exception
|
||||
public void adminIsNotAbleToUpdateTagWithEmptyId()
|
||||
{
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag").toLowerCase());
|
||||
tag.setId("");
|
||||
restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag"));
|
||||
restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag").toLowerCase());
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED)
|
||||
.assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with invalid body")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsNotAbleToUpdateTagWithEmptyBody() throws Exception
|
||||
public void adminIsNotAbleToUpdateTagWithEmptyBody()
|
||||
{
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag").toLowerCase());
|
||||
restClient.withCoreAPI().usingTag(tag).update("");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(RestErrorModel.EMPTY_TAG);
|
||||
.assertLastError().containsSummary(RestErrorModel.BLANK_TAG);
|
||||
}
|
||||
|
||||
@Bug(id="ACE-5629")
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin is not able to update tag with invalid body containing '|' symbol")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario1() throws Exception
|
||||
@Ignore
|
||||
public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario1()
|
||||
{
|
||||
String invalidTagBody = "|.\"/<>*";
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
Utility.sleep(500, 20000, () ->
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag").toLowerCase());
|
||||
try
|
||||
{
|
||||
restClient.withCoreAPI().usingTag(tag).update(invalidTagBody);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody));
|
||||
});
|
||||
Utility.sleep(500, 20000, () ->
|
||||
{
|
||||
restClient.withCoreAPI().usingTag(tag).update(invalidTagBody);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody));
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("Test interrupted while waiting for error status code.");
|
||||
}
|
||||
}
|
||||
|
||||
@Bug(id="ACE-5629")
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin is not able to update tag with invalid body without '|' symbol")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario2() throws Exception
|
||||
@Ignore
|
||||
public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario2()
|
||||
{
|
||||
String invalidTagBody = ".\"/<>*";
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
Utility.sleep(500, 20000, () ->
|
||||
try
|
||||
{
|
||||
restClient.withCoreAPI().usingTag(tag).update(invalidTagBody);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
Utility.sleep(500, 20000, () ->
|
||||
{
|
||||
restClient.withCoreAPI().usingTag(tag).update(invalidTagBody);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody));
|
||||
});
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
fail("Test interrupted while waiting for error status code.");
|
||||
}
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin user can provide large string for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminIsAbleToUpdateTagsProvideLargeStringTag() throws Exception
|
||||
@Ignore
|
||||
public void adminIsAbleToUpdateTagsProvideLargeStringTag()
|
||||
{
|
||||
String largeStringTag = RandomStringUtils.randomAlphanumeric(10000);
|
||||
String largeStringTag = RandomStringUtils.randomAlphanumeric(10000).toLowerCase();
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(largeStringTag);
|
||||
@@ -188,9 +207,9 @@ public class UpdateTagTests extends TagsDataPrep
|
||||
description = "Verify admin user can provide short string for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminIsAbleToUpdateTagsProvideShortStringTag() throws Exception
|
||||
public void adminIsAbleToUpdateTagsProvideShortStringTag()
|
||||
{
|
||||
String shortStringTag = RandomStringUtils.randomAlphanumeric(2);
|
||||
String shortStringTag = RandomStringUtils.randomAlphanumeric(2).toLowerCase();
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(shortStringTag);
|
||||
@@ -203,9 +222,10 @@ public class UpdateTagTests extends TagsDataPrep
|
||||
description = "Verify admin user can provide string with special chars for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminIsAbleToUpdateTagsProvideSpecialCharsStringTag() throws Exception
|
||||
@Ignore
|
||||
public void adminIsAbleToUpdateTagsProvideSpecialCharsStringTag()
|
||||
{
|
||||
String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\";
|
||||
String specialCharsString = RandomData.getRandomName("!@#$%^&*()'\".,<>-_+=|\\").toLowerCase();
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(specialCharsString);
|
||||
@@ -218,9 +238,10 @@ public class UpdateTagTests extends TagsDataPrep
|
||||
description = "Verify Admin user can provide existing tag for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminIsAbleToUpdateTagsProvideExistingTag() throws Exception
|
||||
@Ignore
|
||||
public void adminIsAbleToUpdateTagsProvideExistingTag()
|
||||
{
|
||||
String existingTag = "oldTag";
|
||||
String existingTag = RandomData.getRandomName("oldTag").toLowerCase();
|
||||
RestTagModel oldExistingTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).addTag(existingTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
@@ -236,13 +257,14 @@ public class UpdateTagTests extends TagsDataPrep
|
||||
description = "Verify Admin user can delete a tag, add tag and update it.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminDeleteTagAddTagUpdateTag() throws Exception
|
||||
@Ignore
|
||||
public void adminDeleteTagAddTagUpdateTag()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).deleteTag(oldTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
String newTag = "addTag";
|
||||
String newTag = RandomData.getRandomName("addTag").toLowerCase();
|
||||
RestTagModel newTagModel = restClient.withCoreAPI().usingResource(document).addTag(newTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
@@ -256,9 +278,10 @@ public class UpdateTagTests extends TagsDataPrep
|
||||
description = "Verify Admin user can update a tag, delete tag and add it.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminUpdateTagDeleteTagAddTag() throws Exception
|
||||
@Ignore
|
||||
public void adminUpdateTagDeleteTagAddTag()
|
||||
{
|
||||
String newTag = "addTag";
|
||||
String newTag = RandomData.getRandomName("addTag").toLowerCase();
|
||||
|
||||
returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTag(oldTag).update(newTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
@@ -278,11 +301,28 @@ public class UpdateTagTests extends TagsDataPrep
|
||||
public void adminIsAbleToUpdateOrphanTag()
|
||||
{
|
||||
STEP("Update orphan tag and expect 200");
|
||||
final String newTagName = RandomData.getRandomName("new");
|
||||
final String newTagName = RandomData.getRandomName("new").toLowerCase();
|
||||
returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTag(orphanTag).update(newTagName);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(newTagName);
|
||||
returnedModel.assertThat().field("id").isNotNull();
|
||||
RestTagModel expected = RestTagModel.builder().id(orphanTag.getId()).tag(newTagName).create();
|
||||
returnedModel.assertThat().isEqualTo(expected);
|
||||
}
|
||||
}
|
||||
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.TAGS })
|
||||
public void canUpdateTagAndGetCount()
|
||||
{
|
||||
STEP("Create an orphaned tag");
|
||||
String tagName = RandomData.getRandomName("tag").toLowerCase();
|
||||
RestTagModel createdTag = RestTagModel.builder().tag(tagName).create();
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().createSingleTag(createdTag);
|
||||
|
||||
STEP("Update tag and request the count field");
|
||||
String newTagName = RandomData.getRandomName("new").toLowerCase();
|
||||
returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().include("count").usingTag(tag).update(newTagName);
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
RestTagModel expected = RestTagModel.builder().id(tag.getId()).tag(newTagName).count(0).create();
|
||||
returnedModel.assertThat().isEqualTo(expected);
|
||||
}
|
||||
}
|
||||
|
@@ -33,13 +33,13 @@ public class AddTagTests extends TagsDataPrep
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void generateRandomTag()
|
||||
{
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
tagValue = RandomData.getRandomName("tag").toLowerCase();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin user adds tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsAbleToAddTag() throws Exception
|
||||
public void adminIsAbleToAddTag()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
@@ -51,7 +51,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify Manager user adds tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToTagAFile() throws Exception
|
||||
public void managerIsAbleToTagAFile()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
@@ -63,7 +63,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Collaborator user adds tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorIsAbleToTagAFile() throws Exception
|
||||
public void collaboratorIsAbleToTagAFile()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
@@ -75,7 +75,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsNotAbleToAddTagToAnotherContent() throws Exception
|
||||
public void contributorIsNotAbleToAddTagToAnotherContent()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
@@ -85,7 +85,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user adds tags to his content with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsAbleToAddTagToHisContent() throws Exception
|
||||
public void contributorIsAbleToAddTagToHisContent()
|
||||
{
|
||||
userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor);
|
||||
restClient.authenticateUser(userModel);
|
||||
@@ -99,7 +99,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void consumerIsNotAbleToTagAFile() throws Exception
|
||||
public void consumerIsNotAbleToTagAFile()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
@@ -110,7 +110,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
description = "Verify user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToAddTagIfAuthenticationFails() throws Exception
|
||||
public void userIsNotAbleToAddTagIfAuthenticationFails()
|
||||
{
|
||||
UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager);
|
||||
String managerPassword = siteManager.getPassword();
|
||||
@@ -124,7 +124,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding empty tag returns status code 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void emptyTagTest() throws Exception
|
||||
public void emptyTagTest()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag("");
|
||||
@@ -134,7 +134,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding tag with user that has no permissions returns status code 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagWithUserThatDoesNotHavePermissions() throws Exception
|
||||
public void addTagWithUserThatDoesNotHavePermissions()
|
||||
{
|
||||
restClient.authenticateUser(dataUser.createRandomTestUser());
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
@@ -144,7 +144,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding tag to a node that does not exist returns status code 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagToInexistentNode() throws Exception
|
||||
public void addTagToInexistentNode()
|
||||
{
|
||||
String oldNodeRef = document.getNodeRef();
|
||||
String nodeRef = RandomStringUtils.randomAlphanumeric(10);
|
||||
@@ -159,7 +159,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify that manager is able to tag a folder")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToTagAFolder() throws Exception
|
||||
public void managerIsAbleToTagAFolder()
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
@@ -171,7 +171,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that tagged file can be tagged again")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagToATaggedFile() throws Exception
|
||||
public void addTagToATaggedFile()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
|
||||
@@ -195,7 +195,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that user cannot add invalid tag")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addInvalidTag() throws Exception
|
||||
public void addInvalidTag()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag("-1~!|@#$%^&*()_=");
|
||||
@@ -205,7 +205,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that contributor is able to tag a folder created by self")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsAbleToTagAFolderCreatedBySelf() throws Exception
|
||||
public void contributorIsAbleToTagAFolderCreatedBySelf()
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(siteModel).createFolder();
|
||||
|
||||
@@ -218,7 +218,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that collaborator is able to tag a folder")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorIsAbleToTagAFolder() throws Exception
|
||||
public void collaboratorIsAbleToTagAFolder()
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
@@ -231,7 +231,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that consumer is not able to tag a folder. Check default error model schema.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void consumerIsNotAbleToTagAFolder() throws Exception
|
||||
public void consumerIsNotAbleToTagAFolder()
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
@@ -246,7 +246,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that tagged folder can be tagged again")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagToATaggedFolder() throws Exception
|
||||
public void addTagToATaggedFolder()
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
@@ -269,11 +269,11 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Using collaborator provide more than one tag element")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void provideMoreThanOneTagElement() throws Exception
|
||||
public void provideMoreThanOneTagElement()
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
String tagValue1 = RandomData.getRandomName("tag1");
|
||||
String tagValue2 = RandomData.getRandomName("tag2");
|
||||
String tagValue1 = RandomData.getRandomName("tag1").toLowerCase();
|
||||
String tagValue2 = RandomData.getRandomName("tag2").toLowerCase();
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
|
||||
@@ -288,7 +288,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that manager cannot add tag with special characters.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagWithSpecialCharacters() throws Exception
|
||||
public void addTagWithSpecialCharacters()
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
String specialCharsTag = "!@#$%^&*()'\".,<>-_+=|\\";
|
||||
@@ -301,7 +301,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that you cannot tag a comment and it returns status code 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagToAComment() throws Exception
|
||||
public void addTagToAComment()
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String comment = "comment for a tag";
|
||||
@@ -316,7 +316,7 @@ public class AddTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that you cannot tag a tag and it returns status code 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagToATag() throws Exception
|
||||
public void addTagToATag()
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
@@ -326,4 +326,17 @@ public class AddTagTests extends TagsDataPrep
|
||||
restClient.withCoreAPI().usingResource(file).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG);
|
||||
}
|
||||
}
|
||||
|
||||
@TestRail (section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify the tag name is converted to lower case before being applied")
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void tagNameIsConvertedToLowerCase()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
String tagName = RandomData.getRandomName("TaG-oNe");
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagName);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagName.toLowerCase())
|
||||
.and().field("id").isNotEmpty();
|
||||
}
|
||||
}
|
||||
|
@@ -30,14 +30,14 @@ public class AddTagsTests extends TagsDataPrep
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void generateRandomTagsList()
|
||||
{
|
||||
tag1 = RandomData.getRandomName("tag");
|
||||
tag2 = RandomData.getRandomName("tag");
|
||||
tag1 = RandomData.getRandomName("tag").toLowerCase();
|
||||
tag2 = RandomData.getRandomName("tag").toLowerCase();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin user adds multiple tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsAbleToAddTags() throws Exception
|
||||
public void adminIsAbleToAddTags()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
@@ -49,7 +49,7 @@ public class AddTagsTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify Manager user adds multiple tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToAddTags() throws Exception
|
||||
public void managerIsAbleToAddTags()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
@@ -61,7 +61,7 @@ public class AddTagsTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorIsAbleToAddTags() throws Exception
|
||||
public void collaboratorIsAbleToAddTags()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
@@ -73,7 +73,7 @@ public class AddTagsTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user doesn't have permission to add multiple tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsNotAbleToAddTagsToAnotherContent() throws Exception
|
||||
public void contributorIsNotAbleToAddTagsToAnotherContent()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
@@ -83,7 +83,7 @@ public class AddTagsTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user adds multiple tags to his content with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsAbleToAddTagsToHisContent() throws Exception
|
||||
public void contributorIsAbleToAddTagsToHisContent()
|
||||
{
|
||||
userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor);
|
||||
restClient.authenticateUser(userModel);
|
||||
@@ -97,7 +97,7 @@ public class AddTagsTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Consumer user doesn't have permission to add multiple tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void consumerIsNotAbleToAddTags() throws Exception
|
||||
public void consumerIsNotAbleToAddTags()
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
@@ -107,7 +107,7 @@ public class AddTagsTests extends TagsDataPrep
|
||||
description = "Verify user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToAddTagsIfAuthenticationFails() throws Exception
|
||||
public void userIsNotAbleToAddTagsIfAuthenticationFails()
|
||||
{
|
||||
UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager);
|
||||
String managerPassword = siteManager.getPassword();
|
||||
@@ -120,7 +120,7 @@ public class AddTagsTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify include count parameter")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagsUsingCountParam() throws Exception
|
||||
public void getTagsUsingCountParam()
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String tagName = RandomData.getRandomName("tag");
|
||||
@@ -139,4 +139,4 @@ public class AddTagsTests extends TagsDataPrep
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.Ignore;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
@@ -29,7 +30,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Admin user deletes tags with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsAbleToDeleteTags() throws Exception
|
||||
public void adminIsAbleToDeleteTags()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
@@ -43,7 +44,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify Manager user deletes tags created by admin user with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToDeleteTags() throws Exception
|
||||
public void managerIsAbleToDeleteTags()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
@@ -56,7 +57,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Collaborator user deletes tags created by admin user with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorIsAbleToDeleteTags() throws Exception
|
||||
public void collaboratorIsAbleToDeleteTags()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
@@ -69,7 +70,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsNotAbleToDeleteTagsForAnotherUserContent() throws Exception
|
||||
public void contributorIsNotAbleToDeleteTagsForAnotherUserContent()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
@@ -82,7 +83,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user deletes tags created by him with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsAbleToDeleteTagsForHisContent() throws Exception
|
||||
public void contributorIsAbleToDeleteTagsForHisContent()
|
||||
{
|
||||
userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor);
|
||||
restClient.authenticateUser(userModel);
|
||||
@@ -96,7 +97,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void consumerIsNotAbleToDeleteTags() throws Exception
|
||||
public void consumerIsNotAbleToDeleteTags()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
@@ -110,7 +111,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
description = "Verify user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws Exception
|
||||
public void userIsNotAbleToDeleteTagIfAuthenticationFails()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
@@ -127,7 +128,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if user has no permission to remove tag returned status code is 403. Check default error model schema")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void deleteTagWithUserWithoutPermissionCheckDefaultErrorModelSchema() throws Exception
|
||||
public void deleteTagWithUserWithoutPermissionCheckDefaultErrorModelSchema()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
@@ -144,7 +145,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if node does not exist returned status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void deleteTagForANonexistentNode() throws Exception
|
||||
public void deleteTagForANonexistentNode()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
@@ -159,7 +160,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if tag does not exist returned status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void deleteTagThatDoesNotExist() throws Exception
|
||||
public void deleteTagThatDoesNotExist()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
@@ -172,7 +173,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if tag id is empty returned status code is 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void deleteTagWithEmptyId() throws Exception
|
||||
public void deleteTagWithEmptyId()
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
@@ -185,7 +186,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that folder tag can be deleted")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void deleteFolderTag() throws Exception
|
||||
public void deleteFolderTag()
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();;
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
@@ -200,7 +201,8 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't delete deleted tag.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id = "ACE-5455")
|
||||
public void managerCannotDeleteDeletedTag() throws Exception
|
||||
@Ignore
|
||||
public void managerCannotDeleteDeletedTag()
|
||||
{
|
||||
tag = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
@@ -216,7 +218,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete long tag.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void userCollaboratorCanDeleteLongTag() throws Exception
|
||||
public void userCollaboratorCanDeleteLongTag()
|
||||
{
|
||||
String longTag = RandomStringUtils.randomAlphanumeric(800);
|
||||
|
||||
@@ -231,7 +233,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete short tag.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void managerCanDeleteShortTag() throws Exception
|
||||
public void managerCanDeleteShortTag()
|
||||
{
|
||||
String shortTag = RandomStringUtils.randomAlphanumeric(10);
|
||||
|
||||
@@ -246,7 +248,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Admin can delete tag then add it again.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminRemovesTagAndAddsItAgain() throws Exception
|
||||
public void adminRemovesTagAndAddsItAgain()
|
||||
{
|
||||
String tagValue = RandomStringUtils.randomAlphanumeric(10);
|
||||
|
||||
@@ -267,7 +269,7 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete tag added by another user.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void managerCanDeleteTagAddedByAnotherUser() throws Exception
|
||||
public void managerCanDeleteTagAddedByAnotherUser()
|
||||
{
|
||||
tag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).addTag(RandomStringUtils.randomAlphanumeric(10));
|
||||
@@ -276,4 +278,4 @@ public class DeleteTagTests extends TagsDataPrep
|
||||
.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
20
pom.xml
20
pom.xml
@@ -2,7 +2,7 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Alfresco Community Repo Parent</name>
|
||||
|
||||
@@ -52,12 +52,12 @@
|
||||
<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-A2</dependency.alfresco-transform-service.version>
|
||||
<dependency.alfresco-transform-core.version>3.1.0-A2</dependency.alfresco-transform-core.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-greenmail.version>6.5</dependency.alfresco-greenmail.version>
|
||||
<dependency.acs-event-model.version>0.0.18</dependency.acs-event-model.version>
|
||||
|
||||
<dependency.spring.version>5.3.25</dependency.spring.version>
|
||||
<dependency.spring.version>5.3.27</dependency.spring.version>
|
||||
<dependency.antlr.version>3.5.3</dependency.antlr.version>
|
||||
<dependency.jackson.version>2.15.0-rc1</dependency.jackson.version>
|
||||
<dependency.cxf.version>3.5.5</dependency.cxf.version>
|
||||
@@ -107,12 +107,12 @@
|
||||
<dependency.jakarta-jws-api.version>2.1.0</dependency.jakarta-jws-api.version>
|
||||
<dependency.jakarta-mail-api.version>1.6.5</dependency.jakarta-mail-api.version>
|
||||
<dependency.jakarta-json-api.version>1.1.6</dependency.jakarta-json-api.version>
|
||||
<dependency.jakarta-json-path.version>2.7.0</dependency.jakarta-json-path.version>
|
||||
<dependency.json-smart.version>2.4.8</dependency.json-smart.version>
|
||||
<dependency.jakarta-json-path.version>2.8.0</dependency.jakarta-json-path.version>
|
||||
<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-M1</alfresco.googledrive.version>
|
||||
<alfresco.aos-module.version>1.6.0-A4</alfresco.aos-module.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.maven-plugin.version>2.2.0</alfresco.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.130</tag>
|
||||
<tag>20.155</tag>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
@@ -936,7 +936,7 @@
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.42.0</version>
|
||||
<version>0.42.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -38,10 +38,10 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
||||
public interface Tags
|
||||
{
|
||||
List<Tag> addTags(String nodeId, List<Tag> tags, Parameters parameters);
|
||||
Tag getTag(StoreRef storeRef, String tagId);
|
||||
Tag getTag(StoreRef storeRef, String tagId, Parameters parameters);
|
||||
void deleteTag(String nodeId, String tagId);
|
||||
CollectionWithPagingInfo<Tag> getTags(StoreRef storeRef, Parameters params);
|
||||
Tag changeTag(StoreRef storeRef, String tagId, Tag tag);
|
||||
Tag changeTag(StoreRef storeRef, String tagId, Tag tag, Parameters parameters);
|
||||
CollectionWithPagingInfo<Tag> getTags(String nodeId, Parameters params);
|
||||
|
||||
@Experimental
|
||||
|
@@ -111,6 +111,11 @@ public class CategoriesImpl implements Categories
|
||||
category.setCount(categoriesCount.getOrDefault(category.getId(), 0));
|
||||
}
|
||||
|
||||
if (parameters.getInclude().contains(Nodes.PARAM_INCLUDE_PATH))
|
||||
{
|
||||
category.setPath(getCategoryPath(category));
|
||||
}
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
@@ -128,6 +133,10 @@ public class CategoriesImpl implements Categories
|
||||
{
|
||||
category.setCount(0);
|
||||
}
|
||||
if (parameters.getInclude().contains(Nodes.PARAM_INCLUDE_PATH))
|
||||
{
|
||||
category.setPath(getCategoryPath(category));
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
@@ -136,11 +145,18 @@ public class CategoriesImpl implements Categories
|
||||
public List<Category> getCategoryChildren(final StoreRef storeRef, final String parentCategoryId, final Parameters parameters)
|
||||
{
|
||||
final NodeRef parentNodeRef = getCategoryNodeRef(storeRef, parentCategoryId);
|
||||
final List<Category> categories = nodeService.getChildAssocs(parentNodeRef).stream()
|
||||
.filter(ca -> ContentModel.ASSOC_SUBCATEGORIES.equals(ca.getTypeQName()))
|
||||
.map(ChildAssociationRef::getChildRef)
|
||||
.map(this::mapToCategory)
|
||||
.collect(Collectors.toList());
|
||||
final List<Category> categories = nodeService.getChildAssocs(parentNodeRef)
|
||||
.stream()
|
||||
.filter(ca -> ContentModel.ASSOC_SUBCATEGORIES.equals(ca.getTypeQName()))
|
||||
.map(ChildAssociationRef::getChildRef)
|
||||
.map(this::mapToCategory)
|
||||
.peek(category -> {
|
||||
if (parameters.getInclude().contains(Nodes.PARAM_INCLUDE_PATH))
|
||||
{
|
||||
category.setPath(getCategoryPath(category));
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (parameters.getInclude().contains(INCLUDE_COUNT_PARAM))
|
||||
{
|
||||
@@ -170,6 +186,11 @@ public class CategoriesImpl implements Categories
|
||||
category.setCount(categoriesCount.getOrDefault(category.getId(), 0));
|
||||
}
|
||||
|
||||
if (parameters.getInclude().contains(Nodes.PARAM_INCLUDE_PATH))
|
||||
{
|
||||
category.setPath(getCategoryPath(category));
|
||||
}
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
@@ -200,7 +221,16 @@ public class CategoriesImpl implements Categories
|
||||
}
|
||||
final Collection<NodeRef> actualCategories = DefaultTypeConverter.INSTANCE.getCollection(NodeRef.class, currentCategories);
|
||||
|
||||
return actualCategories.stream().map(this::mapToCategory).collect(Collectors.toList());
|
||||
return actualCategories
|
||||
.stream()
|
||||
.map(this::mapToCategory)
|
||||
.peek(category -> {
|
||||
if (parameters.getInclude().contains(Nodes.PARAM_INCLUDE_PATH))
|
||||
{
|
||||
category.setPath(getCategoryPath(category));
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -230,7 +260,16 @@ public class CategoriesImpl implements Categories
|
||||
|
||||
linkNodeToCategories(contentNodeRef, categoryNodeRefs);
|
||||
|
||||
return categoryNodeRefs.stream().map(this::mapToCategory).collect(Collectors.toList());
|
||||
return categoryNodeRefs
|
||||
.stream()
|
||||
.map(this::mapToCategory)
|
||||
.peek(category -> {
|
||||
if (parameters.getInclude().contains(Nodes.PARAM_INCLUDE_PATH))
|
||||
{
|
||||
category.setPath(getCategoryPath(category));
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -475,4 +514,16 @@ public class CategoriesImpl implements Categories
|
||||
.stream()
|
||||
.collect(Collectors.toMap(pair -> pair.getFirst().toString().replace(idPrefix, StringUtils.EMPTY), Pair::getSecond));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get path for a given category in human-readable form.
|
||||
*
|
||||
* @param category Category to provide path for.
|
||||
* @return Path for a category in human-readable form.
|
||||
*/
|
||||
private String getCategoryPath(final Category category)
|
||||
{
|
||||
final NodeRef categoryNodeRef = nodes.getNode(category.getId()).getNodeRef();
|
||||
return nodeService.getPath(categoryNodeRef).toDisplayPath(nodeService, permissionService);
|
||||
}
|
||||
}
|
||||
|
@@ -30,10 +30,13 @@ import static java.util.stream.Collectors.toList;
|
||||
import static org.alfresco.rest.antlr.WhereClauseParser.EQUALS;
|
||||
import static org.alfresco.rest.antlr.WhereClauseParser.IN;
|
||||
import static org.alfresco.rest.antlr.WhereClauseParser.MATCHES;
|
||||
import static org.alfresco.service.cmr.repository.StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
|
||||
import static org.alfresco.service.cmr.tagging.TaggingService.TAG_ROOT_NODE_REF;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -42,6 +45,8 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.ListBackedPagingResults;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.tagging.NonExistentTagException;
|
||||
import org.alfresco.repo.tagging.TagExistsException;
|
||||
@@ -58,10 +63,12 @@ import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationE
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.resource.parameters.SortColumn;
|
||||
import org.alfresco.rest.framework.resource.parameters.where.Query;
|
||||
import org.alfresco.rest.framework.resource.parameters.where.QueryHelper;
|
||||
import org.alfresco.rest.framework.resource.parameters.where.QueryImpl;
|
||||
import org.alfresco.service.Experimental;
|
||||
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;
|
||||
@@ -79,41 +86,40 @@ import org.apache.commons.collections.CollectionUtils;
|
||||
*/
|
||||
public class TagsImpl implements Tags
|
||||
{
|
||||
private static final String PARAM_INCLUDE_COUNT = "count";
|
||||
private static final String PARAM_WHERE_TAG = "tag";
|
||||
static final String NOT_A_VALID_TAG = "An invalid parameter has been supplied";
|
||||
static final String NO_PERMISSION_TO_MANAGE_A_TAG = "Current user does not have permission to manage a tag";
|
||||
private final NodeRef tagParentNodeRef = new NodeRef("workspace://SpacesStore/tag:tag-root");
|
||||
public static final String PARAM_INCLUDE_COUNT = "count";
|
||||
private static final String PARAM_WHERE_TAG = "tag";
|
||||
static final String NOT_A_VALID_TAG = "An invalid parameter has been supplied";
|
||||
static final String NO_PERMISSION_TO_MANAGE_A_TAG = "Current user does not have permission to manage a tag";
|
||||
|
||||
private Nodes nodes;
|
||||
private NodeService nodeService;
|
||||
private TaggingService taggingService;
|
||||
private TypeConstraint typeConstraint;
|
||||
private AuthorityService authorityService;
|
||||
private NodeService nodeService;
|
||||
private TaggingService taggingService;
|
||||
private TypeConstraint typeConstraint;
|
||||
private AuthorityService authorityService;
|
||||
|
||||
public void setTypeConstraint(TypeConstraint typeConstraint)
|
||||
{
|
||||
this.typeConstraint = typeConstraint;
|
||||
}
|
||||
|
||||
public void setNodes(Nodes nodes)
|
||||
public void setTypeConstraint(TypeConstraint typeConstraint)
|
||||
{
|
||||
this.nodes = nodes;
|
||||
}
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
this.typeConstraint = typeConstraint;
|
||||
}
|
||||
|
||||
public void setNodes(Nodes nodes)
|
||||
{
|
||||
this.nodes = nodes;
|
||||
}
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setTaggingService(TaggingService taggingService)
|
||||
{
|
||||
this.taggingService = taggingService;
|
||||
}
|
||||
this.taggingService = taggingService;
|
||||
}
|
||||
|
||||
public void setAuthorityService(AuthorityService authorityService)
|
||||
{
|
||||
this.authorityService = authorityService;
|
||||
}
|
||||
public void setAuthorityService(AuthorityService authorityService)
|
||||
{
|
||||
this.authorityService = authorityService;
|
||||
}
|
||||
|
||||
public List<Tag> addTags(String nodeId, final List<Tag> tags, final Parameters parameters)
|
||||
{
|
||||
@@ -128,14 +134,15 @@ public class TagsImpl implements Tags
|
||||
{
|
||||
List<Pair<String, NodeRef>> tagNodeRefs = taggingService.addTags(nodeRef, tagValues);
|
||||
List<Tag> ret = new ArrayList<>(tags.size());
|
||||
List<Pair<String, Integer>> tagsCountPairList = taggingService.findTaggedNodesAndCountByTagName(nodeRef.getStoreRef());
|
||||
Map<String, Integer> tagsCountMap = tagsCountPairList.stream().collect(Collectors.toMap(Pair::getFirst,Pair::getSecond));
|
||||
List<Pair<String, Integer>> tagsCountPairList = taggingService.findTaggedNodesAndCountByTagName(nodeRef.getStoreRef());
|
||||
Map<String, Long> tagsCountMap = tagsCountPairList.stream().collect(Collectors.toMap(Pair::getFirst, pair -> Long.valueOf(pair.getSecond())));
|
||||
for (Pair<String, NodeRef> pair : tagNodeRefs)
|
||||
{
|
||||
Tag createdTag = new Tag(pair.getSecond(), pair.getFirst());
|
||||
if (parameters.getInclude().contains(PARAM_INCLUDE_COUNT)) {
|
||||
createdTag.setCount(Optional.ofNullable(tagsCountMap.get(createdTag.getTag())).orElse(0) + 1);
|
||||
}
|
||||
Tag createdTag = new Tag(pair.getSecond(), pair.getFirst());
|
||||
if (parameters.getInclude().contains(PARAM_INCLUDE_COUNT))
|
||||
{
|
||||
createdTag.setCount(Optional.ofNullable(tagsCountMap.get(createdTag.getTag())).orElse(0L) + 1);
|
||||
}
|
||||
ret.add(createdTag);
|
||||
}
|
||||
return ret;
|
||||
@@ -145,105 +152,112 @@ public class TagsImpl implements Tags
|
||||
throw new InvalidArgumentException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void deleteTag(String nodeId, String tagId)
|
||||
{
|
||||
NodeRef nodeRef = nodes.validateNode(nodeId);
|
||||
getTag(tagId);
|
||||
NodeRef existingTagNodeRef = validateTag(tagId);
|
||||
String tagValue = taggingService.getTagName(existingTagNodeRef);
|
||||
taggingService.removeTag(nodeRef, tagValue);
|
||||
NodeRef nodeRef = nodes.validateNode(nodeId);
|
||||
getTag(STORE_REF_WORKSPACE_SPACESSTORE, tagId, null);
|
||||
NodeRef existingTagNodeRef = validateTag(tagId);
|
||||
String tagValue = taggingService.getTagName(existingTagNodeRef);
|
||||
taggingService.removeTag(nodeRef, tagValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTagById(StoreRef storeRef, String tagId) {
|
||||
verifyAdminAuthority();
|
||||
public void deleteTagById(StoreRef storeRef, String tagId) {
|
||||
verifyAdminAuthority();
|
||||
|
||||
NodeRef tagNodeRef = validateTag(storeRef, tagId);
|
||||
String tagValue = taggingService.getTagName(tagNodeRef);
|
||||
taggingService.deleteTag(storeRef, tagValue);
|
||||
}
|
||||
NodeRef tagNodeRef = validateTag(storeRef, tagId);
|
||||
String tagValue = taggingService.getTagName(tagNodeRef);
|
||||
taggingService.deleteTag(storeRef, tagValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CollectionWithPagingInfo<Tag> getTags(StoreRef storeRef, Parameters params)
|
||||
{
|
||||
Paging paging = params.getPaging();
|
||||
Pair<String, Boolean> sorting = !params.getSorting().isEmpty() ? new Pair<>(params.getSorting().get(0).column, params.getSorting().get(0).asc) : null;
|
||||
Map<Integer, Collection<String>> namesFilters = resolveTagNamesQuery(params.getQuery());
|
||||
PagingResults<Pair<NodeRef, String>> results = taggingService.getTags(storeRef, Util.getPagingRequest(paging), namesFilters.get(EQUALS), namesFilters.get(MATCHES));
|
||||
|
||||
Integer totalItems = results.getTotalResultCount().getFirst();
|
||||
List<Pair<NodeRef, String>> page = results.getPage();
|
||||
List<Tag> tags = new ArrayList<>(page.size());
|
||||
for (Pair<NodeRef, String> pair : page)
|
||||
{
|
||||
Tag selectedTag = new Tag(pair.getFirst(), pair.getSecond());
|
||||
tags.add(selectedTag);
|
||||
}
|
||||
Map<NodeRef, Long> results = taggingService.getTags(storeRef, params.getInclude(), sorting, namesFilters.get(EQUALS), namesFilters.get(MATCHES));
|
||||
|
||||
List<Tag> tagsList = results.entrySet().stream().map(entry -> new Tag(entry.getKey(), (String)nodeService.getProperty(entry.getKey(), ContentModel.PROP_NAME))).collect(Collectors.toList());
|
||||
|
||||
if (params.getInclude().contains(PARAM_INCLUDE_COUNT))
|
||||
{
|
||||
List<Pair<String, Integer>> tagsByCount = taggingService.findTaggedNodesAndCountByTagName(storeRef);
|
||||
Map<String, Integer> tagsByCountMap = new HashMap<>();
|
||||
if (tagsByCount != null)
|
||||
{
|
||||
for (Pair<String, Integer> tagByCountElem : tagsByCount)
|
||||
{
|
||||
tagsByCountMap.put(tagByCountElem.getFirst(), tagByCountElem.getSecond());
|
||||
}
|
||||
}
|
||||
tags.forEach(tag -> tag.setCount(Optional.ofNullable(tagsByCountMap.get(tag.getTag())).orElse(0)));
|
||||
tagsList.forEach(tag -> tag.setCount(results.get(tag.getNodeRef())));
|
||||
}
|
||||
|
||||
return CollectionWithPagingInfo.asPaged(paging, tags, results.hasMoreItems(), totalItems);
|
||||
ListBackedPagingResults listBackedPagingResults = new ListBackedPagingResults(tagsList, Util.getPagingRequest(params.getPaging()));
|
||||
|
||||
return CollectionWithPagingInfo.asPaged(paging, listBackedPagingResults.getPage(), listBackedPagingResults.hasMoreItems(), (Integer) listBackedPagingResults.getTotalResultCount().getFirst());
|
||||
}
|
||||
|
||||
public NodeRef validateTag(String tagId)
|
||||
{
|
||||
NodeRef tagNodeRef = nodes.validateNode(tagId);
|
||||
return checkTagRootAsNodePrimaryParent(tagId, tagNodeRef);
|
||||
NodeRef tagNodeRef = nodes.validateNode(tagId);
|
||||
return checkTagRootAsNodePrimaryParent(tagId, tagNodeRef);
|
||||
}
|
||||
|
||||
public NodeRef validateTag(StoreRef storeRef, String tagId)
|
||||
{
|
||||
NodeRef tagNodeRef = nodes.validateNode(storeRef, tagId);
|
||||
return checkTagRootAsNodePrimaryParent(tagId, tagNodeRef);
|
||||
NodeRef tagNodeRef = nodes.validateNode(storeRef, tagId);
|
||||
return checkTagRootAsNodePrimaryParent(tagId, tagNodeRef);
|
||||
}
|
||||
|
||||
public Tag changeTag(StoreRef storeRef, String tagId, Tag tag)
|
||||
/**
|
||||
* Find the number of times the given tag is used (if requested).
|
||||
*
|
||||
* @param storeRef The store the tag is in.
|
||||
* @param tagName The name of the tag.
|
||||
* @param parameters The request parameters object containing the includes parameter.
|
||||
* @return The number of times the tag is applied, or null if "count" wasn't in the include parameter.
|
||||
*/
|
||||
private Long findCountIfRequested(StoreRef storeRef, String tagName, Parameters parameters)
|
||||
{
|
||||
try
|
||||
{
|
||||
NodeRef existingTagNodeRef = validateTag(storeRef, tagId);
|
||||
String existingTagName = taggingService.getTagName(existingTagNodeRef);
|
||||
String newTagName = tag.getTag();
|
||||
NodeRef newTagNodeRef = taggingService.changeTag(storeRef, existingTagName, newTagName);
|
||||
return new Tag(newTagNodeRef, newTagName);
|
||||
}
|
||||
catch(NonExistentTagException e)
|
||||
{
|
||||
throw new NotFoundException(e.getMessage());
|
||||
}
|
||||
catch(TagExistsException e)
|
||||
{
|
||||
throw new ConstraintViolatedException(e.getMessage());
|
||||
}
|
||||
catch(TaggingException e)
|
||||
{
|
||||
throw new InvalidArgumentException(e.getMessage());
|
||||
}
|
||||
Long count = null;
|
||||
if (parameters != null && parameters.getInclude() != null && parameters.getInclude().contains(PARAM_INCLUDE_COUNT))
|
||||
{
|
||||
count = taggingService.findCountByTagName(storeRef, tagName);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public Tag getTag(String tagId)
|
||||
@Override
|
||||
public Tag changeTag(StoreRef storeRef, String tagId, Tag tag, Parameters parameters)
|
||||
{
|
||||
return getTag(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, tagId);
|
||||
try
|
||||
{
|
||||
NodeRef existingTagNodeRef = validateTag(storeRef, tagId);
|
||||
String existingTagName = taggingService.getTagName(existingTagNodeRef);
|
||||
Long count = findCountIfRequested(storeRef, existingTagName, parameters);
|
||||
String newTagName = tag.getTag();
|
||||
NodeRef newTagNodeRef = taggingService.changeTag(storeRef, existingTagName, newTagName);
|
||||
return Tag.builder().nodeRef(newTagNodeRef).tag(newTagName).count(count).create();
|
||||
}
|
||||
catch(NonExistentTagException e)
|
||||
{
|
||||
throw new NotFoundException(e.getMessage());
|
||||
}
|
||||
catch(TagExistsException e)
|
||||
{
|
||||
throw new ConstraintViolatedException(e.getMessage());
|
||||
}
|
||||
catch(TaggingException e)
|
||||
{
|
||||
throw new InvalidArgumentException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public Tag getTag(StoreRef storeRef, String tagId)
|
||||
@Override
|
||||
public Tag getTag(StoreRef storeRef, String tagId, Parameters parameters)
|
||||
{
|
||||
NodeRef tagNodeRef = validateTag(storeRef, tagId);
|
||||
String tagValue = taggingService.getTagName(tagNodeRef);
|
||||
return new Tag(tagNodeRef, tagValue);
|
||||
NodeRef tagNodeRef = validateTag(storeRef, tagId);
|
||||
String tagName = taggingService.getTagName(tagNodeRef);
|
||||
Long count = findCountIfRequested(storeRef, tagName, parameters);
|
||||
return Tag.builder().nodeRef(tagNodeRef).tag(tagName).count(count).create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CollectionWithPagingInfo<Tag> getTags(String nodeId, Parameters params)
|
||||
{
|
||||
NodeRef nodeRef = nodes.validateOrLookupNode(nodeId);
|
||||
@@ -259,80 +273,80 @@ public class TagsImpl implements Tags
|
||||
return CollectionWithPagingInfo.asPaged(params.getPaging(), tags, results.hasMoreItems(), (totalItems == null ? null : totalItems.intValue()));
|
||||
}
|
||||
|
||||
@Experimental
|
||||
@Override
|
||||
public List<Tag> createTags(final StoreRef storeRef, final List<Tag> tags, final Parameters parameters)
|
||||
{
|
||||
verifyAdminAuthority();
|
||||
final List<String> tagNames = Optional.ofNullable(tags).orElse(Collections.emptyList()).stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(Tag::getTag)
|
||||
.distinct()
|
||||
.collect(toList());
|
||||
@Experimental
|
||||
@Override
|
||||
public List<Tag> createTags(final StoreRef storeRef, final List<Tag> tags, final Parameters parameters)
|
||||
{
|
||||
verifyAdminAuthority();
|
||||
final List<String> tagNames = Optional.ofNullable(tags).orElse(Collections.emptyList()).stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(Tag::getTag)
|
||||
.distinct()
|
||||
.collect(toList());
|
||||
|
||||
if (CollectionUtils.isEmpty(tagNames))
|
||||
{
|
||||
throw new InvalidArgumentException(NOT_A_VALID_TAG);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(tagNames))
|
||||
{
|
||||
throw new InvalidArgumentException(NOT_A_VALID_TAG);
|
||||
}
|
||||
|
||||
return taggingService.createTags(storeRef, tagNames).stream()
|
||||
.map(pair -> Tag.builder().tag(pair.getFirst()).nodeRef(pair.getSecond()).create())
|
||||
.peek(tag -> {
|
||||
if (parameters.getInclude().contains(PARAM_INCLUDE_COUNT))
|
||||
{
|
||||
tag.setCount(0);
|
||||
}
|
||||
}).collect(toList());
|
||||
}
|
||||
return taggingService.createTags(storeRef, tagNames).stream()
|
||||
.map(pair -> Tag.builder().tag(pair.getFirst()).nodeRef(pair.getSecond()).create())
|
||||
.peek(tag -> {
|
||||
if (parameters.getInclude().contains(PARAM_INCLUDE_COUNT))
|
||||
{
|
||||
tag.setCount(0L);
|
||||
}
|
||||
}).collect(toList());
|
||||
}
|
||||
|
||||
private void verifyAdminAuthority()
|
||||
{
|
||||
if (!authorityService.hasAdminAuthority())
|
||||
{
|
||||
throw new PermissionDeniedException(NO_PERMISSION_TO_MANAGE_A_TAG);
|
||||
}
|
||||
}
|
||||
private void verifyAdminAuthority()
|
||||
{
|
||||
if (!authorityService.hasAdminAuthority())
|
||||
{
|
||||
throw new PermissionDeniedException(NO_PERMISSION_TO_MANAGE_A_TAG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method resolves where query looking for clauses: EQUALS, IN or MATCHES.
|
||||
* Expected values for EQUALS and IN will be merged under EQUALS clause.
|
||||
* @param namesQuery Where query with expected tag name(s).
|
||||
* @return Map of expected exact and alike tag names.
|
||||
*/
|
||||
private Map<Integer, Collection<String>> resolveTagNamesQuery(final Query namesQuery)
|
||||
{
|
||||
if (namesQuery == null || namesQuery == QueryImpl.EMPTY)
|
||||
{
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
/**
|
||||
* Method resolves where query looking for clauses: EQUALS, IN or MATCHES.
|
||||
* Expected values for EQUALS and IN will be merged under EQUALS clause.
|
||||
* @param namesQuery Where query with expected tag name(s).
|
||||
* @return Map of expected exact and alike tag names.
|
||||
*/
|
||||
private Map<Integer, Collection<String>> resolveTagNamesQuery(final Query namesQuery)
|
||||
{
|
||||
if (namesQuery == null || namesQuery == QueryImpl.EMPTY)
|
||||
{
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
final Map<Integer, Collection<String>> properties = QueryHelper
|
||||
.resolve(namesQuery)
|
||||
.usingOrOperator()
|
||||
.withoutNegations()
|
||||
.getProperty(PARAM_WHERE_TAG)
|
||||
.getExpectedValuesForAnyOf(EQUALS, IN, MATCHES)
|
||||
.skipNegated();
|
||||
final Map<Integer, Collection<String>> properties = QueryHelper
|
||||
.resolve(namesQuery)
|
||||
.usingOrOperator()
|
||||
.withoutNegations()
|
||||
.getProperty(PARAM_WHERE_TAG)
|
||||
.getExpectedValuesForAnyOf(EQUALS, IN, MATCHES)
|
||||
.skipNegated();
|
||||
|
||||
return properties.entrySet().stream()
|
||||
.collect(Collectors.groupingBy((entry) -> {
|
||||
if (entry.getKey() == EQUALS || entry.getKey() == IN)
|
||||
{
|
||||
return EQUALS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MATCHES;
|
||||
}
|
||||
}, Collectors.flatMapping((entry) -> entry.getValue().stream().map(String::toLowerCase), Collectors.toCollection(HashSet::new))));
|
||||
}
|
||||
return properties.entrySet().stream()
|
||||
.collect(Collectors.groupingBy((entry) -> {
|
||||
if (entry.getKey() == EQUALS || entry.getKey() == IN)
|
||||
{
|
||||
return EQUALS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MATCHES;
|
||||
}
|
||||
}, Collectors.flatMapping((entry) -> entry.getValue().stream().map(String::toLowerCase), Collectors.toCollection(HashSet::new))));
|
||||
}
|
||||
|
||||
private NodeRef checkTagRootAsNodePrimaryParent(String tagId, NodeRef tagNodeRef)
|
||||
{
|
||||
if ( tagNodeRef == null || !nodeService.getPrimaryParent(tagNodeRef).getParentRef().equals(tagParentNodeRef))
|
||||
{
|
||||
throw new EntityNotFoundException(tagId);
|
||||
}
|
||||
return tagNodeRef;
|
||||
}
|
||||
private NodeRef checkTagRootAsNodePrimaryParent(String tagId, NodeRef tagNodeRef)
|
||||
{
|
||||
if ( tagNodeRef == null || !nodeService.getPrimaryParent(tagNodeRef).getParentRef().equals(TAG_ROOT_NODE_REF))
|
||||
{
|
||||
throw new EntityNotFoundException(tagId);
|
||||
}
|
||||
return tagNodeRef;
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,7 @@ public class Category
|
||||
private String parentId;
|
||||
private boolean hasChildren;
|
||||
private Integer count;
|
||||
private String path;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
@@ -91,6 +92,14 @@ public class Category
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
@@ -100,19 +109,20 @@ public class Category
|
||||
return false;
|
||||
Category category = (Category) o;
|
||||
return hasChildren == category.hasChildren && Objects.equals(id, category.id) && Objects.equals(name, category.name) && Objects.equals(parentId, category.parentId)
|
||||
&& Objects.equals(count, category.count);
|
||||
&& Objects.equals(count, category.count) && Objects.equals(path, category.path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(id, name, parentId, hasChildren, count);
|
||||
return Objects.hash(id, name, parentId, hasChildren, count, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Category{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", parentId='" + parentId + '\'' + ", hasChildren=" + hasChildren + ", count=" + count + '}';
|
||||
return "Category{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", parentId='" + parentId + '\'' + ", hasChildren=" + hasChildren
|
||||
+ ", count=" + count + ", path=" + path + '}';
|
||||
}
|
||||
|
||||
public static Builder builder()
|
||||
@@ -127,6 +137,7 @@ public class Category
|
||||
private String parentId;
|
||||
private boolean hasChildren;
|
||||
private Integer count;
|
||||
private String path;
|
||||
|
||||
public Builder id(String id)
|
||||
{
|
||||
@@ -158,6 +169,12 @@ public class Category
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder path(String path)
|
||||
{
|
||||
this.path = path;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Category create()
|
||||
{
|
||||
final Category category = new Category();
|
||||
@@ -166,6 +183,7 @@ public class Category
|
||||
category.setParentId(parentId);
|
||||
category.setHasChildren(hasChildren);
|
||||
category.setCount(count);
|
||||
category.setPath(path);
|
||||
return category;
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@
|
||||
package org.alfresco.rest.api.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.alfresco.rest.framework.resource.UniqueId;
|
||||
@@ -41,7 +42,7 @@ public class Tag implements Comparable<Tag>
|
||||
{
|
||||
private NodeRef nodeRef;
|
||||
private String tag;
|
||||
private Integer count;
|
||||
private Long count;
|
||||
|
||||
public Tag()
|
||||
{
|
||||
@@ -50,7 +51,7 @@ public class Tag implements Comparable<Tag>
|
||||
public Tag(NodeRef nodeRef, String tag)
|
||||
{
|
||||
this.nodeRef = nodeRef;
|
||||
this.tag = tag;
|
||||
setTag(tag);
|
||||
}
|
||||
|
||||
@JsonProperty("id")
|
||||
@@ -72,16 +73,16 @@ public class Tag implements Comparable<Tag>
|
||||
|
||||
public void setTag(String tag)
|
||||
{
|
||||
this.tag = tag;
|
||||
this.tag = Optional.ofNullable(tag).map(String::toLowerCase).orElse(null);
|
||||
}
|
||||
|
||||
public Integer getCount()
|
||||
public Long getCount()
|
||||
{
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(Integer count)
|
||||
public void setCount(Long count)
|
||||
{
|
||||
this.count = count;
|
||||
}
|
||||
@@ -132,7 +133,7 @@ public class Tag implements Comparable<Tag>
|
||||
{
|
||||
private NodeRef nodeRef;
|
||||
private String tag;
|
||||
private Integer count;
|
||||
private Long count;
|
||||
|
||||
public Builder nodeRef(NodeRef nodeRef)
|
||||
{
|
||||
@@ -146,7 +147,7 @@ public class Tag implements Comparable<Tag>
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder count(Integer count)
|
||||
public Builder count(Long count)
|
||||
{
|
||||
this.count = count;
|
||||
return this;
|
||||
|
@@ -25,8 +25,8 @@
|
||||
*/
|
||||
package org.alfresco.rest.api.tags;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.rest.api.Tags;
|
||||
import org.alfresco.rest.api.model.Tag;
|
||||
@@ -73,13 +73,13 @@ public class TagsEntityResource implements EntityResourceAction.Read<Tag>,
|
||||
@WebApiDescription(title="Updates a tag by unique Id")
|
||||
public Tag update(String id, Tag entity, Parameters parameters)
|
||||
{
|
||||
return tags.changeTag(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, id, entity);
|
||||
return tags.changeTag(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, id, entity, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tag readById(String id, Parameters parameters) throws EntityNotFoundException
|
||||
{
|
||||
return tags.getTag(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, id);
|
||||
return tags.getTag(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, id, parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -60,6 +60,7 @@ import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.transfer.PathHelper;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
import org.alfresco.rest.api.model.Category;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
@@ -71,6 +72,7 @@ import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
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.Path;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.CategoryService;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
@@ -100,6 +102,9 @@ public class CategoriesImplTest
|
||||
private static final Category CATEGORY = createDefaultCategory();
|
||||
private static final String CONTENT_NODE_ID = "content-node-id";
|
||||
private static final NodeRef CONTENT_NODE_REF = createNodeRefWithId(CONTENT_NODE_ID);
|
||||
private static final String MOCK_ROOT_LEVEL = "/{mockRootLevel}";
|
||||
private static final String MOCK_CHILD_LEVEL = "/{mockChild}";
|
||||
private static final String MOCK_CATEGORY_PATH = "//" + MOCK_ROOT_LEVEL + "//" + MOCK_CHILD_LEVEL;
|
||||
|
||||
@Mock
|
||||
private Nodes nodesMock;
|
||||
@@ -252,6 +257,27 @@ public class CategoriesImplTest
|
||||
.isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCategoryById_includePath()
|
||||
{
|
||||
final QName categoryQName = createCmQNameOf(CATEGORY_NAME);
|
||||
final NodeRef parentCategoryNodeRef = createNodeRefWithId(PARENT_ID);
|
||||
final ChildAssociationRef parentAssociation = createAssociationOf(parentCategoryNodeRef, CATEGORY_NODE_REF, categoryQName);
|
||||
given(nodesMock.getNode(any())).willReturn(createNode());
|
||||
given(nodeServiceMock.getPrimaryParent(any())).willReturn(parentAssociation);
|
||||
given(parametersMock.getInclude()).willReturn(List.of(Nodes.PARAM_INCLUDE_PATH));
|
||||
given(nodeServiceMock.getPath(any())).willReturn(mockCategoryPath());
|
||||
|
||||
// when
|
||||
final Category actualCategory = objectUnderTest.getCategoryById(CATEGORY_ID, parametersMock);
|
||||
|
||||
assertThat(actualCategory)
|
||||
.isNotNull()
|
||||
.extracting(Category::getPath)
|
||||
.isNotNull()
|
||||
.isEqualTo(MOCK_CATEGORY_PATH);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCategoryById_notACategory()
|
||||
{
|
||||
@@ -479,6 +505,36 @@ public class CategoriesImplTest
|
||||
.isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateCategory_includePath()
|
||||
{
|
||||
final QName categoryQName = createCmQNameOf(CATEGORY_NAME);
|
||||
final NodeRef categoryNodeRef = createNodeRefWithId(CATEGORY_ID);
|
||||
final NodeRef parentCategoryNodeRef = createNodeRefWithId(PARENT_ID);
|
||||
final ChildAssociationRef parentAssociation = createAssociationOf(parentCategoryNodeRef, CATEGORY_NODE_REF, categoryQName);
|
||||
given(nodesMock.validateNode(PARENT_ID)).willReturn(parentCategoryNodeRef);
|
||||
given(categoryServiceMock.createCategory(parentCategoryNodeRef, CATEGORY_NAME)).willReturn(categoryNodeRef);
|
||||
given(nodesMock.getNode(any())).willReturn(createNode());
|
||||
given(nodeServiceMock.getPrimaryParent(any())).willReturn(parentAssociation);
|
||||
given(parametersMock.getInclude()).willReturn(List.of(Nodes.PARAM_INCLUDE_PATH));
|
||||
given(nodeServiceMock.getPath(any())).willReturn(mockCategoryPath());
|
||||
final List<Category> categoryModels = new ArrayList<>(prepareCategories());
|
||||
|
||||
// when
|
||||
final List<Category> actualCreatedCategories = objectUnderTest.createSubcategories(PARENT_ID, categoryModels, parametersMock);
|
||||
|
||||
then(categoryServiceMock).should().createCategory(any(), any());
|
||||
then(categoryServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
assertThat(actualCreatedCategories)
|
||||
.isNotNull()
|
||||
.hasSize(1)
|
||||
.element(0)
|
||||
.extracting(Category::getPath)
|
||||
.isNotNull()
|
||||
.isEqualTo(MOCK_CATEGORY_PATH);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateCategories_noPermissions()
|
||||
{
|
||||
@@ -628,6 +684,30 @@ public class CategoriesImplTest
|
||||
.isEqualTo(List.of(0, 2, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCategoryChildren_includePath()
|
||||
{
|
||||
final NodeRef parentCategoryNodeRef = createNodeRefWithId(PARENT_ID);
|
||||
given(nodesMock.validateNode(PARENT_ID)).willReturn(parentCategoryNodeRef);
|
||||
given(nodesMock.isSubClass(parentCategoryNodeRef, ContentModel.TYPE_CATEGORY, false)).willReturn(true);
|
||||
final int childrenCount = 3;
|
||||
final List<ChildAssociationRef> childAssociationRefMocks = prepareChildAssocMocks(childrenCount, parentCategoryNodeRef);
|
||||
given(nodeServiceMock.getChildAssocs(parentCategoryNodeRef)).willReturn(childAssociationRefMocks);
|
||||
childAssociationRefMocks.forEach(this::prepareCategoryNodeMocks);
|
||||
given(parametersMock.getInclude()).willReturn(List.of(Nodes.PARAM_INCLUDE_PATH));
|
||||
given(nodeServiceMock.getPath(any())).willReturn(mockCategoryPath());
|
||||
|
||||
// when
|
||||
final List<Category> actualCategoryChildren = objectUnderTest.getCategoryChildren(PARENT_ID, parametersMock);
|
||||
|
||||
assertThat(actualCategoryChildren)
|
||||
.isNotNull()
|
||||
.hasSize(3)
|
||||
.extracting(Category::getPath)
|
||||
.isNotNull()
|
||||
.isEqualTo(List.of(MOCK_CATEGORY_PATH, MOCK_CATEGORY_PATH, MOCK_CATEGORY_PATH));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCategoryChildren_noChildren()
|
||||
{
|
||||
@@ -751,6 +831,32 @@ public class CategoriesImplTest
|
||||
.isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateCategoryById_includePath()
|
||||
{
|
||||
final String categoryNewName = "categoryNewName";
|
||||
final Category fixedCategory = createCategoryOnlyWithName(categoryNewName);
|
||||
// simulate path provided by client to check if it will be ignored
|
||||
fixedCategory.setPath("/test/TestCat");
|
||||
final QName categoryQName = createCmQNameOf(CATEGORY_NAME);
|
||||
final NodeRef parentCategoryNodeRef = createNodeRefWithId(PARENT_ID);
|
||||
final ChildAssociationRef parentAssociation = createAssociationOf(parentCategoryNodeRef, CATEGORY_NODE_REF, categoryQName);
|
||||
given(nodesMock.getNode(any())).willReturn(createNode(categoryNewName));
|
||||
given(nodeServiceMock.getPrimaryParent(any())).willReturn(parentAssociation);
|
||||
given(nodeServiceMock.moveNode(any(), any(), any(), any())).willReturn(createAssociationOf(parentCategoryNodeRef, CATEGORY_NODE_REF, createCmQNameOf(categoryNewName)));
|
||||
given(parametersMock.getInclude()).willReturn(List.of(Nodes.PARAM_INCLUDE_PATH));
|
||||
given(nodeServiceMock.getPath(any())).willReturn(mockCategoryPath());
|
||||
|
||||
// when
|
||||
final Category actualCategory = objectUnderTest.updateCategoryById(CATEGORY_ID, fixedCategory, parametersMock);
|
||||
|
||||
assertThat(actualCategory)
|
||||
.isNotNull()
|
||||
.extracting(Category::getPath)
|
||||
.isNotNull()
|
||||
.isEqualTo(MOCK_CATEGORY_PATH);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateCategoryById_noPermission()
|
||||
{
|
||||
@@ -918,6 +1024,7 @@ public class CategoriesImplTest
|
||||
then(nodeServiceMock).should().getParentAssocs(categoryParentNodeRef);
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
final List<Category> expectedLinkedCategories = List.of(CATEGORY);
|
||||
expectedLinkedCategories.get(0).setPath(null);
|
||||
assertThat(actualLinkedCategories)
|
||||
.isNotNull().usingRecursiveComparison()
|
||||
.isEqualTo(expectedLinkedCategories);
|
||||
@@ -984,6 +1091,36 @@ public class CategoriesImplTest
|
||||
.isEqualTo(expectedLinkedCategories);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinkNodeToCategories_includePath()
|
||||
{
|
||||
final NodeRef categoryParentNodeRef = createNodeRefWithId(PARENT_ID);
|
||||
final ChildAssociationRef parentAssociation = createAssociationOf(categoryParentNodeRef, CATEGORY_NODE_REF);
|
||||
given(nodesMock.getNode(any())).willReturn(createNode());
|
||||
given(nodeServiceMock.getPrimaryParent(any())).willReturn(parentAssociation);
|
||||
given(nodeServiceMock.hasAspect(any(), any())).willReturn(true);
|
||||
given(parametersMock.getInclude()).willReturn(List.of(Nodes.PARAM_INCLUDE_PATH));
|
||||
given(nodeServiceMock.getPath(any())).willReturn(mockCategoryPath());
|
||||
|
||||
// when
|
||||
final List<Category> actualLinkedCategories = objectUnderTest.linkNodeToCategories(CONTENT_NODE_ID, List.of(CATEGORY), parametersMock);
|
||||
|
||||
then(nodesMock).should(times(2)).getNode(CATEGORY_ID);
|
||||
then(nodeServiceMock).should().getChildAssocs(CATEGORY_NODE_REF, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
|
||||
then(nodeServiceMock).should().getPrimaryParent(CATEGORY_NODE_REF);
|
||||
then(nodeServiceMock).should().getParentAssocs(CATEGORY_NODE_REF);
|
||||
then(nodeServiceMock).should().hasAspect(CONTENT_NODE_REF, ContentModel.ASPECT_GEN_CLASSIFIABLE);
|
||||
then(nodeServiceMock).should().getProperty(CONTENT_NODE_REF, ContentModel.PROP_CATEGORIES);
|
||||
final Serializable expectedCategories = (Serializable) List.of(CATEGORY_NODE_REF);
|
||||
then(nodeServiceMock).should().setProperty(CONTENT_NODE_REF, ContentModel.PROP_CATEGORIES, expectedCategories);
|
||||
then(nodeServiceMock).should().getParentAssocs(categoryParentNodeRef);
|
||||
final List<Category> expectedLinkedCategories = List.of(CATEGORY);
|
||||
expectedLinkedCategories.get(0).setPath(MOCK_CATEGORY_PATH);
|
||||
assertThat(actualLinkedCategories)
|
||||
.isNotNull().usingRecursiveComparison()
|
||||
.isEqualTo(expectedLinkedCategories);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinkNodeToCategories_withPreviouslyLinkedCategories()
|
||||
{
|
||||
@@ -1168,11 +1305,46 @@ public class CategoriesImplTest
|
||||
then(nodeServiceMock).should().getParentAssocs(categoryParentNodeRef);
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
final List<Category> expectedCategories = List.of(CATEGORY);
|
||||
expectedCategories.get(0).setPath(null);
|
||||
assertThat(actualCategories)
|
||||
.isNotNull().usingRecursiveComparison()
|
||||
.isEqualTo(expectedCategories);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListCategoriesForNode_includePath()
|
||||
{
|
||||
final NodeRef categoryParentNodeRef = createNodeRefWithId(PARENT_ID);
|
||||
final ChildAssociationRef parentAssociation = createAssociationOf(categoryParentNodeRef, CATEGORY_NODE_REF);
|
||||
given(nodeServiceMock.getProperty(any(), eq(ContentModel.PROP_CATEGORIES))).willReturn((Serializable) List.of(CATEGORY_NODE_REF));
|
||||
given(nodesMock.getNode(any())).willReturn(createNode());
|
||||
given(nodeServiceMock.getPrimaryParent(any())).willReturn(parentAssociation);
|
||||
given(parametersMock.getInclude()).willReturn(List.of(Nodes.PARAM_INCLUDE_PATH));
|
||||
given(nodeServiceMock.getPath(any())).willReturn(mockCategoryPath());
|
||||
|
||||
// when
|
||||
final List<Category> actualCategories = objectUnderTest.listCategoriesForNode(CONTENT_NODE_ID, parametersMock);
|
||||
|
||||
then(nodesMock).should().validateOrLookupNode(CONTENT_NODE_ID);
|
||||
then(permissionServiceMock).should().hasReadPermission(CONTENT_NODE_REF);
|
||||
then(permissionServiceMock).shouldHaveNoMoreInteractions();
|
||||
then(typeConstraint).should().matches(CONTENT_NODE_REF);
|
||||
then(typeConstraint).shouldHaveNoMoreInteractions();
|
||||
then(nodesMock).should(times(2)).getNode(CATEGORY_ID);
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
then(nodeServiceMock).should().getProperty(CONTENT_NODE_REF, ContentModel.PROP_CATEGORIES);
|
||||
then(nodeServiceMock).should().getChildAssocs(CATEGORY_NODE_REF, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, false);
|
||||
then(nodeServiceMock).should().getPrimaryParent(CATEGORY_NODE_REF);
|
||||
then(nodeServiceMock).should().getParentAssocs(categoryParentNodeRef);
|
||||
then(nodeServiceMock).should().getPath(any());
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
final List<Category> expectedCategories = List.of(CATEGORY);
|
||||
expectedCategories.get(0).setPath(MOCK_CATEGORY_PATH);
|
||||
assertThat(actualCategories)
|
||||
.isNotNull().usingRecursiveComparison()
|
||||
.isEqualTo(expectedCategories);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListCategoriesForNode_withInvalidNodeId()
|
||||
{
|
||||
@@ -1329,4 +1501,13 @@ public class CategoriesImplTest
|
||||
{
|
||||
return new ChildAssociationRef(ContentModel.ASSOC_SUBCATEGORIES, parentNode, childNodeName, childNode);
|
||||
}
|
||||
|
||||
private Path mockCategoryPath()
|
||||
{
|
||||
final Path mockPath = new Path();
|
||||
mockPath.append(PathHelper.stringToPath(MOCK_ROOT_LEVEL));
|
||||
mockPath.append(PathHelper.stringToPath(MOCK_CHILD_LEVEL));
|
||||
mockPath.append(PathHelper.stringToPath("/"));
|
||||
return mockPath;
|
||||
}
|
||||
}
|
||||
|
@@ -40,10 +40,14 @@ import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
@@ -55,6 +59,7 @@ import org.alfresco.rest.framework.core.exceptions.UnsupportedResourceOperationE
|
||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||
import org.alfresco.rest.framework.resource.parameters.Paging;
|
||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||
import org.alfresco.rest.framework.resource.parameters.SortColumn;
|
||||
import org.alfresco.rest.framework.resource.parameters.where.InvalidQueryException;
|
||||
import org.alfresco.rest.framework.tools.RecognizedParamsExtractor;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
@@ -83,6 +88,8 @@ public class TagsImplTest
|
||||
private static final NodeRef TAG_PARENT_NODE_REF = new NodeRef(STORE_REF_WORKSPACE_SPACESSTORE, PARENT_NODE_ID);
|
||||
private static final String CONTENT_NODE_ID = "content-node-id";
|
||||
private static final NodeRef CONTENT_NODE_REF = new NodeRef(STORE_REF_WORKSPACE_SPACESSTORE, CONTENT_NODE_ID);
|
||||
private static final String PARAM_INCLUDE_COUNT = "count";
|
||||
|
||||
|
||||
private final RecognizedParamsExtractor queryExtractor = new RecognizedParamsExtractor() {};
|
||||
|
||||
@@ -115,19 +122,23 @@ public class TagsImplTest
|
||||
given(nodesMock.validateNode(STORE_REF_WORKSPACE_SPACESSTORE, TAG_ID)).willReturn(TAG_NODE_REF);
|
||||
given(taggingServiceMock.getTagName(TAG_NODE_REF)).willReturn(TAG_NAME);
|
||||
given(nodeServiceMock.getPrimaryParent(TAG_NODE_REF)).willReturn(primaryParentMock);
|
||||
given(primaryParentMock.getParentRef()).willReturn(TAG_PARENT_NODE_REF);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTags()
|
||||
{
|
||||
given(parametersMock.getPaging()).willReturn(pagingMock);
|
||||
given(taggingServiceMock.getTags(any(StoreRef.class), any(PagingRequest.class), any(), any())).willReturn(pagingResultsMock);
|
||||
given(pagingResultsMock.getTotalResultCount()).willReturn(new Pair<>(Integer.MAX_VALUE, 0));
|
||||
given(pagingResultsMock.getPage()).willReturn(List.of(new Pair<>(TAG_NODE_REF, TAG_NAME)));
|
||||
given(parametersMock.getSorting()).willReturn(new ArrayList<>());
|
||||
given(parametersMock.getInclude()).willReturn(new ArrayList<>());
|
||||
|
||||
//given(taggingServiceMock.getTags(eq(STORE_REF_WORKSPACE_SPACESSTORE), any(), any(), isNull(), isNull())).willReturn(List.of(new Pair<>(TAG_NODE_REF, null)));
|
||||
given(taggingServiceMock.getTags(eq(STORE_REF_WORKSPACE_SPACESSTORE), any(), any(), isNull(), isNull())).willReturn(Map.of(TAG_NODE_REF, 0L));
|
||||
given(nodeServiceMock.getProperty(any(NodeRef.class), eq(ContentModel.PROP_NAME))).willReturn("tag-dummy-name");
|
||||
|
||||
final CollectionWithPagingInfo<Tag> actualTags = objectUnderTest.getTags(STORE_REF_WORKSPACE_SPACESSTORE, parametersMock);
|
||||
|
||||
then(taggingServiceMock).should().getTags(eq(STORE_REF_WORKSPACE_SPACESSTORE), any(PagingRequest.class), isNull(), isNull());
|
||||
then(taggingServiceMock).should().getTags(eq(STORE_REF_WORKSPACE_SPACESSTORE), any(), any(), isNull(), isNull());
|
||||
then(taggingServiceMock).shouldHaveNoMoreInteractions();
|
||||
final List<Tag> expectedTags = createTagsWithNodeRefs(List.of(TAG_NAME));
|
||||
assertEquals(expectedTags, actualTags.getCollection());
|
||||
@@ -137,16 +148,17 @@ public class TagsImplTest
|
||||
public void testGetTags_verifyIfCountIsZero()
|
||||
{
|
||||
given(parametersMock.getPaging()).willReturn(pagingMock);
|
||||
given(taggingServiceMock.getTags(any(StoreRef.class), any(PagingRequest.class), any(), any())).willReturn(pagingResultsMock);
|
||||
given(pagingResultsMock.getTotalResultCount()).willReturn(new Pair<>(Integer.MAX_VALUE, 0));
|
||||
given(pagingResultsMock.getPage()).willReturn(List.of(new Pair<>(TAG_NODE_REF, TAG_NAME)));
|
||||
given(parametersMock.getSorting()).willReturn(new ArrayList<>());
|
||||
given(parametersMock.getInclude()).willReturn(List.of(PARAM_INCLUDE_COUNT));
|
||||
given(taggingServiceMock.getTags(any(StoreRef.class), any(), any(), any(), any())).willReturn(Map.of(TAG_NODE_REF, 0L));
|
||||
|
||||
given(nodeServiceMock.getProperty(any(NodeRef.class), eq(ContentModel.PROP_NAME))).willReturn("tag-dummy-name");
|
||||
given(parametersMock.getInclude()).willReturn(List.of("count"));
|
||||
|
||||
final CollectionWithPagingInfo<Tag> actualTags = objectUnderTest.getTags(STORE_REF_WORKSPACE_SPACESSTORE, parametersMock);
|
||||
|
||||
then(taggingServiceMock).should().findTaggedNodesAndCountByTagName(STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
final List<Tag> expectedTags = createTagsWithNodeRefs(List.of(TAG_NAME)).stream()
|
||||
.peek(tag -> tag.setCount(0))
|
||||
.peek(tag -> tag.setCount(0L))
|
||||
.collect(toList());
|
||||
assertEquals(expectedTags, actualTags.getCollection());
|
||||
}
|
||||
@@ -157,21 +169,142 @@ public class TagsImplTest
|
||||
{
|
||||
NodeRef tagNodeA = new NodeRef("tag://A/");
|
||||
NodeRef tagNodeB = new NodeRef("tag://B/");
|
||||
List<Pair<NodeRef, String>> tagPairs = List.of(new Pair<>(tagNodeA, "tagA"), new Pair<>(tagNodeB, "tagB"));
|
||||
|
||||
given(parametersMock.getSorting()).willReturn(Collections.emptyList());
|
||||
given(parametersMock.getPaging()).willReturn(pagingMock);
|
||||
given(taggingServiceMock.getTags(any(StoreRef.class), any(PagingRequest.class), any(), any())).willReturn(pagingResultsMock);
|
||||
given(pagingResultsMock.getTotalResultCount()).willReturn(new Pair<>(Integer.MAX_VALUE, 0));
|
||||
given(pagingResultsMock.getPage()).willReturn(tagPairs);
|
||||
given(parametersMock.getInclude()).willReturn(List.of("count"));
|
||||
// Only tagA is included in the returned list since tagB is not in use.
|
||||
given(taggingServiceMock.findTaggedNodesAndCountByTagName(STORE_REF_WORKSPACE_SPACESSTORE)).willReturn(List.of(new Pair<>("tagA", 5)));
|
||||
|
||||
final LinkedHashMap<NodeRef, Long> results = new LinkedHashMap<>();
|
||||
results.put(tagNodeA, 5L);
|
||||
results.put(tagNodeB, 0L);
|
||||
|
||||
given(taggingServiceMock.getTags(any(StoreRef.class), eq(List.of(PARAM_INCLUDE_COUNT)), isNull(), any(), any())).willReturn(results);
|
||||
given(nodeServiceMock.getProperty(any(NodeRef.class), eq(ContentModel.PROP_NAME))).willReturn("taga", "tagb");
|
||||
|
||||
final CollectionWithPagingInfo<Tag> actualTags = objectUnderTest.getTags(STORE_REF_WORKSPACE_SPACESSTORE, parametersMock);
|
||||
|
||||
then(taggingServiceMock).should().findTaggedNodesAndCountByTagName(STORE_REF_WORKSPACE_SPACESSTORE);
|
||||
final List<Tag> expectedTags = List.of(Tag.builder().tag("tagA").nodeRef(tagNodeA).count(5).create(),
|
||||
Tag.builder().tag("tagB").nodeRef(tagNodeB).count(0).create());
|
||||
final List<Tag> expectedTags = List.of(Tag.builder().tag("tagA").nodeRef(tagNodeA).count(5L).create(),
|
||||
Tag.builder().tag("tagB").nodeRef(tagNodeB).count(0L).create());
|
||||
assertEquals(expectedTags, actualTags.getCollection());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTags_orderByCountAscendingOrder()
|
||||
{
|
||||
NodeRef tagNodeA = new NodeRef("tag://A/");
|
||||
NodeRef tagNodeB = new NodeRef("tag://B/");
|
||||
NodeRef tagNodeC = new NodeRef("tag://C/");
|
||||
|
||||
given(parametersMock.getPaging()).willReturn(pagingMock);
|
||||
given(parametersMock.getInclude()).willReturn(List.of("count"));
|
||||
given(parametersMock.getSorting()).willReturn(List.of(new SortColumn("count", true)));
|
||||
|
||||
final LinkedHashMap<NodeRef, Long> results = new LinkedHashMap<>();
|
||||
results.put(tagNodeB, 0L);
|
||||
results.put(tagNodeC, 2L);
|
||||
results.put(tagNodeA, 5L);
|
||||
|
||||
given(taggingServiceMock.getTags(any(StoreRef.class), eq(List.of(PARAM_INCLUDE_COUNT)), eq(new Pair<>("count", true)), any(), any())).willReturn(results);
|
||||
given(nodeServiceMock.getProperty(tagNodeA, ContentModel.PROP_NAME)).willReturn("taga");
|
||||
given(nodeServiceMock.getProperty(tagNodeB, ContentModel.PROP_NAME)).willReturn("tagb");
|
||||
given(nodeServiceMock.getProperty(tagNodeC, ContentModel.PROP_NAME)).willReturn("tagc");
|
||||
|
||||
//when
|
||||
final CollectionWithPagingInfo<Tag> actualTags = objectUnderTest.getTags(STORE_REF_WORKSPACE_SPACESSTORE, parametersMock);
|
||||
|
||||
final List<Tag> expectedTags = List.of(Tag.builder().tag("tagb").nodeRef(tagNodeB).count(0L).create(),
|
||||
Tag.builder().tag("tagc").nodeRef(tagNodeC).count(2L).create(),
|
||||
Tag.builder().tag("taga").nodeRef(tagNodeA).count(5L).create());
|
||||
assertEquals(expectedTags, actualTags.getCollection());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTags_orderByCountDescendingOrder()
|
||||
{
|
||||
NodeRef tagNodeA = new NodeRef("tag://A/");
|
||||
NodeRef tagNodeB = new NodeRef("tag://B/");
|
||||
NodeRef tagNodeC = new NodeRef("tag://C/");
|
||||
|
||||
given(parametersMock.getPaging()).willReturn(pagingMock);
|
||||
given(parametersMock.getInclude()).willReturn(List.of("count"));
|
||||
given(parametersMock.getSorting()).willReturn(List.of(new SortColumn("count", false)));
|
||||
|
||||
final LinkedHashMap<NodeRef, Long> results = new LinkedHashMap<>();
|
||||
results.put(tagNodeA, 5L);
|
||||
results.put(tagNodeC, 2L);
|
||||
results.put(tagNodeB, 0L);
|
||||
|
||||
given(taggingServiceMock.getTags(any(StoreRef.class), eq(List.of(PARAM_INCLUDE_COUNT)), eq(new Pair<>("count", false)), any(), any())).willReturn(results);
|
||||
given(nodeServiceMock.getProperty(tagNodeA, ContentModel.PROP_NAME)).willReturn("taga");
|
||||
given(nodeServiceMock.getProperty(tagNodeB, ContentModel.PROP_NAME)).willReturn("tagb");
|
||||
given(nodeServiceMock.getProperty(tagNodeC, ContentModel.PROP_NAME)).willReturn("tagc");
|
||||
|
||||
//when
|
||||
final CollectionWithPagingInfo<Tag> actualTags = objectUnderTest.getTags(STORE_REF_WORKSPACE_SPACESSTORE, parametersMock);
|
||||
|
||||
final List<Tag> expectedTags = List.of(Tag.builder().tag("taga").nodeRef(tagNodeA).count(5L).create(),
|
||||
Tag.builder().tag("tagc").nodeRef(tagNodeC).count(2L).create(),
|
||||
Tag.builder().tag("tagb").nodeRef(tagNodeB).count(0L).create());
|
||||
assertEquals(expectedTags, actualTags.getCollection());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTags_orderByTagAscendingOrder()
|
||||
{
|
||||
NodeRef tagApple = new NodeRef("tag://apple/");
|
||||
NodeRef tagBanana = new NodeRef("tag://banana/");
|
||||
NodeRef tagCoconut = new NodeRef("tag://coconut/");
|
||||
|
||||
given(parametersMock.getPaging()).willReturn(pagingMock);
|
||||
given(parametersMock.getInclude()).willReturn(Collections.emptyList());
|
||||
given(parametersMock.getSorting()).willReturn(List.of(new SortColumn("tag", true)));
|
||||
|
||||
final LinkedHashMap<NodeRef, Long> results = new LinkedHashMap<>();
|
||||
results.put(tagApple, 0L);
|
||||
results.put(tagBanana, 0L);
|
||||
results.put(tagCoconut, 0L);
|
||||
|
||||
given(taggingServiceMock.getTags(any(StoreRef.class), any(), eq(new Pair<>("tag", true)), any(), any())).willReturn(results);
|
||||
given(nodeServiceMock.getProperty(tagApple, ContentModel.PROP_NAME)).willReturn("apple");
|
||||
given(nodeServiceMock.getProperty(tagBanana, ContentModel.PROP_NAME)).willReturn("banana");
|
||||
given(nodeServiceMock.getProperty(tagCoconut, ContentModel.PROP_NAME)).willReturn("coconut");
|
||||
|
||||
//when
|
||||
final CollectionWithPagingInfo<Tag> actualTags = objectUnderTest.getTags(STORE_REF_WORKSPACE_SPACESSTORE, parametersMock);
|
||||
|
||||
final List<Tag> expectedTags = List.of(Tag.builder().tag("apple").nodeRef(tagApple).create(),
|
||||
Tag.builder().tag("banana").nodeRef(tagBanana).create(),
|
||||
Tag.builder().tag("coconut").nodeRef(tagCoconut).create());
|
||||
assertEquals(expectedTags, actualTags.getCollection());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTags_orderByTagDescendingOrder()
|
||||
{
|
||||
NodeRef tagApple = new NodeRef("tag://apple/");
|
||||
NodeRef tagBanana = new NodeRef("tag://banana/");
|
||||
NodeRef tagCoconut = new NodeRef("tag://coconut/");
|
||||
|
||||
given(parametersMock.getPaging()).willReturn(pagingMock);
|
||||
given(parametersMock.getInclude()).willReturn(Collections.emptyList());
|
||||
given(parametersMock.getSorting()).willReturn(List.of(new SortColumn("tag", false)));
|
||||
|
||||
final LinkedHashMap<NodeRef, Long> results = new LinkedHashMap<>();
|
||||
results.put(tagCoconut, 0L);
|
||||
results.put(tagBanana, 0L);
|
||||
results.put(tagApple, 0L);
|
||||
|
||||
given(taggingServiceMock.getTags(any(StoreRef.class), any(), eq(new Pair<>("tag", false)), any(), any())).willReturn(results);
|
||||
given(nodeServiceMock.getProperty(tagApple, ContentModel.PROP_NAME)).willReturn("apple");
|
||||
given(nodeServiceMock.getProperty(tagBanana, ContentModel.PROP_NAME)).willReturn("banana");
|
||||
given(nodeServiceMock.getProperty(tagCoconut, ContentModel.PROP_NAME)).willReturn("coconut");
|
||||
|
||||
//when
|
||||
final CollectionWithPagingInfo<Tag> actualTags = objectUnderTest.getTags(STORE_REF_WORKSPACE_SPACESSTORE, parametersMock);
|
||||
|
||||
final List<Tag> expectedTags = List.of(Tag.builder().tag("coconut").nodeRef(tagCoconut).create(),
|
||||
Tag.builder().tag("banana").nodeRef(tagBanana).create(),
|
||||
Tag.builder().tag("apple").nodeRef(tagApple).create());
|
||||
assertEquals(expectedTags, actualTags.getCollection());
|
||||
}
|
||||
|
||||
@@ -180,13 +313,13 @@ public class TagsImplTest
|
||||
{
|
||||
given(parametersMock.getPaging()).willReturn(pagingMock);
|
||||
given(parametersMock.getQuery()).willReturn(queryExtractor.getWhereClause("(tag=expectedName)"));
|
||||
given(taggingServiceMock.getTags(any(StoreRef.class), any(PagingRequest.class), any(), any())).willReturn(pagingResultsMock);
|
||||
given(pagingResultsMock.getTotalResultCount()).willReturn(new Pair<>(Integer.MAX_VALUE, 0));
|
||||
given(parametersMock.getSorting()).willReturn(new ArrayList<>());
|
||||
given(parametersMock.getInclude()).willReturn(new ArrayList<>());
|
||||
|
||||
//when
|
||||
final CollectionWithPagingInfo<Tag> actualTags = objectUnderTest.getTags(STORE_REF_WORKSPACE_SPACESSTORE, parametersMock);
|
||||
|
||||
then(taggingServiceMock).should().getTags(eq(STORE_REF_WORKSPACE_SPACESSTORE), any(PagingRequest.class), eq(Set.of("expectedname")), isNull());
|
||||
then(taggingServiceMock).should().getTags(eq(STORE_REF_WORKSPACE_SPACESSTORE), eq(new ArrayList<>()), any(), eq(Set.of("expectedname")), isNull());
|
||||
then(taggingServiceMock).shouldHaveNoMoreInteractions();
|
||||
assertThat(actualTags).isNotNull();
|
||||
}
|
||||
@@ -196,13 +329,13 @@ public class TagsImplTest
|
||||
{
|
||||
given(parametersMock.getPaging()).willReturn(pagingMock);
|
||||
given(parametersMock.getQuery()).willReturn(queryExtractor.getWhereClause("(tag IN (expectedName1, expectedName2))"));
|
||||
given(taggingServiceMock.getTags(any(StoreRef.class), any(PagingRequest.class), any(), any())).willReturn(pagingResultsMock);
|
||||
given(pagingResultsMock.getTotalResultCount()).willReturn(new Pair<>(Integer.MAX_VALUE, 0));
|
||||
given(parametersMock.getSorting()).willReturn(new ArrayList<>());
|
||||
given(parametersMock.getInclude()).willReturn(new ArrayList<>());
|
||||
|
||||
//when
|
||||
final CollectionWithPagingInfo<Tag> actualTags = objectUnderTest.getTags(STORE_REF_WORKSPACE_SPACESSTORE, parametersMock);
|
||||
|
||||
then(taggingServiceMock).should().getTags(eq(STORE_REF_WORKSPACE_SPACESSTORE), any(PagingRequest.class), eq(Set.of("expectedname1", "expectedname2")), isNull());
|
||||
then(taggingServiceMock).should().getTags(eq(STORE_REF_WORKSPACE_SPACESSTORE),any(), any(), eq(Set.of("expectedname1", "expectedname2")), isNull());
|
||||
then(taggingServiceMock).shouldHaveNoMoreInteractions();
|
||||
assertThat(actualTags).isNotNull();
|
||||
}
|
||||
@@ -212,13 +345,13 @@ public class TagsImplTest
|
||||
{
|
||||
given(parametersMock.getPaging()).willReturn(pagingMock);
|
||||
given(parametersMock.getQuery()).willReturn(queryExtractor.getWhereClause("(tag MATCHES ('expectedName*'))"));
|
||||
given(taggingServiceMock.getTags(any(StoreRef.class), any(PagingRequest.class), any(), any())).willReturn(pagingResultsMock);
|
||||
given(pagingResultsMock.getTotalResultCount()).willReturn(new Pair<>(Integer.MAX_VALUE, 0));
|
||||
given(parametersMock.getSorting()).willReturn(new ArrayList<>());
|
||||
given(parametersMock.getInclude()).willReturn(new ArrayList<>());
|
||||
|
||||
//when
|
||||
final CollectionWithPagingInfo<Tag> actualTags = objectUnderTest.getTags(STORE_REF_WORKSPACE_SPACESSTORE, parametersMock);
|
||||
|
||||
then(taggingServiceMock).should().getTags(eq(STORE_REF_WORKSPACE_SPACESSTORE), any(PagingRequest.class), isNull(), eq(Set.of("expectedname*")));
|
||||
then(taggingServiceMock).should().getTags(eq(STORE_REF_WORKSPACE_SPACESSTORE), any(), any(), isNull(), eq(Set.of("expectedname*")));
|
||||
then(taggingServiceMock).shouldHaveNoMoreInteractions();
|
||||
assertThat(actualTags).isNotNull();
|
||||
}
|
||||
@@ -228,6 +361,7 @@ public class TagsImplTest
|
||||
{
|
||||
given(parametersMock.getPaging()).willReturn(pagingMock);
|
||||
given(parametersMock.getQuery()).willReturn(queryExtractor.getWhereClause("(tag=expectedName AND tag IN (expectedName1, expectedName2))"));
|
||||
given(parametersMock.getSorting()).willReturn(new ArrayList<>());
|
||||
|
||||
//when
|
||||
final Throwable actualException = catchThrowable(() -> objectUnderTest.getTags(STORE_REF_WORKSPACE_SPACESSTORE, parametersMock));
|
||||
@@ -241,6 +375,7 @@ public class TagsImplTest
|
||||
{
|
||||
given(parametersMock.getPaging()).willReturn(pagingMock);
|
||||
given(parametersMock.getQuery()).willReturn(queryExtractor.getWhereClause("(tag BETWEEN ('expectedName', 'expectedName2'))"));
|
||||
given(parametersMock.getSorting()).willReturn(new ArrayList<>());
|
||||
|
||||
//when
|
||||
final Throwable actualException = catchThrowable(() -> objectUnderTest.getTags(STORE_REF_WORKSPACE_SPACESSTORE, parametersMock));
|
||||
@@ -254,6 +389,7 @@ public class TagsImplTest
|
||||
{
|
||||
given(parametersMock.getPaging()).willReturn(pagingMock);
|
||||
given(parametersMock.getQuery()).willReturn(queryExtractor.getWhereClause("(NOT tag=expectedName)"));
|
||||
given(parametersMock.getSorting()).willReturn(new ArrayList<>());
|
||||
|
||||
//when
|
||||
final Throwable actualException = catchThrowable(() -> objectUnderTest.getTags(STORE_REF_WORKSPACE_SPACESSTORE, parametersMock));
|
||||
@@ -266,7 +402,6 @@ public class TagsImplTest
|
||||
public void testDeleteTagById()
|
||||
{
|
||||
//when
|
||||
given(primaryParentMock.getParentRef()).willReturn(TAG_PARENT_NODE_REF);
|
||||
objectUnderTest.deleteTagById(STORE_REF_WORKSPACE_SPACESSTORE, TAG_ID);
|
||||
|
||||
then(authorityServiceMock).should().hasAdminAuthority();
|
||||
@@ -425,7 +560,7 @@ public class TagsImplTest
|
||||
final List<Tag> actualCreatedTags = objectUnderTest.createTags(tagsToCreate, parametersMock);
|
||||
|
||||
final List<Tag> expectedTags = createTagsWithNodeRefs(tagNames).stream()
|
||||
.peek(tag -> tag.setCount(0))
|
||||
.peek(tag -> tag.setCount(0L))
|
||||
.collect(toList());
|
||||
assertThat(actualCreatedTags)
|
||||
.isNotNull()
|
||||
@@ -435,8 +570,8 @@ public class TagsImplTest
|
||||
@Test(expected = EntityNotFoundException.class)
|
||||
public void testGetTagByIdNotFoundValidation()
|
||||
{
|
||||
given(primaryParentMock.getParentRef()).willReturn(TAG_NODE_REF);
|
||||
objectUnderTest.getTag(STORE_REF_WORKSPACE_SPACESSTORE,TAG_ID);
|
||||
given(nodesMock.validateNode(STORE_REF_WORKSPACE_SPACESSTORE, TAG_ID)).willThrow(EntityNotFoundException.class);
|
||||
objectUnderTest.getTag(STORE_REF_WORKSPACE_SPACESSTORE, TAG_ID, null);
|
||||
then(nodeServiceMock).shouldHaveNoInteractions();
|
||||
then(nodesMock).should().validateNode(STORE_REF_WORKSPACE_SPACESSTORE, TAG_ID);
|
||||
then(nodesMock).shouldHaveNoMoreInteractions();
|
||||
@@ -450,17 +585,17 @@ public class TagsImplTest
|
||||
NodeRef tagNodeB = new NodeRef("tag://B/");
|
||||
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID)).willReturn(CONTENT_NODE_REF);
|
||||
given(typeConstraintMock.matches(CONTENT_NODE_REF)).willReturn(true);
|
||||
List<Pair<String, NodeRef>> pairs = List.of(new Pair<>("tagA", new NodeRef("tag://A/")), new Pair<>("tagB", new NodeRef("tag://B/")));
|
||||
List<Pair<String, NodeRef>> pairs = List.of(new Pair<>("taga", new NodeRef("tag://A/")), new Pair<>("tagb", new NodeRef("tag://B/")));
|
||||
List<String> tagNames = pairs.stream().map(Pair::getFirst).collect(toList());
|
||||
List<Tag> tags = tagNames.stream().map(name -> Tag.builder().tag(name).create()).collect(toList());
|
||||
given(taggingServiceMock.addTags(CONTENT_NODE_REF, tagNames)).willReturn(pairs);
|
||||
given(taggingServiceMock.findTaggedNodesAndCountByTagName(STORE_REF_WORKSPACE_SPACESSTORE)).willReturn(List.of(new Pair<>("tagA", 4)));
|
||||
given(taggingServiceMock.findTaggedNodesAndCountByTagName(STORE_REF_WORKSPACE_SPACESSTORE)).willReturn(List.of(new Pair<>("taga", 4)));
|
||||
given(parametersMock.getInclude()).willReturn(List.of("count"));
|
||||
|
||||
List<Tag> actual = objectUnderTest.addTags(CONTENT_NODE_ID, tags, parametersMock);
|
||||
|
||||
final List<Tag> expected = List.of(Tag.builder().tag("tagA").nodeRef(tagNodeA).count(5).create(),
|
||||
Tag.builder().tag("tagB").nodeRef(tagNodeB).count(1).create());
|
||||
final List<Tag> expected = List.of(Tag.builder().tag("taga").nodeRef(tagNodeA).count(5L).create(),
|
||||
Tag.builder().tag("tagb").nodeRef(tagNodeB).count(1L).create());
|
||||
assertEquals("Unexpected tags returned.", expected, actual);
|
||||
}
|
||||
|
||||
@@ -489,7 +624,7 @@ public class TagsImplTest
|
||||
{
|
||||
given(nodesMock.validateOrLookupNode(CONTENT_NODE_ID)).willReturn(CONTENT_NODE_REF);
|
||||
given(parametersMock.getPaging()).willReturn(pagingMock);
|
||||
List<Pair<NodeRef, String>> pairs = List.of(new Pair<>(new NodeRef("tag://A/"), "tagA"), new Pair<>(new NodeRef("tag://B/"), "tagB"));
|
||||
List<Pair<NodeRef, String>> pairs = List.of(new Pair<>(new NodeRef("tag://A/"), "taga"), new Pair<>(new NodeRef("tag://B/"), "tagb"));
|
||||
given(taggingServiceMock.getTags(eq(CONTENT_NODE_REF), any(PagingRequest.class))).willReturn(pagingResultsMock);
|
||||
given(pagingResultsMock.getTotalResultCount()).willReturn(new Pair<>(null, null));
|
||||
given(pagingResultsMock.getPage()).willReturn(pairs);
|
||||
@@ -508,6 +643,53 @@ public class TagsImplTest
|
||||
objectUnderTest.getTags(CONTENT_NODE_ID, parametersMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeTag()
|
||||
{
|
||||
Tag suppliedTag = Tag.builder().tag("new-name").create();
|
||||
given(taggingServiceMock.changeTag(STORE_REF_WORKSPACE_SPACESSTORE, TAG_NAME, "new-name")).willReturn(TAG_NODE_REF);
|
||||
|
||||
Tag tag = objectUnderTest.changeTag(STORE_REF_WORKSPACE_SPACESSTORE, TAG_ID, suppliedTag, parametersMock);
|
||||
|
||||
Tag expected = Tag.builder().nodeRef(TAG_NODE_REF).tag("new-name").create();
|
||||
assertEquals("Unexpected return value", expected, tag);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeTagAndGetCount()
|
||||
{
|
||||
Tag suppliedTag = Tag.builder().tag("new-name").create();
|
||||
given(taggingServiceMock.changeTag(STORE_REF_WORKSPACE_SPACESSTORE, TAG_NAME, "new-name")).willReturn(TAG_NODE_REF);
|
||||
given(parametersMock.getInclude()).willReturn(List.of(PARAM_INCLUDE_COUNT));
|
||||
given(taggingServiceMock.findCountByTagName(STORE_REF_WORKSPACE_SPACESSTORE, TAG_NAME)).willReturn(3L);
|
||||
|
||||
Tag tag = objectUnderTest.changeTag(STORE_REF_WORKSPACE_SPACESSTORE, TAG_ID, suppliedTag, parametersMock);
|
||||
|
||||
Tag expected = Tag.builder().nodeRef(TAG_NODE_REF).tag("new-name").count(3L).create();
|
||||
assertEquals("Unexpected return value", expected, tag);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTag()
|
||||
{
|
||||
Tag tag = objectUnderTest.getTag(STORE_REF_WORKSPACE_SPACESSTORE, TAG_ID, parametersMock);
|
||||
|
||||
Tag expected = Tag.builder().nodeRef(TAG_NODE_REF).tag(TAG_NAME).create();
|
||||
assertEquals("Unexpected tag returned", expected, tag);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTagWithCount()
|
||||
{
|
||||
given(parametersMock.getInclude()).willReturn(List.of(PARAM_INCLUDE_COUNT));
|
||||
given(taggingServiceMock.findCountByTagName(STORE_REF_WORKSPACE_SPACESSTORE, TAG_NAME)).willReturn(0L);
|
||||
|
||||
Tag tag = objectUnderTest.getTag(STORE_REF_WORKSPACE_SPACESSTORE, TAG_ID, parametersMock);
|
||||
|
||||
Tag expected = Tag.builder().nodeRef(TAG_NODE_REF).tag(TAG_NAME).count(0L).create();
|
||||
assertEquals("Unexpected tag returned", expected, tag);
|
||||
}
|
||||
|
||||
private static List<Pair<String, NodeRef>> createTagAndNodeRefPairs(final List<String> tagNames)
|
||||
{
|
||||
return tagNames.stream()
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>20.130</version>
|
||||
<version>20.155</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
@@ -809,6 +809,10 @@
|
||||
<artifactId>reflections</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@@ -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 - 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.email.server;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -37,10 +37,7 @@ import org.alfresco.service.cmr.email.EmailMessageException;
|
||||
import org.alfresco.service.cmr.email.EmailService;
|
||||
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* Base implementation of an email server.
|
||||
@@ -62,13 +59,13 @@ public abstract class EmailServer extends AbstractLifecycleBean
|
||||
private boolean requireTLS = false;
|
||||
private boolean authenticate = false;
|
||||
|
||||
private EmailService emailService;
|
||||
private AuthenticationComponent authenticationComponent;
|
||||
private EmailService emailService;
|
||||
private AuthenticationComponent authenticationComponent;
|
||||
private String unknownUser;
|
||||
|
||||
protected EmailServer()
|
||||
{
|
||||
this.enabled = false;
|
||||
|
||||
protected EmailServer()
|
||||
{
|
||||
this.enabled = false;
|
||||
this.port = 25;
|
||||
this.domain = null;
|
||||
this.maxConnections = 3;
|
||||
@@ -301,60 +298,6 @@ public abstract class EmailServer extends AbstractLifecycleBean
|
||||
}
|
||||
}
|
||||
|
||||
private static volatile Boolean stop = false;
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
usage();
|
||||
return;
|
||||
}
|
||||
|
||||
try (AbstractApplicationContext context = new ClassPathXmlApplicationContext(args))
|
||||
{
|
||||
if (!context.containsBean("emailServer"))
|
||||
{
|
||||
usage();
|
||||
return;
|
||||
}
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
public void run()
|
||||
{
|
||||
stop = true;
|
||||
synchronized (stop)
|
||||
{
|
||||
stop.notifyAll();
|
||||
}
|
||||
}
|
||||
});
|
||||
System.out.println("Use Ctrl-C to shutdown EmailServer");
|
||||
|
||||
while (!stop)
|
||||
{
|
||||
synchronized (stop)
|
||||
{
|
||||
stop.wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (BeansException e)
|
||||
{
|
||||
System.err.println("Error creating context: " + e);
|
||||
usage();
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private static void usage()
|
||||
{
|
||||
System.err.println("Use: EmailServer configLocation1, configLocation2, ...");
|
||||
System.err.println("\t configLocation - spring xml configs with EmailServer related beans (emailServer, emailServerConfiguration, emailService)");
|
||||
}
|
||||
|
||||
/**
|
||||
* authenticate with a user/password
|
||||
* @param userName
|
||||
|
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.email.server;
|
||||
|
||||
import org.alfresco.email.server.impl.subetha.SubethaEmailMessage;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.cmr.email.EmailDelivery;
|
||||
import org.alfresco.service.cmr.email.EmailMessage;
|
||||
import org.alfresco.service.cmr.email.EmailService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.remoting.rmi.RmiClientInterceptor;
|
||||
|
||||
/**
|
||||
* @author Michael Shavnev
|
||||
* @since 2.2
|
||||
*/
|
||||
public class EmailServiceRemotable extends AbstractLifecycleBean implements EmailService
|
||||
{
|
||||
private String rmiRegistryHost;
|
||||
|
||||
private int rmiRegistryPort;
|
||||
|
||||
private EmailService emailServiceProxy;
|
||||
|
||||
public void setRmiRegistryHost(String rmiRegistryHost)
|
||||
{
|
||||
this.rmiRegistryHost = rmiRegistryHost;
|
||||
}
|
||||
|
||||
public void setRmiRegistryPort(int rmiRegistryPort)
|
||||
{
|
||||
this.rmiRegistryPort = rmiRegistryPort;
|
||||
}
|
||||
|
||||
public void importMessage(EmailDelivery delivery, EmailMessage message)
|
||||
{
|
||||
if (message instanceof SubethaEmailMessage)
|
||||
{
|
||||
((SubethaEmailMessage) message).setRmiRegistry(rmiRegistryHost, rmiRegistryPort);
|
||||
}
|
||||
emailServiceProxy.importMessage(delivery, message);
|
||||
}
|
||||
|
||||
public void importMessage(EmailDelivery delivery, NodeRef nodeRef, EmailMessage message)
|
||||
{
|
||||
if (message instanceof SubethaEmailMessage)
|
||||
{
|
||||
((SubethaEmailMessage) message).setRmiRegistry(rmiRegistryHost, rmiRegistryPort);
|
||||
}
|
||||
emailServiceProxy.importMessage(delivery, nodeRef, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBootstrap(ApplicationEvent event)
|
||||
{
|
||||
if (rmiRegistryHost == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Property 'rmiRegistryHost' not set");
|
||||
}
|
||||
if (rmiRegistryPort == 0)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Property 'rmiRegistryPort' not set");
|
||||
}
|
||||
|
||||
RmiClientInterceptor rmiClientInterceptor = new RmiClientInterceptor();
|
||||
rmiClientInterceptor.setRefreshStubOnConnectFailure(true);
|
||||
rmiClientInterceptor.setServiceUrl("rmi://" + rmiRegistryHost + ":" + rmiRegistryPort + "/emailService");
|
||||
emailServiceProxy = (EmailService) ProxyFactory.getProxy(EmailService.class, rmiClientInterceptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onShutdown(ApplicationEvent event)
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,35 +1,34 @@
|
||||
/*
|
||||
* #%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 - 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.email.server.impl.subetha;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -417,29 +416,12 @@ public class SubethaEmailMessage implements EmailMessage
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setRmiRegistry(String rmiRegistryHost, int rmiRegistryPort)
|
||||
{
|
||||
if (body instanceof SubethaEmailMessagePart)
|
||||
{
|
||||
((SubethaEmailMessagePart) body).setRmiRegistry(rmiRegistryHost, rmiRegistryPort);
|
||||
}
|
||||
|
||||
for (EmailMessagePart attachment : attachments)
|
||||
{
|
||||
if (attachment instanceof SubethaEmailMessagePart)
|
||||
{
|
||||
((SubethaEmailMessagePart) attachment).setRmiRegistry(rmiRegistryHost, rmiRegistryPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getCC()
|
||||
{
|
||||
return cc;
|
||||
}
|
||||
|
||||
|
||||
public String getFrom()
|
||||
{
|
||||
return from;
|
||||
|
@@ -1,34 +1,31 @@
|
||||
/*
|
||||
* #%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 - 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.email.server.impl.subetha;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -39,7 +36,6 @@ import javax.mail.Part;
|
||||
import org.alfresco.service.cmr.email.EmailMessageException;
|
||||
import org.alfresco.service.cmr.email.EmailMessagePart;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
import org.alfresco.util.remote.RemotableInputStream;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -64,9 +60,6 @@ public class SubethaEmailMessagePart implements EmailMessagePart
|
||||
private String contentType;
|
||||
private InputStream contentInputStream;
|
||||
|
||||
private String rmiRegistryHost;
|
||||
private int rmiRegistryPort;
|
||||
|
||||
protected SubethaEmailMessagePart()
|
||||
{
|
||||
super();
|
||||
@@ -145,20 +138,4 @@ public class SubethaEmailMessagePart implements EmailMessagePart
|
||||
}
|
||||
|
||||
|
||||
public void setRmiRegistry(String rmiRegistryHost, int rmiRegistryPort)
|
||||
{
|
||||
this.rmiRegistryHost = rmiRegistryHost;
|
||||
this.rmiRegistryPort = rmiRegistryPort;
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream out) throws IOException
|
||||
{
|
||||
contentInputStream = new RemotableInputStream(rmiRegistryHost, rmiRegistryPort, contentInputStream);
|
||||
out.defaultWriteObject();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
|
||||
{
|
||||
in.defaultReadObject();
|
||||
}
|
||||
}
|
||||
|
@@ -47,7 +47,6 @@ import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
/**
|
||||
|
@@ -23,225 +23,225 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.repo.jscript;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.CategoryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.mozilla.javascript.Context;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
|
||||
/**
|
||||
* Support class for finding categories, finding root nodes for categories and creating root categories.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public final class Classification extends BaseScopableProcessorExtension
|
||||
{
|
||||
private ServiceRegistry services;
|
||||
|
||||
private StoreRef storeRef;
|
||||
|
||||
/**
|
||||
* Set the default store reference
|
||||
*
|
||||
* @param storeRef the default store reference
|
||||
*/
|
||||
public void setStoreUrl(String storeRef)
|
||||
{
|
||||
this.storeRef = new StoreRef(storeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the service registry
|
||||
*
|
||||
* @param services the service registry
|
||||
*/
|
||||
public void setServiceRegistry(ServiceRegistry services)
|
||||
{
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all the category nodes in a given classification.
|
||||
*
|
||||
* @param aspect String
|
||||
* @return Scriptable
|
||||
*/
|
||||
public Scriptable getAllCategoryNodes(String aspect)
|
||||
{
|
||||
Object[] cats = buildCategoryNodes(services.getCategoryService().getCategories(
|
||||
storeRef, createQName(aspect), CategoryService.Depth.ANY));
|
||||
return Context.getCurrentContext().newArray(getScope(), cats);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the aspects that define a classification.
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] getAllClassificationAspects()
|
||||
{
|
||||
Collection<QName> aspects = services.getCategoryService().getClassificationAspects();
|
||||
String[] answer = new String[aspects.size()];
|
||||
int i = 0;
|
||||
for (QName qname : aspects)
|
||||
{
|
||||
answer[i++] = qname.toPrefixString(this.services.getNamespaceService());
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a root category in a classification.
|
||||
*
|
||||
* @param aspect String
|
||||
* @param name String
|
||||
*/
|
||||
public CategoryNode createRootCategory(String aspect, String name)
|
||||
{
|
||||
NodeRef categoryNodeRef = services.getCategoryService().createRootCategory(storeRef, createQName(aspect), name);
|
||||
CategoryNode categoryNode = new CategoryNode(categoryNodeRef, this.services, getScope());
|
||||
|
||||
return categoryNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category node from the category node reference.
|
||||
*
|
||||
* @param categoryRef category node reference
|
||||
* @return {@link CategoryNode} category node
|
||||
*/
|
||||
public CategoryNode getCategory(String categoryRef)
|
||||
{
|
||||
CategoryNode result = null;
|
||||
NodeRef categoryNodeRef = new NodeRef(categoryRef);
|
||||
if (services.getNodeService().exists(categoryNodeRef) == true &&
|
||||
services.getDictionaryService().isSubClass(ContentModel.TYPE_CATEGORY, services.getNodeService().getType(categoryNodeRef)) == true)
|
||||
{
|
||||
result = new CategoryNode(categoryNodeRef, this.services, getScope());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the root categories in a classification.
|
||||
*
|
||||
* @param aspect String
|
||||
* @return Scriptable
|
||||
*/
|
||||
public Scriptable getRootCategories(String aspect)
|
||||
{
|
||||
Object[] cats = buildCategoryNodes(services.getCategoryService().getRootCategories(
|
||||
storeRef, createQName(aspect)));
|
||||
return Context.getCurrentContext().newArray(getScope(), cats);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ordered, filtered and paged root categories in a classification.
|
||||
*
|
||||
* @param aspect
|
||||
* @param filter
|
||||
* @param maxItems
|
||||
* @param skipCount (offset)
|
||||
* @return
|
||||
*/
|
||||
public Scriptable getRootCategories(String aspect, String filter, int maxItems, int skipCount)
|
||||
{
|
||||
PagingRequest pagingRequest = new PagingRequest(skipCount, maxItems);
|
||||
List<ChildAssociationRef> rootCategories = services.getCategoryService().getRootCategories(storeRef, createQName(aspect), pagingRequest, true, filter).getPage();
|
||||
Object[] cats = buildCategoryNodes(rootCategories);
|
||||
return Context.getCurrentContext().newArray(getScope(), cats);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category usage count.
|
||||
*
|
||||
* @param aspect String
|
||||
* @param maxCount int
|
||||
* @return Scriptable
|
||||
*/
|
||||
public Scriptable getCategoryUsage(String aspect, int maxCount)
|
||||
{
|
||||
List<Pair<NodeRef, Integer>> topCats = services.getCategoryService().getTopCategories(storeRef, createQName(aspect), maxCount);
|
||||
Object[] tags = new Object[topCats.size()];
|
||||
int i = 0;
|
||||
for (Pair<NodeRef, Integer> topCat : topCats)
|
||||
{
|
||||
tags[i++] = new Tag(new CategoryNode(topCat.getFirst(), this.services, getScope()), topCat.getSecond());
|
||||
}
|
||||
|
||||
return Context.getCurrentContext().newArray(getScope(), tags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build category nodes.
|
||||
*
|
||||
* @param cars list of associations to category nodes
|
||||
* @return {@link Object}[] array of category nodes
|
||||
*/
|
||||
private Object[] buildCategoryNodes(Collection<ChildAssociationRef> cars)
|
||||
{
|
||||
Object[] categoryNodes = new Object[cars.size()];
|
||||
int i = 0;
|
||||
for (ChildAssociationRef car : cars)
|
||||
{
|
||||
categoryNodes[i++] = new CategoryNode(car.getChildRef(), this.services, getScope());
|
||||
}
|
||||
return categoryNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create QName from string
|
||||
*
|
||||
* @param s QName string value
|
||||
* @return {@link QName} qualified name object
|
||||
*/
|
||||
private QName createQName(String s)
|
||||
{
|
||||
QName qname;
|
||||
if (s.indexOf(QName.NAMESPACE_BEGIN) != -1)
|
||||
{
|
||||
qname = QName.createQName(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
qname = QName.createQName(s, this.services.getNamespaceService());
|
||||
}
|
||||
return qname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tag class returned from getCategoryUsage().
|
||||
*/
|
||||
public final class Tag
|
||||
{
|
||||
private CategoryNode categoryNode;
|
||||
private int frequency = 0;
|
||||
|
||||
public Tag(CategoryNode categoryNode, int frequency)
|
||||
{
|
||||
this.categoryNode = categoryNode;
|
||||
this.frequency = frequency;
|
||||
}
|
||||
|
||||
public CategoryNode getCategory()
|
||||
{
|
||||
return categoryNode;
|
||||
}
|
||||
|
||||
public int getFrequency()
|
||||
{
|
||||
return frequency;
|
||||
}
|
||||
}
|
||||
}
|
||||
package org.alfresco.repo.jscript;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.CategoryService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.mozilla.javascript.Context;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
|
||||
/**
|
||||
* Support class for finding categories, finding root nodes for categories and creating root categories.
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public final class Classification extends BaseScopableProcessorExtension
|
||||
{
|
||||
private ServiceRegistry services;
|
||||
|
||||
private StoreRef storeRef;
|
||||
|
||||
/**
|
||||
* Set the default store reference
|
||||
*
|
||||
* @param storeRef the default store reference
|
||||
*/
|
||||
public void setStoreUrl(String storeRef)
|
||||
{
|
||||
this.storeRef = new StoreRef(storeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the service registry
|
||||
*
|
||||
* @param services the service registry
|
||||
*/
|
||||
public void setServiceRegistry(ServiceRegistry services)
|
||||
{
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all the category nodes in a given classification.
|
||||
*
|
||||
* @param aspect String
|
||||
* @return Scriptable
|
||||
*/
|
||||
public Scriptable getAllCategoryNodes(String aspect)
|
||||
{
|
||||
Object[] cats = buildCategoryNodes(services.getCategoryService().getCategories(
|
||||
storeRef, createQName(aspect), CategoryService.Depth.ANY));
|
||||
return Context.getCurrentContext().newArray(getScope(), cats);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the aspects that define a classification.
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] getAllClassificationAspects()
|
||||
{
|
||||
Collection<QName> aspects = services.getCategoryService().getClassificationAspects();
|
||||
String[] answer = new String[aspects.size()];
|
||||
int i = 0;
|
||||
for (QName qname : aspects)
|
||||
{
|
||||
answer[i++] = qname.toPrefixString(this.services.getNamespaceService());
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a root category in a classification.
|
||||
*
|
||||
* @param aspect String
|
||||
* @param name String
|
||||
*/
|
||||
public CategoryNode createRootCategory(String aspect, String name)
|
||||
{
|
||||
NodeRef categoryNodeRef = services.getCategoryService().createRootCategory(storeRef, createQName(aspect), name);
|
||||
CategoryNode categoryNode = new CategoryNode(categoryNodeRef, this.services, getScope());
|
||||
|
||||
return categoryNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category node from the category node reference.
|
||||
*
|
||||
* @param categoryRef category node reference
|
||||
* @return {@link CategoryNode} category node
|
||||
*/
|
||||
public CategoryNode getCategory(String categoryRef)
|
||||
{
|
||||
CategoryNode result = null;
|
||||
NodeRef categoryNodeRef = new NodeRef(categoryRef);
|
||||
if (services.getNodeService().exists(categoryNodeRef) == true &&
|
||||
services.getDictionaryService().isSubClass(ContentModel.TYPE_CATEGORY, services.getNodeService().getType(categoryNodeRef)) == true)
|
||||
{
|
||||
result = new CategoryNode(categoryNodeRef, this.services, getScope());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the root categories in a classification.
|
||||
*
|
||||
* @param aspect String
|
||||
* @return Scriptable
|
||||
*/
|
||||
public Scriptable getRootCategories(String aspect)
|
||||
{
|
||||
Object[] cats = buildCategoryNodes(services.getCategoryService().getRootCategories(
|
||||
storeRef, createQName(aspect)));
|
||||
return Context.getCurrentContext().newArray(getScope(), cats);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ordered, filtered and paged root categories in a classification.
|
||||
*
|
||||
* @param aspect
|
||||
* @param filter
|
||||
* @param maxItems
|
||||
* @param skipCount (offset)
|
||||
* @return
|
||||
*/
|
||||
public Scriptable getRootCategories(String aspect, String filter, int maxItems, int skipCount)
|
||||
{
|
||||
PagingRequest pagingRequest = new PagingRequest(skipCount, maxItems);
|
||||
List<ChildAssociationRef> rootCategories = services.getCategoryService().getRootCategories(storeRef, createQName(aspect), pagingRequest, true, filter).getPage();
|
||||
Object[] cats = buildCategoryNodes(rootCategories);
|
||||
return Context.getCurrentContext().newArray(getScope(), cats);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category usage count.
|
||||
*
|
||||
* @param aspect String
|
||||
* @param maxCount int
|
||||
* @return Scriptable
|
||||
*/
|
||||
public Scriptable getCategoryUsage(String aspect, int maxCount)
|
||||
{
|
||||
List<Pair<NodeRef, Integer>> topCats = services.getCategoryService().getTopCategories(storeRef, createQName(aspect), maxCount);
|
||||
Object[] tags = new Object[topCats.size()];
|
||||
int i = 0;
|
||||
for (Pair<NodeRef, Integer> topCat : topCats)
|
||||
{
|
||||
tags[i++] = new Tag(new CategoryNode(topCat.getFirst(), this.services, getScope()), topCat.getSecond());
|
||||
}
|
||||
|
||||
return Context.getCurrentContext().newArray(getScope(), tags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build category nodes.
|
||||
*
|
||||
* @param cars list of associations to category nodes
|
||||
* @return {@link Object}[] array of category nodes
|
||||
*/
|
||||
private Object[] buildCategoryNodes(Collection<ChildAssociationRef> cars)
|
||||
{
|
||||
Object[] categoryNodes = new Object[cars.size()];
|
||||
int i = 0;
|
||||
for (ChildAssociationRef car : cars)
|
||||
{
|
||||
categoryNodes[i++] = new CategoryNode(car.getChildRef(), this.services, getScope());
|
||||
}
|
||||
return categoryNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create QName from string
|
||||
*
|
||||
* @param s QName string value
|
||||
* @return {@link QName} qualified name object
|
||||
*/
|
||||
private QName createQName(String s)
|
||||
{
|
||||
QName qname;
|
||||
if (s.indexOf(QName.NAMESPACE_BEGIN) != -1)
|
||||
{
|
||||
qname = QName.createQName(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
qname = QName.createQName(s, this.services.getNamespaceService());
|
||||
}
|
||||
return qname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tag class returned from getCategoryUsage().
|
||||
*/
|
||||
public final class Tag
|
||||
{
|
||||
private CategoryNode categoryNode;
|
||||
private int frequency = 0;
|
||||
|
||||
public Tag(CategoryNode categoryNode, int frequency)
|
||||
{
|
||||
this.categoryNode = categoryNode;
|
||||
this.frequency = frequency;
|
||||
}
|
||||
|
||||
public CategoryNode getCategory()
|
||||
{
|
||||
return categoryNode;
|
||||
}
|
||||
|
||||
public int getFrequency()
|
||||
{
|
||||
return frequency;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -414,34 +414,7 @@ public abstract class AbstractCategoryServiceImpl implements CategoryService
|
||||
int count = 0;
|
||||
boolean moreItems = false;
|
||||
|
||||
final Function<NodeRef, Collection<ChildAssociationRef>> childNodesSupplier = (nodeRef) -> {
|
||||
final Set<ChildAssociationRef> childNodes = new HashSet<>();
|
||||
if (CollectionUtils.isEmpty(exactNamesFilter) && CollectionUtils.isEmpty(alikeNamesFilter))
|
||||
{
|
||||
// lookup in DB without filtering
|
||||
childNodes.addAll(nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_SUBCATEGORIES, RegexQNamePattern.MATCH_ALL));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CollectionUtils.isNotEmpty(exactNamesFilter))
|
||||
{
|
||||
// lookup in DB filtering by name
|
||||
childNodes.addAll(nodeService.getChildrenByName(nodeRef, ContentModel.ASSOC_SUBCATEGORIES, exactNamesFilter));
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(alikeNamesFilter))
|
||||
{
|
||||
// lookup using search engin filtering by name
|
||||
childNodes.addAll(getChildren(nodeRef, Mode.SUB_CATEGORIES, Depth.IMMEDIATE, sortByName, alikeNamesFilter, skipCount + maxItems + 1));
|
||||
}
|
||||
}
|
||||
|
||||
Stream<ChildAssociationRef> childNodesStream = childNodes.stream();
|
||||
if (sortByName)
|
||||
{
|
||||
childNodesStream = childNodesStream.sorted(Comparator.comparing(tag -> tag.getQName().getLocalName()));
|
||||
}
|
||||
return childNodesStream.collect(Collectors.toList());
|
||||
};
|
||||
final Function<NodeRef, Collection<ChildAssociationRef>> childNodesSupplier = getNodeRefCollectionFunction(sortByName, exactNamesFilter, alikeNamesFilter, skipCount, maxItems);
|
||||
|
||||
OUTER_LOOP: for(NodeRef nodeRef : nodeRefs)
|
||||
{
|
||||
@@ -468,6 +441,55 @@ public abstract class AbstractCategoryServiceImpl implements CategoryService
|
||||
return new ListBackedPagingResults<>(associations, moreItems);
|
||||
}
|
||||
|
||||
public Collection<ChildAssociationRef> getRootCategories(StoreRef storeRef, QName aspectName, Collection<String> exactNamesFilter, Collection<String> alikeNamesFilter)
|
||||
{
|
||||
final Set<NodeRef> nodeRefs = getClassificationNodes(storeRef, aspectName);
|
||||
final List<ChildAssociationRef> associations = new LinkedList<>();
|
||||
|
||||
final Function<NodeRef, Collection<ChildAssociationRef>> childNodesSupplier = getNodeRefCollectionFunction(false, exactNamesFilter, alikeNamesFilter, 0, 10000);
|
||||
|
||||
for (NodeRef nodeRef : nodeRefs)
|
||||
{
|
||||
Collection<ChildAssociationRef> children = childNodesSupplier.apply(nodeRef);
|
||||
associations.addAll(children);
|
||||
}
|
||||
|
||||
return associations;
|
||||
}
|
||||
|
||||
private Function<NodeRef, Collection<ChildAssociationRef>> getNodeRefCollectionFunction(boolean sortByName, Collection<String> exactNamesFilter, Collection<String> alikeNamesFilter, int skipCount, int maxItems)
|
||||
{
|
||||
final Function<NodeRef, Collection<ChildAssociationRef>> childNodesSupplier = (nodeRef) -> {
|
||||
final Set<ChildAssociationRef> childNodes = new HashSet<>();
|
||||
if (CollectionUtils.isEmpty(exactNamesFilter) && CollectionUtils.isEmpty(alikeNamesFilter))
|
||||
{
|
||||
// lookup in DB without filtering
|
||||
childNodes.addAll(nodeService.getChildAssocs(nodeRef, ContentModel.ASSOC_SUBCATEGORIES, RegexQNamePattern.MATCH_ALL));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CollectionUtils.isNotEmpty(exactNamesFilter))
|
||||
{
|
||||
// lookup in DB filtering by name
|
||||
childNodes.addAll(nodeService.getChildrenByName(nodeRef, ContentModel.ASSOC_SUBCATEGORIES, exactNamesFilter));
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(alikeNamesFilter))
|
||||
{
|
||||
// lookup using search engine filtering by name
|
||||
childNodes.addAll(getChildren(nodeRef, Mode.SUB_CATEGORIES, Depth.IMMEDIATE, sortByName, alikeNamesFilter, skipCount + maxItems + 1));
|
||||
}
|
||||
}
|
||||
|
||||
Stream<ChildAssociationRef> childNodesStream = childNodes.stream();
|
||||
if (sortByName)
|
||||
{
|
||||
childNodesStream = childNodesStream.sorted(Comparator.comparing(tag -> tag.getQName().getLocalName()));
|
||||
}
|
||||
return childNodesStream.collect(Collectors.toList());
|
||||
};
|
||||
return childNodesSupplier;
|
||||
}
|
||||
|
||||
public Collection<ChildAssociationRef> getRootCategories(StoreRef storeRef, QName aspectName)
|
||||
{
|
||||
return getRootCategories(storeRef, aspectName, null);
|
||||
|
@@ -504,21 +504,6 @@ public class ResetPasswordServiceImpl implements ResetPasswordService
|
||||
return UrlUtil.replaceShareUrlPlaceholder(url, sysAdminParams);
|
||||
}
|
||||
|
||||
private String getRepoBaseUrl(String url, String propName)
|
||||
{
|
||||
if (url == null)
|
||||
{
|
||||
LOGGER.warn("The url for the property [" + propName + "] is not configured.");
|
||||
return "";
|
||||
}
|
||||
|
||||
if (url.endsWith("/"))
|
||||
{
|
||||
url = url.substring(0, url.length() - 1);
|
||||
}
|
||||
return UrlUtil.replaceRepoBaseUrlPlaceholder(url, sysAdminParams);
|
||||
}
|
||||
|
||||
protected String getResetPasswordEmailTemplate(ClientApp clientApp)
|
||||
{
|
||||
return clientApp.getProperty("requestResetPasswordTemplatePath");
|
||||
@@ -537,16 +522,7 @@ public class ResetPasswordServiceImpl implements ResetPasswordService
|
||||
StringBuilder sb = new StringBuilder(100);
|
||||
|
||||
String pageUrl = clientApp.getProperty("resetPasswordPageUrl");
|
||||
|
||||
if(!StringUtils.isEmpty(clientApp.getProperty("workspaceUrl")))
|
||||
{
|
||||
String workspaceUrlPlaceholder = clientApp.getProperty("workspaceUrl");
|
||||
String workSpaceUrl = getRepoBaseUrl(workspaceUrlPlaceholder,"");
|
||||
sb.append(UrlUtil.replaceWorkSpaceUrlPlaceholder(pageUrl,workSpaceUrl));
|
||||
LOGGER.warn("Client Name is " + clientApp.getName() + " The url used is " + sb.toString());
|
||||
|
||||
}
|
||||
else if(StringUtils.isEmpty(pageUrl))
|
||||
if (StringUtils.isEmpty(pageUrl))
|
||||
{
|
||||
sb.append(UrlUtil.getShareUrl(sysAdminParams));
|
||||
|
||||
@@ -559,7 +535,7 @@ public class ResetPasswordServiceImpl implements ResetPasswordService
|
||||
sb.append(getUrl(pageUrl, ""));
|
||||
}
|
||||
|
||||
sb.append("?key=").append(key)
|
||||
sb.append("?key=").append(key)
|
||||
.append("&id=").append(BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, id));
|
||||
|
||||
return sb.toString();
|
||||
|
@@ -26,9 +26,7 @@
|
||||
package org.alfresco.repo.security.authentication.identityservice;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
/**
|
||||
@@ -36,12 +34,9 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
*/
|
||||
public class IdentityServiceConfig implements InitializingBean
|
||||
public class IdentityServiceConfig
|
||||
{
|
||||
private static final String REALMS = "realms";
|
||||
private static final String CREDENTIALS_SECRET = "identity-service.credentials.secret";
|
||||
|
||||
private Properties globalProperties;
|
||||
|
||||
private int clientConnectionTimeout;
|
||||
private int clientSocketTimeout;
|
||||
@@ -59,11 +54,8 @@ public class IdentityServiceConfig implements InitializingBean
|
||||
private String clientKeystorePassword;
|
||||
private String clientKeyPassword;
|
||||
private String realmKey;
|
||||
|
||||
public void setGlobalProperties(Properties globalProperties)
|
||||
{
|
||||
this.globalProperties = globalProperties;
|
||||
}
|
||||
private int publicKeyCacheTtl;
|
||||
private boolean publicClient;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -111,12 +103,6 @@ public class IdentityServiceConfig implements InitializingBean
|
||||
return connectionPoolSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
clientSecret = this.globalProperties.getProperty(CREDENTIALS_SECRET);
|
||||
}
|
||||
|
||||
public String getAuthServerUrl()
|
||||
{
|
||||
return authServerUrl;
|
||||
@@ -147,6 +133,11 @@ public class IdentityServiceConfig implements InitializingBean
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
public void setClientSecret(String clientSecret)
|
||||
{
|
||||
this.clientSecret = clientSecret;
|
||||
}
|
||||
|
||||
public String getClientSecret()
|
||||
{
|
||||
return Optional.ofNullable(clientSecret)
|
||||
@@ -240,4 +231,24 @@ public class IdentityServiceConfig implements InitializingBean
|
||||
{
|
||||
return realmKey;
|
||||
}
|
||||
|
||||
public void setPublicKeyCacheTtl(int publicKeyCacheTtl)
|
||||
{
|
||||
this.publicKeyCacheTtl = publicKeyCacheTtl;
|
||||
}
|
||||
|
||||
public int getPublicKeyCacheTtl()
|
||||
{
|
||||
return publicKeyCacheTtl;
|
||||
}
|
||||
|
||||
public void setPublicClient(boolean publicClient)
|
||||
{
|
||||
this.publicClient = publicClient;
|
||||
}
|
||||
|
||||
public boolean isPublicClient()
|
||||
{
|
||||
return publicClient;
|
||||
}
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.time.Duration;
|
||||
@@ -42,11 +43,20 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.nimbusds.jose.JWSAlgorithm;
|
||||
import com.nimbusds.jose.jwk.source.DefaultJWKSetCache;
|
||||
import com.nimbusds.jose.jwk.source.JWKSource;
|
||||
import com.nimbusds.jose.jwk.source.RemoteJWKSet;
|
||||
import com.nimbusds.jose.proc.JWSVerificationKeySelector;
|
||||
import com.nimbusds.jose.proc.SecurityContext;
|
||||
import com.nimbusds.jose.util.ResourceRetriever;
|
||||
import com.nimbusds.jwt.proc.ConfigurableJWTProcessor;
|
||||
import com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadata;
|
||||
|
||||
import org.alfresco.repo.security.authentication.identityservice.IdentityServiceFacade.IdentityServiceFacadeException;
|
||||
@@ -253,8 +263,8 @@ public class IdentityServiceFacadeFactoryBean implements FactoryBean<IdentitySer
|
||||
{
|
||||
HttpClientBuilder clientBuilder = HttpClients.custom();
|
||||
|
||||
clientBuilder = applyConnectionConfiguration(clientBuilder);
|
||||
clientBuilder = applySSLConfiguration(clientBuilder);
|
||||
applyConnectionConfiguration(clientBuilder);
|
||||
applySSLConfiguration(clientBuilder);
|
||||
|
||||
return clientBuilder.build();
|
||||
}
|
||||
@@ -264,18 +274,18 @@ public class IdentityServiceFacadeFactoryBean implements FactoryBean<IdentitySer
|
||||
}
|
||||
}
|
||||
|
||||
private HttpClientBuilder applyConnectionConfiguration(HttpClientBuilder builder)
|
||||
private void applyConnectionConfiguration(HttpClientBuilder builder)
|
||||
{
|
||||
final RequestConfig requestConfig = RequestConfig.custom()
|
||||
.setConnectTimeout(config.getClientConnectionTimeout())
|
||||
.setSocketTimeout(config.getClientSocketTimeout())
|
||||
.build();
|
||||
|
||||
return builder.setDefaultRequestConfig(requestConfig)
|
||||
.setMaxConnTotal(config.getConnectionPoolSize());
|
||||
builder.setDefaultRequestConfig(requestConfig)
|
||||
.setMaxConnTotal(config.getConnectionPoolSize());
|
||||
}
|
||||
|
||||
private HttpClientBuilder applySSLConfiguration(HttpClientBuilder builder) throws Exception
|
||||
private void applySSLConfiguration(HttpClientBuilder builder) throws Exception
|
||||
{
|
||||
SSLContextBuilder sslContextBuilder = null;
|
||||
if (config.isDisableTrustManager())
|
||||
@@ -311,8 +321,6 @@ public class IdentityServiceFacadeFactoryBean implements FactoryBean<IdentitySer
|
||||
{
|
||||
builder.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE);
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
private char[] asCharArray(String value, char[] nullValue)
|
||||
@@ -342,21 +350,36 @@ public class IdentityServiceFacadeFactoryBean implements FactoryBean<IdentitySer
|
||||
.map(Optional::get)
|
||||
.findFirst()
|
||||
.map(this::createBuilder)
|
||||
.map(this::configureClientAuthentication)
|
||||
.map(Builder::build)
|
||||
.orElseThrow(() -> new IllegalStateException("Failed to create ClientRegistration."));
|
||||
}
|
||||
|
||||
private ClientRegistration.Builder createBuilder(OIDCProviderMetadata metadata)
|
||||
{
|
||||
final String authUri = Optional.of(metadata)
|
||||
.map(OIDCProviderMetadata::getAuthorizationEndpointURI)
|
||||
.map(URI::toASCIIString)
|
||||
.orElse(null);
|
||||
return ClientRegistration
|
||||
.withRegistrationId("ids")
|
||||
.authorizationUri(authUri)
|
||||
.tokenUri(metadata.getTokenEndpointURI().toASCIIString())
|
||||
.jwkSetUri(metadata.getJWKSetURI().toASCIIString())
|
||||
.issuerUri(config.getIssuerUrl())
|
||||
.clientId(config.getResource())
|
||||
.clientSecret(config.getClientSecret())
|
||||
.authorizationGrantType(AuthorizationGrantType.PASSWORD)
|
||||
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC);
|
||||
.authorizationGrantType(AuthorizationGrantType.PASSWORD);
|
||||
}
|
||||
|
||||
private Builder configureClientAuthentication(Builder builder)
|
||||
{
|
||||
builder.clientId(config.getResource());
|
||||
if (config.isPublicClient())
|
||||
{
|
||||
return builder.clientSecret(null)
|
||||
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_POST);
|
||||
}
|
||||
return builder.clientSecret(config.getClientSecret())
|
||||
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC);
|
||||
}
|
||||
|
||||
private Optional<OIDCProviderMetadata> extractMetadata(RestOperations rest, URI metadataUri)
|
||||
@@ -437,9 +460,45 @@ public class IdentityServiceFacadeFactoryBean implements FactoryBean<IdentitySer
|
||||
return NimbusJwtDecoder.withJwkSetUri(jwkSetUri)
|
||||
.jwsAlgorithm(SIGNATURE_ALGORITHM)
|
||||
.restOperations(rest)
|
||||
.jwtProcessorCustomizer(this::reconfigureJWKSCache)
|
||||
.build();
|
||||
}
|
||||
|
||||
private void reconfigureJWKSCache(ConfigurableJWTProcessor<SecurityContext> jwtProcessor)
|
||||
{
|
||||
final Optional<RemoteJWKSet<SecurityContext>> jwkSource = ofNullable(jwtProcessor)
|
||||
.map(ConfigurableJWTProcessor::getJWSKeySelector)
|
||||
.filter(JWSVerificationKeySelector.class::isInstance).map(o -> (JWSVerificationKeySelector<SecurityContext>)o)
|
||||
.map(JWSVerificationKeySelector::getJWKSource)
|
||||
.filter(RemoteJWKSet.class::isInstance).map(o -> (RemoteJWKSet<SecurityContext>)o);
|
||||
if (jwkSource.isEmpty())
|
||||
{
|
||||
LOGGER.warn("Not able to reconfigure the JWK Cache. Unexpected JWKSource.");
|
||||
return;
|
||||
}
|
||||
|
||||
final Optional<URL> jwkSetUrl = jwkSource.map(RemoteJWKSet::getJWKSetURL);
|
||||
if (jwkSetUrl.isEmpty())
|
||||
{
|
||||
LOGGER.warn("Not able to reconfigure the JWK Cache. Unknown JWKSetURL.");
|
||||
return;
|
||||
}
|
||||
|
||||
final Optional<ResourceRetriever> resourceRetriever = jwkSource.map(RemoteJWKSet::getResourceRetriever);
|
||||
if (resourceRetriever.isEmpty())
|
||||
{
|
||||
LOGGER.warn("Not able to reconfigure the JWK Cache. Unknown ResourceRetriever.");
|
||||
return;
|
||||
}
|
||||
|
||||
final DefaultJWKSetCache cache = new DefaultJWKSetCache(config.getPublicKeyCacheTtl(), -1, TimeUnit.SECONDS);
|
||||
final JWKSource<SecurityContext> cachingJWKSource = new RemoteJWKSet<>(jwkSetUrl.get(), resourceRetriever.get(), cache);
|
||||
|
||||
jwtProcessor.setJWSKeySelector(new JWSVerificationKeySelector<>(
|
||||
JWSAlgorithm.parse(SIGNATURE_ALGORITHM.getName()),
|
||||
cachingJWKSource));
|
||||
}
|
||||
|
||||
private OAuth2TokenValidator<Jwt> createJwtTokenValidator(ProviderDetails providerDetails)
|
||||
{
|
||||
return new DelegatingOAuth2TokenValidator<>(
|
||||
|
@@ -25,6 +25,14 @@
|
||||
*/
|
||||
package org.alfresco.repo.tagging;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
||||
import static org.alfresco.model.ContentModel.ASPECT_WORKING_COPY;
|
||||
import static org.alfresco.model.ContentModel.ASSOC_SUBCATEGORIES;
|
||||
import static org.alfresco.model.ContentModel.PROP_NAME;
|
||||
import static org.alfresco.service.cmr.search.SearchService.LANGUAGE_LUCENE;
|
||||
import static org.alfresco.service.namespace.NamespaceService.CONTENT_MODEL_1_0_URI;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -38,23 +46,28 @@ import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.EmptyPagingResults;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.audit.AuditComponent;
|
||||
import org.alfresco.repo.coci.CheckOutCheckInServicePolicies;
|
||||
import org.alfresco.repo.copy.CopyServicePolicies;
|
||||
import org.alfresco.repo.coci.CheckOutCheckInServicePolicies.OnCheckOut;
|
||||
import org.alfresco.repo.copy.CopyServicePolicies.BeforeCopyPolicy;
|
||||
import org.alfresco.repo.copy.CopyServicePolicies.OnCopyCompletePolicy;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
import org.alfresco.repo.domain.query.QueryException;
|
||||
import org.alfresco.repo.event2.EventGenerator;
|
||||
import org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy;
|
||||
import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy;
|
||||
import org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy;
|
||||
import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy;
|
||||
@@ -90,6 +103,7 @@ import org.alfresco.util.ISO9075;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -100,19 +114,19 @@ import org.apache.commons.logging.LogFactory;
|
||||
*/
|
||||
public class TaggingServiceImpl implements TaggingService,
|
||||
TransactionListener,
|
||||
NodeServicePolicies.BeforeDeleteNodePolicy,
|
||||
NodeServicePolicies.OnMoveNodePolicy,
|
||||
CopyServicePolicies.OnCopyCompletePolicy,
|
||||
CopyServicePolicies.BeforeCopyPolicy
|
||||
BeforeDeleteNodePolicy,
|
||||
OnMoveNodePolicy,
|
||||
OnCopyCompletePolicy,
|
||||
BeforeCopyPolicy
|
||||
{
|
||||
protected static final String TAGGING_AUDIT_APPLICATION_NAME = "Alfresco Tagging Service";
|
||||
protected static final String TAGGING_AUDIT_ROOT_PATH = "/tagging";
|
||||
protected static final String TAGGING_AUDIT_KEY_NODEREF = "node";
|
||||
protected static final String TAGGING_AUDIT_KEY_TAGS = "tags";
|
||||
|
||||
|
||||
private static Log logger = LogFactory.getLog(TaggingServiceImpl.class);
|
||||
|
||||
private static Collator collator = Collator.getInstance();
|
||||
private static Collator collator = Collator.getInstance();
|
||||
|
||||
private NodeService nodeService;
|
||||
private NodeService nodeServiceInternal;
|
||||
@@ -123,18 +137,22 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
private NamespaceService namespaceService;
|
||||
private PolicyComponent policyComponent;
|
||||
private AuditComponent auditComponent;
|
||||
|
||||
private EventGenerator eventGenerator;
|
||||
|
||||
/** Tag Details Delimiter */
|
||||
private static final String TAG_DETAILS_DELIMITER = "|";
|
||||
/** Next tag delimiter */
|
||||
private static final String NEXT_TAG_DELIMITER = "\n";
|
||||
|
||||
/** Parameters Include count */
|
||||
private static final String PARAM_INCLUDE_COUNT = "count";
|
||||
|
||||
|
||||
private static Set<String> FORBIDDEN_TAGS_SEQUENCES = new HashSet<String>(Arrays.asList(new String[] {NEXT_TAG_DELIMITER, TAG_DETAILS_DELIMITER}));
|
||||
|
||||
|
||||
/** Policy behaviour */
|
||||
private JavaBehaviour updateTagBehaviour;
|
||||
private JavaBehaviour createTagBehaviour;
|
||||
|
||||
|
||||
/**
|
||||
* Set the cateogry service
|
||||
*/
|
||||
@@ -206,7 +224,16 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
{
|
||||
this.auditComponent = auditComponent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the event generator.
|
||||
* @param eventGenerator
|
||||
*/
|
||||
public void setEventGenerator(EventGenerator eventGenerator)
|
||||
{
|
||||
this.eventGenerator = eventGenerator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*/
|
||||
@@ -253,7 +280,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
new JavaBehaviour(this, "onCopyComplete", NotificationFrequency.EVERY_EVENT));
|
||||
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
CheckOutCheckInServicePolicies.OnCheckOut.QNAME,
|
||||
OnCheckOut.QNAME,
|
||||
ContentModel.ASPECT_TAGGABLE,
|
||||
new JavaBehaviour(this, "afterCheckOut", NotificationFrequency.EVERY_EVENT));
|
||||
}
|
||||
@@ -311,12 +338,12 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef)
|
||||
* @see BeforeDeleteNodePolicy#beforeDeleteNode(NodeRef)
|
||||
*/
|
||||
public void beforeDeleteNode(NodeRef nodeRef)
|
||||
{
|
||||
if (this.nodeService.exists(nodeRef) == true &&
|
||||
this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TAGGABLE) == true && !this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
|
||||
this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TAGGABLE) == true && !this.nodeService.hasAspect(nodeRef, ASPECT_WORKING_COPY))
|
||||
{
|
||||
updateAllScopeTags(nodeRef, Boolean.FALSE);
|
||||
}
|
||||
@@ -456,11 +483,11 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
|
||||
public String getTagName(NodeRef nodeRef)
|
||||
{
|
||||
return (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
return (String)nodeService.getProperty(nodeRef, PROP_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#isTag(StoreRef, java.lang.String)
|
||||
* @see TaggingService#isTag(StoreRef, String)
|
||||
*/
|
||||
public boolean isTag(StoreRef storeRef, String tag)
|
||||
{
|
||||
@@ -469,18 +496,18 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#createTag(StoreRef, java.lang.String)
|
||||
* @see TaggingService#createTag(StoreRef, String)
|
||||
*/
|
||||
public NodeRef createTag(StoreRef storeRef, String tag)
|
||||
{
|
||||
// Lower the case of the tag
|
||||
tag = tag.toLowerCase();
|
||||
|
||||
return getTagNodeRef(storeRef, tag, true);
|
||||
|
||||
return getTagNodeRef(storeRef, tag, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#deleteTag(org.alfresco.service.cmr.repository.StoreRef, java.lang.String)
|
||||
* @see TaggingService#deleteTag(StoreRef, String)
|
||||
*/
|
||||
public void deleteTag(StoreRef storeRef, String tag)
|
||||
{
|
||||
@@ -505,45 +532,51 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
|
||||
public NodeRef changeTag(StoreRef storeRef, String existingTag, String newTag)
|
||||
{
|
||||
if (existingTag == null)
|
||||
{
|
||||
throw new TaggingException("Existing tag cannot be null");
|
||||
}
|
||||
|
||||
if (newTag == null)
|
||||
{
|
||||
throw new TaggingException("New tag cannot be null");
|
||||
}
|
||||
|
||||
if (existingTag.equals(newTag))
|
||||
{
|
||||
throw new TaggingException("New and existing tags are the same");
|
||||
}
|
||||
|
||||
if (getTagNodeRef(storeRef, existingTag) == null)
|
||||
{
|
||||
throw new NonExistentTagException("Tag " + existingTag + " not found");
|
||||
}
|
||||
|
||||
if (getTagNodeRef(storeRef, newTag) != null)
|
||||
{
|
||||
throw new TagExistsException("Tag " + newTag + " already exists");
|
||||
}
|
||||
|
||||
List<NodeRef> taggedNodes = findTaggedNodes(storeRef, existingTag);
|
||||
for (NodeRef nodeRef : taggedNodes)
|
||||
if (existingTag == null)
|
||||
{
|
||||
removeTag(nodeRef, existingTag);
|
||||
addTag(nodeRef, newTag);
|
||||
throw new TaggingException("Existing tag cannot be null");
|
||||
}
|
||||
|
||||
deleteTag(storeRef, existingTag);
|
||||
if (newTag == null || StringUtils.isBlank(newTag))
|
||||
{
|
||||
throw new TaggingException("New tag cannot be blank");
|
||||
}
|
||||
|
||||
return getTagNodeRef(storeRef, newTag, true);
|
||||
existingTag = existingTag.toLowerCase();
|
||||
newTag = newTag.toLowerCase();
|
||||
|
||||
if (existingTag.equals(newTag))
|
||||
{
|
||||
throw new TaggingException("New and existing tags are the same");
|
||||
}
|
||||
|
||||
if (getTagNodeRef(storeRef, existingTag) == null)
|
||||
{
|
||||
throw new NonExistentTagException("Tag " + existingTag + " not found");
|
||||
}
|
||||
|
||||
if (getTagNodeRef(storeRef, newTag) != null)
|
||||
{
|
||||
throw new TagExistsException("Tag " + newTag + " already exists");
|
||||
}
|
||||
|
||||
NodeRef tagNodeRef = getTagNodeRef(storeRef, existingTag);
|
||||
nodeService.setProperty(tagNodeRef, PROP_NAME, newTag);
|
||||
nodeService.moveNode(tagNodeRef, TAG_ROOT_NODE_REF, ASSOC_SUBCATEGORIES, QName.createQName(CONTENT_MODEL_1_0_URI, newTag));
|
||||
|
||||
// Raise events on all tagged nodes and also fix the tag scopes.
|
||||
List<NodeRef> taggedNodes = findTaggedNodes(storeRef, existingTag);
|
||||
for (NodeRef nodeRef : taggedNodes)
|
||||
{
|
||||
eventGenerator.onUpdateProperties(nodeRef, emptyMap(), nodeService.getProperties(nodeRef));
|
||||
updateTagScope(nodeRef, Map.of(existingTag, false, newTag, true));
|
||||
}
|
||||
|
||||
return tagNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#getTags(StoreRef)
|
||||
* @see TaggingService#getTags(StoreRef)
|
||||
*/
|
||||
public List<String> getTags(StoreRef storeRef)
|
||||
{
|
||||
@@ -553,7 +586,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
List<String> result = new ArrayList<String>(rootCategories.size());
|
||||
for (ChildAssociationRef rootCategory : rootCategories)
|
||||
{
|
||||
String name = (String)this.nodeService.getProperty(rootCategory.getChildRef(), ContentModel.PROP_NAME);
|
||||
String name = (String)this.nodeService.getProperty(rootCategory.getChildRef(), PROP_NAME);
|
||||
result.add(name);
|
||||
}
|
||||
return result;
|
||||
@@ -579,7 +612,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String name = (String)this.nodeService.getProperty(rootCategory.getChildRef(), ContentModel.PROP_NAME);
|
||||
String name = (String)this.nodeService.getProperty(rootCategory.getChildRef(), PROP_NAME);
|
||||
result.add(name);
|
||||
if (index == endIndex)
|
||||
{
|
||||
@@ -590,7 +623,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#getTags(org.alfresco.service.cmr.repository.StoreRef, java.lang.String)
|
||||
* @see TaggingService#getTags(StoreRef, String)
|
||||
*/
|
||||
public List<String> getTags(StoreRef storeRef, String filter)
|
||||
{
|
||||
@@ -607,7 +640,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
result = new ArrayList<String>(rootCategories.size());
|
||||
for (ChildAssociationRef rootCategory : rootCategories)
|
||||
{
|
||||
String name = (String)this.nodeService.getProperty(rootCategory.getChildRef(), ContentModel.PROP_NAME);
|
||||
String name = (String)this.nodeService.getProperty(rootCategory.getChildRef(), PROP_NAME);
|
||||
if (name.contains(filter.toLowerCase()) == true)
|
||||
{
|
||||
result.add(name);
|
||||
@@ -644,7 +677,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String name = (String)this.nodeService.getProperty(rootCategory.getChildRef(), ContentModel.PROP_NAME);
|
||||
String name = (String)this.nodeService.getProperty(rootCategory.getChildRef(), PROP_NAME);
|
||||
result.add(name);
|
||||
if (index == endIndex)
|
||||
{
|
||||
@@ -655,8 +688,23 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Long> calculateCount(StoreRef storeRef)
|
||||
{
|
||||
List<Pair<String, Integer>> tagsByCount = findTaggedNodesAndCountByTagName(storeRef);
|
||||
Map<String, Long> tagsByCountMap = new HashMap<>();
|
||||
if (tagsByCount != null)
|
||||
{
|
||||
for (Pair<String, Integer> tagByCountElem : tagsByCount)
|
||||
{
|
||||
tagsByCountMap.put(tagByCountElem.getFirst(), Long.valueOf(tagByCountElem.getSecond()));
|
||||
}
|
||||
}
|
||||
return tagsByCountMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#hasTag(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||
* @see TaggingService#hasTag(NodeRef, String)
|
||||
*/
|
||||
public boolean hasTag(NodeRef nodeRef, String tag)
|
||||
{
|
||||
@@ -665,17 +713,17 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#addTag(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||
* @see TaggingService#addTag(NodeRef, String)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public NodeRef addTag(final NodeRef nodeRef, final String tagName)
|
||||
{
|
||||
NodeRef newTagNodeRef = null;
|
||||
|
||||
if(tagName == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Must provide a non-null tag");
|
||||
}
|
||||
NodeRef newTagNodeRef = null;
|
||||
|
||||
if(tagName == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Must provide a non-null tag");
|
||||
}
|
||||
|
||||
updateTagBehaviour.disable();
|
||||
createTagBehaviour.disable();
|
||||
@@ -721,11 +769,11 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#addTags(org.alfresco.service.cmr.repository.NodeRef, java.util.List)
|
||||
* @see TaggingService#addTags(NodeRef, List)
|
||||
*/
|
||||
public List<Pair<String, NodeRef>> addTags(NodeRef nodeRef, List<String> tags)
|
||||
{
|
||||
List<Pair<String, NodeRef>> ret = new ArrayList<Pair<String, NodeRef>>();
|
||||
List<Pair<String, NodeRef>> ret = new ArrayList<Pair<String, NodeRef>>();
|
||||
for (String tag : tags)
|
||||
{
|
||||
NodeRef tagNodeRef = addTag(nodeRef, tag);
|
||||
@@ -778,7 +826,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#removeTag(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||
* @see TaggingService#removeTag(NodeRef, String)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void removeTag(NodeRef nodeRef, String tag)
|
||||
@@ -818,7 +866,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#removeTags(org.alfresco.service.cmr.repository.NodeRef, java.util.List)
|
||||
* @see TaggingService#removeTags(NodeRef, List)
|
||||
*/
|
||||
public void removeTags(NodeRef nodeRef, List<String> tags)
|
||||
{
|
||||
@@ -829,7 +877,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#getTags(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.query.PagingRequest)
|
||||
* @see TaggingService#getTags(NodeRef, PagingRequest)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// TODO canned query
|
||||
@@ -846,36 +894,36 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
int skipCount = pagingRequest.getSkipCount();
|
||||
int maxItems = pagingRequest.getMaxItems();
|
||||
int end = maxItems == Integer.MAX_VALUE ? totalItems : skipCount + maxItems;
|
||||
int size = (maxItems == Integer.MAX_VALUE ? totalItems : maxItems);
|
||||
int size = (maxItems == Integer.MAX_VALUE ? totalItems : maxItems);
|
||||
|
||||
final List<Pair<NodeRef, String>> sortedTags = new ArrayList<Pair<NodeRef, String>>(size);
|
||||
// grab all tags and sort (assume fairly low number of tags)
|
||||
for(NodeRef tagNode : currentTagNodes)
|
||||
{
|
||||
String tag = (String)this.nodeService.getProperty(tagNode, ContentModel.PROP_NAME);
|
||||
// grab all tags and sort (assume fairly low number of tags)
|
||||
for(NodeRef tagNode : currentTagNodes)
|
||||
{
|
||||
String tag = (String)this.nodeService.getProperty(tagNode, PROP_NAME);
|
||||
sortedTags.add(new Pair<NodeRef, String>(tagNode, tag));
|
||||
}
|
||||
}
|
||||
Collections.sort(sortedTags, new Comparator<Pair<NodeRef, String>>()
|
||||
{
|
||||
@Override
|
||||
public int compare(Pair<NodeRef, String> o1, Pair<NodeRef, String> o2)
|
||||
{
|
||||
String tag1 = o1.getSecond();
|
||||
String tag2 = o2.getSecond();
|
||||
return collator.compare(tag1, tag2);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public int compare(Pair<NodeRef, String> o1, Pair<NodeRef, String> o2)
|
||||
{
|
||||
String tag1 = o1.getSecond();
|
||||
String tag2 = o2.getSecond();
|
||||
return collator.compare(tag1, tag2);
|
||||
}
|
||||
});
|
||||
|
||||
final List<Pair<NodeRef, String>> result = new ArrayList<Pair<NodeRef, String>>(size);
|
||||
Iterator<Pair<NodeRef, String>> it = sortedTags.iterator();
|
||||
Iterator<Pair<NodeRef, String>> it = sortedTags.iterator();
|
||||
for(int count = 0; count < end && it.hasNext(); count++)
|
||||
{
|
||||
Pair<NodeRef, String> tagPair = it.next();
|
||||
Pair<NodeRef, String> tagPair = it.next();
|
||||
|
||||
if(count < skipCount)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(count < skipCount)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
result.add(tagPair);
|
||||
}
|
||||
@@ -884,30 +932,30 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
|
||||
return new PagingResults<Pair<NodeRef, String>>()
|
||||
{
|
||||
@Override
|
||||
public List<Pair<NodeRef, String>> getPage()
|
||||
{
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public List<Pair<NodeRef, String>> getPage()
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreItems()
|
||||
{
|
||||
return hasMoreItems;
|
||||
}
|
||||
@Override
|
||||
public boolean hasMoreItems()
|
||||
{
|
||||
return hasMoreItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Integer> getTotalResultCount()
|
||||
{
|
||||
Integer total = Integer.valueOf(totalItems);
|
||||
return new Pair<Integer, Integer>(total, total);
|
||||
}
|
||||
@Override
|
||||
public Pair<Integer, Integer> getTotalResultCount()
|
||||
{
|
||||
Integer total = Integer.valueOf(totalItems);
|
||||
return new Pair<Integer, Integer>(total, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryExecutionId()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public String getQueryExecutionId()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -921,7 +969,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#getTags(org.alfresco.service.cmr.repository.StoreRef, org.alfresco.query.PagingRequest)
|
||||
* @see TaggingService#getTags(StoreRef, PagingRequest)
|
||||
*/
|
||||
public PagingResults<Pair<NodeRef, String>> getTags(StoreRef storeRef, PagingRequest pagingRequest, Collection<String> exactNamesFilter, Collection<String> alikeNamesFilter)
|
||||
{
|
||||
@@ -931,11 +979,87 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
exactNamesFilter, alikeNamesFilter);
|
||||
|
||||
return mapPagingResult(rootCategories,
|
||||
(childAssociation) -> new Pair<>(childAssociation.getChildRef(), childAssociation.getQName().getLocalName()));
|
||||
(childAssociation) -> new Pair<>(childAssociation.getChildRef(), childAssociation.getQName().getLocalName()));
|
||||
}
|
||||
|
||||
public Map<NodeRef, Long> getTags(StoreRef storeRef, List<String> parameterIncludes, Pair<String, Boolean> sorting, Collection<String> exactNamesFilter, Collection<String> alikeNamesFilter)
|
||||
{
|
||||
ParameterCheck.mandatory("storeRef", storeRef);
|
||||
Collection<ChildAssociationRef> rootCategories = categoryService.getRootCategories(storeRef, ContentModel.ASPECT_TAGGABLE, exactNamesFilter, alikeNamesFilter);
|
||||
|
||||
Map<String, Long> tagsMap = new TreeMap<>();
|
||||
for (ChildAssociationRef childAssociation : rootCategories)
|
||||
{
|
||||
tagsMap.put(childAssociation.getQName().getLocalName(), 0L);
|
||||
}
|
||||
|
||||
Map<String, Long> tagsByCountMap = new HashMap<>();
|
||||
|
||||
if(parameterIncludes.contains(PARAM_INCLUDE_COUNT))
|
||||
{
|
||||
tagsByCountMap = calculateCount(storeRef);
|
||||
|
||||
for (Map.Entry<String, Long> entry : tagsMap.entrySet()) {
|
||||
entry.setValue(Optional.ofNullable(tagsByCountMap.get(entry.getKey())).orElse(0L));
|
||||
}
|
||||
}
|
||||
|
||||
//check if we should sort results. Can only sort by one parameter, default order is ascending
|
||||
if (sorting != null)
|
||||
{
|
||||
if (sorting.getFirst().equals("tag"))
|
||||
{
|
||||
if (!sorting.getSecond())
|
||||
{
|
||||
Stream<Map.Entry<String,Long>> sortedTags =
|
||||
tagsMap.entrySet().stream()
|
||||
.sorted(Collections.reverseOrder(Map.Entry.comparingByKey()));
|
||||
tagsMap = sortedTags.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
|
||||
}
|
||||
else
|
||||
{
|
||||
Stream<Map.Entry<String,Long>> sortedTags =
|
||||
tagsMap.entrySet().stream()
|
||||
.sorted(Map.Entry.comparingByKey());
|
||||
tagsMap = sortedTags.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
|
||||
}
|
||||
}
|
||||
else if (sorting.getFirst().equals(PARAM_INCLUDE_COUNT))
|
||||
{
|
||||
if (tagsByCountMap.isEmpty())
|
||||
{
|
||||
throw new IllegalArgumentException("Tag count should be included when ordering by count");
|
||||
}
|
||||
|
||||
if (!sorting.getSecond())
|
||||
{
|
||||
Stream<Map.Entry<String, Long>> sortedTags =
|
||||
tagsMap.entrySet().stream()
|
||||
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue()));
|
||||
tagsMap = sortedTags.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
|
||||
}
|
||||
else
|
||||
{
|
||||
Stream<Map.Entry<String,Long>> sortedTags =
|
||||
tagsMap.entrySet().stream()
|
||||
.sorted(Map.Entry.comparingByValue());
|
||||
tagsMap = sortedTags.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<NodeRef, Long> tagNodeRefMap = new LinkedHashMap<>();
|
||||
|
||||
for (Map.Entry<String, Long> entry : tagsMap.entrySet())
|
||||
{
|
||||
tagNodeRefMap.put(getTagNodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, entry.getKey()), entry.getValue());
|
||||
}
|
||||
|
||||
return tagNodeRefMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#getTags(org.alfresco.service.cmr.repository.NodeRef)
|
||||
* @see TaggingService#getTags(NodeRef)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getTags(NodeRef nodeRef)
|
||||
@@ -951,7 +1075,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
{
|
||||
for (NodeRef currentTagNode : currentTagNodes)
|
||||
{
|
||||
String tag = (String)this.nodeService.getProperty(currentTagNode, ContentModel.PROP_NAME);
|
||||
String tag = (String)this.nodeService.getProperty(currentTagNode, PROP_NAME);
|
||||
result.add(tag);
|
||||
}
|
||||
}
|
||||
@@ -961,7 +1085,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#setTags(org.alfresco.service.cmr.repository.NodeRef, java.util.List)
|
||||
* @see TaggingService#setTags(NodeRef, List)
|
||||
*/
|
||||
public void setTags(NodeRef nodeRef, List<String> tags)
|
||||
{
|
||||
@@ -1022,7 +1146,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#clearTags(org.alfresco.service.cmr.repository.NodeRef)
|
||||
* @see TaggingService#clearTags(NodeRef)
|
||||
*/
|
||||
public void clearTags(NodeRef nodeRef)
|
||||
{
|
||||
@@ -1030,7 +1154,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#isTagScope(org.alfresco.service.cmr.repository.NodeRef)
|
||||
* @see TaggingService#isTagScope(NodeRef)
|
||||
*/
|
||||
public boolean isTagScope(NodeRef nodeRef)
|
||||
{
|
||||
@@ -1039,7 +1163,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#addTagScope(org.alfresco.service.cmr.repository.NodeRef)
|
||||
* @see TaggingService#addTagScope(NodeRef)
|
||||
*/
|
||||
public void addTagScope(NodeRef nodeRef)
|
||||
{
|
||||
@@ -1054,7 +1178,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#refreshTagScope(org.alfresco.service.cmr.repository.NodeRef, boolean)
|
||||
* @see TaggingService#refreshTagScope(NodeRef, boolean)
|
||||
*/
|
||||
public void refreshTagScope(NodeRef nodeRef, boolean async)
|
||||
{
|
||||
@@ -1067,7 +1191,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#removeTagScope(org.alfresco.service.cmr.repository.NodeRef)
|
||||
* @see TaggingService#removeTagScope(NodeRef)
|
||||
*/
|
||||
public void removeTagScope(NodeRef nodeRef)
|
||||
{
|
||||
@@ -1078,7 +1202,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#findTagScope(org.alfresco.service.cmr.repository.NodeRef)
|
||||
* @see TaggingService#findTagScope(NodeRef)
|
||||
*/
|
||||
public TagScope findTagScope(NodeRef nodeRef)
|
||||
{
|
||||
@@ -1115,7 +1239,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#findAllTagScopes(org.alfresco.service.cmr.repository.NodeRef)
|
||||
* @see TaggingService#findAllTagScopes(NodeRef)
|
||||
*/
|
||||
public List<TagScope> findAllTagScopes(NodeRef nodeRef)
|
||||
{
|
||||
@@ -1165,15 +1289,15 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
*/
|
||||
private void getTagScopes(final NodeRef nodeRef, List<NodeRef> tagScopes, boolean firstOnly)
|
||||
{
|
||||
Boolean hasAspect = AuthenticationUtil.runAs(new RunAsWork<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public Boolean doWork() throws Exception
|
||||
{
|
||||
return new Boolean(nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TAGSCOPE));
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
|
||||
Boolean hasAspect = AuthenticationUtil.runAs(new RunAsWork<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public Boolean doWork() throws Exception
|
||||
{
|
||||
return new Boolean(nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TAGSCOPE));
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
|
||||
if (Boolean.TRUE.equals(hasAspect) == true)
|
||||
{
|
||||
tagScopes.add(nodeRef);
|
||||
@@ -1184,28 +1308,28 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
NodeRef parent = AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef doWork() throws Exception
|
||||
{
|
||||
NodeRef result = null;
|
||||
ChildAssociationRef assoc = nodeService.getPrimaryParent(nodeRef);
|
||||
if (assoc != null)
|
||||
{
|
||||
result = assoc.getParentRef();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
{
|
||||
@Override
|
||||
public NodeRef doWork() throws Exception
|
||||
{
|
||||
NodeRef result = null;
|
||||
ChildAssociationRef assoc = nodeService.getPrimaryParent(nodeRef);
|
||||
if (assoc != null)
|
||||
{
|
||||
result = assoc.getParentRef();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
|
||||
if (parent != null)
|
||||
{
|
||||
getTagScopes(parent, tagScopes, firstOnly);
|
||||
getTagScopes(parent, tagScopes, firstOnly);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#findTaggedNodes(StoreRef, java.lang.String)
|
||||
* @see TaggingService#findTaggedNodes(StoreRef, String)
|
||||
*/
|
||||
public List<NodeRef> findTaggedNodes(StoreRef storeRef, String tag)
|
||||
{
|
||||
@@ -1218,7 +1342,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
// Do the search for nodes
|
||||
resultSet = this.searchService.query(
|
||||
storeRef,
|
||||
SearchService.LANGUAGE_LUCENE,
|
||||
LANGUAGE_LUCENE,
|
||||
"+PATH:\"/cm:taggable/cm:" + ISO9075.encode(tag) + "/member\"");
|
||||
List<NodeRef> nodeRefs = resultSet.getNodeRefs();
|
||||
return nodeRefs;
|
||||
@@ -1230,7 +1354,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#findTaggedNodes(StoreRef, java.lang.String, org.alfresco.service.cmr.repository.NodeRef)
|
||||
* @see TaggingService#findTaggedNodes(StoreRef, String, NodeRef)
|
||||
*/
|
||||
public List<NodeRef> findTaggedNodes(StoreRef storeRef, String tag, NodeRef nodeRef)
|
||||
{
|
||||
@@ -1247,7 +1371,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
// Do query
|
||||
resultSet = this.searchService.query(
|
||||
storeRef,
|
||||
SearchService.LANGUAGE_LUCENE,
|
||||
LANGUAGE_LUCENE,
|
||||
"+PATH:\"" + pathString + "//*\" +PATH:\"/cm:taggable/cm:" + ISO9075.encode(tag) + "/member\"");
|
||||
List<NodeRef> nodeRefs = resultSet.getNodeRefs();
|
||||
return nodeRefs;
|
||||
@@ -1459,7 +1583,7 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
// ===== Transaction Listener Callback Methods ===== //
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.transaction.TransactionListener#afterCommit()
|
||||
* @see TransactionListener#afterCommit()
|
||||
*/
|
||||
public void afterCommit()
|
||||
{
|
||||
@@ -1467,14 +1591,14 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.transaction.TransactionListener#afterRollback()
|
||||
* @see TransactionListener#afterRollback()
|
||||
*/
|
||||
public void afterRollback()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.transaction.TransactionListener#beforeCommit(boolean)
|
||||
* @see TransactionListener#beforeCommit(boolean)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void beforeCommit(boolean readOnly)
|
||||
@@ -1499,14 +1623,14 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.transaction.TransactionListener#beforeCompletion()
|
||||
* @see TransactionListener#beforeCompletion()
|
||||
*/
|
||||
public void beforeCompletion()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.transaction.TransactionListener#flush()
|
||||
* @see TransactionListener#flush()
|
||||
*/
|
||||
public void flush()
|
||||
{
|
||||
@@ -1515,22 +1639,22 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
public void afterCheckOut(NodeRef workingCopy)
|
||||
{
|
||||
if (this.nodeService.exists(workingCopy) == true && this.nodeService.hasAspect(workingCopy, ContentModel.ASPECT_TAGGABLE) == true
|
||||
&& this.nodeService.hasAspect(workingCopy, ContentModel.ASPECT_WORKING_COPY))
|
||||
&& this.nodeService.hasAspect(workingCopy, ASPECT_WORKING_COPY))
|
||||
{
|
||||
updateAllScopeTags(workingCopy, Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.tagging.TaggingService#findTaggedNodesAndCountByTagName(StoreRef)
|
||||
* @see TaggingService#findTaggedNodesAndCountByTagName(StoreRef)
|
||||
*/
|
||||
@Override
|
||||
public List<Pair<String, Integer>> findTaggedNodesAndCountByTagName(StoreRef storeRef)
|
||||
{
|
||||
String queryTaggeble = "ASPECT:\"" + ContentModel.ASPECT_TAGGABLE + "\"" + "-ASPECT:\"" + ContentModel.ASPECT_WORKING_COPY + "\"";
|
||||
String queryTaggeble = "ASPECT:\"" + ContentModel.ASPECT_TAGGABLE + "\"" + "-ASPECT:\"" + ASPECT_WORKING_COPY + "\"";
|
||||
SearchParameters sp = new SearchParameters();
|
||||
sp.setQuery(queryTaggeble);
|
||||
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
|
||||
sp.setLanguage(LANGUAGE_LUCENE);
|
||||
sp.addStore(storeRef);
|
||||
sp.addFieldFacet(new FieldFacet("TAG"));
|
||||
|
||||
@@ -1550,6 +1674,32 @@ public class TaggingServiceImpl implements TaggingService,
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public long findCountByTagName(StoreRef storeRef, String name)
|
||||
{
|
||||
String query = "TAG:\"" + name + "\"" + "-ASPECT:\"" + ASPECT_WORKING_COPY + "\"";
|
||||
SearchParameters sp = new SearchParameters();
|
||||
sp.setQuery(query);
|
||||
sp.setLanguage(LANGUAGE_LUCENE);
|
||||
sp.addStore(storeRef);
|
||||
|
||||
ResultSet resultSet = null;
|
||||
try
|
||||
{
|
||||
// Do the search for nodes
|
||||
resultSet = this.searchService.query(sp);
|
||||
return resultSet.getNumberFound();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (resultSet != null)
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Experimental
|
||||
@Override
|
||||
public List<Pair<String, NodeRef>> createTags(final StoreRef storeRef, final List<String> tagNames)
|
||||
|
@@ -26,6 +26,7 @@
|
||||
package org.alfresco.service.cmr.search;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -150,11 +151,21 @@ public interface CategoryService
|
||||
*/
|
||||
@Auditable(parameters = {"storeRef", "aspectName", "pagingRequest", "sortByName", "exactNamesFilter", "alikeNamesFilter"})
|
||||
default PagingResults<ChildAssociationRef> getRootCategories(StoreRef storeRef, QName aspectName, PagingRequest pagingRequest, boolean sortByName,
|
||||
Collection<String> exactNamesFilter, Collection<String> alikeNamesFilter)
|
||||
Collection<String> exactNamesFilter, Collection<String> alikeNamesFilter)
|
||||
{
|
||||
return new EmptyPagingResults<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a collection of the root categories for an aspect/classification supporting multiple name filters.
|
||||
*/
|
||||
@Auditable(parameters = {"storeRef", "aspectName", "exactNamesFilter", "alikeNamesFilter"})
|
||||
default Collection<ChildAssociationRef> getRootCategories(StoreRef storeRef, QName aspectName, Collection<String> exactNamesFilter, Collection<String> alikeNamesFilter)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the root categories for an aspect/classification with names that start with filter
|
||||
*
|
||||
|
@@ -28,6 +28,7 @@ package org.alfresco.service.cmr.tagging;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.api.AlfrescoPublicApi;
|
||||
import org.alfresco.query.EmptyPagingResults;
|
||||
@@ -48,6 +49,8 @@ import org.alfresco.util.Pair;
|
||||
@AlfrescoPublicApi
|
||||
public interface TaggingService
|
||||
{
|
||||
NodeRef TAG_ROOT_NODE_REF = new NodeRef("workspace://SpacesStore/tag:tag-root");
|
||||
|
||||
/**
|
||||
* Indicates whether the tag already exists
|
||||
*
|
||||
@@ -92,6 +95,18 @@ public interface TaggingService
|
||||
{
|
||||
return new EmptyPagingResults<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a map of tag NodeRefs and their respective usage count filtered by name and sorted by tag name or count
|
||||
*
|
||||
* @param storeRef
|
||||
* @param parameterIncludes
|
||||
* @param sorting
|
||||
* @param exactNamesFilter
|
||||
* @param alikeNamesFilter
|
||||
* @return
|
||||
*/
|
||||
Map<NodeRef, Long> getTags(StoreRef storeRef, List<String>parameterIncludes, Pair<String, Boolean> sorting, Collection<String> exactNamesFilter, Collection<String> alikeNamesFilter);
|
||||
|
||||
/**
|
||||
* Get all the tags currently available that match the provided filter.
|
||||
@@ -325,8 +340,7 @@ public interface TaggingService
|
||||
*/
|
||||
@NotAuditable
|
||||
Pair<List<String>, Integer> getPagedTags(StoreRef storeRef, String filter, int fromTag, int pageSize);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get tagged nodes and count of nodes group by tag name
|
||||
*
|
||||
@@ -336,6 +350,16 @@ public interface TaggingService
|
||||
@NotAuditable
|
||||
List<Pair<String, Integer>> findTaggedNodesAndCountByTagName(StoreRef storeRef);
|
||||
|
||||
/**
|
||||
* Get the number of tagged nodes for a given tag.
|
||||
*
|
||||
* @param storeRef The store containing the nodes.
|
||||
* @param name The name of the tag.
|
||||
* @return The number of nodes tagged with the specified tag.
|
||||
*/
|
||||
@NotAuditable
|
||||
long findCountByTagName(StoreRef storeRef, String name);
|
||||
|
||||
/**
|
||||
* Creates orphan tags. Tag names case will be lowered.
|
||||
*
|
||||
@@ -350,6 +374,13 @@ public interface TaggingService
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param storeRef
|
||||
* @return a map with each tag name and its usage count
|
||||
*/
|
||||
Map<String, Long> calculateCount(StoreRef storeRef);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -41,12 +41,6 @@ public class UrlUtil
|
||||
public static final Pattern PATTERN = Pattern.compile("\\$\\{shareUrl\\}");
|
||||
// ${alfrescoUrl} placeholder
|
||||
public static final Pattern REPO_PATTERN = Pattern.compile("\\$\\{alfrescoUrl\\}");
|
||||
|
||||
public static final Pattern REPOBASE_PATTERN = Pattern.compile("\\$\\{repoBaseUrl\\}");
|
||||
|
||||
public static final Pattern WORKSPACE_PATTERN = Pattern.compile("\\$\\{workspaceUrl\\}");
|
||||
|
||||
|
||||
/**
|
||||
* Builds up the Url to Alfresco based on the settings in the
|
||||
* {@link SysAdminParams}.
|
||||
@@ -152,68 +146,4 @@ public class UrlUtil
|
||||
url.append(context);
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds up the Url to Adw based on the settings in the
|
||||
* {@link SysAdminParams}.
|
||||
* @return Adw Url such as https://col.ab.or.ate/#/
|
||||
* or http://localhost:8081/#/
|
||||
*/
|
||||
public static String getWorkspaceUrl(SysAdminParams sysAdminParams)
|
||||
{
|
||||
return buildWorkspaceUrl(
|
||||
sysAdminParams.getAlfrescoProtocol(),
|
||||
sysAdminParams.getAlfrescoHost(),
|
||||
sysAdminParams.getAlfrescoPort());
|
||||
}
|
||||
|
||||
protected static String buildWorkspaceUrl(String workSpaceProtocol, String workspaceHost, int workspacePort) {
|
||||
StringBuilder workspaceUrl = new StringBuilder();
|
||||
workspaceUrl.append(workSpaceProtocol);
|
||||
workspaceUrl.append("://");
|
||||
workspaceUrl.append(workspaceHost);
|
||||
if ("http".equals(workSpaceProtocol) && workspacePort == 80)
|
||||
{
|
||||
// Not needed
|
||||
}
|
||||
else if ("https".equals(workSpaceProtocol) && workspacePort == 443)
|
||||
{
|
||||
// Not needed
|
||||
}
|
||||
else
|
||||
{
|
||||
workspaceUrl.append(':');
|
||||
workspaceUrl.append(workspacePort);
|
||||
}
|
||||
|
||||
return workspaceUrl.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the repo base url placeholder, namely {@literal ${repoBaseUrl}}, with <b>workspace</b> url.
|
||||
*
|
||||
* @param value the string value which contains the repoBase url placeholder
|
||||
* @param sysAdminParams the {@code SysAdminParams} object
|
||||
* @return if the given {@code value} contains share url placeholder,
|
||||
* the placeholder is replaced with share url; otherwise, the given {@code value} is simply returned
|
||||
*/
|
||||
|
||||
public static String replaceRepoBaseUrlPlaceholder(String value, SysAdminParams sysAdminParams)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
return REPOBASE_PATTERN.matcher(value).replaceAll(getWorkspaceUrl(sysAdminParams));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static String replaceWorkSpaceUrlPlaceholder(String pageUrl,String workspaceUrl)
|
||||
{
|
||||
if (pageUrl != null)
|
||||
{
|
||||
return WORKSPACE_PATTERN.matcher(pageUrl).replaceAll(workspaceUrl);
|
||||
}
|
||||
return pageUrl;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,144 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.util.remote;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
|
||||
import org.alfresco.util.remote.server.RemoteInputStreamServer;
|
||||
import org.alfresco.util.remote.server.RmiRemoteInputStreamServer;
|
||||
|
||||
/**
|
||||
* The data consuming side of the remote connection that the <code>InputStream</code> spans.
|
||||
*
|
||||
* @author <a href="mailto:Michael.Shavnev@effective-soft.com">Michael Shavnev</a>
|
||||
* @since Alfresco 2.2
|
||||
*/
|
||||
public class RemotableInputStream extends InputStream implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 2434858590717000057L;
|
||||
|
||||
private int port;
|
||||
private String host;
|
||||
private String name;
|
||||
|
||||
transient private RemoteInputStreamServer inputStreamServer;
|
||||
|
||||
public RemotableInputStream(String host, int port, InputStream inputStream)
|
||||
{
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.inputStreamServer = new RmiRemoteInputStreamServer(inputStream);
|
||||
}
|
||||
|
||||
public void close() throws IOException
|
||||
{
|
||||
inputStreamServer.close();
|
||||
}
|
||||
|
||||
public int read() throws IOException
|
||||
{
|
||||
return inputStreamServer.read();
|
||||
}
|
||||
|
||||
public int read(byte[] bytes) throws IOException
|
||||
{
|
||||
return inputStreamServer.read(bytes);
|
||||
}
|
||||
|
||||
public int read(byte[] bytes, int off, int len) throws IOException
|
||||
{
|
||||
return inputStreamServer.read(bytes, off, len);
|
||||
}
|
||||
|
||||
public long skip(long n) throws IOException
|
||||
{
|
||||
return inputStreamServer.skip(n);
|
||||
}
|
||||
|
||||
public int available() throws IOException
|
||||
{
|
||||
return inputStreamServer.available();
|
||||
}
|
||||
|
||||
public void mark(int readlimit)
|
||||
{
|
||||
inputStreamServer.mark(readlimit);
|
||||
}
|
||||
|
||||
public boolean markSupported()
|
||||
{
|
||||
return inputStreamServer.markSupported();
|
||||
}
|
||||
|
||||
public void reset() throws IOException
|
||||
{
|
||||
inputStreamServer.reset();
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream out) throws IOException
|
||||
{
|
||||
name = inputStreamServer.start(host, port);
|
||||
out.defaultWriteObject();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
|
||||
{
|
||||
in.defaultReadObject();
|
||||
inputStreamServer = (RemoteInputStreamServer) RmiRemoteInputStreamServer.obtain(host, port, name);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
RemotableInputStream remotableInputStream = new RemotableInputStream(InetAddress.getLocalHost().getHostName(), 7777, new ByteArrayInputStream("test".getBytes()));
|
||||
|
||||
for (int b = -1; (b = remotableInputStream.read()) != -1;)
|
||||
{
|
||||
System.out.println((char) b);
|
||||
}
|
||||
|
||||
remotableInputStream = new RemotableInputStream(InetAddress.getLocalHost().getHostName(), 7777, new ByteArrayInputStream("test".getBytes()));
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
oos.writeObject(remotableInputStream);
|
||||
|
||||
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
|
||||
remotableInputStream = (RemotableInputStream) ois.readObject();
|
||||
|
||||
for (int b = -1; (b = remotableInputStream.read()) != -1;)
|
||||
{
|
||||
System.out.println((char) b);
|
||||
}
|
||||
remotableInputStream.close();
|
||||
}
|
||||
}
|
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.util.remote.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* The data producing side of the remote connection that the <code>InputStream</code> spans.
|
||||
*
|
||||
* @author <a href="mailto:Michael.Shavnev@effective-soft.com">Michael Shavnev</a>
|
||||
* @since Alfresco 2.2
|
||||
*/
|
||||
public abstract class AbstractRemoteInputStreamServer implements RemoteInputStreamServer
|
||||
{
|
||||
protected InputStream inputStream;
|
||||
|
||||
protected AbstractRemoteInputStreamServer(InputStream inputStream)
|
||||
{
|
||||
this.inputStream = inputStream;
|
||||
}
|
||||
|
||||
public int read() throws IOException
|
||||
{
|
||||
return inputStream.read();
|
||||
}
|
||||
|
||||
public int read(byte[] bytes) throws IOException
|
||||
{
|
||||
return inputStream.read(bytes);
|
||||
}
|
||||
|
||||
public int read(byte[] bytes, int off, int len) throws IOException
|
||||
{
|
||||
return inputStream.read(bytes, off, len);
|
||||
}
|
||||
|
||||
public long skip(long n) throws IOException
|
||||
{
|
||||
return inputStream.skip(n);
|
||||
}
|
||||
|
||||
public int available() throws IOException
|
||||
{
|
||||
return inputStream.available();
|
||||
}
|
||||
|
||||
public void mark(int readlimit)
|
||||
{
|
||||
inputStream.mark(readlimit);
|
||||
}
|
||||
|
||||
public boolean markSupported()
|
||||
{
|
||||
return inputStream.markSupported();
|
||||
}
|
||||
|
||||
public void reset() throws IOException
|
||||
{
|
||||
inputStream.reset();
|
||||
}
|
||||
|
||||
public void close() throws IOException
|
||||
{
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.util.remote.server;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
import org.springframework.remoting.rmi.RmiServiceExporter;
|
||||
|
||||
public class AlfrescoRMIServiceExporter extends RmiServiceExporter
|
||||
{
|
||||
private boolean enabled = true;
|
||||
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void prepare() throws RemoteException
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
super.prepare();
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() throws RemoteException
|
||||
{
|
||||
if(enabled)
|
||||
{
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.util.remote.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
/**
|
||||
* Interface for remote input stream support.
|
||||
*
|
||||
* @author <a href="mailto:Michael.Shavnev@effective-soft.com">Michael Shavnev</a>
|
||||
* @since Alfresco 2.2
|
||||
*/
|
||||
public interface RemoteInputStreamServer
|
||||
{
|
||||
public String start(String host, int port) throws RemoteException;
|
||||
|
||||
public int read() throws IOException;
|
||||
|
||||
public int read(byte[] bytes) throws IOException;
|
||||
|
||||
public int read(byte[] bytes, int off, int len) throws IOException;
|
||||
|
||||
public long skip(long n) throws IOException;
|
||||
|
||||
public int available() throws IOException;
|
||||
|
||||
public void mark(int readlimit);
|
||||
|
||||
public boolean markSupported();
|
||||
|
||||
public void reset() throws IOException;
|
||||
|
||||
public void close() throws IOException;
|
||||
}
|
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.util.remote.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.remoting.rmi.RmiProxyFactoryBean;
|
||||
import org.springframework.remoting.rmi.RmiServiceExporter;
|
||||
|
||||
/**
|
||||
* Concrete implementation of a remoting InputStream based on RMI.
|
||||
*
|
||||
* @author <a href="mailto:Michael.Shavnev@effective-soft.com">Michael Shavnev</a>
|
||||
* @since Alfresco 2.2
|
||||
*/
|
||||
public class RmiRemoteInputStreamServer extends AbstractRemoteInputStreamServer
|
||||
{
|
||||
private RmiServiceExporter rmiServiceExporter;
|
||||
|
||||
public RmiRemoteInputStreamServer(InputStream inputStream)
|
||||
{
|
||||
super(inputStream);
|
||||
}
|
||||
|
||||
public String start(String host, int port) throws RemoteException
|
||||
{
|
||||
String name = inputStream.getClass().getName() + UUID.randomUUID();
|
||||
rmiServiceExporter = new RmiServiceExporter();
|
||||
rmiServiceExporter.setServiceName(name);
|
||||
rmiServiceExporter.setRegistryPort(port);
|
||||
rmiServiceExporter.setRegistryHost(host);
|
||||
rmiServiceExporter.setServiceInterface(RemoteInputStreamServer.class);
|
||||
rmiServiceExporter.setService(this);
|
||||
rmiServiceExporter.afterPropertiesSet();
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the stream and the RMI connection to the peer.
|
||||
*/
|
||||
public void close() throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
inputStream.close();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (rmiServiceExporter != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
rmiServiceExporter.destroy();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
throw new IOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to lookup a remote stream peer over RMI.
|
||||
*/
|
||||
public static RemoteInputStreamServer obtain(String host, int port, String name) throws RemoteException
|
||||
{
|
||||
RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
|
||||
rmiProxyFactoryBean.setServiceUrl("rmi://" + host + ":" + port + "/" + name);
|
||||
rmiProxyFactoryBean.setServiceInterface(RemoteInputStreamServer.class);
|
||||
rmiProxyFactoryBean.setRefreshStubOnConnectFailure(true);
|
||||
try
|
||||
{
|
||||
rmiProxyFactoryBean.afterPropertiesSet();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RemoteException("Error create rmi proxy");
|
||||
}
|
||||
return (RemoteInputStreamServer) rmiProxyFactoryBean.getObject();
|
||||
}
|
||||
}
|
@@ -20,15 +20,6 @@ repo.client-app.share.resetPasswordPageUrl=${shareUrl}/page/reset-password
|
||||
repo.client-app.share.confirmResetPasswordTemplatePath=
|
||||
|
||||
### Digital workspace template configurations
|
||||
#repo.client-app.workspace.inviteModeratedTemplatePath=
|
||||
|
||||
repo.client-app.workspace.workspaceUrl=${repoBaseUrl}/workspace
|
||||
|
||||
repo.client-app.workspace.templateAssetsUrl=${workspaceUrl}/images
|
||||
|
||||
# reset password request email template path
|
||||
repo.client-app.workspace.requestResetPasswordTemplatePath=alfresco/templates/reset-password-email-templates/forgot-password-email-template.ftl
|
||||
# reset password UI page url
|
||||
repo.client-app.workspace.resetPasswordPageUrl=${workspaceUrl}/reset-password/
|
||||
# reset password confirmation email template path
|
||||
repo.client-app.workspace.confirmResetPasswordTemplatePath=
|
||||
repo.client-app.workspace.inviteModeratedTemplatePath=
|
||||
repo.client-app.workspace.workspaceUrl=workspace
|
||||
repo.client-app.workspace.templateAssetsUrl=${alfrescoUrl}/images
|
||||
|
@@ -1,74 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN//EN"
|
||||
"http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
|
||||
<beans>
|
||||
|
||||
<!-- Remote FileFolderService exposure -->
|
||||
|
||||
<bean id="fileFolderRemoteServer" class="org.alfresco.repo.remote.FileFolderRemoteServer">
|
||||
<property name="transactionService">
|
||||
<ref bean="TransactionService"/>
|
||||
</property>
|
||||
<property name="fileFolderService">
|
||||
<ref bean="FileFolderService"/>
|
||||
</property>
|
||||
<property name="authenticationService">
|
||||
<ref bean="AuthenticationService"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="fileFolderRemoteRMI" class="org.springframework.remoting.rmi.RmiServiceExporter" parent="baseServiceExporter">
|
||||
<property name="service">
|
||||
<ref bean="fileFolderRemoteServer"/>
|
||||
</property>
|
||||
<property name="serviceInterface">
|
||||
<value>org.alfresco.service.cmr.remote.FileFolderRemote</value>
|
||||
</property>
|
||||
<property name="serviceName">
|
||||
<value>org.alfresco.FileFolderRemote</value>
|
||||
</property>
|
||||
<property name="registryPort">
|
||||
<value>${alfresco.rmi.services.port}</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Remote Loader exposure -->
|
||||
|
||||
<bean id="loaderRemoteServer" class="org.alfresco.repo.remote.LoaderRemoteServer">
|
||||
<property name="transactionService">
|
||||
<ref bean="TransactionService"/>
|
||||
</property>
|
||||
<property name="authenticationService">
|
||||
<ref bean="AuthenticationService"/>
|
||||
</property>
|
||||
<property name="nodeService">
|
||||
<ref bean="NodeService"/>
|
||||
</property>
|
||||
<property name="fileFolderService">
|
||||
<ref bean="FileFolderService"/>
|
||||
</property>
|
||||
<property name="checkOutCheckInService">
|
||||
<ref bean="CheckoutCheckinService"/>
|
||||
</property>
|
||||
<property name="fileFolderRemote">
|
||||
<ref bean="fileFolderRemoteServer"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="loaderRemoteServerRMI" class="org.springframework.remoting.rmi.RmiServiceExporter" parent="baseServiceExporter">
|
||||
<property name="service">
|
||||
<ref bean="loaderRemoteServer"/>
|
||||
</property>
|
||||
<property name="serviceInterface">
|
||||
<value>org.alfresco.service.cmr.remote.LoaderRemote</value>
|
||||
</property>
|
||||
<property name="serviceName">
|
||||
<value>org.alfresco.LoaderRemote</value>
|
||||
</property>
|
||||
<property name="registryPort">
|
||||
<value>${alfresco.rmi.services.port}</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
@@ -752,12 +752,16 @@ encryption.ssl.truststore.keyMetaData.location=
|
||||
## HttpClient config for Transform Service
|
||||
#enable mtls in HttpClientFactory for Transform Service.
|
||||
httpclient.config.transform.mTLSEnabled=false
|
||||
httpclient.config.transform.maxTotalConnections=40
|
||||
httpclient.config.transform.maxHostConnections=40
|
||||
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
|
||||
encryption.reencryptor.numThreads=2
|
||||
|
@@ -86,9 +86,6 @@
|
||||
</bean>
|
||||
|
||||
<bean name="identityServiceConfig" class="org.alfresco.repo.security.authentication.identityservice.IdentityServiceConfig">
|
||||
<property name="globalProperties">
|
||||
<ref bean="global-properties" />
|
||||
</property>
|
||||
<property name="realm">
|
||||
<value>${identity-service.realm}</value>
|
||||
</property>
|
||||
@@ -98,6 +95,9 @@
|
||||
<property name="resource">
|
||||
<value>${identity-service.resource}</value>
|
||||
</property>
|
||||
<property name="clientSecret">
|
||||
<value>${identity-service.credentials.secret:#{null}}</value>
|
||||
</property>
|
||||
<property name="allowAnyHostname">
|
||||
<value>${identity-service.allow-any-hostname:false}</value>
|
||||
</property>
|
||||
@@ -131,6 +131,12 @@
|
||||
<property name="realmKey">
|
||||
<value>${identity-service.realm-public-key:#{null}}</value>
|
||||
</property>
|
||||
<property name="publicKeyCacheTtl">
|
||||
<value>${identity-service.public-key-cache-ttl:86400}</value>
|
||||
</property>
|
||||
<property name="publicClient">
|
||||
<value>${identity-service.public-client:false}</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Enable control over mapping between request and user ID -->
|
||||
|
@@ -9,4 +9,5 @@ identity-service.authentication.enable-username-password-authentication=true
|
||||
identity-service.auth-server-url=http://localhost:8180/auth
|
||||
identity-service.realm=alfresco
|
||||
identity-service.resource=alfresco
|
||||
identity-service.credentials.secret=
|
||||
identity-service.public-client=true
|
||||
|
@@ -37,13 +37,14 @@
|
||||
<bean id="taggingService" class="org.alfresco.repo.tagging.TaggingServiceImpl" init-method="init">
|
||||
<property name="nodeService" ref="NodeService"/>
|
||||
<property name="nodeServiceInternal" ref="nodeService"/>
|
||||
<property name="categoryService" ref="CategoryService"/>
|
||||
<property name="searchService" ref="SearchService"/>
|
||||
<property name="actionService" ref="ActionService"/>
|
||||
<property name="contentService" ref="ContentService"/>
|
||||
<property name="namespaceService" ref="NamespaceService"/>
|
||||
<property name="policyComponent" ref="policyComponent"/>
|
||||
<property name="auditComponent" ref="auditComponent"/>
|
||||
<property name="categoryService" ref="CategoryService"/>
|
||||
<property name="searchService" ref="SearchService"/>
|
||||
<property name="actionService" ref="ActionService"/>
|
||||
<property name="contentService" ref="ContentService"/>
|
||||
<property name="namespaceService" ref="NamespaceService"/>
|
||||
<property name="policyComponent" ref="policyComponent"/>
|
||||
<property name="auditComponent" ref="auditComponent"/>
|
||||
<property name="eventGenerator" ref="eventGeneratorV2"/>
|
||||
</bean>
|
||||
|
||||
<bean id="update-tagscope" class="org.alfresco.repo.tagging.UpdateTagScopesActionExecuter" parent="action-executer">
|
||||
|
@@ -1,12 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Forgot Password</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>You are receiving this email because you(or someone else) requested the password reset of your account.</p>
|
||||
<p>Please click on the following link, or paste this url into your browser to complete the process:</p>
|
||||
<p><a href="${reset_password_url}">${reset_password_url}</a></p>
|
||||
<p>If you received this in error, you can safely ignore it.</p>
|
||||
<p>Kind regards</p>
|
||||
</body>
|
||||
</html>
|
@@ -91,7 +91,6 @@ public class ResetPasswordServiceImplTest
|
||||
|
||||
private static TestPerson testPerson;
|
||||
private static EmailUtil emailUtil;
|
||||
private static TestPerson testPersonForWorkspace;
|
||||
|
||||
@BeforeClass
|
||||
public static void initStaticData() throws Exception
|
||||
@@ -115,18 +114,9 @@ public class ResetPasswordServiceImplTest
|
||||
.setPassword("password")
|
||||
.setEmail(userName + "@example.com");
|
||||
|
||||
String userNameForWorkspace = "shane.doe" + System.currentTimeMillis();
|
||||
testPersonForWorkspace = new TestPerson()
|
||||
.setUserName(userNameForWorkspace)
|
||||
.setFirstName("Shane")
|
||||
.setLastName("doe")
|
||||
.setPassword("password")
|
||||
.setEmail(userNameForWorkspace + "@example.com");
|
||||
|
||||
transactionHelper.doInTransaction((RetryingTransactionCallback<Void>) () ->
|
||||
{
|
||||
createUser(testPerson);
|
||||
createUser(testPersonForWorkspace);
|
||||
return null;
|
||||
});
|
||||
|
||||
@@ -504,84 +494,4 @@ public class ResetPasswordServiceImplTest
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResetPasswordForClientWorkspace() throws Exception
|
||||
{
|
||||
// Try the credential before change of password
|
||||
authenticateUser(testPersonForWorkspace.userName, testPersonForWorkspace.password);
|
||||
|
||||
// Make sure to run as system
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
AuthenticationUtil.setRunAsUserSystem();
|
||||
|
||||
// Request password reset
|
||||
resetPasswordService.requestReset(testPersonForWorkspace.userName, "workspace");
|
||||
assertEquals("A reset password email should have been sent.", 1, emailUtil.getSentCount());
|
||||
// Check the email
|
||||
MimeMessage msg = emailUtil.getLastEmail();
|
||||
assertNotNull("There should be an email.", msg);
|
||||
assertEquals("Should've been only one email recipient.", 1, msg.getAllRecipients().length);
|
||||
// Check the recipient is the person who requested the reset password
|
||||
assertEquals(testPersonForWorkspace.email, msg.getAllRecipients()[0].toString());
|
||||
//Check the sender is what we set as default
|
||||
assertEquals(DEFAULT_SENDER, msg.getFrom()[0].toString());
|
||||
// There should be a subject
|
||||
assertNotNull("There should be a subject.", msg.getSubject());
|
||||
// Check the default email subject - (check that we are sending the right email)
|
||||
String emailSubjectKey = getDeclaredField(SendResetPasswordEmailDelegate.class, "EMAIL_SUBJECT_KEY");
|
||||
assertNotNull(emailSubjectKey);
|
||||
assertEquals(msg.getSubject(), I18NUtil.getMessage(emailSubjectKey));
|
||||
|
||||
// Check the reset password url.
|
||||
String resetPasswordUrl = (String) emailUtil.getLastEmailTemplateModelValue("reset_password_url");
|
||||
assertNotNull("Wrong email is sent.", resetPasswordUrl);
|
||||
// Get the workflow id and key
|
||||
Pair<String, String> pair = getWorkflowIdAndKeyFromUrl(resetPasswordUrl);
|
||||
assertNotNull("Workflow Id can't be null.", pair.getFirst());
|
||||
assertNotNull("Workflow Key can't be null.", pair.getSecond());
|
||||
|
||||
emailUtil.reset();
|
||||
// Now that we have got the email, try to reset the password
|
||||
ResetPasswordDetails passwordDetails = new ResetPasswordDetails()
|
||||
.setUserId(testPersonForWorkspace.userName)
|
||||
.setPassword("newPassword")
|
||||
.setWorkflowId(pair.getFirst())
|
||||
.setWorkflowKey(pair.getSecond());
|
||||
|
||||
resetPasswordService.initiateResetPassword(passwordDetails);
|
||||
assertEquals("A reset password confirmation email should have been sent.", 1, emailUtil.getSentCount());
|
||||
// Check the email
|
||||
msg = emailUtil.getLastEmail();
|
||||
assertNotNull("There should be an email.", msg);
|
||||
assertEquals("Should've been only one email recipient.", 1, msg.getAllRecipients().length);
|
||||
// Check the recipient is the person who requested the reset password
|
||||
assertEquals(testPersonForWorkspace.email, msg.getAllRecipients()[0].toString());
|
||||
// Check the sender is what we set as default
|
||||
assertEquals(DEFAULT_SENDER, msg.getFrom()[0].toString());
|
||||
// There should be a subject
|
||||
assertNotNull("There should be a subject.", msg.getSubject());
|
||||
// Check the default email subject - (check that we are sending the right email)
|
||||
emailSubjectKey = getDeclaredField(SendResetPasswordConfirmationEmailDelegate.class, "EMAIL_SUBJECT_KEY");
|
||||
assertNotNull(emailSubjectKey);
|
||||
assertEquals(msg.getSubject(), I18NUtil.getMessage(emailSubjectKey));
|
||||
|
||||
// Try the old credential
|
||||
TestHelper.assertThrows(() -> authenticateUser(testPersonForWorkspace.userName, testPersonForWorkspace.password),
|
||||
AuthenticationException.class,
|
||||
"As the user changed her password, the authentication should have failed.");
|
||||
|
||||
// Try the new credential
|
||||
authenticateUser(testPersonForWorkspace.userName, "newPassword");
|
||||
|
||||
// Make sure to run as system
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
AuthenticationUtil.setRunAsUserSystem();
|
||||
emailUtil.reset();
|
||||
// Try reset again with the used workflow
|
||||
TestHelper.assertThrows(() -> resetPasswordService.initiateResetPassword(passwordDetails),
|
||||
InvalidResetPasswordWorkflowException.class,
|
||||
"The workflow instance is not active (it has already been used).");
|
||||
assertEquals("No email should have been sent.", 0, emailUtil.getSentCount());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -25,10 +25,16 @@
|
||||
*/
|
||||
package org.alfresco.repo.tagging;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
||||
import static org.alfresco.model.ContentModel.ASPECT_TAGGABLE;
|
||||
import static org.alfresco.model.ContentModel.PROP_TAGS;
|
||||
import static org.alfresco.model.ContentModel.ASSOC_SUBCATEGORIES;
|
||||
import static org.alfresco.model.ContentModel.PROP_NAME;
|
||||
import static org.alfresco.repo.tagging.TaggingServiceImpl.TAG_UPDATES;
|
||||
import static org.alfresco.service.cmr.repository.StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
|
||||
import static org.alfresco.service.cmr.search.SearchService.LANGUAGE_LUCENE;
|
||||
import static org.alfresco.service.cmr.tagging.TaggingService.TAG_ROOT_NODE_REF;
|
||||
import static org.alfresco.service.namespace.NamespaceService.CONTENT_MODEL_1_0_URI;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.catchThrowable;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
@@ -36,16 +42,15 @@ import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.event2.EventGenerator;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
@@ -56,6 +61,7 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.CategoryService;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -84,6 +90,8 @@ public class TaggingServiceImplUnitTest
|
||||
private ResultSet resultSetMock;
|
||||
@Mock(extraInterfaces = List.class)
|
||||
private Serializable currentTagsMock;
|
||||
@Mock
|
||||
private EventGenerator eventGenerator;
|
||||
|
||||
@InjectMocks
|
||||
private TaggingServiceImpl taggingService;
|
||||
@@ -128,45 +136,25 @@ public class TaggingServiceImplUnitTest
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testChangeTag()
|
||||
{
|
||||
final String newTagName = "new-tag-name";
|
||||
final NodeRef newTagNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, newTagName);
|
||||
given(searchServiceMock.query(any(), any(String.class), any(String.class))).willReturn(resultSetMock);
|
||||
given(resultSetMock.getNodeRefs()).willReturn(List.of(CONTENT_NODE_REF), Collections.emptyList());
|
||||
given(nodeServiceMock.hasAspect(CONTENT_NODE_REF, ASPECT_TAGGABLE)).willReturn(true);
|
||||
given(categoryServiceMock.getRootCategories(STORE_REF_WORKSPACE_SPACESSTORE, ASPECT_TAGGABLE, TAG_NAME, false)).willReturn(childAssociationsOf(TAG_NODE_REF));
|
||||
given(nodeServiceMock.getProperty(CONTENT_NODE_REF, PROP_TAGS)).willReturn(currentTagsMock);
|
||||
given(((List<NodeRef>) currentTagsMock).size()).willReturn(1);
|
||||
given(((List<NodeRef>) currentTagsMock).contains(TAG_NODE_REF)).willReturn(true);
|
||||
given(categoryServiceMock.getRootCategories(STORE_REF_WORKSPACE_SPACESSTORE, ASPECT_TAGGABLE, newTagName, true)).willReturn(childAssociationsOf(newTagNodeRef));
|
||||
given(((List<NodeRef>) currentTagsMock).contains(newTagNodeRef)).willReturn(false);
|
||||
given(searchServiceMock.query(STORE_REF_WORKSPACE_SPACESSTORE, LANGUAGE_LUCENE, "+PATH:\"/cm:taggable/cm:" + TAG_NAME + "/member\"")).willReturn(resultSetMock);
|
||||
given(resultSetMock.getNodeRefs()).willReturn(List.of(CONTENT_NODE_REF));
|
||||
|
||||
//when
|
||||
taggingService.changeTag(STORE_REF_WORKSPACE_SPACESSTORE, TAG_NAME, newTagName);
|
||||
|
||||
then((List<NodeRef>) currentTagsMock).should().remove(TAG_NODE_REF);
|
||||
then((List<NodeRef>) currentTagsMock).should().add(newTagNodeRef);
|
||||
then(nodeServiceMock).should(times(2)).setProperty(CONTENT_NODE_REF, PROP_TAGS, currentTagsMock);
|
||||
then(categoryServiceMock).should().deleteCategory(TAG_NODE_REF);
|
||||
then(categoryServiceMock).should(times(2)).getRootCategories(STORE_REF_WORKSPACE_SPACESSTORE, ASPECT_TAGGABLE, newTagName, true);
|
||||
}
|
||||
then(nodeServiceMock).should().setProperty(TAG_NODE_REF, PROP_NAME, newTagName);
|
||||
then(nodeServiceMock).should().moveNode(TAG_NODE_REF, TAG_ROOT_NODE_REF, ASSOC_SUBCATEGORIES, QName.createQName(CONTENT_MODEL_1_0_URI, newTagName));
|
||||
then(nodeServiceMock).should().getProperties(CONTENT_NODE_REF);
|
||||
then(nodeServiceMock).should().hasAspect(CONTENT_NODE_REF, ContentModel.ASPECT_TAGSCOPE);
|
||||
then(nodeServiceMock).should().getPrimaryParent(CONTENT_NODE_REF);
|
||||
then(nodeServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
@Test
|
||||
public void testChangeOrphanTag()
|
||||
{
|
||||
final String newTagName = "new-tag-name";
|
||||
given(searchServiceMock.query(any(), any(String.class), any(String.class))).willReturn(resultSetMock);
|
||||
given(resultSetMock.getNodeRefs()).willReturn(Collections.emptyList());
|
||||
given(categoryServiceMock.getRootCategories(STORE_REF_WORKSPACE_SPACESSTORE, ASPECT_TAGGABLE, TAG_NAME, false)).willReturn(childAssociationsOf(TAG_NODE_REF));
|
||||
|
||||
//when
|
||||
taggingService.changeTag(STORE_REF_WORKSPACE_SPACESSTORE, TAG_NAME, newTagName);
|
||||
|
||||
then(nodeServiceMock).should(never()).setProperty(any(), any(), any());
|
||||
then(categoryServiceMock).should().deleteCategory(TAG_NODE_REF);
|
||||
then(categoryServiceMock).should().getRootCategories(STORE_REF_WORKSPACE_SPACESSTORE, ASPECT_TAGGABLE, newTagName, true);
|
||||
then(eventGenerator).should().onUpdateProperties(eq(CONTENT_NODE_REF), eq(emptyMap()), any());
|
||||
then(eventGenerator).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
private static List<ChildAssociationRef> childAssociationsOf(final NodeRef... childNodeRefs)
|
||||
@@ -175,4 +163,4 @@ public class TaggingServiceImplUnitTest
|
||||
.map(childNodeRef -> new ChildAssociationRef(null, null, null, childNodeRef))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,8 +31,8 @@ services:
|
||||
ports:
|
||||
- 8090:8090
|
||||
volumes:
|
||||
- ${GITHUB_WORKSPACE}/keystores/tengineAIO/tengineAIO.truststore:/tengineAIO.truststore
|
||||
- ${GITHUB_WORKSPACE}/keystores/tengineAIO/tengineAIO.keystore:/tengineAIO.keystore
|
||||
- ${CI_WORKSPACE}/keystores/tengineAIO/tengineAIO.truststore:/tengineAIO.truststore
|
||||
- ${CI_WORKSPACE}/keystores/tengineAIO/tengineAIO.keystore:/tengineAIO.keystore
|
||||
environment:
|
||||
ACTIVEMQ_URL: "nio://activemq:61616"
|
||||
ACTIVEMQ_USER: "admin"
|
||||
|
@@ -1,27 +0,0 @@
|
||||
#! /bin/bash
|
||||
#! /bin/bash
|
||||
|
||||
# SETTINGS
|
||||
# Alfresco Format: "classic" / "current" is supported only from 7.0
|
||||
ALFRESCO_FORMAT=current
|
||||
|
||||
#Contains directory settings
|
||||
source ${GITHUB_WORKSPACE}/alfresco-ssl-generator/ssl-tool/utils.sh
|
||||
|
||||
# Cleanup previous output of script
|
||||
rm -rd $CA_DIR
|
||||
rm -rd $KEYSTORES_DIR
|
||||
rm -rd $CERTIFICATES_DIR
|
||||
|
||||
# SETTINGS
|
||||
# Alfresco Format: "classic" / "current" is supported only from 7.0
|
||||
ALFRESCO_FORMAT=current
|
||||
|
||||
#CA
|
||||
${GITHUB_WORKSPACE}/alfresco-ssl-generator/ssl-tool/run_ca.sh -keysize 2048 -keystorepass password -certdname "/C=GB/ST=UK/L=Maidenhead/O=Alfresco Software Ltd./OU=Unknown/CN=Custom Alfresco CA" -servername localhost -validityduration 1
|
||||
#Alfresco
|
||||
${GITHUB_WORKSPACE}/alfresco-ssl-generator/ssl-tool/run_additional.sh -servicename alfresco -rootcapass password -keysize 2048 -keystoretype JCEKS -keystorepass password -truststoretype JCEKS -truststorepass password -certdname "/C=GB/ST=UK/L=Maidenhead/O=Alfresco Software Ltd./OU=Unknown/CN=Custom Alfresco Repository" -servername localhost -alfrescoformat $ALFRESCO_FORMAT
|
||||
#Alfresco Metadata encryption
|
||||
${GITHUB_WORKSPACE}/alfresco-ssl-generator/ssl-tool/run_encryption.sh -subfoldername alfresco -servicename encryption -encstorepass mp6yc0UD9e -encmetadatapass oKIWzVdEdA -alfrescoformat $ALFRESCO_FORMAT
|
||||
#T-Engine AIO
|
||||
${GITHUB_WORKSPACE}/alfresco-ssl-generator/ssl-tool/run_additional.sh -servicename tengineAIO -rootcapass password -keysize 2048 -keystoretype JCEKS -keystorepass password -truststoretype JCEKS -truststorepass password -certdname "/C=GB/ST=UK/L=Maidenhead/O=Alfresco Software Ltd./OU=Unknown/CN=T-Engine AIO" -servername localhost -alfrescoformat $ALFRESCO_FORMAT
|
Reference in New Issue
Block a user