From fbd1a7f5dcda10a7c475161dde87b5761e534129 Mon Sep 17 00:00:00 2001 From: "heavyrain.lee" Date: Fri, 24 May 2019 21:08:31 +0800 Subject: [PATCH] update --- .../action/admin/BlockUserAction.java | 4 +- .../action/admin/GetGroupInfoAction.java | 71 ++++++++++++++++ .../action/admin/GetGroupMembersAction.java | 78 ++++++++++++++++++ .../action/admin/TransferGroupAction.java | 2 +- .../imhandler/CreateGroupHandler.java | 8 ++ .../imhandler/TransferGroupHandler.java | 2 +- .../persistence/MemoryMessagesStore.java | 4 +- .../java/io/moquette/spi/IMessagesStore.java | 2 +- .../cn.wildfirechat.pojos/InputGetGroup.java | 21 +++++ .../OutputGroupMemberList.java | 23 ++++++ .../java/cn/wildfirechat/common/APIPath.java | 2 + .../cn/wildfirechat/common/ErrorCode.java | 2 +- .../java/cn/wildfirechat/sdk/GroupAdmin.java | 19 +++++ .../main/java/cn/wildfirechat/sdk/Main.java | 82 +++++++++++++++++++ 14 files changed, 313 insertions(+), 7 deletions(-) create mode 100755 broker/src/main/java/com/xiaoleilu/loServer/action/admin/GetGroupInfoAction.java create mode 100755 broker/src/main/java/com/xiaoleilu/loServer/action/admin/GetGroupMembersAction.java create mode 100755 common/src/main/java/cn.wildfirechat.pojos/InputGetGroup.java create mode 100644 common/src/main/java/cn.wildfirechat.pojos/OutputGroupMemberList.java diff --git a/broker/src/main/java/com/xiaoleilu/loServer/action/admin/BlockUserAction.java b/broker/src/main/java/com/xiaoleilu/loServer/action/admin/BlockUserAction.java index 26db43b5..e2c920fa 100755 --- a/broker/src/main/java/com/xiaoleilu/loServer/action/admin/BlockUserAction.java +++ b/broker/src/main/java/com/xiaoleilu/loServer/action/admin/BlockUserAction.java @@ -45,7 +45,9 @@ public class BlockUserAction extends AdminAction { result = RestResult.resultOf(errorCode); response.setContent(new Gson().toJson(result)); - RPCCenter.getInstance().sendRequest(null, null, RPCCenter.KICKOFF_USER_REQUEST, inputUserBlock.getUserId().getBytes(), inputUserBlock.getUserId(), TargetEntry.Type.TARGET_TYPE_USER, null, true); + if (inputUserBlock.getStatus() != 0) { + RPCCenter.getInstance().sendRequest(null, null, RPCCenter.KICKOFF_USER_REQUEST, inputUserBlock.getUserId().getBytes(), inputUserBlock.getUserId(), TargetEntry.Type.TARGET_TYPE_USER, null, true); + } sendResponse(response, ErrorCode.ERROR_CODE_SUCCESS, null); } else { diff --git a/broker/src/main/java/com/xiaoleilu/loServer/action/admin/GetGroupInfoAction.java b/broker/src/main/java/com/xiaoleilu/loServer/action/admin/GetGroupInfoAction.java new file mode 100755 index 00000000..de97781c --- /dev/null +++ b/broker/src/main/java/com/xiaoleilu/loServer/action/admin/GetGroupInfoAction.java @@ -0,0 +1,71 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +package com.xiaoleilu.loServer.action.admin; + +import cn.wildfirechat.common.APIPath; +import cn.wildfirechat.common.ErrorCode; +import cn.wildfirechat.pojos.InputGetGroup; +import cn.wildfirechat.pojos.InputGetUserInfo; +import cn.wildfirechat.pojos.InputOutputUserInfo; +import cn.wildfirechat.pojos.PojoGroupInfo; +import cn.wildfirechat.proto.WFCMessage; +import com.google.gson.Gson; +import com.xiaoleilu.loServer.RestResult; +import com.xiaoleilu.loServer.annotation.HttpMethod; +import com.xiaoleilu.loServer.annotation.Route; +import com.xiaoleilu.loServer.handler.Request; +import com.xiaoleilu.loServer.handler.Response; +import io.netty.handler.codec.http.FullHttpRequest; +import io.netty.handler.codec.http.HttpResponseStatus; +import io.netty.util.internal.StringUtil; + +@Route(APIPath.Group_Get_Info) +@HttpMethod("POST") +public class GetGroupInfoAction extends AdminAction { + + @Override + public boolean isTransactionAction() { + return true; + } + + @Override + public boolean action(Request request, Response response) { + if (request.getNettyRequest() instanceof FullHttpRequest) { + InputGetGroup inputGetGroup = getRequestBody(request.getNettyRequest(), InputGetGroup.class); + if (inputGetGroup != null + && (!StringUtil.isNullOrEmpty(inputGetGroup.getGroupId()))) { + + WFCMessage.GroupInfo groupInfo = messagesStore.getGroupInfo(inputGetGroup.getGroupId()); + + response.setStatus(HttpResponseStatus.OK); + RestResult result; + if (groupInfo == null) { + result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST); + } else { + PojoGroupInfo pojoGroupInfo = new PojoGroupInfo(); + pojoGroupInfo.setExtra(groupInfo.getExtra()); + pojoGroupInfo.setName(groupInfo.getName()); + pojoGroupInfo.setOwner(groupInfo.getOwner()); + pojoGroupInfo.setPortrait(groupInfo.getPortrait()); + pojoGroupInfo.setTarget_id(groupInfo.getTargetId()); + pojoGroupInfo.setType(groupInfo.getType()); + result = RestResult.ok(pojoGroupInfo); + } + + response.setContent(new Gson().toJson(result)); + } else { + response.setStatus(HttpResponseStatus.OK); + RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER); + response.setContent(new Gson().toJson(result)); + } + + } + return true; + } +} diff --git a/broker/src/main/java/com/xiaoleilu/loServer/action/admin/GetGroupMembersAction.java b/broker/src/main/java/com/xiaoleilu/loServer/action/admin/GetGroupMembersAction.java new file mode 100755 index 00000000..13d32b9e --- /dev/null +++ b/broker/src/main/java/com/xiaoleilu/loServer/action/admin/GetGroupMembersAction.java @@ -0,0 +1,78 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +package com.xiaoleilu.loServer.action.admin; + +import cn.wildfirechat.common.APIPath; +import cn.wildfirechat.common.ErrorCode; +import cn.wildfirechat.pojos.InputGetGroup; +import cn.wildfirechat.pojos.OutputGroupMemberList; +import cn.wildfirechat.pojos.PojoGroupInfo; +import cn.wildfirechat.pojos.PojoGroupMember; +import cn.wildfirechat.proto.WFCMessage; +import com.google.gson.Gson; +import com.xiaoleilu.loServer.RestResult; +import com.xiaoleilu.loServer.annotation.HttpMethod; +import com.xiaoleilu.loServer.annotation.Route; +import com.xiaoleilu.loServer.handler.Request; +import com.xiaoleilu.loServer.handler.Response; +import io.netty.handler.codec.http.FullHttpRequest; +import io.netty.handler.codec.http.HttpResponseStatus; +import io.netty.util.internal.StringUtil; + +import java.util.ArrayList; +import java.util.List; + +@Route(APIPath.Group_Member_List) +@HttpMethod("POST") +public class GetGroupMembersAction extends AdminAction { + + @Override + public boolean isTransactionAction() { + return true; + } + + @Override + public boolean action(Request request, Response response) { + if (request.getNettyRequest() instanceof FullHttpRequest) { + InputGetGroup inputGetGroup = getRequestBody(request.getNettyRequest(), InputGetGroup.class); + if (inputGetGroup != null + && (!StringUtil.isNullOrEmpty(inputGetGroup.getGroupId()))) { + + List members = new ArrayList<>(); + ErrorCode errorCode = messagesStore.getGroupMembers(inputGetGroup.getGroupId(), 0, members); + + + response.setStatus(HttpResponseStatus.OK); + RestResult result; + if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) { + result = RestResult.resultOf(errorCode); + } else { + OutputGroupMemberList out = new OutputGroupMemberList(); + out.setMembers(new ArrayList<>()); + for (WFCMessage.GroupMember member : members) { + PojoGroupMember pm = new PojoGroupMember(); + pm.setMember_id(member.getMemberId()); + pm.setAlias(member.getAlias()); + pm.setType(member.getType()); + out.getMembers().add(pm); + } + result = RestResult.ok(out); + } + + response.setContent(new Gson().toJson(result)); + } else { + response.setStatus(HttpResponseStatus.OK); + RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER); + response.setContent(new Gson().toJson(result)); + } + + } + return true; + } +} diff --git a/broker/src/main/java/com/xiaoleilu/loServer/action/admin/TransferGroupAction.java b/broker/src/main/java/com/xiaoleilu/loServer/action/admin/TransferGroupAction.java index b8ee82b2..ad14da79 100755 --- a/broker/src/main/java/com/xiaoleilu/loServer/action/admin/TransferGroupAction.java +++ b/broker/src/main/java/com/xiaoleilu/loServer/action/admin/TransferGroupAction.java @@ -42,7 +42,7 @@ public class TransferGroupAction extends AdminAction { if (request.getNettyRequest() instanceof FullHttpRequest) { InputTransferGroup inputDismissGroup = getRequestBody(request.getNettyRequest(), InputTransferGroup.class); if (inputDismissGroup.isValide()) { - RPCCenter.getInstance().sendRequest(inputDismissGroup.getOperator(), null, IMTopic.AddGroupMemberTopic, inputDismissGroup.toProtoGroupRequest().toByteArray(), inputDismissGroup.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() { + RPCCenter.getInstance().sendRequest(inputDismissGroup.getOperator(), null, IMTopic.TransferGroupTopic, inputDismissGroup.toProtoGroupRequest().toByteArray(), inputDismissGroup.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() { @Override public void onSuccess(byte[] result) { ByteBuf byteBuf = Unpooled.buffer(); diff --git a/broker/src/main/java/io/moquette/imhandler/CreateGroupHandler.java b/broker/src/main/java/io/moquette/imhandler/CreateGroupHandler.java index cf4e2abb..e1ed85bb 100644 --- a/broker/src/main/java/io/moquette/imhandler/CreateGroupHandler.java +++ b/broker/src/main/java/io/moquette/imhandler/CreateGroupHandler.java @@ -10,6 +10,7 @@ package io.moquette.imhandler; import cn.wildfirechat.proto.WFCMessage; import cn.wildfirechat.pojos.GroupNotificationBinaryContent; +import com.hazelcast.util.StringUtil; import io.moquette.spi.impl.Qos1PublishHandler; import io.netty.buffer.ByteBuf; import cn.wildfirechat.common.ErrorCode; @@ -19,6 +20,13 @@ import win.liyufan.im.IMTopic; public class CreateGroupHandler extends GroupHandler { @Override public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.CreateGroupRequest request, Qos1PublishHandler.IMCallback callback) { + + if (!StringUtil.isNullOrEmpty(request.getGroup().getGroupInfo().getTargetId())) { + WFCMessage.GroupInfo existGroupInfo = m_messagesStore.getGroupInfo(request.getGroup().getGroupInfo().getTargetId()); + if (existGroupInfo != null) { + return ErrorCode.ERROR_CODE_GROUP_ALREADY_EXIST; + } + } WFCMessage.GroupInfo groupInfo = m_messagesStore.createGroup(fromUser, request.getGroup().getGroupInfo(), request.getGroup().getMembersList()); if (groupInfo != null) { if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0) { diff --git a/broker/src/main/java/io/moquette/imhandler/TransferGroupHandler.java b/broker/src/main/java/io/moquette/imhandler/TransferGroupHandler.java index b00deff7..9d298d96 100644 --- a/broker/src/main/java/io/moquette/imhandler/TransferGroupHandler.java +++ b/broker/src/main/java/io/moquette/imhandler/TransferGroupHandler.java @@ -21,7 +21,7 @@ import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS; public class TransferGroupHandler extends GroupHandler { @Override public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.TransferGroupRequest request, Qos1PublishHandler.IMCallback callback) { - ErrorCode errorCode = m_messagesStore.transferGroup(fromUser, request.getGroupId(), request.getNewOwner()); + ErrorCode errorCode = m_messagesStore.transferGroup(fromUser, request.getGroupId(), request.getNewOwner(), isAdmin); if (errorCode == ERROR_CODE_SUCCESS) { if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) { sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent()); diff --git a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java index 330e9c27..6394201f 100755 --- a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java +++ b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java @@ -913,7 +913,7 @@ public class MemoryMessagesStore implements IMessagesStore { @Override - public ErrorCode transferGroup(String operator, String groupId, String newOwner) { + public ErrorCode transferGroup(String operator, String groupId, String newOwner, boolean isAdmin) { HazelcastInstance hzInstance = m_Server.getHazelcastInstance(); IMap mIMap = hzInstance.getMap(GROUPS_MAP); @@ -924,7 +924,7 @@ public class MemoryMessagesStore implements IMessagesStore { return ErrorCode.ERROR_CODE_NOT_EXIST; } - if ((groupInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted || groupInfo.getType() == ProtoConstants.GroupType.GroupType_Normal) + if (!isAdmin && (groupInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted || groupInfo.getType() == ProtoConstants.GroupType.GroupType_Normal) && (groupInfo.getOwner() == null || !groupInfo.getOwner().equals(operator))) { return ErrorCode.ERROR_CODE_NOT_RIGHT; } diff --git a/broker/src/main/java/io/moquette/spi/IMessagesStore.java b/broker/src/main/java/io/moquette/spi/IMessagesStore.java index 019a696a..1c7c8cd3 100755 --- a/broker/src/main/java/io/moquette/spi/IMessagesStore.java +++ b/broker/src/main/java/io/moquette/spi/IMessagesStore.java @@ -110,7 +110,7 @@ public interface IMessagesStore { List getGroupInfos(List requests); WFCMessage.GroupInfo getGroupInfo(String groupId); ErrorCode getGroupMembers(String groupId, long maxDt, List members); - ErrorCode transferGroup(String operator, String groupId, String newOwner); + ErrorCode transferGroup(String operator, String groupId, String newOwner, boolean isAdmin); boolean isMemberInGroup(String member, String groupId); boolean isForbiddenInGroup(String member, String groupId); diff --git a/common/src/main/java/cn.wildfirechat.pojos/InputGetGroup.java b/common/src/main/java/cn.wildfirechat.pojos/InputGetGroup.java new file mode 100755 index 00000000..1908ea90 --- /dev/null +++ b/common/src/main/java/cn.wildfirechat.pojos/InputGetGroup.java @@ -0,0 +1,21 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +package cn.wildfirechat.pojos; + +public class InputGetGroup { + private String groupId; + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } +} diff --git a/common/src/main/java/cn.wildfirechat.pojos/OutputGroupMemberList.java b/common/src/main/java/cn.wildfirechat.pojos/OutputGroupMemberList.java new file mode 100644 index 00000000..4917c541 --- /dev/null +++ b/common/src/main/java/cn.wildfirechat.pojos/OutputGroupMemberList.java @@ -0,0 +1,23 @@ +/* + * This file is part of the Wildfire Chat package. + * (c) Heavyrain2012 + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +package cn.wildfirechat.pojos; + +import java.util.List; + +public class OutputGroupMemberList { + private List members; + + public List getMembers() { + return members; + } + + public void setMembers(List members) { + this.members = members; + } +} diff --git a/common/src/main/java/cn/wildfirechat/common/APIPath.java b/common/src/main/java/cn/wildfirechat/common/APIPath.java index e15d7776..bd207c38 100644 --- a/common/src/main/java/cn/wildfirechat/common/APIPath.java +++ b/common/src/main/java/cn/wildfirechat/common/APIPath.java @@ -28,6 +28,8 @@ public interface APIPath { String Create_Group = "/admin/group/create"; String Group_Dismiss = "/admin/group/del"; String Group_Transfer = "/admin/group/transfer"; + String Group_Get_Info = "/admin/group/get_info"; + String Group_Member_List = "/admin/group/member/list"; String Group_Member_Add = "/admin/group/member/add"; String Group_Member_Kickoff = "/admin/group/member/del"; diff --git a/common/src/main/java/cn/wildfirechat/common/ErrorCode.java b/common/src/main/java/cn/wildfirechat/common/ErrorCode.java index 0d7421ac..381bbd80 100755 --- a/common/src/main/java/cn/wildfirechat/common/ErrorCode.java +++ b/common/src/main/java/cn/wildfirechat/common/ErrorCode.java @@ -68,7 +68,7 @@ public enum ErrorCode { public static ErrorCode fromCode(int code) { for (ErrorCode errorCode : ErrorCode.values()) { - if(errorCode.code == code) { + if(errorCode.code == (code&0xff)) { return errorCode; } } diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/GroupAdmin.java b/sdk/src/main/java/cn/wildfirechat/sdk/GroupAdmin.java index c8efd83e..3af0ee5b 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/GroupAdmin.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/GroupAdmin.java @@ -23,6 +23,14 @@ public class GroupAdmin { return AdminHttpUtils.httpJsonPost(path, createGroup, OutputCreateGroupResult.class); } + public static IMResult getGroupInfo(String groupId) throws Exception { + String path = APIPath.Group_Get_Info; + InputGetGroup input = new InputGetGroup(); + input.setGroupId(groupId); + + return AdminHttpUtils.httpJsonPost(path, input, PojoGroupInfo.class); + } + public static IMResult dismissGroup(String operator, String groupId, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Group_Dismiss; InputDismissGroup dismissGroup = new InputDismissGroup(); @@ -38,11 +46,20 @@ public class GroupAdmin { InputTransferGroup transferGroup = new InputTransferGroup(); transferGroup.setGroup_id(groupId); transferGroup.setNew_owner(newOwner); + transferGroup.setOperator(operator); transferGroup.setTo_lines(to_lines); transferGroup.setNotify_message(notify_message); return AdminHttpUtils.httpJsonPost(path, transferGroup, Void.class); } + + public static IMResult getGroupMembers(String groupId) throws Exception { + String path = APIPath.Group_Member_List; + InputGetGroup input = new InputGetGroup(); + input.setGroupId(groupId); + return AdminHttpUtils.httpJsonPost(path, input, OutputGroupMemberList.class); + } + public static IMResult addGroupMembers(String operator, String groupId, List groupMemberIds, List to_lines, MessagePayload notify_message) throws Exception { String path = APIPath.Group_Member_Add; InputAddGroupMember addGroupMember = new InputAddGroupMember(); @@ -54,6 +71,7 @@ public class GroupAdmin { members.add(m); } addGroupMember.setMembers(members); + addGroupMember.setOperator(operator); addGroupMember.setTo_lines(to_lines); addGroupMember.setNotify_message(notify_message); return AdminHttpUtils.httpJsonPost(path, addGroupMember, Void.class); @@ -64,6 +82,7 @@ public class GroupAdmin { InputKickoffGroupMember kickoffGroupMember = new InputKickoffGroupMember(); kickoffGroupMember.setGroup_id(groupId); kickoffGroupMember.setMembers(groupMemberIds); + kickoffGroupMember.setOperator(operator); kickoffGroupMember.setTo_lines(to_lines); kickoffGroupMember.setNotify_message(notify_message); return AdminHttpUtils.httpJsonPost(path, kickoffGroupMember, Void.class); diff --git a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java index 53d146d5..457bdd09 100644 --- a/sdk/src/main/java/cn/wildfirechat/sdk/Main.java +++ b/sdk/src/main/java/cn/wildfirechat/sdk/Main.java @@ -5,10 +5,17 @@ import cn.wildfirechat.pojos.*; import cn.wildfirechat.sdk.model.IMResult; import cn.wildfirechat.sdk.utilities.AdminHttpUtils; +import java.util.ArrayList; +import java.util.List; + public class Main { public static void main(String[] args) throws Exception { AdminHttpUtils.init("http://localhost:18080", "123456"); + +//*********************************************** +//**** 用户相关的API +//*********************************************** InputOutputUserInfo userInfo = new InputOutputUserInfo(); userInfo.setUserId("userId1"); userInfo.setName("user1"); @@ -119,5 +126,80 @@ public class Main { System.exit(-1); } + +//*********************************************** +//**** 群组相关API +//*********************************************** + PojoGroupInfo groupInfo = new PojoGroupInfo(); + groupInfo.setTarget_id("groupId1"); + groupInfo.setOwner("user1"); + groupInfo.setName("test_group"); + groupInfo.setExtra("hello extra"); + groupInfo.setPortrait("http://portrait"); + List members = new ArrayList<>(); + PojoGroupMember member1 = new PojoGroupMember(); + member1.setMember_id(groupInfo.getOwner()); + members.add(member1); + + PojoGroupMember member2 = new PojoGroupMember(); + member2.setMember_id("user2"); + members.add(member2); + + PojoGroupMember member3 = new PojoGroupMember(); + member3.setMember_id("user3"); + members.add(member3); + + IMResult resultCreateGroup = GroupAdmin.createGroup(groupInfo.getOwner(), groupInfo, members, null, null); + if (resultCreateGroup != null && resultCreateGroup.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { + System.out.println("create group success"); + } else { + System.out.println("create group failure"); + System.exit(-1); + } + + IMResult resultGetGroupInfo = GroupAdmin.getGroupInfo(groupInfo.getTarget_id()); + if (resultGetGroupInfo != null && resultGetGroupInfo.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { + if (groupInfo.getExtra().equals(resultGetGroupInfo.getResult().getExtra()) + && groupInfo.getName().equals(resultGetGroupInfo.getResult().getName()) + && groupInfo.getOwner().equals(resultGetGroupInfo.getResult().getOwner())) { + System.out.println("get group success"); + } else { + System.out.println("group info is not expected"); + System.exit(-1); + } + } else { + System.out.println("create group failure"); + System.exit(-1); + } + + IMResult voidIMResult = GroupAdmin.transferGroup(groupInfo.getOwner(), groupInfo.getTarget_id(), "user2", null, null); + if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { + System.out.println("transfer success"); + } else { + System.out.println("create group failure"); + System.exit(-1); + } + + resultGetGroupInfo = GroupAdmin.getGroupInfo(groupInfo.getTarget_id()); + if (resultGetGroupInfo != null && resultGetGroupInfo.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { + if ("user2".equals(resultGetGroupInfo.getResult().getOwner())) { + groupInfo.setOwner("user2"); + } else { + System.out.println("group info is not expected"); + System.exit(-1); + } + } else { + System.out.println("create group failure"); + System.exit(-1); + } + + IMResult resultGetMembers = GroupAdmin.getGroupMembers(groupInfo.getTarget_id()); + if (resultGetMembers != null && resultGetMembers.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) { + System.out.println("get group member success"); + } else { + System.out.println("create group failure"); + System.exit(-1); + } + } }