mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-10 14:11:58 +00:00
Compare commits
2 Commits
17.106
...
hack/hacka
Author | SHA1 | Date | |
---|---|---|---|
|
cd8ef77b3e | ||
|
8622e0e102 |
11
.github/workflows/hackathon.yml
vendored
Normal file
11
.github/workflows/hackathon.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
name: Hackathon
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
sleep:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: sleep 240
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -11,7 +11,7 @@ function main()
|
||||
var params =
|
||||
{
|
||||
type: "people",
|
||||
term: args.t + " [hint:useCQ]",
|
||||
term: args.t,
|
||||
maxResults: (args.maxResults !== null) ? parseInt(args.maxResults, 10) : DEFAULT_MAX_RESULTS,
|
||||
startIndex: (args.startIndex !== null) ? parseInt(args.startIndex, 10) : 0
|
||||
};
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -9,6 +9,6 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
</project>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -35,7 +35,6 @@ import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestRuleModel;
|
||||
import org.alfresco.rest.model.RestRuleSetModel;
|
||||
import org.alfresco.rest.model.RestRuleSetModelsCollection;
|
||||
import org.alfresco.rest.model.RestRuleSettingsModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
@@ -52,8 +51,6 @@ public class GetRuleSetsTests extends RestTest
|
||||
private UserModel user;
|
||||
private SiteModel site;
|
||||
private FolderModel ruleFolder;
|
||||
private FolderModel inheritingChildFolder;
|
||||
private FolderModel notInheritingChildFolder;
|
||||
private RestRuleModel rule;
|
||||
private String ruleSetId;
|
||||
|
||||
@@ -65,14 +62,6 @@ public class GetRuleSetsTests extends RestTest
|
||||
site = dataSite.usingUser(user).createPublicRandomSite();
|
||||
ruleFolder = dataContent.usingUser(user).usingSite(site).createFolder();
|
||||
|
||||
STEP("Create two children of the folder - one that inherits rules and one that doesn't");
|
||||
inheritingChildFolder = dataContent.usingUser(user).usingResource(ruleFolder).createFolder();
|
||||
notInheritingChildFolder = dataContent.usingUser(user).usingResource(ruleFolder).createFolder();
|
||||
RestRuleSettingsModel doesntInherit = new RestRuleSettingsModel();
|
||||
doesntInherit.setValue(false);
|
||||
restClient.authenticateUser(user).withCoreAPI().usingNode(notInheritingChildFolder)
|
||||
.usingIsInheritanceEnabledRuleSetting().updateSetting(doesntInherit);
|
||||
|
||||
STEP("Create a rule in the folder.");
|
||||
RestRuleModel ruleModel = createRuleModel("ruleName");
|
||||
rule = restClient.authenticateUser(user).withCoreAPI().usingNode(ruleFolder).usingDefaultRuleSet()
|
||||
@@ -144,7 +133,7 @@ public class GetRuleSetsTests extends RestTest
|
||||
|
||||
/** Check we can get the reason that a rule set is included in the list. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void getRuleSetsAndOwnedInclusionType()
|
||||
public void getRuleSetsAndInclusionType()
|
||||
{
|
||||
STEP("Get the rule sets and inclusion type");
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
@@ -159,36 +148,6 @@ public class GetRuleSetsTests extends RestTest
|
||||
ruleSets.assertThat().entriesListCountIs(1);
|
||||
}
|
||||
|
||||
/** Check we can tell that a rule set has been inherited. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void getRuleSetsAndInheritedInclusionType()
|
||||
{
|
||||
STEP("Get the rule sets and inclusion type");
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
.usingNode(inheritingChildFolder)
|
||||
.include("inclusionType")
|
||||
.getListOfRuleSets();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
ruleSets.getEntries().get(0).onModel()
|
||||
.assertThat().field("inclusionType").is("inherited")
|
||||
.assertThat().field("id").is(ruleSetId);
|
||||
ruleSets.assertThat().entriesListCountIs(1);
|
||||
}
|
||||
|
||||
/** Check that a rule set is not inherited if inheriting is disabled. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES })
|
||||
public void getRuleSetsWithoutInheriting()
|
||||
{
|
||||
STEP("Get the rule sets and inclusion type");
|
||||
RestRuleSetModelsCollection ruleSets = restClient.authenticateUser(user).withCoreAPI()
|
||||
.usingNode(notInheritingChildFolder)
|
||||
.getListOfRuleSets();
|
||||
|
||||
restClient.assertStatusCodeIs(OK);
|
||||
ruleSets.assertThat().entriesListCountIs(0);
|
||||
}
|
||||
|
||||
/** Check we can get a rule set by its id. */
|
||||
@Test (groups = { TestGroup.REST_API, TestGroup.RULES, TestGroup.SANITY })
|
||||
public void getRuleSetById()
|
||||
|
@@ -234,7 +234,7 @@ public class RuleSetLinksTests extends RestTest
|
||||
STEP("Assert link result is 400");
|
||||
restClient.assertStatusCodeIs(BAD_REQUEST)
|
||||
.assertLastError().containsSummary(
|
||||
"Unable to link to a rule set because the folder has pre-existing rules or is already linked to a rule set.");
|
||||
"Unable to link to a ruleset because the folder has pre-existing rules or is already linked to a ruleset.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
6
pom.xml
6
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>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Alfresco Community Repo Parent</name>
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
<dependency.jakarta-json-path.version>2.7.0</dependency.jakarta-json-path.version>
|
||||
<dependency.jakarta-rpc-api.version>1.1.4</dependency.jakarta-rpc-api.version>
|
||||
|
||||
<alfresco.googledrive.version>3.2.3-A2</alfresco.googledrive.version>
|
||||
<alfresco.googledrive.version>3.2.2</alfresco.googledrive.version>
|
||||
<alfresco.aos-module.version>1.4.1</alfresco.aos-module.version>
|
||||
<alfresco.api-explorer.version>7.2.1</alfresco.api-explorer.version> <!-- Also in alfresco-enterprise-share -->
|
||||
|
||||
@@ -148,7 +148,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>17.106</tag>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -29,7 +29,7 @@ package org.alfresco.rest.api.impl.rules;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.alfresco.repo.rule.RuleModel;
|
||||
import org.alfresco.repo.rule.RuntimeRuleService;
|
||||
@@ -59,13 +59,10 @@ public class RuleSetsImpl implements RuleSets
|
||||
{
|
||||
NodeRef folderNode = validator.validateFolderNode(folderNodeId, false);
|
||||
|
||||
List<RuleSet> ruleSets = ruleService.getNodesSupplyingRuleSets(folderNode)
|
||||
.stream()
|
||||
.map(ruleService::getRuleSetNode)
|
||||
.filter(Objects::nonNull)
|
||||
.map(nodeRef -> ruleSetLoader.loadRuleSet(nodeRef, folderNode, includes))
|
||||
.distinct()
|
||||
.collect(toList());
|
||||
NodeRef ruleSetNode = ruleService.getRuleSetNode(folderNode);
|
||||
List<RuleSet> ruleSets = Optional.ofNullable(ruleSetNode)
|
||||
.map(nodeRef -> ruleSetLoader.loadRuleSet(nodeRef, folderNode, includes))
|
||||
.stream().collect(toList());
|
||||
|
||||
return ListPage.of(ruleSets, paging);
|
||||
}
|
||||
@@ -96,7 +93,7 @@ public class RuleSetsImpl implements RuleSets
|
||||
|
||||
//The folder shouldn't have any pre-existing rules
|
||||
if (ruleService.hasRules(folderNodeRef)) {
|
||||
throw new InvalidArgumentException("Unable to link to a rule set because the folder has pre-existing rules or is already linked to a rule set.");
|
||||
throw new InvalidArgumentException("Unable to link to a ruleset because the folder has pre-existing rules or is already linked to a ruleset.");
|
||||
}
|
||||
|
||||
// Create the destination folder as a secondary child of the first
|
||||
|
@@ -30,7 +30,7 @@ public class RuleSetLink
|
||||
{
|
||||
|
||||
/**
|
||||
* This id is referring to the node id of the linked-to-folder which contains the rule set(s)
|
||||
* This id is referring to the node id of the linked-to-folder which contains the ruleset(s)
|
||||
*/
|
||||
private String id;
|
||||
|
||||
|
@@ -309,7 +309,7 @@ function sortByName(a, b)
|
||||
|
||||
function findUsers(searchTerm, maxResults, results)
|
||||
{
|
||||
var personRefs = people.getPeople(searchTerm+ " [hint:useCQ]", maxResults, "lastName", true);
|
||||
var personRefs = people.getPeople(searchTerm, maxResults, "lastName", true);
|
||||
|
||||
// create person object for each result
|
||||
for each(var personRef in personRefs)
|
||||
|
@@ -33,7 +33,6 @@ import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
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 java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -102,8 +101,6 @@ public class RuleSetsImplTest extends TestCase
|
||||
given(nodeValidatorMock.validateRuleSetNode(RULE_SET_ID, FOLDER_NODE)).willReturn(RULE_SET_NODE);
|
||||
|
||||
given(ruleServiceMock.getRuleSetNode(FOLDER_NODE)).willReturn(RULE_SET_NODE);
|
||||
given(ruleServiceMock.getNodesSupplyingRuleSets(FOLDER_NODE)).willReturn(List.of(FOLDER_NODE));
|
||||
|
||||
given(ruleSetLoaderMock.loadRuleSet(RULE_SET_NODE, FOLDER_NODE, INCLUDES)).willReturn(ruleSetMock);
|
||||
}
|
||||
|
||||
@@ -116,7 +113,6 @@ public class RuleSetsImplTest extends TestCase
|
||||
then(nodeValidatorMock).should().validateFolderNode(FOLDER_ID, false);
|
||||
then(nodeValidatorMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(ruleServiceMock).should().getNodesSupplyingRuleSets(FOLDER_NODE);
|
||||
then(ruleServiceMock).should().getRuleSetNode(FOLDER_NODE);
|
||||
then(ruleServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
@@ -137,7 +133,6 @@ public class RuleSetsImplTest extends TestCase
|
||||
then(nodeValidatorMock).should().validateFolderNode(FOLDER_ID, false);
|
||||
then(nodeValidatorMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(ruleServiceMock).should().getNodesSupplyingRuleSets(FOLDER_NODE);
|
||||
then(ruleServiceMock).should().getRuleSetNode(FOLDER_NODE);
|
||||
then(ruleServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
@@ -145,62 +140,6 @@ public class RuleSetsImplTest extends TestCase
|
||||
assertEquals(PAGING, actual.getPaging());
|
||||
}
|
||||
|
||||
/** Check that a folder with a parent and grandparent can inherit rule sets from the grandparent, even if the parent has no rules. */
|
||||
@Test
|
||||
public void testGetInheritedRuleSets()
|
||||
{
|
||||
// Simulate a parent node without a rule set.
|
||||
NodeRef parentNode = new NodeRef("parent://node/");
|
||||
// Simulate a grandparent node providing a rule set.
|
||||
NodeRef grandparentNode = new NodeRef("grandparent://node/");
|
||||
RuleSet grandparentRuleSet = mock(RuleSet.class);
|
||||
NodeRef grandparentRuleSetNode = new NodeRef("grandparent://rule-set/");
|
||||
given(ruleServiceMock.getRuleSetNode(grandparentNode)).willReturn(grandparentRuleSetNode);
|
||||
given(ruleSetLoaderMock.loadRuleSet(grandparentRuleSetNode, FOLDER_NODE, INCLUDES)).willReturn(grandparentRuleSet);
|
||||
// These should be returned with the highest in hierarchy first.
|
||||
given(ruleServiceMock.getNodesSupplyingRuleSets(FOLDER_NODE)).willReturn(List.of(grandparentNode, parentNode, FOLDER_NODE));
|
||||
|
||||
// Call the method under test.
|
||||
CollectionWithPagingInfo<RuleSet> actual = ruleSets.getRuleSets(FOLDER_ID, INCLUDES, PAGING);
|
||||
|
||||
then(nodeValidatorMock).should().validateFolderNode(FOLDER_ID, false);
|
||||
then(nodeValidatorMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
then(ruleServiceMock).should().getNodesSupplyingRuleSets(FOLDER_NODE);
|
||||
then(ruleServiceMock).should().getRuleSetNode(grandparentNode);
|
||||
then(ruleServiceMock).should().getRuleSetNode(parentNode);
|
||||
then(ruleServiceMock).should().getRuleSetNode(FOLDER_NODE);
|
||||
then(ruleServiceMock).shouldHaveNoMoreInteractions();
|
||||
|
||||
Collection<RuleSet> expected = List.of(grandparentRuleSet, ruleSetMock);
|
||||
assertEquals(expected, actual.getCollection());
|
||||
assertEquals(PAGING, actual.getPaging());
|
||||
}
|
||||
|
||||
/** When getting rule sets then only the first instance of each rule set should be included (ancestor first). */
|
||||
@Test
|
||||
public void testGetDuplicateRuleSets()
|
||||
{
|
||||
// Simulate a grandparent, parent and child with the grandparent linking to the child's rule set.
|
||||
NodeRef grandparentNode = new NodeRef("grandparent://node/");
|
||||
given(ruleServiceMock.getRuleSetNode(grandparentNode)).willReturn(RULE_SET_NODE);
|
||||
NodeRef parentNode = new NodeRef("parent://node/");
|
||||
RuleSet parentRuleSet = mock(RuleSet.class);
|
||||
NodeRef parentRuleSetNode = new NodeRef("parent://rule-set/");
|
||||
given(ruleServiceMock.getRuleSetNode(parentNode)).willReturn(parentRuleSetNode);
|
||||
given(ruleSetLoaderMock.loadRuleSet(parentRuleSetNode, FOLDER_NODE, INCLUDES)).willReturn(parentRuleSet);
|
||||
// These should be returned with the highest in hierarchy first.
|
||||
given(ruleServiceMock.getNodesSupplyingRuleSets(FOLDER_NODE)).willReturn(List.of(grandparentNode, parentNode, FOLDER_NODE));
|
||||
|
||||
// Call the method under test.
|
||||
CollectionWithPagingInfo<RuleSet> actual = ruleSets.getRuleSets(FOLDER_ID, INCLUDES, PAGING);
|
||||
|
||||
// The grandparent's linked rule set should be first and only appear once.
|
||||
Collection<RuleSet> expected = List.of(ruleSetMock, parentRuleSet);
|
||||
assertEquals(expected, actual.getCollection());
|
||||
assertEquals(PAGING, actual.getPaging());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRuleSetById()
|
||||
{
|
||||
|
@@ -106,7 +106,6 @@ import org.apache.commons.collections.map.MultiValueMap;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@@ -3612,7 +3611,6 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
||||
* {@literal <host>:<port>/alfresco/api/-default-/public/alfresco/versions/1/nodes/<nodeId>/content}
|
||||
*/
|
||||
@Test
|
||||
@Ignore("ACS-3531 Frequent intermittent failure")
|
||||
public void testDownloadFileContent() throws Exception
|
||||
{
|
||||
setRequestContext(user1);
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>17.106</version>
|
||||
<version>17.102-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -220,7 +220,6 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
{
|
||||
// Process batch
|
||||
primaryId = processPrimaryTableResultSet(primaryPrepStmt, secondaryPrepStmts, deletePrepStmt, deleteIds, primaryTableName, primaryColumnName, tableColumn);
|
||||
connection.commit();
|
||||
|
||||
if (primaryId == null)
|
||||
{
|
||||
@@ -299,6 +298,7 @@ public class DeleteNotExistsExecutor implements StatementExecutor
|
||||
if (deleteIds.size() == deleteBatchSize)
|
||||
{
|
||||
deleteFromPrimaryTable(deletePrepStmt, deleteIds, primaryTableName);
|
||||
connection.commit();
|
||||
}
|
||||
|
||||
if (!resultSet.next())
|
||||
|
@@ -117,7 +117,6 @@ public class MySQLDeleteNotExistsExecutor extends DeleteNotExistsExecutor
|
||||
{
|
||||
// Process batch
|
||||
primaryId = processPrimaryTableResultSet(primaryPrepStmt, secondaryPrepStmts, deletePrepStmt, deleteIds, primaryTableName, primaryColumnName, tableColumn);
|
||||
connection.commit();
|
||||
|
||||
if (primaryId == null)
|
||||
{
|
||||
|
@@ -25,8 +25,6 @@
|
||||
*/
|
||||
package org.alfresco.repo.rule;
|
||||
|
||||
import static org.alfresco.repo.rule.RuleModel.ASPECT_IGNORE_INHERITED_RULES;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -481,7 +479,7 @@ public class RuleServiceImpl
|
||||
// Node has gone or is not the correct type
|
||||
return rules;
|
||||
}
|
||||
if (includeInherited && !runtimeNodeService.hasAspect(nodeRef, ASPECT_IGNORE_INHERITED_RULES))
|
||||
if (includeInherited == true && runtimeNodeService.hasAspect(nodeRef, RuleModel.ASPECT_IGNORE_INHERITED_RULES) == false)
|
||||
{
|
||||
// Get any inherited rules
|
||||
for (Rule rule : getInheritedRules(nodeRef, ruleTypeName, null))
|
||||
@@ -599,53 +597,10 @@ public class RuleServiceImpl
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
@Experimental
|
||||
public List<NodeRef> getNodesSupplyingRuleSets(NodeRef nodeRef)
|
||||
{
|
||||
return getNodesSupplyingRuleSets(nodeRef, new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverse the folder hierarchy find all the folder nodes that could supply rules by inheritance.
|
||||
* <p>
|
||||
* The order of nodes returned by this methods has to match the order used by {@link #getInheritedRules}.
|
||||
*
|
||||
* @param nodeRef The starting node ref.
|
||||
* @param visitedNodeRefs All the visited node refs (will be modified).
|
||||
* @return A list of node refs, starting with the first parent of the first parent of ... and ending with the object generated by the
|
||||
* given node ref.
|
||||
*/
|
||||
private List<NodeRef> getNodesSupplyingRuleSets(NodeRef nodeRef, List<NodeRef> visitedNodeRefs)
|
||||
{
|
||||
List<NodeRef> returnList = new ArrayList<>();
|
||||
// This check prevents stack over flow when we have a cyclic node graph
|
||||
if (!visitedNodeRefs.contains(nodeRef))
|
||||
{
|
||||
visitedNodeRefs.add(nodeRef);
|
||||
if (!runtimeNodeService.hasAspect(nodeRef, ASPECT_IGNORE_INHERITED_RULES))
|
||||
{
|
||||
List<ChildAssociationRef> parents = runtimeNodeService.getParentAssocs(nodeRef);
|
||||
for (ChildAssociationRef parent : parents)
|
||||
{
|
||||
// We are not interested in following potentially massive person group membership trees!
|
||||
if (!IGNORE_PARENT_ASSOC_TYPES.contains(parent.getTypeQName()))
|
||||
{
|
||||
// Update visitedNodeRefs with all the ancestors.
|
||||
returnList.addAll(getNodesSupplyingRuleSets(parent.getParentRef(), visitedNodeRefs));
|
||||
}
|
||||
}
|
||||
}
|
||||
returnList.add(nodeRef);
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the inherited rules for a given node reference
|
||||
*
|
||||
*
|
||||
* @param nodeRef the nodeRef
|
||||
* @param ruleTypeName the rule type (null if all applicable)
|
||||
* @return a list of inherited rules (empty if none)
|
||||
@@ -653,20 +608,20 @@ public class RuleServiceImpl
|
||||
private List<Rule> getInheritedRules(NodeRef nodeRef, String ruleTypeName, Set<NodeRef> visitedNodeRefs)
|
||||
{
|
||||
List<Rule> inheritedRules = new ArrayList<Rule>();
|
||||
|
||||
|
||||
if (this.runtimeNodeService.hasAspect(nodeRef, RuleModel.ASPECT_IGNORE_INHERITED_RULES) == false)
|
||||
{
|
||||
{
|
||||
// Create the visited nodes set if it has not already been created
|
||||
if (visitedNodeRefs == null)
|
||||
{
|
||||
visitedNodeRefs = new HashSet<NodeRef>();
|
||||
}
|
||||
|
||||
|
||||
// This check prevents stack over flow when we have a cyclic node graph
|
||||
if (visitedNodeRefs.contains(nodeRef) == false)
|
||||
{
|
||||
visitedNodeRefs.add(nodeRef);
|
||||
|
||||
|
||||
List<Rule> allInheritedRules = new ArrayList<Rule>();
|
||||
List<ChildAssociationRef> parents = this.runtimeNodeService.getParentAssocs(nodeRef);
|
||||
for (ChildAssociationRef parent : parents)
|
||||
@@ -686,7 +641,7 @@ public class RuleServiceImpl
|
||||
allInheritedRules.add(rule);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<Rule> rules = getRules(parent.getParentRef(), false);
|
||||
for (Rule rule : rules)
|
||||
{
|
||||
@@ -697,7 +652,7 @@ public class RuleServiceImpl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ruleTypeName == null)
|
||||
{
|
||||
inheritedRules = allInheritedRules;
|
||||
@@ -715,7 +670,7 @@ public class RuleServiceImpl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return inheritedRules;
|
||||
}
|
||||
|
||||
|
@@ -215,18 +215,7 @@ public interface RuleService
|
||||
*/
|
||||
@Auditable(parameters = {"nodeRef"})
|
||||
public int countRules(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Traverse the folder hierarchy find all the folder nodes that could supply rules by inheritance.
|
||||
*
|
||||
* @param nodeRef The starting node ref.
|
||||
* @return A list of node refs, starting with the first parent of the first parent of ... and ending with the object generated by the
|
||||
* given node ref.
|
||||
*/
|
||||
@Auditable (parameters = { "nodeRef" })
|
||||
@Experimental
|
||||
List<NodeRef> getNodesSupplyingRuleSets(NodeRef nodeRef);
|
||||
|
||||
|
||||
/**
|
||||
* Get the rule given its node reference
|
||||
*
|
||||
|
@@ -25,12 +25,7 @@
|
||||
*/
|
||||
package org.alfresco.repo.rule;
|
||||
|
||||
import static java.util.stream.Collectors.joining;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import static org.alfresco.model.ContentModel.ASSOC_CONTAINS;
|
||||
import static org.alfresco.model.ContentModel.ASSOC_MEMBER;
|
||||
import static org.alfresco.repo.rule.RuleModel.ASPECT_IGNORE_INHERITED_RULES;
|
||||
import static org.alfresco.repo.rule.RuleModel.ASSOC_ACTION;
|
||||
import static org.alfresco.repo.rule.RuleModel.ASSOC_RULE_FOLDER;
|
||||
import static org.alfresco.repo.rule.RuleModel.TYPE_RULE;
|
||||
@@ -38,7 +33,6 @@ import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED;
|
||||
import static org.alfresco.service.cmr.security.AccessStatus.DENIED;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.nullable;
|
||||
@@ -53,13 +47,8 @@ import static org.mockito.MockitoAnnotations.openMocks;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.action.RuntimeActionService;
|
||||
import org.alfresco.repo.cache.SimpleCache;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
@@ -72,7 +61,6 @@ import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.service.cmr.rule.RuleServiceException;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
@@ -368,174 +356,4 @@ public class RuleServiceImplUnitTest
|
||||
{
|
||||
return new ChildAssociationRef(null, parentRef, null, childRef, isPrimary, 1);
|
||||
}
|
||||
|
||||
/** Check that a straight chain of nodes is traversed correctly. */
|
||||
@Test
|
||||
public void testGetNodesSupplyingRuleSets_chain()
|
||||
{
|
||||
Map<String, NodeRef> nodes = createParentChildHierarchy("A,B", "B,C", "C,D", "D,E");
|
||||
|
||||
List<NodeRef> actual = ruleService.getNodesSupplyingRuleSets(nodes.get("E"));
|
||||
|
||||
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
|
||||
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
|
||||
|
||||
assertEquals("A,B,C,D,E", nodeNames);
|
||||
}
|
||||
|
||||
/** Check that ordered parents are returned in the correct order. */
|
||||
@Test
|
||||
public void testGetNodesSupplyingRuleSets_multipleParents()
|
||||
{
|
||||
Map<String, NodeRef> nodes = createParentChildHierarchy("A,E", "B,E", "C,E", "D,E");
|
||||
|
||||
List<NodeRef> actual = ruleService.getNodesSupplyingRuleSets(nodes.get("E"));
|
||||
|
||||
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
|
||||
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
|
||||
|
||||
assertEquals("A,B,C,D,E", nodeNames);
|
||||
}
|
||||
|
||||
/** Check that the ASPECT_IGNORE_INHERITED_RULES aspect breaks the chain. */
|
||||
@Test
|
||||
public void testGetNodesSupplyingRuleSets_brokenChain()
|
||||
{
|
||||
Map<String, NodeRef> nodes = createParentChildHierarchy("A,B", "B,C", "C,D", "D,E");
|
||||
given(runtimeNodeService.hasAspect(nodes.get("C"), ASPECT_IGNORE_INHERITED_RULES)).willReturn(true);
|
||||
|
||||
List<NodeRef> actual = ruleService.getNodesSupplyingRuleSets(nodes.get("E"));
|
||||
|
||||
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
|
||||
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
|
||||
|
||||
assertEquals("C,D,E", nodeNames);
|
||||
}
|
||||
|
||||
/** Check that the user group hierarchy is not traversed. */
|
||||
@Test
|
||||
public void testGetNodesSupplyingRuleSets_userGroupHierarchy()
|
||||
{
|
||||
Map<String, NodeRef> nodes = createParentChildHierarchy("A,B", "B,C", "C,D", "D,E");
|
||||
// Replace the B,C association with a user group membership association.
|
||||
ChildAssociationRef memberAssoc = new ChildAssociationRef(ASSOC_MEMBER, nodes.get("B"), ContentModel.TYPE_FOLDER, nodes.get("C"));
|
||||
given(runtimeNodeService.getParentAssocs(nodes.get("C"))).willReturn(List.of(memberAssoc));
|
||||
|
||||
List<NodeRef> actual = ruleService.getNodesSupplyingRuleSets(nodes.get("E"));
|
||||
|
||||
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
|
||||
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
|
||||
|
||||
assertEquals("C,D,E", nodeNames);
|
||||
}
|
||||
|
||||
/** Check that a cycle doesn't cause a problem. */
|
||||
@Test
|
||||
public void testGetNodesSupplyingRuleSets_infiniteCycle()
|
||||
{
|
||||
Map<String, NodeRef> nodes = createParentChildHierarchy("A,B", "B,C", "C,A");
|
||||
|
||||
List<NodeRef> actual = ruleService.getNodesSupplyingRuleSets(nodes.get("C"));
|
||||
|
||||
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
|
||||
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
|
||||
|
||||
assertEquals("A,B,C", nodeNames);
|
||||
}
|
||||
|
||||
/** Check that a diamond of nodes is traversed correctly. */
|
||||
@Test
|
||||
public void testGetNodesSupplyingRuleSets_diamond()
|
||||
{
|
||||
Map<String, NodeRef> nodes = createParentChildHierarchy("A,B", "A,C", "B,D", "C,D");
|
||||
|
||||
List<NodeRef> actual = ruleService.getNodesSupplyingRuleSets(nodes.get("D"));
|
||||
|
||||
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
|
||||
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
|
||||
|
||||
assertEquals("A,B,C,D", nodeNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that hierarchy of nodes is traversed correctly. Parent-child associations are created in alphabetical order.
|
||||
* <pre>
|
||||
* A
|
||||
* /|\
|
||||
* B C D
|
||||
* | |\|
|
||||
* E | F
|
||||
* \|/
|
||||
* G
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
public void testGetNodesSupplyingRuleSets_alphabetical()
|
||||
{
|
||||
Map<String, NodeRef> nodes = createParentChildHierarchy("A,B", "A,C", "A,D", "B,E", "C,F", "C,G", "D,F", "E,G", "F,G");
|
||||
|
||||
List<NodeRef> actual = ruleService.getNodesSupplyingRuleSets(nodes.get("G"));
|
||||
|
||||
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
|
||||
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
|
||||
|
||||
assertEquals("A,C,B,E,D,F,G", nodeNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that hierarchy of nodes is traversed correctly. Parent-child associations are created in reverse alphabetical order.
|
||||
* <pre>
|
||||
* A
|
||||
* /|\
|
||||
* B C D
|
||||
* | |\|
|
||||
* E | F
|
||||
* \|/
|
||||
* G
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
public void testGetNodesSupplyingRuleSets_reversedAssociationOrder()
|
||||
{
|
||||
Map<String, NodeRef> nodes = createParentChildHierarchy("F,G", "E,G", "D,F", "C,G", "C,F", "B,E", "A,D", "A,C", "A,B");
|
||||
|
||||
List<NodeRef> actual = ruleService.getNodesSupplyingRuleSets(nodes.get("G"));
|
||||
|
||||
Map<NodeRef, String> invertedMap = MapUtils.invertMap(nodes);
|
||||
String nodeNames = actual.stream().map(invertedMap::get).collect(joining(","));
|
||||
|
||||
assertEquals("A,D,C,F,B,E,G", nodeNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a mock hierarchy of nodes using the supplied parent child associations.
|
||||
*
|
||||
* @param parentChildAssociations A list of strings of the form "Parent,Child". Associations will be created in this order.
|
||||
* @return A map from the node name to the new NodeRef object.
|
||||
*/
|
||||
private Map<String, NodeRef> createParentChildHierarchy(String... parentChildAssociations)
|
||||
{
|
||||
// Find all the node names mentioned.
|
||||
Set<String> nodeNames = new HashSet<>();
|
||||
List.of(parentChildAssociations).forEach(parentChildAssociation -> {
|
||||
String[] parentChildPair = parentChildAssociation.split(",");
|
||||
nodeNames.addAll(List.of(parentChildPair));
|
||||
});
|
||||
// Create the NodeRefs.
|
||||
Map<String, NodeRef> nodeRefMap = nodeNames.stream().collect(
|
||||
Collectors.toMap(nodeName -> nodeName, nodeName -> new NodeRef("node://" + nodeName + "/")));
|
||||
// Mock the associations.
|
||||
nodeNames.forEach(nodeName -> {
|
||||
NodeRef nodeRef = nodeRefMap.get(nodeName);
|
||||
List<ChildAssociationRef> parentAssocs = List.of(parentChildAssociations)
|
||||
.stream()
|
||||
.filter(assoc -> assoc.endsWith(nodeName))
|
||||
.map(assoc -> assoc.split(",")[0])
|
||||
.map(nodeRefMap::get)
|
||||
.map(parentRef -> new ChildAssociationRef(ASSOC_CONTAINS, parentRef, ContentModel.TYPE_FOLDER, nodeRef))
|
||||
.collect(toList());
|
||||
given(runtimeNodeService.getParentAssocs(nodeRef)).willReturn(parentAssocs);
|
||||
});
|
||||
return nodeRefMap;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user