Merged 5.2.N (5.2.1) to HEAD (5.2)

128332 adavis: Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
      128253 adavis: Merged 5.0.N (5.0.4) to 5.1.N (5.1.2)
         128241 adavis: Merged V4.2-BUG-FIX (4.2.7) to 5.0.N (5.0.4)
            128225 adavis: Merged V4.1-BUG-FIX (4.1.11) to V4.2-BUG-FIX (4.2.7)
               128166 amorarasu: Merged V4.1.9 (4.1.9.16) to V4.1-BUG-FIX (4.1.11)
                  128155 amorarasu: MNT-16316: GET /alfresco/service/api/groups API slow performance when the 'zone' filter is used.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@129283 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alexandru Epure
2016-08-09 13:55:31 +00:00
parent c06c9a208a
commit 43724e8ec6
6 changed files with 121 additions and 51 deletions

View File

@@ -47,7 +47,11 @@
assoc.qname_localname as authority_name <!-- see note --> assoc.qname_localname as authority_name <!-- see note -->
from from
alf_child_assoc assoc alf_child_assoc assoc
join alf_node childNode on (childNode.id = assoc.child_node_id) join alf_node childNode on (childNode.id = assoc.child_node_id
<if test="typeQNameId != null">
and childNode.type_qname_id = #{typeQNameId}
</if>
)
left join alf_node_properties adn on (adn.node_id = childNode.id and adn.qname_id = #{authorityDisplayNameQNameId}) left join alf_node_properties adn on (adn.node_id = childNode.id and adn.qname_id = #{authorityDisplayNameQNameId})
where where
assoc.parent_node_id = #{parentNodeId} assoc.parent_node_id = #{parentNodeId}

View File

@@ -47,7 +47,11 @@
assoc.qname_localname as authority_name <!-- see note --> assoc.qname_localname as authority_name <!-- see note -->
from from
alf_child_assoc assoc alf_child_assoc assoc
join alf_node childNode on (childNode.id = assoc.child_node_id) join alf_node childNode on (childNode.id = assoc.child_node_id
<if test="typeQNameId != null">
and childNode.type_qname_id = #{typeQNameId}
</if>
)
left join alf_node_properties adn on (adn.node_id = childNode.id and adn.qname_id = #{authorityDisplayNameQNameId}) left join alf_node_properties adn on (adn.node_id = childNode.id and adn.qname_id = #{authorityDisplayNameQNameId})
where where
assoc.parent_node_id = #{parentNodeId} assoc.parent_node_id = #{parentNodeId}

View File

@@ -1,4 +1,4 @@
/* /*
* #%L * #%L
* Alfresco Repository * Alfresco Repository
* %% * %%
@@ -9,20 +9,20 @@
* the paid license agreement will prevail. Otherwise, the software is * the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms: * provided under the following open source license terms:
* *
* Alfresco is free software: you can redistribute it and/or modify * 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 * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* Alfresco is distributed in the hope that it will be useful, * Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.repo.security.authority; package org.alfresco.repo.security.authority;
import org.alfresco.repo.domain.node.NodeEntity; import org.alfresco.repo.domain.node.NodeEntity;
@@ -45,6 +45,8 @@ public class AuthorityInfoEntity
// Supplemental query-related parameters // Supplemental query-related parameters
private Long parentNodeId; private Long parentNodeId;
private Long authorityDisplayNameQNameId; private Long authorityDisplayNameQNameId;
// Authority type
private Long typeQNameId;
/** /**
* Default constructor * Default constructor
@@ -53,10 +55,11 @@ public class AuthorityInfoEntity
{ {
} }
public AuthorityInfoEntity(Long parentNodeId, Long authorityDisplayNameQNameId) public AuthorityInfoEntity(Long parentNodeId, Long authorityDisplayNameQNameId, Long typeQNameId)
{ {
this.parentNodeId = parentNodeId; this.parentNodeId = parentNodeId;
this.authorityDisplayNameQNameId = authorityDisplayNameQNameId; this.authorityDisplayNameQNameId = authorityDisplayNameQNameId;
this.typeQNameId = typeQNameId;
} }
public Long getId() public Long getId()
@@ -110,4 +113,9 @@ public class AuthorityInfoEntity
{ {
return authorityDisplayNameQNameId; return authorityDisplayNameQNameId;
} }
public Long getTypeQNameId()
{
return typeQNameId;
}
} }

View File

@@ -1,4 +1,4 @@
/* /*
* #%L * #%L
* Alfresco Repository * Alfresco Repository
* %% * %%
@@ -9,20 +9,20 @@
* the paid license agreement will prevail. Otherwise, the software is * the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms: * provided under the following open source license terms:
* *
* Alfresco is free software: you can redistribute it and/or modify * 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 * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* Alfresco is distributed in the hope that it will be useful, * Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.repo.security.authority; package org.alfresco.repo.security.authority;
import java.util.ArrayList; import java.util.ArrayList;
@@ -116,8 +116,11 @@ public class GetAuthoritiesCannedQueryFactory extends AbstractCannedQueryFactory
qnameAuthDisplayNameId = qnameAuthDisplayNamePair.getFirst(); qnameAuthDisplayNameId = qnameAuthDisplayNamePair.getFirst();
} }
// this can be null, in which case, there is no filtering on type, done at the database level
Long typeQNameId = getQNameIdForType(type);
// specific query params // specific query params
GetAuthoritiesCannedQueryParams paramBean = new GetAuthoritiesCannedQueryParams(type, GetAuthoritiesCannedQueryParams paramBean = new GetAuthoritiesCannedQueryParams(type,
typeQNameId,
containerNodeId, containerNodeId,
qnameAuthDisplayNameId, qnameAuthDisplayNameId,
displayNameFilter); displayNameFilter);
@@ -140,7 +143,29 @@ public class GetAuthoritiesCannedQueryFactory extends AbstractCannedQueryFactory
// return canned query instance // return canned query instance
return getCannedQuery(params); return getCannedQuery(params);
} }
private Long getQNameIdForType(AuthorityType type)
{
if (type == null)
{
return null;
}
Pair<Long, QName> typeQNamePair = null;
switch (type)
{
case GROUP:
case ROLE:
typeQNamePair = qnameDAO.getQName(ContentModel.TYPE_AUTHORITY_CONTAINER);
break;
case USER:
typeQNamePair = qnameDAO.getQName(ContentModel.TYPE_PERSON);
break;
default:
break;
}
return typeQNamePair != null ? typeQNamePair.getFirst() : null;
}
@Override @Override
public void afterPropertiesSet() throws Exception public void afterPropertiesSet() throws Exception
{ {

View File

@@ -1,4 +1,4 @@
/* /*
* #%L * #%L
* Alfresco Repository * Alfresco Repository
* %% * %%
@@ -9,20 +9,20 @@
* the paid license agreement will prevail. Otherwise, the software is * the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms: * provided under the following open source license terms:
* *
* Alfresco is free software: you can redistribute it and/or modify * 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 * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* Alfresco is distributed in the hope that it will be useful, * Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.repo.security.authority; package org.alfresco.repo.security.authority;
import org.alfresco.service.cmr.security.AuthorityType; import org.alfresco.service.cmr.security.AuthorityType;
@@ -39,9 +39,9 @@ public class GetAuthoritiesCannedQueryParams extends AuthorityInfoEntity
private String displayNameFilter; // startsWith / ignoreCase (note: trailing * is implied) private String displayNameFilter; // startsWith / ignoreCase (note: trailing * is implied)
private AuthorityType type; private AuthorityType type;
public GetAuthoritiesCannedQueryParams(AuthorityType type, Long parentNodeId, Long authorityDisplayNameQNameId, String displayNameFilter) public GetAuthoritiesCannedQueryParams(AuthorityType type, Long typeQNameId, Long parentNodeId, Long authorityDisplayNameQNameId, String displayNameFilter)
{ {
super(parentNodeId, authorityDisplayNameQNameId); super(parentNodeId, authorityDisplayNameQNameId, typeQNameId);
if ((displayNameFilter == null) || (displayNameFilter.equals("")) || (displayNameFilter.equals("*"))) if ((displayNameFilter == null) || (displayNameFilter.equals("")) || (displayNameFilter.equals("*")))
{ {

View File

@@ -1516,6 +1516,35 @@ public class AuthorityServiceTest extends TestCase
*/ */
} }
public void testGetAuthoritiesForZone()
{
String role = pubAuthorityService.createAuthority(AuthorityType.ROLE, "one");
String group = pubAuthorityService.createAuthority(AuthorityType.GROUP, "group1");
String user = "user@" + System.currentTimeMillis();
createUserAuthority(user);
PagingResults<String> authorities = authorityService.getAuthorities(null, AuthorityService.ZONE_APP_DEFAULT, "*", false, false, new PagingRequest(100));
assertTrue(authorities.getPage().contains(user));
assertTrue(authorities.getPage().contains(role));
assertTrue(authorities.getPage().contains(group));
PagingResults<String> groups = authorityService.getAuthorities(AuthorityType.GROUP, AuthorityService.ZONE_APP_DEFAULT, "*", false, false, new PagingRequest(100));
assertTrue(groups.getPage().contains(group));
assertFalse(groups.getPage().contains(user));
assertFalse(groups.getPage().contains(role));
}
private void createUserAuthority(String user)
{
Map<QName, Serializable> props = new HashMap<QName, Serializable>(4, 1.0f);
props.put(ContentModel.PROP_USERNAME, user);
props.put(ContentModel.PROP_FIRSTNAME, user);
props.put(ContentModel.PROP_LASTNAME, user);
props.put(ContentModel.PROP_EMAIL, user + "@gmail.com");
personService.createPerson(props);
authenticationService.createAuthentication(user, "123123".toCharArray());
}
private void assertContains(List<String> results, List<String> checklist, boolean included) private void assertContains(List<String> results, List<String> checklist, boolean included)
{ {
for (String check : checklist) for (String check : checklist)