You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2018/03/08 11:34:14 UTC

[openmeetings] branch master updated: [OPENMEETINGS-1841] list groups method is fixed

This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/master by this push:
     new 3bfeb10  [OPENMEETINGS-1841] list groups method is fixed
3bfeb10 is described below

commit 3bfeb10f58d27fe5c82d10c9af1508144158aa4d
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Thu Mar 8 18:33:43 2018 +0700

    [OPENMEETINGS-1841] list groups method is fixed
---
 .../apache/openmeetings/db/dto/user/GroupDTO.java  | 87 ++++++++++++++++++++++
 .../openmeetings/webservice/TestGroupService.java  | 14 ++++
 .../openmeetings/webservice/TestUserService.java   | 12 +++
 .../openmeetings/webservice/GroupWebService.java   |  5 +-
 4 files changed, 116 insertions(+), 2 deletions(-)

diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/user/GroupDTO.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/user/GroupDTO.java
new file mode 100644
index 0000000..fbafe14
--- /dev/null
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/user/GroupDTO.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.db.dto.user;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.openmeetings.db.dao.user.GroupDao;
+import org.apache.openmeetings.db.entity.user.Group;
+
+@XmlRootElement
+public class GroupDTO implements Serializable {
+	private static final long serialVersionUID = 1L;
+	private Long id;
+	private String name;
+	private String tag;
+
+	public GroupDTO() {
+		//def constructor
+	}
+
+	public GroupDTO(Group g) {
+		id = g.getId();
+		name = g.getName();
+		tag = g.getTag();
+	}
+
+	public Group get(GroupDao groupDao) {
+		Group g = id == null ? new Group() : groupDao.get(id);
+		g.setName(name);
+		g.setTag(tag);
+		return g;
+	}
+
+	public static List<GroupDTO> list(List<Group> l) {
+		List<GroupDTO> gList = new ArrayList<>();
+		if (l != null) {
+			for (Group g : l) {
+				gList.add(new GroupDTO(g));
+			}
+		}
+		return gList;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getTag() {
+		return tag;
+	}
+
+	public void setTag(String tag) {
+		this.tag = tag;
+	}
+}
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestGroupService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestGroupService.java
index e3873ed..619dd69 100644
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestGroupService.java
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestGroupService.java
@@ -19,18 +19,32 @@
 package org.apache.openmeetings.webservice;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 
+import java.util.Collection;
+
 import javax.ws.rs.core.Response;
 
 import org.apache.openmeetings.db.dto.basic.ServiceResult;
 import org.apache.openmeetings.db.dto.basic.ServiceResult.Type;
+import org.apache.openmeetings.db.dto.user.GroupDTO;
 import org.junit.Test;
 
 public class TestGroupService extends AbstractWebServiceTest {
 	public static final String GROUP_SERVICE_MOUNT = "group";
 
 	@Test
+	public void list() {
+		ServiceResult r = login();
+		Collection<? extends GroupDTO> groups = getClient(getGroupUrl())
+				.path("/")
+				.query("sid", r.getMessage()).getCollection(GroupDTO.class);
+		assertNotNull("Collection should be not null", groups);
+		assertFalse("Collection should be not empty", groups.isEmpty());
+	}
+
+	@Test
 	public void putTest() {
 		ServiceResult r = login();
 		Response resp = getClient(getGroupUrl())
diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestUserService.java b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestUserService.java
index 5e22f23..2921b46 100644
--- a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestUserService.java
+++ b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestUserService.java
@@ -20,9 +20,11 @@ package org.apache.openmeetings.webservice;
 
 import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.util.Collection;
 import java.util.Locale;
 import java.util.TimeZone;
 import java.util.UUID;
@@ -131,4 +133,14 @@ public class TestUserService extends AbstractWebServiceTest {
 		assertEquals("OM Call should be successful", u.getLogin(), user.getLogin());
 		assertEquals("OM Call should be successful", tz, user.getTimeZoneId());
 	}
+
+	@Test
+	public void list() {
+		ServiceResult r = login();
+		Collection<? extends UserDTO> users = getClient(getUserUrl())
+				.path("/")
+				.query("sid", r.getMessage()).getCollection(UserDTO.class);
+		assertNotNull("Collection should be not null", users);
+		assertFalse("Collection should be not empty", users.isEmpty());
+	}
 }
diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
index e7a7a03..e217509 100644
--- a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
+++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
@@ -46,6 +46,7 @@ import org.apache.openmeetings.db.dao.user.UserDao;
 import org.apache.openmeetings.db.dto.basic.SearchResult;
 import org.apache.openmeetings.db.dto.basic.ServiceResult;
 import org.apache.openmeetings.db.dto.basic.ServiceResult.Type;
+import org.apache.openmeetings.db.dto.user.GroupDTO;
 import org.apache.openmeetings.db.dto.user.UserSearchResult;
 import org.apache.openmeetings.db.entity.room.Room;
 import org.apache.openmeetings.db.entity.room.RoomGroup;
@@ -105,8 +106,8 @@ public class GroupWebService extends BaseWebService {
 	 */
 	@GET
 	@Path("/")
-	public List<Group> get(@QueryParam("sid") @WebParam(name="sid") String sid) {
-		return performCall(sid, User.Right.Soap, sd -> getDao().get(0, Integer.MAX_VALUE));
+	public List<GroupDTO> get(@QueryParam("sid") @WebParam(name="sid") String sid) {
+		return performCall(sid, User.Right.Soap, sd -> GroupDTO.list(getDao().get(0, Integer.MAX_VALUE)));
 	}
 
 	/**

-- 
To stop receiving notification emails like this one, please contact
solomax@apache.org.