Merge 7.0.0-A3 changes into new projects (#3)

* Cherry pick (merge) changes from original projects in 7.0.0-A3)

Bump spring-surf-core-configservice from 8.5 to 8.6 (#144)

(cherry picked from commit 43e2592b264a6876da779d694f9a54f944c674c8)
Bump dependency.spring.version from 5.2.7.RELEASE to 5.2.8.RELEASE (#143)

(cherry picked from commit 9310346f19d6f4fb10317b6acbfb03df0bdefbd7)
Bump spring-surf-core-configservice from 8.6 to 8.7 (#145)

(cherry picked from commit 7ad131f31cd73b5ec103d279831fbc1fa8241496)
Bump spring-surf-core-configservice from 8.7 to 8.8 (#147)

(cherry picked from commit fcb5bd88e8331cfabf5a9a40e3c00e2aa013265a)
Bump mockito-core from 3.4.4 to 3.4.6 (#149)

(cherry picked from commit 1febbc71c8a52bb71620d218a15c2d7ff40350bb)
[SEARCH-2354] (#298)

Added support for DAYOFWEEK and DAYOFYEAR sql date functions

(cherry picked from commit 48bf24654945626eb8b26ff2ac0144bd92fe3302)
Bump jackson-annotations from 2.11.1 to 2.11.2 (#300)

(cherry picked from commit cde846f16f25e111b191eb8db4b46a967f40ff8e)
SEARCH-2273: Add detailed message when ignoring nodes in SOLR without… (#1111)

* SEARCH-2273: Add detailed message when ignoring nodes in SOLR without type or with types not registered in Dictionary Service.

* SEARCH-2273: Using non-registered type name.

* SEARCH-2273: Creating node without type using DB Service.

* SEARCH-2273: Check the right exception is produced when using a non registered TYPE.

* SEARCH-2273: Simplified case identification for exception message.

* SEARCH-2273: Remove unused library.

(cherry picked from commit f4bdc8c888dab01a1180715441c1669ac20e564d)
Bump dependency.spring.version from 5.2.6.RELEASE to 5.2.8.RELEASE (#1116)

(cherry picked from commit b7fc60bb60f483745f0461b9709b52e47d21e453)
Bump dependency.webscripts.version from 8.5 to 8.6 (#1117)

(cherry picked from commit 137013790b7852e549f7316c60b5305dff5f68f8)
SEARCH-800: Get values in DBResultSetRow in the same way they are rec… (#1114)

* SEARCH-800: Get values in DBResultSetRow in the same way they are recovered in SolrJSONResultSetRow.
This will provide the same behaviour when using getValue() method from Search ResultSet.

* SEARCH-800: Testing that using TRANSACTIONAL query consistency allows getting values using "getValue" method.

(cherry picked from commit 695113f4c40e34dcd8663d28e0ee56c956930a5e)
MNT-21317 Move on Update Folder Rule triggers unexpectedly for MOVED content. (#1115)

* MNT-21317_fix folder rule trigger

* MNT-21317_folder rule test case added

* Update .travis.yml

* Update OnPropertyUpdateRuleTrigger.java

* MNT-21317 updated test

(cherry picked from commit 33ca87046019416875fd23b72293e84b912f4cd9)
Bump aspectjrt from 1.9.5 to 1.9.6 (#1124)

(cherry picked from commit 330bb0820d2ce9608612eba9fed5acd76786853a)
Bump groovy-all from 2.4.19 to 2.4.20 (#1125)

(cherry picked from commit 4ab253bb21348f23a4df7e79ded43c16a9347e7c)
Bump dependency.webscripts.version from 8.6 to 8.7 (#1127)

(cherry picked from commit ac270757a7ff4bcd477375008902cf53bc220838)
Bump mariadb-java-client from 2.6.1 to 2.6.2 (#1128)

(cherry picked from commit 1f633aef1020aaeb31a71e0e4fed883f5a677f0f)
Bump gytheio-messaging-camel from 0.11.3 to 0.11.6 (#1095)

Bumps gytheio-messaging-camel from 0.11.3 to 0.11.6.

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

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

(cherry picked from commit 16179db5fc4524c339097f1f3a9a6409dd895b11)
Bump dependency.webscripts.version from 8.7 to 8.8 (#1133)

(cherry picked from commit d363862d653e85e9366367817a82353580b2c6ce)
Bump dependency.transform.model.version from 1.0.2.10 to 1.0.2.11 (#1143)

(cherry picked from commit beaccd28608d2c70ef9eaf640d47a2e86a59ced4)
ATS-811: Updated T-engines to 2.3.3 (#1145)

(cherry picked from commit cbe6d78767741cb2b5f38d17cf4556dbda7c5311)
MNT-21614: LDAP sync communication error leads to group members deletion (#1149)

* Catch reported exceptions to filter ldap sync aborts

(cherry picked from commit 7e8cbd044e9ec2d31e05d072c0d47aa2d22ef771)
Bump commons-net from 3.6 to 3.7 (#1153)

(cherry picked from commit 3b5503bbf1c231a844536c54c639ad41a9c1b6aa)
ATS-817: Updated T-engines to 2.3.4 (#1151)

(cherry picked from commit b7f9ae0b71b599e27a59787ec3fe584ab64f1330)
[REPO-5239] - Added filter by displayName to /groups endpoint (#706)

* [REPO-5239] - Added filter by displayName to /groups endpoint

* [REPO-5239] - minor fix, brackets style

* [REPO-5239] Refactoring

* [REPO-5239] Fix to avoid the usage of displayName filter implemented in authorityService.getAuthoritiesInfo

(cherry picked from commit a01b80448ef48c5bb68978159b0ea134382ee653)

* Include branch in build

* More changes as a result of merging to alfresco-enterprise-repo. Dependencies now defined in community

* ACS-222: tests jobs using AIMS fail (#1464)

* Added a 3 minutes sleep after the curl request is succeeded preventing tests from starting immediately

Reimplemented from commit a6abc8a2c952d8c8d894bdeb50efe42f695d13cf on acs-packaging master. Now takes a second
optional parameter for the extra wait, so no all uses have to wait. Only AIMS.

* Merge commit to do with base-tomcat:8.5.51
This commit is contained in:
Alan Davis
2020-08-11 12:37:46 +01:00
committed by GitHub
parent 4dd068a98a
commit c7fbb97f76
25 changed files with 720 additions and 144 deletions

View File

@@ -35,7 +35,6 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -74,6 +73,7 @@ import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.util.AlfrescoCollator;
import org.alfresco.util.Pair;
import org.apache.commons.lang3.StringUtils;
import org.springframework.extensions.surf.util.I18NUtil;
/**
@@ -84,7 +84,9 @@ import org.springframework.extensions.surf.util.I18NUtil;
public class GroupsImpl implements Groups
{
private static final int MAX_ZONES = 1;
private static final int MAX_DISPLAY_NAMES = 1;
private static final String DISPLAY_NAME = "displayName";
private static final String ZONE = "zone";
private static final String AUTHORITY_NAME = "authorityName";
private static final String ERR_MSG_MODIFY_FIXED_AUTHORITY = "Trying to modify a fixed authority";
@@ -181,39 +183,20 @@ public class GroupsImpl implements Groups
public CollectionWithPagingInfo<Group> getGroups(final Parameters parameters)
{
final List<String> includeParam = parameters.getInclude();
Paging paging = parameters.getPaging();
// Retrieve sort column. This is limited for now to sort column due to
// v0 api implementation. Should be improved in the future.
Pair<String, Boolean> sortProp = getGroupsSortProp(parameters);
// Parse where clause properties.
Query q = parameters.getQuery();
Boolean isRootParam = null;
String zoneFilter = null;
if (q != null)
{
GroupsQueryWalker propertyWalker = new GroupsQueryWalker();
QueryHelper.walk(q, propertyWalker);
isRootParam = propertyWalker.getIsRoot();
List<String> zonesParam = propertyWalker.getZones();
if (zonesParam != null)
{
validateZonesParam(zonesParam);
zoneFilter = zonesParam.get(0);
}
}
GroupsFilter groupsFilters = getGroupsFilterFromQueryParameters(parameters.getQuery());
final AuthorityType authorityType = AuthorityType.GROUP;
final Set<String> rootAuthorities = getAllRootAuthorities(authorityType);
PagingResults<AuthorityInfo> pagingResult;
try
{
pagingResult = getAuthoritiesInfo(authorityType, isRootParam, zoneFilter, rootAuthorities, sortProp, paging);
pagingResult = getAuthoritiesInfo(authorityType, groupsFilters, rootAuthorities, sortProp, paging);
}
catch (UnknownAuthorityException e)
{
@@ -221,9 +204,15 @@ public class GroupsImpl implements Groups
pagingResult = new EmptyPagingResults<>();
}
// Create response.
final List<AuthorityInfo> page = pagingResult.getPage();
List<Group> groups = createGroupsResponse(pagingResult.getPage(), parameters.getInclude(), rootAuthorities);
int totalItems = pagingResult.getTotalResultCount().getFirst();
return CollectionWithPagingInfo.asPaged(paging, groups, pagingResult.hasMoreItems(), totalItems);
}
private List<Group> createGroupsResponse(final List<AuthorityInfo> page, final List<String> includeParam, final Set<String> rootAuthorities)
{
List<Group> groups = new AbstractList<Group>()
{
@Override
@@ -239,27 +228,58 @@ public class GroupsImpl implements Groups
return page.size();
}
};
return CollectionWithPagingInfo.asPaged(paging, groups, pagingResult.hasMoreItems(), totalItems);
return groups;
}
private void validateZonesParam(List<String> zonesParam)
private GroupsFilter getGroupsFilterFromQueryParameters(Query queryParameters)
{
if (zonesParam.size() > MAX_ZONES)
GroupsFilter.GroupsFilterBuilder groupsFilterBuilder = GroupsFilter.builder();
if (queryParameters != null)
{
throw new IllegalArgumentException("A maximum of " + MAX_ZONES + " zones may be specified.");
GroupsQueryWalker propertyWalker = new GroupsQueryWalker();
QueryHelper.walk(queryParameters, propertyWalker);
groupsFilterBuilder
.withIsRoot(
propertyWalker.getIsRoot())
.withZoneFilter(
getStringFilterFromList(propertyWalker.getZones(), ZONE, MAX_ZONES))
.withDisplayNameFilter(
getStringFilterFromList(propertyWalker.getDisplayNames(), DISPLAY_NAME, MAX_DISPLAY_NAMES));
}
else if (zonesParam.isEmpty())
return groupsFilterBuilder.build();
}
private String getStringFilterFromList(List<String> listParam, String paramName, int maxItems)
{
String filter = null;
if (listParam != null)
{
throw new IllegalArgumentException("Zones filter list cannot be empty.");
validateListParam(listParam, paramName, maxItems);
filter = listParam.get(0);
}
// Validate each zone name
zonesParam.forEach(zone -> {
if (zone.isEmpty())
{
throw new IllegalArgumentException("Zone name cannot be empty (i.e. '')");
}
});
return filter;
}
private void validateListParam(List<String> listParam, String paramName, int maxItems)
{
if (listParam.size() > maxItems)
{
throw new IllegalArgumentException("A maximum of " + maxItems + " " + paramName + "s may be specified.");
}
else if (listParam.isEmpty())
{
throw new IllegalArgumentException(StringUtils.capitalize(paramName) + "s filter list cannot be empty.");
}
listParam
.stream()
.filter(String::isEmpty)
.findAny()
.ifPresent(displayName -> {
throw new IllegalArgumentException(StringUtils.capitalize(paramName) + " cannot be empty (i.e. '')");
});
}
@Override
@@ -290,7 +310,7 @@ public class GroupsImpl implements Groups
List<String> zonesParam = propertyWalker.getZones();
if (zonesParam != null)
{
validateZonesParam(zonesParam);
validateListParam(zonesParam, ZONE, MAX_ZONES);
zoneFilter = zonesParam.get(0);
}
}
@@ -334,22 +354,26 @@ public class GroupsImpl implements Groups
return CollectionWithPagingInfo.asPaged(paging, groups, pagingResult.hasMoreItems(), totalItems);
}
private PagingResults<AuthorityInfo> getAuthoritiesInfo(AuthorityType authorityType, Boolean isRootParam, String zoneFilter, Set<String> rootAuthorities, Pair<String, Boolean> sortProp,
Paging paging)
private PagingResults<AuthorityInfo> getAuthoritiesInfo(AuthorityType authorityType, GroupsFilter groupsFilter, Set<String> rootAuthorities,
Pair<String, Boolean> sortProp, Paging paging)
{
Boolean isRootParam = groupsFilter.getIsRoot();
String zoneFilter = groupsFilter.getZoneFilter();
String displayNameFilter = groupsFilter.getDisplayNameFilter();
PagingResults<AuthorityInfo> pagingResult;
if (isRootParam != null)
if (isRootParam != null || displayNameFilter != null)
{
List<AuthorityInfo> groupList;
if (isRootParam)
if (isRootParam != null && isRootParam)
{
// Limit the post processing work by using the already loaded
// list of root authorities.
List<AuthorityInfo> authorities = rootAuthorities.stream().
map(this::getAuthorityInfo).
filter(auth -> zonePredicate(auth.getAuthorityName(), zoneFilter)).
filter(auth -> displayNamePredicate(auth.getAuthorityDisplayName(), displayNameFilter)).
collect(Collectors.toList());
groupList = new ArrayList<>(rootAuthorities.size());
groupList.addAll(authorities);
@@ -376,14 +400,11 @@ public class GroupsImpl implements Groups
groupList = nonPagingResult.getPage();
if (groupList != null)
{
for (Iterator<AuthorityInfo> i = groupList.iterator(); i.hasNext();)
{
AuthorityInfo authorityInfo = i.next();
if (!isRootParam.equals(isRootAuthority(rootAuthorities, authorityInfo.getAuthorityName())))
{
i.remove();
}
}
groupList = groupList
.stream()
.filter(auth -> isRootPredicate(isRootParam, rootAuthorities, auth.getAuthorityName()))
.filter(auth -> displayNamePredicate(auth.getAuthorityDisplayName(), displayNameFilter))
.collect(Collectors.toList());
}
}
@@ -463,6 +484,25 @@ public class GroupsImpl implements Groups
return true;
}
/**
* Checks to see if the named group authority should be included in results
* when filtered by displayName.
* <p>
* If the requiredDisplayName parameter is null, then the filter will not be applied (returns true.)
* <p>
* @param groupDisplayName
* @param requiredDisplayName
* @return true if result should be included.
*/
private boolean displayNamePredicate(String groupDisplayName, String requiredDisplayName)
{
if (requiredDisplayName != null)
{
return groupDisplayName != null && groupDisplayName.equalsIgnoreCase(requiredDisplayName);
}
return true;
}
private Set<String> getAllRootAuthorities(AuthorityType authorityType)
{
Set<String> authorities;
@@ -1026,6 +1066,7 @@ public class GroupsImpl implements Groups
private static class GroupsQueryWalker extends MapBasedQueryWalker
{
private List<String> zones;
private List<String> displayNames;
public GroupsQueryWalker()
{
@@ -1045,6 +1086,10 @@ public class GroupsImpl implements Groups
{
zones = Arrays.asList(propertyValues);
}
if (propertyName.equalsIgnoreCase(DISPLAY_NAME))
{
displayNames = Arrays.asList(propertyValues);
}
}
/**
@@ -1066,5 +1111,81 @@ public class GroupsImpl implements Groups
{
return getProperty(PARAM_IS_ROOT, WhereClauseParser.EQUALS, Boolean.class);
}
/**
* The list of displayName specified in the where clause.
*
* @return The displayNames list if specified, or null if not.
*/
public List<String> getDisplayNames()
{
return displayNames;
}
}
}
class GroupsFilter
{
private Boolean isRoot;
private String zoneFilter;
private String displayNameFilter;
private GroupsFilter()
{
}
public static GroupsFilterBuilder builder()
{
return new GroupsFilterBuilder();
}
public Boolean getIsRoot()
{
return isRoot;
}
public String getZoneFilter()
{
return zoneFilter;
}
public String getDisplayNameFilter()
{
return displayNameFilter;
}
public static class GroupsFilterBuilder
{
private Boolean isRoot;
private String zoneFilter;
private String displayNameFilter;
public GroupsFilterBuilder withIsRoot(Boolean isRoot)
{
this.isRoot = isRoot;
return this;
}
public GroupsFilterBuilder withZoneFilter(String zoneFilter)
{
this.zoneFilter = zoneFilter;
return this;
}
public GroupsFilterBuilder withDisplayNameFilter(String displayNameFilter)
{
this.displayNameFilter = displayNameFilter;
return this;
}
public GroupsFilter build()
{
GroupsFilter groupsFilter = new GroupsFilter();
groupsFilter.isRoot = this.isRoot;
groupsFilter.zoneFilter = this.zoneFilter;
groupsFilter.displayNameFilter = this.displayNameFilter;
return groupsFilter;
}
}
}

View File

@@ -115,6 +115,7 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
testGetGroupsByIsRoot(true);
testGetGroupsByIsRoot(false);
testGetGroupsWithZoneFilter();
testGetGroupsWithDisplayNameFilter();
}
finally
{
@@ -1856,4 +1857,193 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
return subGroup;
}
private void testGetGroupsWithDisplayNameFilter() throws Exception
{
shouldFilterGroupByDisplayName();
shouldFilterGroupByDisplayNameWhenNameNotExist();
shouldFilterGroupByDisplayNameAndZone();
shouldFilterGroupByDisplayNameWhenGroupIsRoot();
shouldFilterGroupByDisplayNameWhenIsRootIsFalse();
shouldFilterGroupByDisplayNameAndZoneWhenGroupIsRoot();
shouldReturnBadRequestErrorWhenTooManyDisplayNames();
shouldReturnBadRequestErrorWhenDisplayNameIsEmpty();
shouldNotAllowWildcards();
}
private void shouldFilterGroupByDisplayName() throws Exception
{
Paging paging = getPaging(0, Integer.MAX_VALUE);
Map<String, String> otherParams = new HashMap<>();
otherParams.put("where", "(displayName in ('A Group'))");
ListResponse<Group> response = getGroups(paging, otherParams);
List<Group> groups = response.getList();
assertEquals(1, groups.size());
assertEquals("A Group", groups.get(0).getDisplayName());
otherParams.put("where", "(displayName in ('a group'))");
response = getGroups(paging, otherParams);
response.getList();
assertEquals(1, groups.size());
assertEquals("A Group", groups.get(0).getDisplayName());
}
private void shouldFilterGroupByDisplayNameWhenNameNotExist() throws Exception
{
Paging paging = getPaging(0, Integer.MAX_VALUE);
Map<String, String> otherParams = new HashMap<>();
otherParams.put("where", "(displayName in ('AGroupName'))");
ListResponse<Group> response = getGroups(paging, otherParams);
List<Group> groups = response.getList();
assertTrue(groups.isEmpty());
}
private void shouldFilterGroupByDisplayNameAndZone() throws Exception
{
Paging paging = getPaging(0, Integer.MAX_VALUE);
Map<String, String> otherParams = new HashMap<>();
addOrderBy(otherParams, org.alfresco.rest.api.Groups.PARAM_DISPLAY_NAME, true);
otherParams.put("include", org.alfresco.rest.api.Groups.PARAM_INCLUDE_ZONES);
otherParams.put("where", "(zones in ('APITEST.MYZONE') AND displayName in ('A Group'))");
ListResponse<Group> response = getGroups(paging, otherParams);
List<Group> groups = response.getList();
assertEquals(1, groups.size());
assertTrue(groups.get(0).getZones().contains("APITEST.MYZONE"));
assertEquals("A Group", groups.get(0).getDisplayName());
}
private void shouldFilterGroupByDisplayNameWhenGroupIsRoot() throws Exception
{
Paging paging = getPaging(0, Integer.MAX_VALUE);
Map<String, String> otherParams = new HashMap<>();
otherParams.put("where", "(isRoot=true AND displayName in ('Root Group'))");
ListResponse<Group> response = getGroups(paging, otherParams);
List<Group> groups = response.getList();
assertEquals(1, groups.size());
assertEquals("Root Group", groups.get(0).getDisplayName());
}
private void shouldFilterGroupByDisplayNameWhenIsRootIsFalse() throws Exception
{
Paging paging = getPaging(0, Integer.MAX_VALUE);
Map<String, String> otherParams = new HashMap<>();
otherParams.put("where", "(isRoot=False AND displayName in ('A Group'))");
ListResponse<Group> response = getGroups(paging, otherParams);
List<Group> groups = response.getList();
assertEquals(1, groups.size());
assertEquals("A Group", groups.get(0).getDisplayName());
}
private void shouldFilterGroupByDisplayNameAndZoneWhenGroupIsRoot() throws Exception
{
Paging paging = getPaging(0, Integer.MAX_VALUE);
Map<String, String> otherParams = new HashMap<>();
otherParams.put("include", org.alfresco.rest.api.Groups.PARAM_INCLUDE_ZONES);
otherParams.put("where", "(isRoot=true AND zones in ('APITEST.MYZONE') AND displayName in ('Root Group'))");
ListResponse<Group> response = getGroups(paging, otherParams);
List<Group> groups = response.getList();
assertEquals(1, groups.size());
assertTrue(groups.get(0).getZones().contains("APP.DEFAULT"));
assertEquals("Root Group", groups.get(0).getDisplayName());
}
private void shouldReturnBadRequestErrorWhenTooManyDisplayNames() throws Exception
{
Paging paging = getPaging(0, Integer.MAX_VALUE);
Map<String, String> otherParams = new HashMap<>();
otherParams.put("where", "(displayName in ('Group A', 'Group B'))");
getGroups(paging, otherParams, "Incorrect response", 400);
}
private void shouldReturnBadRequestErrorWhenDisplayNameIsEmpty() throws Exception
{
Paging paging = getPaging(0, Integer.MAX_VALUE);
Map<String, String> otherParams = new HashMap<>();
otherParams.put("where","(displayName in ())");
getGroups(paging, otherParams, "Incorrect response",400);
otherParams.put("where","(displayName in (''))");
getGroups(paging, otherParams, "Incorrect response",400);
}
private void shouldNotAllowWildcards() throws Exception
{
Paging paging = getPaging(0, Integer.MAX_VALUE);
Map<String, String> otherParams = new HashMap<>();
otherParams.put("where", "(displayName in ('*'))");
ListResponse<Group> response = getGroups(paging, otherParams);
List<Group> groups = response.getList();
assertEquals(0, groups.size());
otherParams.put("where", "(isRoot=true AND displayName in ('*'))");
response = getGroups(paging, otherParams);
groups = response.getList();
assertEquals(0, groups.size());
otherParams.put("where", "(displayName in ('A*'))");
response = getGroups(paging, otherParams);
groups = response.getList();
assertEquals(0, groups.size());
otherParams.put("where", "(isRoot=true AND displayName in ('A*'))");
response = getGroups(paging, otherParams);
groups = response.getList();
assertEquals(0, groups.size());
otherParams.put("where", "(displayName in ('*roup'))");
response = getGroups(paging, otherParams);
groups = response.getList();
assertEquals(0, groups.size());
otherParams.put("where", "(isRoot=true AND displayName in ('*roup'))");
response = getGroups(paging, otherParams);
groups = response.getList();
assertEquals(0, groups.size());
otherParams.put("where", "(displayName in ('Root ?ROUP'))");
response = getGroups(paging, otherParams);
groups = response.getList();
assertEquals(0, groups.size());
otherParams.put("where", "(isRoot=true AND displayName in ('Root ?ROUP'))");
response = getGroups(paging, otherParams);
groups = response.getList();
assertEquals(0, groups.size());
otherParams.put("where", "(displayName in ('Group'))");
response = getGroups(paging, otherParams);
groups = response.getList();
assertEquals(0, groups.size());
otherParams.put("where", "(isRoot=true AND displayName in ('Group'))");
response = getGroups(paging, otherParams);
groups = response.getList();
assertEquals(0, groups.size());
}
}