diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/query-authorities-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/query-authorities-common-SqlMap.xml
index c13b0ccc3b..54d9e454c8 100644
--- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/query-authorities-common-SqlMap.xml
+++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/query-authorities-common-SqlMap.xml
@@ -47,7 +47,11 @@
assoc.qname_localname as authority_name
from
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
+
+ and childNode.type_qname_id = #{typeQNameId}
+
+ )
left join alf_node_properties adn on (adn.node_id = childNode.id and adn.qname_id = #{authorityDisplayNameQNameId})
where
assoc.parent_node_id = #{parentNodeId}
diff --git a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/query-authorities-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/query-authorities-common-SqlMap.xml
index dda23708e9..5c08be2412 100644
--- a/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/query-authorities-common-SqlMap.xml
+++ b/config/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/query-authorities-common-SqlMap.xml
@@ -47,7 +47,11 @@
assoc.qname_localname as authority_name
from
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
+
+ and childNode.type_qname_id = #{typeQNameId}
+
+ )
left join alf_node_properties adn on (adn.node_id = childNode.id and adn.qname_id = #{authorityDisplayNameQNameId})
where
assoc.parent_node_id = #{parentNodeId}
diff --git a/source/java/org/alfresco/repo/security/authority/AuthorityInfoEntity.java b/source/java/org/alfresco/repo/security/authority/AuthorityInfoEntity.java
index b25cbe2aca..6e61db1b77 100644
--- a/source/java/org/alfresco/repo/security/authority/AuthorityInfoEntity.java
+++ b/source/java/org/alfresco/repo/security/authority/AuthorityInfoEntity.java
@@ -1,4 +1,4 @@
-/*
+/*
* #%L
* Alfresco Repository
* %%
@@ -9,20 +9,20 @@
* 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 .
- * #L%
- */
+ * 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 .
+ * #L%
+ */
package org.alfresco.repo.security.authority;
import org.alfresco.repo.domain.node.NodeEntity;
@@ -45,6 +45,8 @@ public class AuthorityInfoEntity
// Supplemental query-related parameters
private Long parentNodeId;
private Long authorityDisplayNameQNameId;
+ // Authority type
+ private Long typeQNameId;
/**
* 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.authorityDisplayNameQNameId = authorityDisplayNameQNameId;
+ this.typeQNameId = typeQNameId;
}
public Long getId()
@@ -110,4 +113,9 @@ public class AuthorityInfoEntity
{
return authorityDisplayNameQNameId;
}
+
+ public Long getTypeQNameId()
+ {
+ return typeQNameId;
+ }
}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQueryFactory.java b/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQueryFactory.java
index 9ec1cc2d0d..4ddb2bc991 100644
--- a/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQueryFactory.java
+++ b/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQueryFactory.java
@@ -1,4 +1,4 @@
-/*
+/*
* #%L
* Alfresco Repository
* %%
@@ -9,20 +9,20 @@
* 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 .
- * #L%
- */
+ * 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 .
+ * #L%
+ */
package org.alfresco.repo.security.authority;
import java.util.ArrayList;
@@ -116,8 +116,11 @@ public class GetAuthoritiesCannedQueryFactory extends AbstractCannedQueryFactory
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
GetAuthoritiesCannedQueryParams paramBean = new GetAuthoritiesCannedQueryParams(type,
+ typeQNameId,
containerNodeId,
qnameAuthDisplayNameId,
displayNameFilter);
@@ -140,7 +143,29 @@ public class GetAuthoritiesCannedQueryFactory extends AbstractCannedQueryFactory
// return canned query instance
return getCannedQuery(params);
}
-
+
+ private Long getQNameIdForType(AuthorityType type)
+ {
+ if (type == null)
+ {
+ return null;
+ }
+ Pair 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
public void afterPropertiesSet() throws Exception
{
diff --git a/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQueryParams.java b/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQueryParams.java
index 038f5a0de5..ff22a1ae71 100644
--- a/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQueryParams.java
+++ b/source/java/org/alfresco/repo/security/authority/GetAuthoritiesCannedQueryParams.java
@@ -1,4 +1,4 @@
-/*
+/*
* #%L
* Alfresco Repository
* %%
@@ -9,20 +9,20 @@
* 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 .
- * #L%
- */
+ * 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 .
+ * #L%
+ */
package org.alfresco.repo.security.authority;
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 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("*")))
{
diff --git a/source/test-java/org/alfresco/repo/security/authority/AuthorityServiceTest.java b/source/test-java/org/alfresco/repo/security/authority/AuthorityServiceTest.java
index 37bc47ed61..9e58b1d4d9 100644
--- a/source/test-java/org/alfresco/repo/security/authority/AuthorityServiceTest.java
+++ b/source/test-java/org/alfresco/repo/security/authority/AuthorityServiceTest.java
@@ -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 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 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 props = new HashMap(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 results, List checklist, boolean included)
{
for (String check : checklist)