Author: solomax
Date: Sat Apr  2 09:03:49 2016
New Revision: 1737477

URL: http://svn.apache.org/viewvc?rev=1737477&view=rev
Log:
[OPENMEETINGS-16] missing methods are added

Modified:
    
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/user/UserDTO.java
    
openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
    
openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
    
openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/UserService.java
    
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/user/UserDTO.java
    
openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
    
openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
    
openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/UserService.java

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/user/UserDTO.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/user/UserDTO.java?rev=1737477&r1=1737476&r2=1737477&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/user/UserDTO.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/user/UserDTO.java
 Sat Apr  2 09:03:49 2016
@@ -19,6 +19,8 @@
 package org.apache.openmeetings.db.dto.user;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Set;
 
 import javax.xml.bind.annotation.XmlRootElement;
@@ -75,6 +77,16 @@ public class UserDTO implements Serializ
                return u;
        }
        
+       public static List<UserDTO> list(List<User> l) {
+               List<UserDTO> uList = new ArrayList<>();
+               if (l != null) {
+                       for (User u : l) {
+                               uList.add(new UserDTO(u));
+                       }
+               }
+               return uList;
+       }
+       
        public Long getId() {
                return id;
        }

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java?rev=1737477&r1=1737476&r2=1737477&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
 Sat Apr  2 09:03:49 2016
@@ -22,9 +22,13 @@ import static org.apache.openmeetings.ut
 import static org.apache.openmeetings.webservice.Constants.TNS;
 
 import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
+import javax.jws.WebMethod;
 import javax.jws.WebParam;
 import javax.jws.WebService;
+import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
@@ -86,8 +90,8 @@ public class GroupWebService {
         * @param sid
         *            The SID from getSession
         * @param name
-        *            the name of the org
-        * @return the new id of the org or -1 in case an error happened
+        *            the name of the group
+        * @return the new id of the group or -1 in case an error happened
         * @throws ServiceException
         */
        @POST
@@ -105,8 +109,28 @@ public class GroupWebService {
        }
        
        /**
+        * Get the list of all groups
         * 
-        * Add a user to a certain group
+        * @param sid
+        *            The SID from getSession
+        * @return list of all groups
+        * @throws ServiceException
+        */
+       @GET
+       @Path("/")
+       public List<Group> get(@QueryParam("sid") @WebParam(name="sid") String 
sid) throws ServiceException {
+               Long userId = sessionDao.checkSession(sid);
+               if 
(AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
+                       return groupDao.get(0, Integer.MAX_VALUE);
+               } else {
+                       log.error("Insufficient permissions");
+                       throw new ServiceException("Insufficient permissions"); 
//TODO code -26
+               }
+       }
+       
+       /**
+        * 
+        * Add user to a certain group
         * 
         * @param sid
         *            The SID from getSession
@@ -117,7 +141,7 @@ public class GroupWebService {
         * @return - id of the user added, or error id in case of the error
         */
        @POST
-       @Path("/{id}/users/add/{userid}")
+       @Path("/{id}/users/{userid}")
        public ServiceResult addUser(
                        @QueryParam("sid") @WebParam(name="sid") String sid
                        , @PathParam("id") @WebParam(name="id") Long id
@@ -143,6 +167,49 @@ public class GroupWebService {
        }
 
        /**
+        * 
+        * Remove user from a certain group
+        * 
+        * @param sid
+        *            The SID from getSession
+        * @param userid
+        *            the user id
+        * @param id
+        *            the group id
+        * @return - id of the user added, or error id in case of the error
+        */
+       @DELETE
+       @Path("/{id}/users/{userid}")
+       public ServiceResult removeUser(
+                       @QueryParam("sid") @WebParam(name="sid") String sid
+                       , @PathParam("id") @WebParam(name="id") Long id
+                       , @PathParam("userid") @WebParam(name="userid") Long 
userid
+                       ) throws ServiceException
+       {
+               try {
+                       Long authUserId = sessionDao.checkSession(sid);
+                       if 
(AuthLevelUtil.hasWebServiceLevel(userDao.getRights(authUserId))) {
+                               if (groupUserDao.isUserInGroup(id, userid)) {
+                                       User u = userDao.get(userid);
+                                       for (Iterator<GroupUser> iter = 
u.getGroupUsers().iterator(); iter.hasNext(); ) {
+                                               GroupUser gu = iter.next();
+                                               if 
(id.equals(gu.getGroup().getId())) {
+                                                       iter.remove();
+                                               }
+                                       }
+                                       userDao.update(u, authUserId);
+                               }
+                               return new ServiceResult(userid, "Success", 
Type.SUCCESS);
+                       } else {
+                               return new ServiceResult(-26L, "Insufficient 
permissions", Type.ERROR);
+                       }
+               } catch (Exception err) {
+                       log.error("addUser", err);
+                       throw new ServiceException(err.getMessage());
+               }
+       }
+
+       /**
         * Adds a room to an group
         * 
         * @param sid - The SID of the User. This SID must be marked as Loggedin
@@ -237,4 +304,34 @@ public class GroupWebService {
                        throw new ServiceException(err.getMessage());
                }
        }
+
+       /**
+        * Deletes a group
+        * 
+        * @param sid
+        *            The SID of the User. This SID must be marked as Loggedin
+        * @param id
+        *            the id of the group
+        *            
+        * @throws {@link ServiceException} in case of any error
+        */
+       @WebMethod
+       @DELETE
+       @Path("/{id}")
+       public ServiceResult delete(@WebParam(name="sid") @QueryParam("sid") 
String sid, @WebParam(name="id") @PathParam("id") long id) throws 
ServiceException {
+               try {
+                       Long authUserId = sessionDao.checkSession(sid);
+
+                       if 
(AuthLevelUtil.hasAdminLevel(userDao.getRights(authUserId))) {
+                               groupDao.delete(groupDao.get(id), authUserId);
+
+                               return new ServiceResult(id, "Deleted", 
Type.SUCCESS);
+                       } else {
+                               return new ServiceResult(-26L, "Insufficient 
permissions", Type.ERROR);
+                       }
+               } catch (Exception err) {
+                       log.error("deleteUserById", err);
+                       throw new ServiceException(err.getMessage());
+               }
+       }
 }

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java?rev=1737477&r1=1737476&r2=1737477&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
 Sat Apr  2 09:03:49 2016
@@ -24,6 +24,7 @@ import static org.apache.openmeetings.we
 import static 
org.apache.openmeetings.webservice.Constants.USER_SERVICE_PORT_NAME;
 
 import java.util.Date;
+import java.util.List;
 
 import javax.jws.WebMethod;
 import javax.jws.WebParam;
@@ -122,6 +123,28 @@ public class UserWebService implements U
                }
        }
 
+       /* (non-Javadoc)
+        * @see 
org.apache.openmeetings.webservice.cluster.UserService#get(java.lang.String)
+        */
+       @Override
+       @WebMethod
+       @GET
+       @Path("/")
+       public List<UserDTO> get(@WebParam(name="sid") @QueryParam("sid") 
String sid) throws ServiceException {
+               try {
+                       Long authUserId = sessionDao.checkSession(sid);
+       
+                       if 
(AuthLevelUtil.hasWebServiceLevel(userDao.getRights(authUserId))) {
+                               return UserDTO.list(userDao.getAllUsers());
+                       } else {
+                               throw new ServiceException("Insufficient 
permissions"); //TODO code -26
+                       }
+               } catch (Exception err) {
+                       log.error("addNewUser", err);
+                       throw new ServiceException(err.getMessage());
+               }
+       }
+
        /* (non-Javadoc)
         * @see 
org.apache.openmeetings.webservice.cluster.UserService#add(java.lang.String, 
org.apache.openmeetings.db.dto.user.UserDTO, java.lang.Boolean)
         */

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/UserService.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/UserService.java?rev=1737477&r1=1737476&r2=1737477&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/UserService.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/UserService.java
 Sat Apr  2 09:03:49 2016
@@ -22,6 +22,8 @@ import static org.apache.openmeetings.we
 import static org.apache.openmeetings.webservice.Constants.USER_SERVICE_NAME;
 import static 
org.apache.openmeetings.webservice.Constants.USER_SERVICE_PORT_NAME;
 
+import java.util.List;
+
 import javax.jws.WebParam;
 import javax.jws.WebService;
 import javax.ws.rs.FormParam;
@@ -49,6 +51,17 @@ public interface UserService {
        ServiceResult login(@WebParam(name="user") @QueryParam("user") String 
user, @WebParam(name="pass") @QueryParam("pass") String pass);
 
        /**
+        * Lists all users in the system!
+        * 
+        * @param sid
+        *            The SID from getSession
+        *            
+        * @return - list of users
+        * @throws ServiceException
+        */
+       List<UserDTO> get(@WebParam(name="sid") @QueryParam("sid") String sid) 
throws ServiceException;
+       
+       /**
         * Adds a new User like through the Frontend, but also does activates 
the
         * Account To do SSO see the methods to create a hash and use those 
ones!
         * 

Modified: 
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/user/UserDTO.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/user/UserDTO.java?rev=1737477&r1=1737476&r2=1737477&view=diff
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/user/UserDTO.java
 (original)
+++ 
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/dto/user/UserDTO.java
 Sat Apr  2 09:03:49 2016
@@ -19,6 +19,8 @@
 package org.apache.openmeetings.db.dto.user;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Set;
 
 import javax.xml.bind.annotation.XmlRootElement;
@@ -75,6 +77,16 @@ public class UserDTO implements Serializ
                return u;
        }
        
+       public static List<UserDTO> list(List<User> l) {
+               List<UserDTO> uList = new ArrayList<>();
+               if (l != null) {
+                       for (User u : l) {
+                               uList.add(new UserDTO(u));
+                       }
+               }
+               return uList;
+       }
+       
        public Long getId() {
                return id;
        }

Modified: 
openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java?rev=1737477&r1=1737476&r2=1737477&view=diff
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
 (original)
+++ 
openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
 Sat Apr  2 09:03:49 2016
@@ -22,9 +22,13 @@ import static org.apache.openmeetings.ut
 import static org.apache.openmeetings.webservice.Constants.TNS;
 
 import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
+import javax.jws.WebMethod;
 import javax.jws.WebParam;
 import javax.jws.WebService;
+import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
@@ -86,8 +90,8 @@ public class GroupWebService {
         * @param sid
         *            The SID from getSession
         * @param name
-        *            the name of the org
-        * @return the new id of the org or -1 in case an error happened
+        *            the name of the group
+        * @return the new id of the group or -1 in case an error happened
         * @throws ServiceException
         */
        @POST
@@ -105,8 +109,28 @@ public class GroupWebService {
        }
        
        /**
+        * Get the list of all groups
         * 
-        * Add a user to a certain group
+        * @param sid
+        *            The SID from getSession
+        * @return list of all groups
+        * @throws ServiceException
+        */
+       @GET
+       @Path("/")
+       public List<Group> get(@QueryParam("sid") @WebParam(name="sid") String 
sid) throws ServiceException {
+               Long userId = sessionDao.checkSession(sid);
+               if 
(AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
+                       return groupDao.get(0, Integer.MAX_VALUE);
+               } else {
+                       log.error("Insufficient permissions");
+                       throw new ServiceException("Insufficient permissions"); 
//TODO code -26
+               }
+       }
+       
+       /**
+        * 
+        * Add user to a certain group
         * 
         * @param sid
         *            The SID from getSession
@@ -117,7 +141,7 @@ public class GroupWebService {
         * @return - id of the user added, or error id in case of the error
         */
        @POST
-       @Path("/{id}/users/add/{userid}")
+       @Path("/{id}/users/{userid}")
        public ServiceResult addUser(
                        @QueryParam("sid") @WebParam(name="sid") String sid
                        , @PathParam("id") @WebParam(name="id") Long id
@@ -143,6 +167,49 @@ public class GroupWebService {
        }
 
        /**
+        * 
+        * Remove user from a certain group
+        * 
+        * @param sid
+        *            The SID from getSession
+        * @param userid
+        *            the user id
+        * @param id
+        *            the group id
+        * @return - id of the user added, or error id in case of the error
+        */
+       @DELETE
+       @Path("/{id}/users/{userid}")
+       public ServiceResult removeUser(
+                       @QueryParam("sid") @WebParam(name="sid") String sid
+                       , @PathParam("id") @WebParam(name="id") Long id
+                       , @PathParam("userid") @WebParam(name="userid") Long 
userid
+                       ) throws ServiceException
+       {
+               try {
+                       Long authUserId = sessionDao.checkSession(sid);
+                       if 
(AuthLevelUtil.hasWebServiceLevel(userDao.getRights(authUserId))) {
+                               if (groupUserDao.isUserInGroup(id, userid)) {
+                                       User u = userDao.get(userid);
+                                       for (Iterator<GroupUser> iter = 
u.getGroupUsers().iterator(); iter.hasNext(); ) {
+                                               GroupUser gu = iter.next();
+                                               if 
(id.equals(gu.getGroup().getId())) {
+                                                       iter.remove();
+                                               }
+                                       }
+                                       userDao.update(u, authUserId);
+                               }
+                               return new ServiceResult(userid, "Success", 
Type.SUCCESS);
+                       } else {
+                               return new ServiceResult(-26L, "Insufficient 
permissions", Type.ERROR);
+                       }
+               } catch (Exception err) {
+                       log.error("addUser", err);
+                       throw new ServiceException(err.getMessage());
+               }
+       }
+
+       /**
         * Adds a room to an group
         * 
         * @param sid - The SID of the User. This SID must be marked as Loggedin
@@ -237,4 +304,34 @@ public class GroupWebService {
                        throw new ServiceException(err.getMessage());
                }
        }
+
+       /**
+        * Deletes a group
+        * 
+        * @param sid
+        *            The SID of the User. This SID must be marked as Loggedin
+        * @param id
+        *            the id of the group
+        *            
+        * @throws {@link ServiceException} in case of any error
+        */
+       @WebMethod
+       @DELETE
+       @Path("/{id}")
+       public ServiceResult delete(@WebParam(name="sid") @QueryParam("sid") 
String sid, @WebParam(name="id") @PathParam("id") long id) throws 
ServiceException {
+               try {
+                       Long authUserId = sessionDao.checkSession(sid);
+
+                       if 
(AuthLevelUtil.hasAdminLevel(userDao.getRights(authUserId))) {
+                               groupDao.delete(groupDao.get(id), authUserId);
+
+                               return new ServiceResult(id, "Deleted", 
Type.SUCCESS);
+                       } else {
+                               return new ServiceResult(-26L, "Insufficient 
permissions", Type.ERROR);
+                       }
+               } catch (Exception err) {
+                       log.error("deleteUserById", err);
+                       throw new ServiceException(err.getMessage());
+               }
+       }
 }

Modified: 
openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java?rev=1737477&r1=1737476&r2=1737477&view=diff
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
 (original)
+++ 
openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/UserWebService.java
 Sat Apr  2 09:03:49 2016
@@ -24,6 +24,7 @@ import static org.apache.openmeetings.we
 import static 
org.apache.openmeetings.webservice.Constants.USER_SERVICE_PORT_NAME;
 
 import java.util.Date;
+import java.util.List;
 
 import javax.jws.WebMethod;
 import javax.jws.WebParam;
@@ -122,6 +123,28 @@ public class UserWebService implements U
                }
        }
 
+       /* (non-Javadoc)
+        * @see 
org.apache.openmeetings.webservice.cluster.UserService#get(java.lang.String)
+        */
+       @Override
+       @WebMethod
+       @GET
+       @Path("/")
+       public List<UserDTO> get(@WebParam(name="sid") @QueryParam("sid") 
String sid) throws ServiceException {
+               try {
+                       Long authUserId = sessionDao.checkSession(sid);
+       
+                       if 
(AuthLevelUtil.hasWebServiceLevel(userDao.getRights(authUserId))) {
+                               return UserDTO.list(userDao.getAllUsers());
+                       } else {
+                               throw new ServiceException("Insufficient 
permissions"); //TODO code -26
+                       }
+               } catch (Exception err) {
+                       log.error("addNewUser", err);
+                       throw new ServiceException(err.getMessage());
+               }
+       }
+
        /* (non-Javadoc)
         * @see 
org.apache.openmeetings.webservice.cluster.UserService#add(java.lang.String, 
org.apache.openmeetings.db.dto.user.UserDTO, java.lang.Boolean)
         */

Modified: 
openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/UserService.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/UserService.java?rev=1737477&r1=1737476&r2=1737477&view=diff
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/UserService.java
 (original)
+++ 
openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/UserService.java
 Sat Apr  2 09:03:49 2016
@@ -22,6 +22,8 @@ import static org.apache.openmeetings.we
 import static org.apache.openmeetings.webservice.Constants.USER_SERVICE_NAME;
 import static 
org.apache.openmeetings.webservice.Constants.USER_SERVICE_PORT_NAME;
 
+import java.util.List;
+
 import javax.jws.WebParam;
 import javax.jws.WebService;
 import javax.ws.rs.FormParam;
@@ -49,6 +51,17 @@ public interface UserService {
        ServiceResult login(@WebParam(name="user") @QueryParam("user") String 
user, @WebParam(name="pass") @QueryParam("pass") String pass);
 
        /**
+        * Lists all users in the system!
+        * 
+        * @param sid
+        *            The SID from getSession
+        *            
+        * @return - list of users
+        * @throws ServiceException
+        */
+       List<UserDTO> get(@WebParam(name="sid") @QueryParam("sid") String sid) 
throws ServiceException;
+       
+       /**
         * Adds a new User like through the Frontend, but also does activates 
the
         * Account To do SSO see the methods to create a hash and use those 
ones!
         * 


Reply via email to