mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-5506 Add description and hasSubgroups to groups API
This commit is contained in:
@@ -38,8 +38,12 @@ public class RestGroupsModel extends TestModel implements IRestModel<RestGroupsM
|
|||||||
private String id;
|
private String id;
|
||||||
@JsonProperty(required = true)
|
@JsonProperty(required = true)
|
||||||
private String displayName;
|
private String displayName;
|
||||||
|
@JsonProperty()
|
||||||
|
private String description;
|
||||||
@JsonProperty(required = true)
|
@JsonProperty(required = true)
|
||||||
private Boolean isRoot;
|
private Boolean isRoot;
|
||||||
|
@JsonProperty(required = true)
|
||||||
|
private Boolean hasSubgroups;
|
||||||
|
|
||||||
@JsonProperty("parentIds")
|
@JsonProperty("parentIds")
|
||||||
private ArrayList<String> parentIds;
|
private ArrayList<String> parentIds;
|
||||||
@@ -75,6 +79,22 @@ public class RestGroupsModel extends TestModel implements IRestModel<RestGroupsM
|
|||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getHasSubgroups() {
|
||||||
|
return hasSubgroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasSubgroups(Boolean hasSubgroups) {
|
||||||
|
this.hasSubgroups = hasSubgroups;
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean getIsRoot()
|
public Boolean getIsRoot()
|
||||||
{
|
{
|
||||||
return isRoot;
|
return isRoot;
|
||||||
|
@@ -34,7 +34,8 @@ public class GroupsTests extends RestTest
|
|||||||
public void createListUpdateAndDeleteGroup() throws Exception
|
public void createListUpdateAndDeleteGroup() throws Exception
|
||||||
{
|
{
|
||||||
String groupName = "ZtestGroup" + UUID.randomUUID().toString();
|
String groupName = "ZtestGroup" + UUID.randomUUID().toString();
|
||||||
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build();
|
String groupDescription = "ZtestGroup description" + UUID.randomUUID().toString();
|
||||||
|
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).add("description", groupDescription).build();
|
||||||
String groupBodyCreate = groupBody.toString();
|
String groupBodyCreate = groupBody.toString();
|
||||||
|
|
||||||
//GroupCreation:
|
//GroupCreation:
|
||||||
@@ -45,7 +46,9 @@ public class GroupsTests extends RestTest
|
|||||||
restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate)
|
restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate)
|
||||||
.assertThat().field("zones").contains("APP.DEFAULT")
|
.assertThat().field("zones").contains("APP.DEFAULT")
|
||||||
.and().field("isRoot").is(true)
|
.and().field("isRoot").is(true)
|
||||||
.and().field("displayName").is(groupName);
|
.and().field("displayName").is(groupName)
|
||||||
|
.and().field("description").is(groupDescription)
|
||||||
|
.and().field("hasSubgroups").is(false);
|
||||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||||
|
|
||||||
//ListGroups:
|
//ListGroups:
|
||||||
@@ -55,11 +58,12 @@ public class GroupsTests extends RestTest
|
|||||||
.and().paginationField("maxItems").is("10");
|
.and().paginationField("maxItems").is("10");
|
||||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||||
|
|
||||||
groupBody = Json.createObjectBuilder().add("displayName", "Z"+groupName).build();
|
groupBody = Json.createObjectBuilder().add("displayName", "Z"+groupName).add("description", "Z"+groupDescription).build();
|
||||||
String groupBodyUpdate = groupBody.toString();
|
String groupBodyUpdate = groupBody.toString();
|
||||||
//UpdateGroup:
|
//UpdateGroup:
|
||||||
restClient.withCoreAPI().usingGroups().updateGroupDetails("GROUP_"+groupName, groupBodyUpdate)
|
restClient.withCoreAPI().usingGroups().updateGroupDetails("GROUP_"+groupName, groupBodyUpdate)
|
||||||
.assertThat().field("displayName").is("Z"+groupName)
|
.assertThat().field("displayName").is("Z"+groupName)
|
||||||
|
.and().field("description").is("Z"+groupDescription)
|
||||||
.and().field("id").is("GROUP_"+groupName)
|
.and().field("id").is("GROUP_"+groupName)
|
||||||
.and().field("zones").isNull();
|
.and().field("zones").isNull();
|
||||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||||
@@ -68,7 +72,8 @@ public class GroupsTests extends RestTest
|
|||||||
restClient.withCoreAPI().usingParams("include=zones").usingGroups().getGroupDetail("GROUP_"+groupName)
|
restClient.withCoreAPI().usingParams("include=zones").usingGroups().getGroupDetail("GROUP_"+groupName)
|
||||||
.assertThat().field("id").is("GROUP_"+groupName)
|
.assertThat().field("id").is("GROUP_"+groupName)
|
||||||
.and().field("zones").contains("APP.DEFAULT")
|
.and().field("zones").contains("APP.DEFAULT")
|
||||||
.and().field("isRoot").is(true);
|
.and().field("isRoot").is(true)
|
||||||
|
.and().field("hasSubgroups").is(false);
|
||||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||||
|
|
||||||
//DeleteGroup:
|
//DeleteGroup:
|
||||||
@@ -86,15 +91,23 @@ public class GroupsTests extends RestTest
|
|||||||
public void createListDeleteGroupMembership() throws Exception
|
public void createListDeleteGroupMembership() throws Exception
|
||||||
{
|
{
|
||||||
String groupName = "ZtestGroup" + UUID.randomUUID().toString();
|
String groupName = "ZtestGroup" + UUID.randomUUID().toString();
|
||||||
|
String subGroupName = "ZtestSubgroup" + UUID.randomUUID().toString();
|
||||||
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build();
|
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build();
|
||||||
|
JsonObject subgroupBody = Json.createObjectBuilder().add("id", subGroupName).add("displayName", subGroupName).build();
|
||||||
String groupBodyCreate = groupBody.toString();
|
String groupBodyCreate = groupBody.toString();
|
||||||
|
String subgroupBodyCreate = subgroupBody.toString();
|
||||||
|
|
||||||
//GroupCreation:
|
//GroupCreation:
|
||||||
restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate);
|
restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate);
|
||||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||||
|
restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(subgroupBodyCreate);
|
||||||
|
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||||
|
|
||||||
JsonObject groupMembershipBody = Json.createObjectBuilder().add("id", userModel.getUsername()).add("memberType", "PERSON").build();
|
JsonObject groupMembershipBody = Json.createObjectBuilder().add("id", userModel.getUsername()).add("memberType", "PERSON").build();
|
||||||
String groupMembershipBodyCreate = groupMembershipBody.toString();
|
String groupMembershipBodyCreate = groupMembershipBody.toString();
|
||||||
|
JsonObject groupMembershipGroupBody = Json.createObjectBuilder().add("id", subGroupName).add("memberType", "GROUP").build();
|
||||||
|
String groupMembershipGroupBodyCreate = groupMembershipGroupBody.toString();
|
||||||
|
|
||||||
//MembershipCreation:
|
//MembershipCreation:
|
||||||
//-ve
|
//-ve
|
||||||
restClient.authenticateUser(userModel).withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate);
|
restClient.authenticateUser(userModel).withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate);
|
||||||
@@ -102,10 +115,19 @@ public class GroupsTests extends RestTest
|
|||||||
//+ve
|
//+ve
|
||||||
restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate);
|
restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate);
|
||||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||||
|
restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipGroupBodyCreate);
|
||||||
|
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||||
|
|
||||||
//ListPersonMembership
|
//ListPersonMembership
|
||||||
restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).listGroupMemberships()
|
restClient.authenticateUser(userModel).withCoreAPI().usingUser(userModel).listGroupMemberships()
|
||||||
.assertThat().entriesListContains("id", "GROUP_"+groupName);
|
.assertThat().entriesListContains("id", "GROUP_"+groupName)
|
||||||
|
.and().entriesListContains("id", "GROUP_"+subGroupName);
|
||||||
|
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||||
|
|
||||||
|
//CheckListDetails
|
||||||
|
restClient.withCoreAPI().usingParams("include=zones").usingGroups().getGroupDetail("GROUP_"+groupName)
|
||||||
|
.assertThat().field("id").is("GROUP_"+groupName)
|
||||||
|
.and().field("hasSubgroups").is(true);
|
||||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||||
|
|
||||||
//DeleteGroupMembership
|
//DeleteGroupMembership
|
||||||
|
@@ -51,9 +51,11 @@ import org.alfresco.repo.security.authority.AuthorityInfo;
|
|||||||
import org.alfresco.repo.security.authority.UnknownAuthorityException;
|
import org.alfresco.repo.security.authority.UnknownAuthorityException;
|
||||||
import org.alfresco.rest.antlr.WhereClauseParser;
|
import org.alfresco.rest.antlr.WhereClauseParser;
|
||||||
import org.alfresco.rest.api.Groups;
|
import org.alfresco.rest.api.Groups;
|
||||||
|
import org.alfresco.rest.api.Nodes;
|
||||||
import org.alfresco.rest.api.People;
|
import org.alfresco.rest.api.People;
|
||||||
import org.alfresco.rest.api.model.Group;
|
import org.alfresco.rest.api.model.Group;
|
||||||
import org.alfresco.rest.api.model.GroupMember;
|
import org.alfresco.rest.api.model.GroupMember;
|
||||||
|
import org.alfresco.rest.api.model.Node;
|
||||||
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
||||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||||
@@ -68,6 +70,7 @@ 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.QueryHelper;
|
||||||
import org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker;
|
import org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker;
|
||||||
import org.alfresco.rest.workflow.api.impl.MapBasedQueryWalkerOrSupported;
|
import org.alfresco.rest.workflow.api.impl.MapBasedQueryWalkerOrSupported;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.security.AuthorityService;
|
import org.alfresco.service.cmr.security.AuthorityService;
|
||||||
import org.alfresco.service.cmr.security.AuthorityType;
|
import org.alfresco.service.cmr.security.AuthorityType;
|
||||||
import org.alfresco.service.cmr.security.PermissionService;
|
import org.alfresco.service.cmr.security.PermissionService;
|
||||||
@@ -109,6 +112,7 @@ public class GroupsImpl implements Groups
|
|||||||
private AuthorityDAO authorityDAO;
|
private AuthorityDAO authorityDAO;
|
||||||
|
|
||||||
protected People people;
|
protected People people;
|
||||||
|
protected Nodes nodes;
|
||||||
|
|
||||||
public AuthorityService getAuthorityService()
|
public AuthorityService getAuthorityService()
|
||||||
{
|
{
|
||||||
@@ -130,6 +134,10 @@ public class GroupsImpl implements Groups
|
|||||||
this.people = people;
|
this.people = people;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setNodes(Nodes nodes) {
|
||||||
|
this.nodes = nodes;
|
||||||
|
}
|
||||||
|
|
||||||
public Group create(Group group, Parameters parameters)
|
public Group create(Group group, Parameters parameters)
|
||||||
{
|
{
|
||||||
validateGroup(group, false);
|
validateGroup(group, false);
|
||||||
@@ -151,6 +159,17 @@ public class GroupsImpl implements Groups
|
|||||||
authorityService.addAuthority(group.getParentIds(), authority);
|
authorityService.addAuthority(group.getParentIds(), authority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (group.getDescription() != null && !group.getDescription().isEmpty())
|
||||||
|
{
|
||||||
|
NodeRef groupNodeRef = authorityService.getAuthorityNodeRef(authorityDisplayName);
|
||||||
|
Node groupNode = nodes.getNode(groupNodeRef.getId());
|
||||||
|
Map<String, Object> props = groupNode.getProperties();
|
||||||
|
if (props != null)
|
||||||
|
{
|
||||||
|
props.put("cm:description", group.getDescription());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return getGroup(authority, parameters);
|
return getGroup(authority, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +187,17 @@ public class GroupsImpl implements Groups
|
|||||||
handleAuthorityException(ae);
|
handleAuthorityException(ae);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (group.getDescription() != null && !group.getDescription().isEmpty())
|
||||||
|
{
|
||||||
|
NodeRef groupNodeRef = authorityService.getAuthorityNodeRef(group.getDisplayName());
|
||||||
|
Node groupNode = nodes.getNode(groupNodeRef.getId());
|
||||||
|
Map<String, Object> props = groupNode.getProperties();
|
||||||
|
if (props != null)
|
||||||
|
{
|
||||||
|
props.put("cm:description", group.getDescription());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return getGroup(groupId, parameters);
|
return getGroup(groupId, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -584,6 +614,17 @@ public class GroupsImpl implements Groups
|
|||||||
group.setDisplayName(authorityDisplayName);
|
group.setDisplayName(authorityDisplayName);
|
||||||
|
|
||||||
group.setIsRoot(isRootAuthority(rootAuthorities, authorityInfo.getAuthorityName()));
|
group.setIsRoot(isRootAuthority(rootAuthorities, authorityInfo.getAuthorityName()));
|
||||||
|
group.setHasSubgroups(!authorityService.getContainedAuthorities(AuthorityType.GROUP, authorityInfo.getAuthorityName(), true).isEmpty());
|
||||||
|
|
||||||
|
NodeRef groupNodeRef = authorityService.getAuthorityNodeRef(authorityDisplayName);
|
||||||
|
Node groupNode = nodes.getNode(groupNodeRef.getId());
|
||||||
|
Map<String, Object> props = groupNode.getProperties();
|
||||||
|
String description = "";
|
||||||
|
if (props != null)
|
||||||
|
{
|
||||||
|
description = props.get("cm:description") != null ? (String) props.get("cm:description") : "";
|
||||||
|
}
|
||||||
|
group.setDescription(description);
|
||||||
|
|
||||||
// Optionally include
|
// Optionally include
|
||||||
if (includeParam != null)
|
if (includeParam != null)
|
||||||
@@ -1014,6 +1055,10 @@ public class GroupsImpl implements Groups
|
|||||||
{
|
{
|
||||||
throw new InvalidArgumentException("Group update does not support field: zones");
|
throw new InvalidArgumentException("Group update does not support field: zones");
|
||||||
}
|
}
|
||||||
|
if (group.wasSet(Group.HAS_SUBGROUPS))
|
||||||
|
{
|
||||||
|
throw new InvalidArgumentException("Group update does not support field: hasSubgroups");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,7 +42,9 @@ public class Group implements Comparable<Group>
|
|||||||
|
|
||||||
protected String id; // group id (aka authority name)
|
protected String id; // group id (aka authority name)
|
||||||
protected String displayName;
|
protected String displayName;
|
||||||
|
protected String description;
|
||||||
protected Boolean isRoot;
|
protected Boolean isRoot;
|
||||||
|
protected Boolean hasSubgroups;
|
||||||
protected Set<String> parentIds;
|
protected Set<String> parentIds;
|
||||||
protected Set<String> zones;
|
protected Set<String> zones;
|
||||||
|
|
||||||
@@ -50,7 +52,9 @@ public class Group implements Comparable<Group>
|
|||||||
|
|
||||||
public static final String ID = "id";
|
public static final String ID = "id";
|
||||||
public static final String DISPLAY_NAME = "displayName";
|
public static final String DISPLAY_NAME = "displayName";
|
||||||
|
public static final String DESCRIPTION = "description";
|
||||||
public static final String IS_ROOT = "isRoot";
|
public static final String IS_ROOT = "isRoot";
|
||||||
|
public static final String HAS_SUBGROUPS = "hasSubgroups";
|
||||||
public static final String PARENT_IDS = "parentIds";
|
public static final String PARENT_IDS = "parentIds";
|
||||||
public static final String ZONES = "zones";
|
public static final String ZONES = "zones";
|
||||||
|
|
||||||
@@ -81,6 +85,14 @@ public class Group implements Comparable<Group>
|
|||||||
setFields.put(DISPLAY_NAME, true);
|
setFields.put(DISPLAY_NAME, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean getIsRoot()
|
public Boolean getIsRoot()
|
||||||
{
|
{
|
||||||
return isRoot;
|
return isRoot;
|
||||||
@@ -92,6 +104,14 @@ public class Group implements Comparable<Group>
|
|||||||
setFields.put(IS_ROOT, true);
|
setFields.put(IS_ROOT, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getHasSubgroups() {
|
||||||
|
return hasSubgroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasSubgroups(Boolean hasSubgroups) {
|
||||||
|
this.hasSubgroups = hasSubgroups;
|
||||||
|
}
|
||||||
|
|
||||||
public Set<String> getParentIds()
|
public Set<String> getParentIds()
|
||||||
{
|
{
|
||||||
return parentIds;
|
return parentIds;
|
||||||
@@ -154,7 +174,8 @@ public class Group implements Comparable<Group>
|
|||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "Group [id=" + id + ", displayName=" + displayName + ", isRoot=" + isRoot + "]";
|
return "Group [id=" + id + ", displayName=" + displayName + ", description=" + description
|
||||||
|
+ ", isRoot=" + isRoot + ", hasSubgroups=" + hasSubgroups + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean wasSet(String fieldName)
|
public boolean wasSet(String fieldName)
|
||||||
|
@@ -1693,6 +1693,7 @@
|
|||||||
<property name="authorityService" ref="AuthorityService" />
|
<property name="authorityService" ref="AuthorityService" />
|
||||||
<property name="authorityDAO" ref="authorityDAO" />
|
<property name="authorityDAO" ref="authorityDAO" />
|
||||||
<property name="people" ref="people"/>
|
<property name="people" ref="people"/>
|
||||||
|
<property name="nodes" ref="nodes"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="Groups" class="org.springframework.aop.framework.ProxyFactoryBean">
|
<bean id="Groups" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||||
|
@@ -1,28 +1,28 @@
|
|||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* Alfresco Remote API
|
* Alfresco Remote API
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
* 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.web.scripts.groups;
|
package org.alfresco.repo.web.scripts.groups;
|
||||||
|
|
||||||
|
|
||||||
@@ -229,7 +229,8 @@ public class GroupsTest extends BaseWebScriptTest
|
|||||||
assertEquals("shortName wrong", TEST_ROOTGROUP, rootGroup.getString("shortName"));
|
assertEquals("shortName wrong", TEST_ROOTGROUP, rootGroup.getString("shortName"));
|
||||||
assertEquals("displayName wrong", TEST_ROOTGROUP_DISPLAY_NAME, rootGroup.getString("displayName"));
|
assertEquals("displayName wrong", TEST_ROOTGROUP_DISPLAY_NAME, rootGroup.getString("displayName"));
|
||||||
assertEquals("authorityType wrong", "GROUP", rootGroup.getString("authorityType"));
|
assertEquals("authorityType wrong", "GROUP", rootGroup.getString("authorityType"));
|
||||||
gotRootGroup = true;
|
assertEquals("hasSubgroups wrong", true, rootGroup.getString("hasSubgroups"));
|
||||||
|
gotRootGroup = true;
|
||||||
}
|
}
|
||||||
if(rootGroup.getString("shortName").equals(EMAIL_GROUP))
|
if(rootGroup.getString("shortName").equals(EMAIL_GROUP))
|
||||||
{
|
{
|
||||||
@@ -270,7 +271,8 @@ public class GroupsTest extends BaseWebScriptTest
|
|||||||
assertEquals("shortName wrong", TEST_ROOTGROUP, rootGroup.getString("shortName"));
|
assertEquals("shortName wrong", TEST_ROOTGROUP, rootGroup.getString("shortName"));
|
||||||
assertEquals("displayName wrong", TEST_ROOTGROUP_DISPLAY_NAME, rootGroup.getString("displayName"));
|
assertEquals("displayName wrong", TEST_ROOTGROUP_DISPLAY_NAME, rootGroup.getString("displayName"));
|
||||||
assertEquals("authorityType wrong", "GROUP", rootGroup.getString("authorityType"));
|
assertEquals("authorityType wrong", "GROUP", rootGroup.getString("authorityType"));
|
||||||
}
|
assertEquals("hasSubgroups wrong", true, rootGroup.getString("hasSubgroups"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,7 +295,8 @@ public class GroupsTest extends BaseWebScriptTest
|
|||||||
assertEquals("shortName wrong", TEST_ROOTGROUP, rootGroup.getString("shortName"));
|
assertEquals("shortName wrong", TEST_ROOTGROUP, rootGroup.getString("shortName"));
|
||||||
assertEquals("displayName wrong", TEST_ROOTGROUP_DISPLAY_NAME, rootGroup.getString("displayName"));
|
assertEquals("displayName wrong", TEST_ROOTGROUP_DISPLAY_NAME, rootGroup.getString("displayName"));
|
||||||
assertEquals("authorityType wrong", "GROUP", rootGroup.getString("authorityType"));
|
assertEquals("authorityType wrong", "GROUP", rootGroup.getString("authorityType"));
|
||||||
}
|
assertEquals("hasSubgroups wrong", true, rootGroup.getString("hasSubgroups"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,12 +385,14 @@ public class GroupsTest extends BaseWebScriptTest
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
JSONObject newGroupJSON = new JSONObject();
|
JSONObject newGroupJSON = new JSONObject();
|
||||||
newGroupJSON.put("displayName", myDisplayName);
|
newGroupJSON.put("displayName", myDisplayName);
|
||||||
|
newGroupJSON.put("description", "testDesc");
|
||||||
Response response = sendRequest(new PostRequest(URL_ROOTGROUPS + "/" + myGroupName, newGroupJSON.toString(), "application/json"), Status.STATUS_CREATED);
|
Response response = sendRequest(new PostRequest(URL_ROOTGROUPS + "/" + myGroupName, newGroupJSON.toString(), "application/json"), Status.STATUS_CREATED);
|
||||||
JSONObject top = new JSONObject(response.getContentAsString());
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
JSONObject rootGroup = top.getJSONObject("data");
|
JSONObject rootGroup = top.getJSONObject("data");
|
||||||
assertEquals("shortName wrong", myGroupName, rootGroup.getString("shortName"));
|
assertEquals("shortName wrong", myGroupName, rootGroup.getString("shortName"));
|
||||||
assertEquals("displayName wrong", myDisplayName, rootGroup.getString("displayName"));
|
assertEquals("displayName wrong", myDisplayName, rootGroup.getString("displayName"));
|
||||||
|
assertEquals("description wrong", "testDesc", rootGroup.getString("description"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -502,7 +507,18 @@ public class GroupsTest extends BaseWebScriptTest
|
|||||||
assertEquals("shortName wrong", TEST_LINK, subGroup.getString("shortName"));
|
assertEquals("shortName wrong", TEST_LINK, subGroup.getString("shortName"));
|
||||||
assertEquals("authorityType wrong", "GROUP", subGroup.getString("authorityType"));
|
assertEquals("authorityType wrong", "GROUP", subGroup.getString("authorityType"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if myGroup has subgroups
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
Response response = sendRequest(new GetRequest(URL_GROUPS + "/" + myRootGroup), Status.STATUS_OK);
|
||||||
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
|
logger.debug(response.getContentAsString());
|
||||||
|
JSONObject myGroup = top.getJSONObject("data");
|
||||||
|
assertTrue(myGroup.getBoolean("hasSubgroups"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Now link in an existing user
|
* Now link in an existing user
|
||||||
*/
|
*/
|
||||||
@@ -555,6 +571,17 @@ public class GroupsTest extends BaseWebScriptTest
|
|||||||
|
|
||||||
//assertTrue("group B not removed", data.length() == 0);
|
//assertTrue("group B not removed", data.length() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if myGroup has no subgroups
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
Response response = sendRequest(new GetRequest(URL_GROUPS + "/" + myRootGroup), Status.STATUS_OK);
|
||||||
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
|
logger.debug(response.getContentAsString());
|
||||||
|
JSONObject myGroup = top.getJSONObject("data");
|
||||||
|
assertFalse(myGroup.getBoolean("hasSubgroups"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new group (BUFFY)
|
* Create a new group (BUFFY)
|
||||||
@@ -613,19 +640,22 @@ public class GroupsTest extends BaseWebScriptTest
|
|||||||
{
|
{
|
||||||
String myGroupName = "GT_UG";
|
String myGroupName = "GT_UG";
|
||||||
String myDisplayName = "GT_UGDisplay";
|
String myDisplayName = "GT_UGDisplay";
|
||||||
|
String description = "GT_UGDesc";
|
||||||
String myNewDisplayName = "GT_UGDisplayNew";
|
String myNewDisplayName = "GT_UGDisplayNew";
|
||||||
|
String newDescription = "GT_UGDescNew";
|
||||||
this.authenticationComponent.setSystemUserAsCurrentUser();
|
|
||||||
|
this.authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create a root group
|
* Create a root group with descrription
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
JSONObject newGroupJSON = new JSONObject();
|
JSONObject newGroupJSON = new JSONObject();
|
||||||
newGroupJSON.put("displayName", myDisplayName);
|
newGroupJSON.put("displayName", myDisplayName);
|
||||||
sendRequest(new PostRequest(URL_ROOTGROUPS + "/" + myGroupName, newGroupJSON.toString(), "application/json"), Status.STATUS_CREATED);
|
newGroupJSON.put("description", description);
|
||||||
|
sendRequest(new PostRequest(URL_ROOTGROUPS + "/" + myGroupName, newGroupJSON.toString(), "application/json"), Status.STATUS_CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -633,14 +663,15 @@ public class GroupsTest extends BaseWebScriptTest
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
JSONObject newGroupJSON = new JSONObject();
|
JSONObject newGroupJSON = new JSONObject();
|
||||||
newGroupJSON.put("displayName", myNewDisplayName);
|
newGroupJSON.put("displayName", myNewDisplayName);
|
||||||
Response response = sendRequest(new PutRequest(URL_GROUPS + "/" + myGroupName, newGroupJSON.toString(), "application/json"), Status.STATUS_OK);
|
newGroupJSON.put("description", newDescription);
|
||||||
|
Response response = sendRequest(new PutRequest(URL_GROUPS + "/" + myGroupName, newGroupJSON.toString(), "application/json"), Status.STATUS_OK);
|
||||||
JSONObject top = new JSONObject(response.getContentAsString());
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
logger.debug(response.getContentAsString());
|
logger.debug(response.getContentAsString());
|
||||||
JSONObject data = top.getJSONObject("data");
|
JSONObject data = top.getJSONObject("data");
|
||||||
assertTrue(data.length() > 0);
|
assertTrue(data.length() > 0);
|
||||||
assertEquals("displayName wrong", myNewDisplayName, data.getString("displayName"));
|
assertEquals("displayName wrong", myNewDisplayName, data.getString("displayName"));
|
||||||
|
assertEquals("description wrong", newDescription, data.getString("description"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -653,7 +684,7 @@ public class GroupsTest extends BaseWebScriptTest
|
|||||||
JSONObject data = top.getJSONObject("data");
|
JSONObject data = top.getJSONObject("data");
|
||||||
assertTrue(data.length() > 0);
|
assertTrue(data.length() > 0);
|
||||||
assertEquals("displayName wrong", myNewDisplayName, data.getString("displayName"));
|
assertEquals("displayName wrong", myNewDisplayName, data.getString("displayName"));
|
||||||
|
assertEquals("description wrong", newDescription, data.getString("description"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -43,11 +43,9 @@ import org.alfresco.service.cmr.security.AuthorityService;
|
|||||||
import org.alfresco.service.cmr.security.AuthorityType;
|
import org.alfresco.service.cmr.security.AuthorityType;
|
||||||
import org.alfresco.service.cmr.security.PermissionService;
|
import org.alfresco.service.cmr.security.PermissionService;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.testing.category.LuceneTests;
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
@@ -663,7 +661,9 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
|
|||||||
assertNotNull(group);
|
assertNotNull(group);
|
||||||
assertNotNull(group.getId());
|
assertNotNull(group.getId());
|
||||||
assertNotNull(group.getDisplayName());
|
assertNotNull(group.getDisplayName());
|
||||||
|
assertNotNull(group.getDescription());
|
||||||
assertNotNull(group.getIsRoot());
|
assertNotNull(group.getIsRoot());
|
||||||
|
assertNotNull(group.getHasSubgroups());
|
||||||
|
|
||||||
if (!ignoreOptionallyIncluded)
|
if (!ignoreOptionallyIncluded)
|
||||||
{
|
{
|
||||||
@@ -1421,13 +1421,16 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
|
|||||||
otherParams.put("include", org.alfresco.rest.api.Groups.PARAM_INCLUDE_PARENT_IDS);
|
otherParams.put("include", org.alfresco.rest.api.Groups.PARAM_INCLUDE_PARENT_IDS);
|
||||||
|
|
||||||
Group group = generateGroup();
|
Group group = generateGroup();
|
||||||
|
group.setDescription("testDesc");
|
||||||
|
|
||||||
Group createdGroup01 = groupsProxy.createGroup(group, null, HttpServletResponse.SC_CREATED);
|
Group createdGroup01 = groupsProxy.createGroup(group, null, HttpServletResponse.SC_CREATED);
|
||||||
|
|
||||||
assertNotNull(createdGroup01);
|
assertNotNull(createdGroup01);
|
||||||
assertNotNull(createdGroup01.getId());
|
assertNotNull(createdGroup01.getId());
|
||||||
|
assertEquals(createdGroup01.getDescription(), "testDesc");
|
||||||
assertTrue(createdGroup01.getIsRoot());
|
assertTrue(createdGroup01.getIsRoot());
|
||||||
assertNull(createdGroup01.getParentIds());
|
assertNull(createdGroup01.getParentIds());
|
||||||
|
assertFalse(createdGroup01.getHasSubgroups());
|
||||||
|
|
||||||
Set<String> subGroup01Parents = new HashSet<>();
|
Set<String> subGroup01Parents = new HashSet<>();
|
||||||
subGroup01Parents.add(createdGroup01.getId());
|
subGroup01Parents.add(createdGroup01.getId());
|
||||||
@@ -1441,6 +1444,8 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
|
|||||||
assertFalse(createdSubGroup01.getIsRoot());
|
assertFalse(createdSubGroup01.getIsRoot());
|
||||||
assertNotNull(createdSubGroup01.getParentIds());
|
assertNotNull(createdSubGroup01.getParentIds());
|
||||||
assertEquals(subGroup01Parents, createdSubGroup01.getParentIds());
|
assertEquals(subGroup01Parents, createdSubGroup01.getParentIds());
|
||||||
|
assertTrue(createdGroup01.getHasSubgroups());
|
||||||
|
assertFalse(createdSubGroup01.getHasSubgroups());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Group id is missing.
|
// Group id is missing.
|
||||||
@@ -1623,6 +1628,7 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
|
|||||||
subGroupParents.add(group.getId());
|
subGroupParents.add(group.getId());
|
||||||
|
|
||||||
Group generatedSubGroup = generateGroup();
|
Group generatedSubGroup = generateGroup();
|
||||||
|
generatedSubGroup.setDescription("initialDesc");
|
||||||
generatedSubGroup.setParentIds(subGroupParents);
|
generatedSubGroup.setParentIds(subGroupParents);
|
||||||
|
|
||||||
Group subGroup = groupsProxy.createGroup(generatedSubGroup, otherParams, HttpServletResponse.SC_CREATED);
|
Group subGroup = groupsProxy.createGroup(generatedSubGroup, otherParams, HttpServletResponse.SC_CREATED);
|
||||||
@@ -1645,9 +1651,11 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
|
|||||||
|
|
||||||
|
|
||||||
String displayName = "newDisplayName";
|
String displayName = "newDisplayName";
|
||||||
|
String description = "newDesc";
|
||||||
|
|
||||||
Group mySubGroup = new Group();
|
Group mySubGroup = new Group();
|
||||||
mySubGroup.setDisplayName(displayName);
|
mySubGroup.setDisplayName(displayName);
|
||||||
|
mySubGroup.setDescription(description);
|
||||||
|
|
||||||
Group updateGroup = groupsProxy.updateGroup(subGroup.getId(), mySubGroup, otherParams, HttpServletResponse.SC_OK);
|
Group updateGroup = groupsProxy.updateGroup(subGroup.getId(), mySubGroup, otherParams, HttpServletResponse.SC_OK);
|
||||||
|
|
||||||
@@ -1657,8 +1665,9 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
|
|||||||
assertFalse(updateGroup.getIsRoot());
|
assertFalse(updateGroup.getIsRoot());
|
||||||
assertNotNull(updateGroup.getParentIds());
|
assertNotNull(updateGroup.getParentIds());
|
||||||
|
|
||||||
// Check that only display name changed.
|
// Check that only display name and description changed.
|
||||||
assertEquals(displayName, updateGroup.getDisplayName());
|
assertEquals(displayName, updateGroup.getDisplayName());
|
||||||
|
assertEquals(description, updateGroup.getDescription());
|
||||||
|
|
||||||
// Check that nothing else changed.
|
// Check that nothing else changed.
|
||||||
assertEquals(subGroup.getId(), updateGroup.getId());
|
assertEquals(subGroup.getId(), updateGroup.getId());
|
||||||
|
Reference in New Issue
Block a user