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

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


The following commit(s) were added to refs/heads/4.0.x by this push:
     new b2eb900  [OPENMEETINGS-1866] documentation is updated, code clean-up, 
tests are fixed
b2eb900 is described below

commit b2eb900e026a3813375b0f5d629d33cf712d7e38
Author: Maxim Solodovnik <solomax...@gmail.com>
AuthorDate: Tue Apr 10 09:48:28 2018 +0700

    [OPENMEETINGS-1866] documentation is updated, code clean-up, tests are fixed
---
 .../openmeetings/core/ldap/LdapLoginManager.java       |  5 +----
 .../openmeetings/db/dao/basic/ConfigurationDao.java    | 11 +++++++++++
 .../org/apache/openmeetings/db/dao/room/RoomDao.java   |  3 ++-
 .../org/apache/openmeetings/db/dao/user/UserDao.java   |  7 +------
 .../org/apache/openmeetings/db/entity/user/User.java   |  7 +++----
 .../openmeetings/installation/ImportInitvalues.java    | 17 ++++++++++-------
 .../apache/openmeetings/service/user/UserManager.java  |  6 ++----
 .../openmeetings/util/OpenmeetingsVariables.java       | 10 ++++++++++
 .../org/apache/openmeetings/AbstractJUnitDefaults.java |  4 ++--
 .../org/apache/openmeetings/db/dao/TestRoomDao.java    | 18 ++++++++++++++++++
 .../apache/openmeetings/webservice/RoomWebService.java |  7 ++++---
 11 files changed, 64 insertions(+), 31 deletions(-)

diff --git 
a/openmeetings-core/src/main/java/org/apache/openmeetings/core/ldap/LdapLoginManager.java
 
b/openmeetings-core/src/main/java/org/apache/openmeetings/core/ldap/LdapLoginManager.java
index e957177..a1acd87 100644
--- 
a/openmeetings-core/src/main/java/org/apache/openmeetings/core/ldap/LdapLoginManager.java
+++ 
b/openmeetings-core/src/main/java/org/apache/openmeetings/core/ldap/LdapLoginManager.java
@@ -54,7 +54,6 @@ import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.ldap.client.api.EntryCursorImpl;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
-import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
 import org.apache.openmeetings.db.dao.server.LdapConfigDao;
 import org.apache.openmeetings.db.dao.user.GroupDao;
 import org.apache.openmeetings.db.dao.user.UserDao;
@@ -129,8 +128,6 @@ public class LdapLoginManager {
                , QUERY
        }
        @Autowired
-       private ConfigurationDao cfgDao;
-       @Autowired
        private LdapConfigDao ldapConfigDao;
        @Autowired
        private UserDao userDao;
@@ -249,7 +246,7 @@ public class LdapLoginManager {
                                case AUTOCREATE:
                                        u = w.getUser(entry, u);
                                        if (w.options.syncPasswd) {
-                                               u.updatePassword(cfgDao, 
passwd);
+                                               u.updatePassword(passwd);
                                        }
                                        u = userDao.update(u, null);
                                        break;
diff --git 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
index 8916505..01dfa14 100644
--- 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
+++ 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/basic/ConfigurationDao.java
@@ -47,9 +47,11 @@ import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_MP4_AUDI
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_PASS_MIN_LENGTH;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_REST_ALLOW_ORIGIN;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_SIP_ENABLED;
+import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_SIP_EXTEN_CONTEXT;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.DEFAULT_APP_NAME;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.DEFAULT_BASE_URL;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.DEFAULT_MAX_UPLOAD_SIZE;
+import static 
org.apache.openmeetings.util.OpenmeetingsVariables.DEFAULT_SIP_CONTEXT;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.FLASH_BANDWIDTH;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.FLASH_ECHO_PATH;
 import static org.apache.openmeetings.util.OpenmeetingsVariables.FLASH_FPS;
@@ -79,6 +81,7 @@ import static 
org.apache.openmeetings.util.OpenmeetingsVariables.setMinLoginLeng
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.setMinPasswdLength;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.setRestAllowOrigin;
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.setRoomSettings;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.setSipContext;
 import static org.apache.openmeetings.util.OpenmeetingsVariables.setSipEnabled;
 
 import java.io.File;
@@ -368,6 +371,9 @@ public class ConfigurationDao implements 
IDataProviderDao<Configuration> {
                        case CONFIG_DEFAULT_GROUP_ID:
                                reloadDefaultGroup();
                                break;
+                       case CONFIG_SIP_EXTEN_CONTEXT:
+                               reloadSipContext();
+                               break;
                }
                return entity;
        }
@@ -451,6 +457,10 @@ public class ConfigurationDao implements 
IDataProviderDao<Configuration> {
                setDefaultGroup(getLong(CONFIG_DEFAULT_GROUP_ID, null));
        }
 
+       private void reloadSipContext() {
+               setSipContext(getString(CONFIG_SIP_EXTEN_CONTEXT, 
DEFAULT_SIP_CONTEXT));
+       }
+
        public void reinit() {
                reloadMaxUpload();
                reloadCrypt();
@@ -467,6 +477,7 @@ public class ConfigurationDao implements 
IDataProviderDao<Configuration> {
                reloadLoginMinLength();
                reloadPasswdMinLength();
                reloadDefaultGroup();
+               reloadSipContext();
        }
 
        private JSONObject reloadRoomSettings() {
diff --git 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/RoomDao.java
 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/RoomDao.java
index 0300f57..f98e5ec 100644
--- 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/RoomDao.java
+++ 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/RoomDao.java
@@ -171,7 +171,8 @@ public class RoomDao implements 
IGroupAdminDataProviderDao<Room> {
        }
 
        public List<Room> getPublicRooms(Type type) {
-               return em.createNamedQuery("getPublicRooms", 
Room.class).setParameter("type", type).getResultList();
+               return type == null ? getPublicRooms()
+                               : em.createNamedQuery("getPublicRooms", 
Room.class).setParameter("type", type).getResultList();
        }
 
        public List<Long> getSipRooms(List<Long> ids) {
diff --git 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
index fb03f8e..4970ca3 100644
--- 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
+++ 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/UserDao.java
@@ -46,7 +46,6 @@ import org.apache.openjpa.persistence.OpenJPAEntityManager;
 import org.apache.openjpa.persistence.OpenJPAPersistence;
 import org.apache.openjpa.persistence.OpenJPAQuery;
 import org.apache.openmeetings.db.dao.IGroupAdminDataProviderDao;
-import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
 import org.apache.openmeetings.db.dao.label.LabelDao;
 import org.apache.openmeetings.db.entity.user.Address;
 import org.apache.openmeetings.db.entity.user.User;
@@ -61,7 +60,6 @@ import org.apache.openmeetings.util.crypt.ICrypt;
 import org.apache.wicket.util.string.Strings;
 import org.red5.logging.Red5LoggerFactory;
 import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -80,9 +78,6 @@ public class UserDao implements 
IGroupAdminDataProviderDao<User> {
        @PersistenceContext
        private EntityManager em;
 
-       @Autowired
-       private ConfigurationDao cfgDao;
-
        public static Set<Right> getDefaultRights() {
                Set<Right> rights = new HashSet<>();
                rights.add(Right.Login);
@@ -250,7 +245,7 @@ public class UserDao implements 
IGroupAdminDataProviderDao<User> {
        private User updatePassword(Long id, String pwd, Long updatedBy) throws 
NoSuchAlgorithmException {
                //OpenJPA is not allowing to set fields not being fetched before
                User u = get(id, true);
-               u.updatePassword(cfgDao, pwd);
+               u.updatePassword(pwd);
                return update(u, updatedBy);
        }
 
diff --git 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java
 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java
index f8a3073..34a39c2 100644
--- 
a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java
+++ 
b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/user/User.java
@@ -18,7 +18,7 @@
  */
 package org.apache.openmeetings.db.entity.user;
 
-import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_SIP_EXTEN_CONTEXT;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getSipContext;
 import static org.apache.openmeetings.util.OpenmeetingsVariables.isSipEnabled;
 
 import java.security.NoSuchAlgorithmException;
@@ -56,7 +56,6 @@ import org.apache.openjpa.persistence.FetchGroup;
 import org.apache.openjpa.persistence.FetchGroups;
 import org.apache.openjpa.persistence.LoadFetchGroup;
 import org.apache.openjpa.persistence.jdbc.ForeignKey;
-import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
 import org.apache.openmeetings.db.entity.HistoricalEntity;
 import org.apache.openmeetings.db.entity.server.Sessiondata;
 import org.apache.openmeetings.util.crypt.CryptProvider;
@@ -374,13 +373,13 @@ public class User extends HistoricalEntity {
                this.login = login;
        }
 
-       public void updatePassword(ConfigurationDao configDao, String pass) 
throws NoSuchAlgorithmException {
+       public void updatePassword(String pass) throws NoSuchAlgorithmException 
{
                if (isSipEnabled()) {
                        AsteriskSipUser u = getSipUser();
                        if (u == null) {
                                setSipUser(u = new AsteriskSipUser());
                        }
-                       String defaultRoomContext = 
configDao.getString(CONFIG_SIP_EXTEN_CONTEXT, "rooms");
+                       String defaultRoomContext = getSipContext();
                        u.setName(login);
                        u.setDefaultuser(login);
                        u.setMd5secret(MD5.checksum(login + ":asterisk:" + 
pass));
diff --git 
a/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java
 
b/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java
index d89fe95..0b1e755 100644
--- 
a/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java
+++ 
b/openmeetings-install/src/main/java/org/apache/openmeetings/installation/ImportInitvalues.java
@@ -412,12 +412,15 @@ public class ImportInitvalues {
 
        public void loadInitUserAndGroup(InstallationConfig cfg) throws 
Exception {
                // Add default group
-               Group org = new Group();
-               org.setName(cfg.getGroup());
-               org.setInsertedby(1L);
-               org.setDeleted(false);
-               org.setInserted(new Date());
-               org = groupDao.update(org, null);
+               Group g = new Group();
+               g.setName(cfg.getGroup());
+               g.setInsertedby(1L);
+               g.setDeleted(false);
+               g.setInserted(new Date());
+               g = groupDao.update(g, null);
+               Configuration c = cfgDao.get(CONFIG_DEFAULT_GROUP_ID);
+               c.setValueN(g.getId());
+               cfgDao.update(c, null);
 
                User u = getNewUserInstance(null);
                u.setType(User.Type.user);
@@ -427,7 +430,7 @@ public class ImportInitvalues {
                u.setFirstname("firstname");
                u.setLastname("lastname");
                u.getAddress().setEmail(cfg.getEmail());
-               u.getGroupUsers().add(new GroupUser(org, u));
+               u.getGroupUsers().add(new GroupUser(g, u));
 
                u = userDao.update(u, cfg.getPassword(), -1L);
 
diff --git 
a/openmeetings-service/src/main/java/org/apache/openmeetings/service/user/UserManager.java
 
b/openmeetings-service/src/main/java/org/apache/openmeetings/service/user/UserManager.java
index 7134de3..d0f72d0 100644
--- 
a/openmeetings-service/src/main/java/org/apache/openmeetings/service/user/UserManager.java
+++ 
b/openmeetings-service/src/main/java/org/apache/openmeetings/service/user/UserManager.java
@@ -177,13 +177,11 @@ public class UserManager implements IUserManager {
                                }
 
                                u.setActivatehash(ahash);
-
-                               // this is needed cause the language is not a 
needed data at registering
                                if (!Strings.isEmpty(password)) {
-                                       u.updatePassword(cfgDao, password);
+                                       u.updatePassword(password);
                                }
                                u = userDao.update(u, null);
-                               log.debug("Added user-Id " + u.getId());
+                               log.debug("Added user-Id {}", u.getId());
 
                                if (u.getId() != null) {
                                        return u;
diff --git 
a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
 
b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
index 3b5cfaa..a22c088 100644
--- 
a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
+++ 
b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OpenmeetingsVariables.java
@@ -116,6 +116,7 @@ public class OpenmeetingsVariables {
        public static final String FLASH_MIC_RATE = "micRate";
        public static final int DEFAULT_MINUTES_REMINDER_SEND = 15;
        public static final String DEFAULT_BASE_URL = 
"http://localhost:5080/openmeetings/";;
+       public static final String DEFAULT_SIP_CONTEXT = "rooms";
 
        private static String webAppRootKey = null;
        private static String cryptClassName = null;
@@ -136,6 +137,7 @@ public class OpenmeetingsVariables {
        private static String audioBitrate = "32k";
        private static String defaultTimezone = "Europe/Berlin";
        private static String restAllowOrigin = null;
+       private static String sipContext = DEFAULT_SIP_CONTEXT;
 
        private OpenmeetingsVariables() {}
 
@@ -294,4 +296,12 @@ public class OpenmeetingsVariables {
        public static void setDefaultGroup(Long group) {
                defaultGroup = group;
        }
+
+       public static String getSipContext() {
+               return sipContext;
+       }
+
+       public static void setSipContext(String context) {
+               sipContext = context;
+       }
 }
diff --git 
a/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractJUnitDefaults.java
 
b/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractJUnitDefaults.java
index f898a8b..4c191fb 100644
--- 
a/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractJUnitDefaults.java
+++ 
b/openmeetings-web/src/test/java/org/apache/openmeetings/AbstractJUnitDefaults.java
@@ -170,7 +170,7 @@ public abstract class AbstractJUnitDefaults extends 
AbstractSpringTest {
                u.getAddress().setEmail(getEmail(uuid));
                u.setRights(UserDao.getDefaultRights());
                u.setTimeZoneId("Asia/Bangkok");
-               u.updatePassword(cfgDao, createPass());
+               u.updatePassword(createPass());
                u.setLanguageId(1L);
                return u;
        }
@@ -181,7 +181,7 @@ public abstract class AbstractJUnitDefaults extends 
AbstractSpringTest {
                gu.setModerator(groupAdmin);
                u.getGroupUsers().add(gu);
                u.setLogin(login);
-               u.updatePassword(cfgDao, userpass);
+               u.updatePassword(userpass);
                return createUser(u);
        }
 
diff --git 
a/openmeetings-web/src/test/java/org/apache/openmeetings/db/dao/TestRoomDao.java
 
b/openmeetings-web/src/test/java/org/apache/openmeetings/db/dao/TestRoomDao.java
index 4510492..244246f 100644
--- 
a/openmeetings-web/src/test/java/org/apache/openmeetings/db/dao/TestRoomDao.java
+++ 
b/openmeetings-web/src/test/java/org/apache/openmeetings/db/dao/TestRoomDao.java
@@ -19,9 +19,13 @@
 package org.apache.openmeetings.db.dao;
 
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.openmeetings.AbstractJUnitDefaults;
 import org.apache.openmeetings.db.dao.room.RoomDao;
 import org.apache.openmeetings.db.entity.room.Room;
@@ -56,4 +60,18 @@ public class TestRoomDao extends AbstractJUnitDefaults {
                Assert.assertEquals("User presentation room should be created", 
Room.Type.presentation, r.getType());
                assertTrue("User presentation room should have mic status 
hidden", hidden);
        }
+
+       @Test
+       public void testPublicRooms() {
+               for (Room.Type type : Room.Type.values()) {
+                       for (Room r : roomDao.getPublicRooms(type)) {
+                               assertEquals(String.format("Room type should be 
%s", type), type, r.getType());
+                       }
+               }
+               Set<Room.Type> types = new HashSet<>();
+               for (Room r : roomDao.getPublicRooms()) {
+                       types.add(r.getType());
+               }
+               assertEquals("All room types should be listed", 
Room.Type.values().length, types.size());
+       }
 }
diff --git 
a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RoomWebService.java
 
b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RoomWebService.java
index fcea5e7..1d48425 100644
--- 
a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RoomWebService.java
+++ 
b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RoomWebService.java
@@ -56,6 +56,7 @@ import org.apache.openmeetings.db.manager.IClientManager;
 import org.apache.openmeetings.db.util.ws.RoomMessage;
 import org.apache.openmeetings.service.room.InvitationManager;
 import org.apache.openmeetings.webservice.error.ServiceException;
+import org.apache.wicket.util.string.Strings;
 import org.red5.logging.Red5LoggerFactory;
 import org.slf4j.Logger;
 import org.springframework.stereotype.Service;
@@ -78,8 +79,7 @@ public class RoomWebService extends BaseWebService {
         * Returns an Object of Type RoomsList which contains a list of
         * Room-Objects. Every Room-Object contains a Roomtype and all 
informations
         * about that Room. The List of current-users in the room is Null if 
you get
-        * them via SOAP. The Roomtype can be 1 for conference rooms or 2 for
-        * audience rooms.
+        * them via SOAP. The Roomtype can be 'conference', 'presentation' or 
'interview'.
         *
         * @param sid
         *            The SID of the User. This SID must be marked as Loggedin
@@ -91,7 +91,8 @@ public class RoomWebService extends BaseWebService {
        @GET
        @Path("/public/{type}")
        public List<RoomDTO> getPublic(@QueryParam("sid") @WebParam(name="sid") 
String sid, @PathParam("type") @WebParam(name="type") String type) {
-               return performCall(sid, User.Right.Room, sd -> 
RoomDTO.list(getRoomDao().getPublicRooms(Room.Type.valueOf(type))));
+               Room.Type t = Strings.isEmpty(type) ? null : 
Room.Type.valueOf(type);
+               return performCall(sid, User.Right.Room, sd -> 
RoomDTO.list(getRoomDao().getPublicRooms(t)));
        }
 
        /**

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

Reply via email to