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 2017/05/18 05:36:31 UTC
[24/26] openmeetings git commit: Normalize all the line endings
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/SipDao.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/SipDao.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/SipDao.java
index c6f2d18..140c719 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/SipDao.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/room/SipDao.java
@@ -1,191 +1,191 @@
-/*
- * 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.dao.room;
-
-import org.apache.openmeetings.db.entity.room.Room;
-import org.asteriskjava.manager.DefaultManagerConnection;
-import org.asteriskjava.manager.ManagerConnection;
-import org.asteriskjava.manager.ManagerConnectionFactory;
-import org.asteriskjava.manager.ResponseEvents;
-import org.asteriskjava.manager.action.ConfbridgeListAction;
-import org.asteriskjava.manager.action.DbDelAction;
-import org.asteriskjava.manager.action.DbDelTreeAction;
-import org.asteriskjava.manager.action.DbGetAction;
-import org.asteriskjava.manager.action.DbPutAction;
-import org.asteriskjava.manager.action.EventGeneratingAction;
-import org.asteriskjava.manager.action.ManagerAction;
-import org.asteriskjava.manager.action.OriginateAction;
-import org.asteriskjava.manager.response.ManagerError;
-import org.asteriskjava.manager.response.ManagerResponse;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-
-public class SipDao {
- private static final Logger log = Red5LoggerFactory.getLogger(SipDao.class);
- public static final String ASTERISK_OM_FAMILY = "openmeetings";
- public static final String ASTERISK_OM_KEY = "rooms";
- private String sipHostname;
- private int sipPort;
- private String sipUsername;
- private String sipPassword;
- private long timeout;
- private ManagerConnectionFactory factory;
-
- @SuppressWarnings("unused")
- private SipDao() {
- // prohibited default constructor
- }
-
- public SipDao(String sipHostname, int sipPort, String sipUsername, String sipPassword, long timeout) {
- this.sipHostname = sipHostname;
- this.sipPort = sipPort;
- this.sipUsername = sipUsername;
- this.sipPassword = sipPassword;
- this.timeout = timeout;
- factory = new ManagerConnectionFactory(this.sipHostname, this.sipPort, this.sipUsername, this.sipPassword);
- }
-
- private ManagerConnection getConnection() {
- DefaultManagerConnection con = (DefaultManagerConnection)factory.createManagerConnection(); // TODO secure
- con.setDefaultEventTimeout(timeout);
- con.setDefaultResponseTimeout(timeout);
- con.setSocketReadTimeout((int)timeout);
- con.setSocketTimeout((int)timeout);
- return con;
- }
-
- private ManagerResponse exec(ManagerAction action) {
- if (factory == null) {
- log.warn("There is no Asterisk configured");
- return null;
- }
- ManagerConnection con = getConnection();
- try {
- con.login();
- ManagerResponse r = con.sendAction(action);
- if (r != null) {
- log.debug(r.toString());
- }
- return (r instanceof ManagerError) ? null : r;
- } catch (Exception e) {
- log.error("Error while executing ManagerAction: " + action, e);
- } finally {
- try {
- con.logoff();
- } catch (Exception e) {
- // no-op
- }
- }
- return null;
- }
-
- private ResponseEvents execEvent(EventGeneratingAction action) {
- if (factory == null) {
- log.warn("There is no Asterisk configured");
- return null;
- }
- ManagerConnection con = getConnection();
- try {
- con.login("on");
- ResponseEvents r = con.sendEventGeneratingAction(action);
- if (r != null) {
- log.debug(r.getResponse().toString());
- }
- return (r == null || r.getResponse() instanceof ManagerError) ? null : r;
- } catch (Exception e) {
- log.error("Error while executing EventGeneratingAction: " + action, e);
- } finally {
- try {
- con.logoff();
- } catch (Exception e) {
- // no-op
- }
- }
- return null;
- }
-
- private static String getKey(String confno) {
- return ASTERISK_OM_KEY + "/" + confno;
- }
-
- public String get(String confno) {
- String pin = null;
- DbGetAction da = new DbGetAction(ASTERISK_OM_FAMILY, getKey(confno));
- ManagerResponse r = exec(da);
- if (r != null) {
- pin = r.getResponse();
- }
- return pin;
- }
-
- public void update(String confno, String pin) {
- delete(confno);
- DbPutAction da = new DbPutAction(ASTERISK_OM_FAMILY, getKey(confno), pin);
- exec(da);
- }
-
- public void delete() {
- DbDelTreeAction da = new DbDelTreeAction(ASTERISK_OM_FAMILY, ASTERISK_OM_KEY);
- exec(da);
- }
-
- public void delete(String confno) {
- DbDelAction da = new DbDelAction(ASTERISK_OM_FAMILY, getKey(confno));
- exec(da);
- }
-
- public Integer countUsers(String confno) {
- if (confno == null) {
- return null;
- }
- ConfbridgeListAction da = new ConfbridgeListAction(confno);
- ResponseEvents r = execEvent(da);
- if (r != null) {
- log.debug("SipDao::countUsers size == " + r.getEvents().size());
- // "- 1" here means: ListComplete event
- return r.getEvents().size() - 1; // TODO check if was successfull
- }
- return 0;
- }
-
- /**
- * Perform call to specified phone number and join to conference
- *
- * @param number
- * number to call
- * @param r
- * room to be connected to the call
- */
- public void joinToConfCall(String number, Room r) {
- String sipNumber = (r != null && r.getConfno() != null) ? r.getConfno() : null;
- if (sipNumber == null) {
- log.warn("Failed to get SIP number for room: {}", r);
- return;
- }
-
- OriginateAction oa = new OriginateAction();
- oa.setChannel(String.format("Local/%s@rooms-originate", sipNumber));
- oa.setContext("rooms-out");
- oa.setExten(number);
- oa.setPriority(1);
- oa.setTimeout(timeout);
-
- exec(oa); //TODO handle response
- }
-}
+/*
+ * 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.dao.room;
+
+import org.apache.openmeetings.db.entity.room.Room;
+import org.asteriskjava.manager.DefaultManagerConnection;
+import org.asteriskjava.manager.ManagerConnection;
+import org.asteriskjava.manager.ManagerConnectionFactory;
+import org.asteriskjava.manager.ResponseEvents;
+import org.asteriskjava.manager.action.ConfbridgeListAction;
+import org.asteriskjava.manager.action.DbDelAction;
+import org.asteriskjava.manager.action.DbDelTreeAction;
+import org.asteriskjava.manager.action.DbGetAction;
+import org.asteriskjava.manager.action.DbPutAction;
+import org.asteriskjava.manager.action.EventGeneratingAction;
+import org.asteriskjava.manager.action.ManagerAction;
+import org.asteriskjava.manager.action.OriginateAction;
+import org.asteriskjava.manager.response.ManagerError;
+import org.asteriskjava.manager.response.ManagerResponse;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+
+public class SipDao {
+ private static final Logger log = Red5LoggerFactory.getLogger(SipDao.class);
+ public static final String ASTERISK_OM_FAMILY = "openmeetings";
+ public static final String ASTERISK_OM_KEY = "rooms";
+ private String sipHostname;
+ private int sipPort;
+ private String sipUsername;
+ private String sipPassword;
+ private long timeout;
+ private ManagerConnectionFactory factory;
+
+ @SuppressWarnings("unused")
+ private SipDao() {
+ // prohibited default constructor
+ }
+
+ public SipDao(String sipHostname, int sipPort, String sipUsername, String sipPassword, long timeout) {
+ this.sipHostname = sipHostname;
+ this.sipPort = sipPort;
+ this.sipUsername = sipUsername;
+ this.sipPassword = sipPassword;
+ this.timeout = timeout;
+ factory = new ManagerConnectionFactory(this.sipHostname, this.sipPort, this.sipUsername, this.sipPassword);
+ }
+
+ private ManagerConnection getConnection() {
+ DefaultManagerConnection con = (DefaultManagerConnection)factory.createManagerConnection(); // TODO secure
+ con.setDefaultEventTimeout(timeout);
+ con.setDefaultResponseTimeout(timeout);
+ con.setSocketReadTimeout((int)timeout);
+ con.setSocketTimeout((int)timeout);
+ return con;
+ }
+
+ private ManagerResponse exec(ManagerAction action) {
+ if (factory == null) {
+ log.warn("There is no Asterisk configured");
+ return null;
+ }
+ ManagerConnection con = getConnection();
+ try {
+ con.login();
+ ManagerResponse r = con.sendAction(action);
+ if (r != null) {
+ log.debug(r.toString());
+ }
+ return (r instanceof ManagerError) ? null : r;
+ } catch (Exception e) {
+ log.error("Error while executing ManagerAction: " + action, e);
+ } finally {
+ try {
+ con.logoff();
+ } catch (Exception e) {
+ // no-op
+ }
+ }
+ return null;
+ }
+
+ private ResponseEvents execEvent(EventGeneratingAction action) {
+ if (factory == null) {
+ log.warn("There is no Asterisk configured");
+ return null;
+ }
+ ManagerConnection con = getConnection();
+ try {
+ con.login("on");
+ ResponseEvents r = con.sendEventGeneratingAction(action);
+ if (r != null) {
+ log.debug(r.getResponse().toString());
+ }
+ return (r == null || r.getResponse() instanceof ManagerError) ? null : r;
+ } catch (Exception e) {
+ log.error("Error while executing EventGeneratingAction: " + action, e);
+ } finally {
+ try {
+ con.logoff();
+ } catch (Exception e) {
+ // no-op
+ }
+ }
+ return null;
+ }
+
+ private static String getKey(String confno) {
+ return ASTERISK_OM_KEY + "/" + confno;
+ }
+
+ public String get(String confno) {
+ String pin = null;
+ DbGetAction da = new DbGetAction(ASTERISK_OM_FAMILY, getKey(confno));
+ ManagerResponse r = exec(da);
+ if (r != null) {
+ pin = r.getResponse();
+ }
+ return pin;
+ }
+
+ public void update(String confno, String pin) {
+ delete(confno);
+ DbPutAction da = new DbPutAction(ASTERISK_OM_FAMILY, getKey(confno), pin);
+ exec(da);
+ }
+
+ public void delete() {
+ DbDelTreeAction da = new DbDelTreeAction(ASTERISK_OM_FAMILY, ASTERISK_OM_KEY);
+ exec(da);
+ }
+
+ public void delete(String confno) {
+ DbDelAction da = new DbDelAction(ASTERISK_OM_FAMILY, getKey(confno));
+ exec(da);
+ }
+
+ public Integer countUsers(String confno) {
+ if (confno == null) {
+ return null;
+ }
+ ConfbridgeListAction da = new ConfbridgeListAction(confno);
+ ResponseEvents r = execEvent(da);
+ if (r != null) {
+ log.debug("SipDao::countUsers size == " + r.getEvents().size());
+ // "- 1" here means: ListComplete event
+ return r.getEvents().size() - 1; // TODO check if was successfull
+ }
+ return 0;
+ }
+
+ /**
+ * Perform call to specified phone number and join to conference
+ *
+ * @param number
+ * number to call
+ * @param r
+ * room to be connected to the call
+ */
+ public void joinToConfCall(String number, Room r) {
+ String sipNumber = (r != null && r.getConfno() != null) ? r.getConfno() : null;
+ if (sipNumber == null) {
+ log.warn("Failed to get SIP number for room: {}", r);
+ return;
+ }
+
+ OriginateAction oa = new OriginateAction();
+ oa.setChannel(String.format("Local/%s@rooms-originate", sipNumber));
+ oa.setContext("rooms-out");
+ oa.setExten(number);
+ oa.setPriority(1);
+ oa.setTimeout(timeout);
+
+ exec(oa); //TODO handle response
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ISessionManager.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ISessionManager.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ISessionManager.java
index 698dbe0..920647a 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ISessionManager.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ISessionManager.java
@@ -1,206 +1,206 @@
-/*
- * 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.dao.server;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.openmeetings.db.dto.basic.SearchResult;
-import org.apache.openmeetings.db.dto.server.ClientSessionInfo;
-import org.apache.openmeetings.db.entity.room.Client;
-import org.apache.openmeetings.db.entity.server.Server;
-
-/**
- * Methods to add/get/remove {@link Client}s to the session
- *
- *
- * @author sebawagner
- *
- */
-public interface ISessionManager {
- void clearCache();
-
- /**
- * Notified on server start, when the session manager should be started and
- * eventually caches cleared/setup
- */
- void sessionStart();
-
- Client add(Client c, Server server);
- /**
- * add a new client item
- *
- * @param streamId
- * @param scopeName
- * @param remotePort
- * @param remoteAddress
- * @param swfUrl
- * @param server
- * @return
- */
- Client addClientListItem(String streamId, String scopeName, int remotePort, String remoteAddress, String swfUrl, Server server);
-
- Collection<Client> getClients();
-
- /**
- * loads the server into the client (only if database cache is used)
- *
- * @return
- */
- Collection<Client> getClientsWithServer();
-
- /**
- * Get a client by its streamId
- *
- * @param streamId
- * @param server
- * @return
- */
- Client getClientByStreamId(String streamId, Server server);
-
- /**
- * get a client by its publicSID and the server,
- *
- * @param publicSID
- * @param server
- * @return
- */
- Client getClientByPublicSID(String publicSID, Server server);
-
- /**
- * same as {@link #getClientByPublicSID(String, boolean, Server)} but it ignores
- * if the server part, so it will deliver any client just by its publicSID.<br/>
- * <br/>
- * <b>Note:</b>
- * This method requires more time to find the user, so under normal circumstances
- * you should use {@link #getClientByPublicSID(String, boolean, Server)}!
- *
- * @param publicSID
- * @return
- */
- ClientSessionInfo getClientByPublicSIDAnyServer(String publicSID);
-
- /**
- *
- * @param userId
- * @return
- *
- * @deprecated There could be multiple users logged in with the same userid,
- * then this call would return a list not a single user
- */
- @Deprecated
- Client getClientByUserId(Long userId);
-
- /**
- * Update the session object of the audio/video-connection and additionally
- * swap the values to the session object of the user that holds the full
- * session object
- *
- * @param streamId
- * @param rcm
- * @return
- */
- boolean updateAVClientByStreamId(String streamId, Client rcm, Server server);
-
- /**
- * Update the session object
- *
- * updateRoomCount is only <i>one</i> time true, in
- * ScopeApplicationAdapter#setRoomValues(Long, Boolean, Boolean, String)
- * .
- *
- * @param streamId
- * @param rcm
- * @param updateRoomCount
- * true means the count for the room has to be updated
- * @return
- */
- boolean updateClientByStreamId(String streamId, Client rcm, boolean updateRoomCount, Server server);
-
- /**
- * Remove a client from the session store
- *
- * @param streamId
- * @return
- */
- boolean removeClient(String streamId, Server server);
-
- /**
- * Get all ClientList Objects of that room and domain This Function is
- * needed cause it is invoked internally AFTER the current user has been
- * already removed from the ClientList to see if the Room is empty again and
- * the PollList can be removed
- * @param roomId
- * @return
- */
- List<Client> getClientListByRoom(Long roomId);
-
- Collection<Client> getClientListByRoomAll(Long roomId);
-
- /**
- * get the current Moderator in this room
- *
- * @param roomname
- * @return
- */
- List<Client> getCurrentModeratorByRoom(Long roomId);
-
- /**
- * Get list of current client sessions
- *
- * @param start
- * @param max
- * @param orderby
- * @param asc
- * @return
- */
- SearchResult<Client> getListByStartAndMax(int start, int max, String orderby, boolean asc);
-
- /**
- * returns number of current users recording
- *
- * @param roomId
- * @return
- */
- long getRecordingCount(long roomId);
-
- /**
- * returns a number of current users publishing screensharing
- *
- * @param roomId
- * @return
- */
- long getPublishingCount(long roomId);
-
- /**
- * Get a list of all servers of all rooms on that server, serverId = null
- * means it is a local session on the master.
- *
- * @param server
- * @return a set, a roomId can be only one time in this list
- */
- List<Long> getActiveRoomIdsByServer(Server server);
-
- /**
- * Get some statistics about the current sessions
- *
- * @return
- */
- String getSessionStatistics();
-}
+/*
+ * 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.dao.server;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.openmeetings.db.dto.basic.SearchResult;
+import org.apache.openmeetings.db.dto.server.ClientSessionInfo;
+import org.apache.openmeetings.db.entity.room.Client;
+import org.apache.openmeetings.db.entity.server.Server;
+
+/**
+ * Methods to add/get/remove {@link Client}s to the session
+ *
+ *
+ * @author sebawagner
+ *
+ */
+public interface ISessionManager {
+ void clearCache();
+
+ /**
+ * Notified on server start, when the session manager should be started and
+ * eventually caches cleared/setup
+ */
+ void sessionStart();
+
+ Client add(Client c, Server server);
+ /**
+ * add a new client item
+ *
+ * @param streamId
+ * @param scopeName
+ * @param remotePort
+ * @param remoteAddress
+ * @param swfUrl
+ * @param server
+ * @return
+ */
+ Client addClientListItem(String streamId, String scopeName, int remotePort, String remoteAddress, String swfUrl, Server server);
+
+ Collection<Client> getClients();
+
+ /**
+ * loads the server into the client (only if database cache is used)
+ *
+ * @return
+ */
+ Collection<Client> getClientsWithServer();
+
+ /**
+ * Get a client by its streamId
+ *
+ * @param streamId
+ * @param server
+ * @return
+ */
+ Client getClientByStreamId(String streamId, Server server);
+
+ /**
+ * get a client by its publicSID and the server,
+ *
+ * @param publicSID
+ * @param server
+ * @return
+ */
+ Client getClientByPublicSID(String publicSID, Server server);
+
+ /**
+ * same as {@link #getClientByPublicSID(String, boolean, Server)} but it ignores
+ * if the server part, so it will deliver any client just by its publicSID.<br/>
+ * <br/>
+ * <b>Note:</b>
+ * This method requires more time to find the user, so under normal circumstances
+ * you should use {@link #getClientByPublicSID(String, boolean, Server)}!
+ *
+ * @param publicSID
+ * @return
+ */
+ ClientSessionInfo getClientByPublicSIDAnyServer(String publicSID);
+
+ /**
+ *
+ * @param userId
+ * @return
+ *
+ * @deprecated There could be multiple users logged in with the same userid,
+ * then this call would return a list not a single user
+ */
+ @Deprecated
+ Client getClientByUserId(Long userId);
+
+ /**
+ * Update the session object of the audio/video-connection and additionally
+ * swap the values to the session object of the user that holds the full
+ * session object
+ *
+ * @param streamId
+ * @param rcm
+ * @return
+ */
+ boolean updateAVClientByStreamId(String streamId, Client rcm, Server server);
+
+ /**
+ * Update the session object
+ *
+ * updateRoomCount is only <i>one</i> time true, in
+ * ScopeApplicationAdapter#setRoomValues(Long, Boolean, Boolean, String)
+ * .
+ *
+ * @param streamId
+ * @param rcm
+ * @param updateRoomCount
+ * true means the count for the room has to be updated
+ * @return
+ */
+ boolean updateClientByStreamId(String streamId, Client rcm, boolean updateRoomCount, Server server);
+
+ /**
+ * Remove a client from the session store
+ *
+ * @param streamId
+ * @return
+ */
+ boolean removeClient(String streamId, Server server);
+
+ /**
+ * Get all ClientList Objects of that room and domain This Function is
+ * needed cause it is invoked internally AFTER the current user has been
+ * already removed from the ClientList to see if the Room is empty again and
+ * the PollList can be removed
+ * @param roomId
+ * @return
+ */
+ List<Client> getClientListByRoom(Long roomId);
+
+ Collection<Client> getClientListByRoomAll(Long roomId);
+
+ /**
+ * get the current Moderator in this room
+ *
+ * @param roomname
+ * @return
+ */
+ List<Client> getCurrentModeratorByRoom(Long roomId);
+
+ /**
+ * Get list of current client sessions
+ *
+ * @param start
+ * @param max
+ * @param orderby
+ * @param asc
+ * @return
+ */
+ SearchResult<Client> getListByStartAndMax(int start, int max, String orderby, boolean asc);
+
+ /**
+ * returns number of current users recording
+ *
+ * @param roomId
+ * @return
+ */
+ long getRecordingCount(long roomId);
+
+ /**
+ * returns a number of current users publishing screensharing
+ *
+ * @param roomId
+ * @return
+ */
+ long getPublishingCount(long roomId);
+
+ /**
+ * Get a list of all servers of all rooms on that server, serverId = null
+ * means it is a local session on the master.
+ *
+ * @param server
+ * @return a set, a roomId can be only one time in this list
+ */
+ List<Long> getActiveRoomIdsByServer(Server server);
+
+ /**
+ * Get some statistics about the current sessions
+ *
+ * @return
+ */
+ String getSessionStatistics();
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ServerDao.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ServerDao.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ServerDao.java
index ed612eb..dad22cf 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ServerDao.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/server/ServerDao.java
@@ -1,222 +1,222 @@
-/*
- * 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.dao.server;
-
-import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
-
-import java.util.Date;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.NoResultException;
-import javax.persistence.PersistenceContext;
-import javax.persistence.TypedQuery;
-
-import org.apache.openmeetings.db.dao.IDataProviderDao;
-import org.apache.openmeetings.db.dao.user.UserDao;
-import org.apache.openmeetings.db.entity.server.Server;
-import org.apache.openmeetings.util.DaoHelper;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- *
- * CRUD for {@link Server}
- *
- * @author solomax, sebawagner
- *
- */
-@Transactional
-public class ServerDao implements IDataProviderDao<Server> {
- private static final Logger log = Red5LoggerFactory.getLogger(ServerDao.class, webAppRootKey);
- public final static String[] searchFields = { "name", "address", "comment" };
-
- @PersistenceContext
- private EntityManager em;
-
- @Autowired
- private UserDao userDao;
-
- /**
- * Get a list of all available servers
- *
- * @return
- */
- public List<Server> getServerList() {
- log.debug("getServerList enter");
- TypedQuery<Server> q = em.createNamedQuery("getAllServers",
- Server.class);
- return q.getResultList();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.openmeetings.data.OmDAO#get(int, int)
- */
- @Override
- public List<Server> get(int start, int max) {
- TypedQuery<Server> q = em.createNamedQuery("getAllServers", Server.class);
- q.setFirstResult(start);
- q.setMaxResults(max);
- return q.getResultList();
- }
-
- @Override
- public List<Server> get(String search, int start, int count, String order) {
- TypedQuery<Server> q = em.createQuery(DaoHelper.getSearchQuery(
- "Server", "s", search, true, false, order, searchFields),
- Server.class);
- q.setFirstResult(start);
- q.setMaxResults(count);
- return q.getResultList();
- }
-
- /**
- * get the list of all servers in the cluster that are ready to receive a
- * ping (active = true)
- *
- * @return
- */
- public List<Server> getActiveServers() {
- return em.createNamedQuery("getActiveServers", Server.class)
- .getResultList();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.openmeetings.data.OmDAO#count()
- */
- @Override
- public long count() {
- log.debug("getServerCount enter");
- TypedQuery<Long> q = em.createNamedQuery("getServerCount", Long.class);
-
- return q.getSingleResult();
- }
-
- @Override
- public long count(String search) {
- TypedQuery<Long> q = em.createQuery(DaoHelper.getSearchQuery("Server",
- "s", search, true, true, null, searchFields), Long.class);
- return q.getSingleResult();
- }
-
- @Override
- public Server get(long id) {
- return get(Long.valueOf(id));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.openmeetings.data.OmDAO#get(long)
- */
- @Override
- public Server get(Long id) {
- Server result = null;
- log.debug("getServer enter, id = " + id);
- TypedQuery<Server> q = em.createNamedQuery("getServerById",
- Server.class);
- q.setParameter("id", id);
- try {
- result = q.getSingleResult();
- } catch (NoResultException e) {
- // noop
- }
- return result;
- }
-
- /**
- * Get server by its address
- *
- * @param address
- * @return
- */
- public Server getServerByAddress(String address) {
- log.debug("getServer enter, address = " + address);
- TypedQuery<Server> q = em.createNamedQuery("getServerByAddress",
- Server.class);
- q.setParameter("address", address);
- List<Server> list = q.getResultList();
- return list.size() > 0 ? list.get(0) : null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.openmeetings.data.OmDAO#update(org.apache.openmeetings.persistence
- * .beans.OmEntity, long)
- */
- @Override
- public Server update(Server entity, Long userId) {
- entity.setDeleted(false);
- if (entity.getId() == null) {
- entity.setInserted(new Date());
- if (userId != null) {
- entity.setInsertedby(userDao.get(userId));
- }
- em.persist(entity);
- } else {
- entity.setUpdated(new Date());
- if (userId != null) {
- entity.setUpdatedby(userDao.get(userId));
- }
- em.merge(entity);
- }
- return entity;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.openmeetings.data.OmDAO#delete(org.apache.openmeetings.persistence
- * .beans.OmEntity, long)
- */
- @Override
- public void delete(Server entity, Long userId) {
- if (entity.getId() != null) {
- entity.setUpdated(new Date());
- if (userId != null) {
- entity.setUpdatedby(userDao.get(userId));
- }
- entity.setDeleted(true);
- em.merge(entity);
- }
- }
-
- /**
- * get {@link Server} by name
- *
- * @param name
- * @return
- */
- public List<Server> getServersByName(String name) {
- TypedQuery<Server> q = em.createNamedQuery("getServerByName",
- Server.class);
- q.setParameter("name", name);
- return q.getResultList();
- }
-
-}
+/*
+ * 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.dao.server;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
+import javax.persistence.PersistenceContext;
+import javax.persistence.TypedQuery;
+
+import org.apache.openmeetings.db.dao.IDataProviderDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.server.Server;
+import org.apache.openmeetings.util.DaoHelper;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ *
+ * CRUD for {@link Server}
+ *
+ * @author solomax, sebawagner
+ *
+ */
+@Transactional
+public class ServerDao implements IDataProviderDao<Server> {
+ private static final Logger log = Red5LoggerFactory.getLogger(ServerDao.class, webAppRootKey);
+ public final static String[] searchFields = { "name", "address", "comment" };
+
+ @PersistenceContext
+ private EntityManager em;
+
+ @Autowired
+ private UserDao userDao;
+
+ /**
+ * Get a list of all available servers
+ *
+ * @return
+ */
+ public List<Server> getServerList() {
+ log.debug("getServerList enter");
+ TypedQuery<Server> q = em.createNamedQuery("getAllServers",
+ Server.class);
+ return q.getResultList();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.openmeetings.data.OmDAO#get(int, int)
+ */
+ @Override
+ public List<Server> get(int start, int max) {
+ TypedQuery<Server> q = em.createNamedQuery("getAllServers", Server.class);
+ q.setFirstResult(start);
+ q.setMaxResults(max);
+ return q.getResultList();
+ }
+
+ @Override
+ public List<Server> get(String search, int start, int count, String order) {
+ TypedQuery<Server> q = em.createQuery(DaoHelper.getSearchQuery(
+ "Server", "s", search, true, false, order, searchFields),
+ Server.class);
+ q.setFirstResult(start);
+ q.setMaxResults(count);
+ return q.getResultList();
+ }
+
+ /**
+ * get the list of all servers in the cluster that are ready to receive a
+ * ping (active = true)
+ *
+ * @return
+ */
+ public List<Server> getActiveServers() {
+ return em.createNamedQuery("getActiveServers", Server.class)
+ .getResultList();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.openmeetings.data.OmDAO#count()
+ */
+ @Override
+ public long count() {
+ log.debug("getServerCount enter");
+ TypedQuery<Long> q = em.createNamedQuery("getServerCount", Long.class);
+
+ return q.getSingleResult();
+ }
+
+ @Override
+ public long count(String search) {
+ TypedQuery<Long> q = em.createQuery(DaoHelper.getSearchQuery("Server",
+ "s", search, true, true, null, searchFields), Long.class);
+ return q.getSingleResult();
+ }
+
+ @Override
+ public Server get(long id) {
+ return get(Long.valueOf(id));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.openmeetings.data.OmDAO#get(long)
+ */
+ @Override
+ public Server get(Long id) {
+ Server result = null;
+ log.debug("getServer enter, id = " + id);
+ TypedQuery<Server> q = em.createNamedQuery("getServerById",
+ Server.class);
+ q.setParameter("id", id);
+ try {
+ result = q.getSingleResult();
+ } catch (NoResultException e) {
+ // noop
+ }
+ return result;
+ }
+
+ /**
+ * Get server by its address
+ *
+ * @param address
+ * @return
+ */
+ public Server getServerByAddress(String address) {
+ log.debug("getServer enter, address = " + address);
+ TypedQuery<Server> q = em.createNamedQuery("getServerByAddress",
+ Server.class);
+ q.setParameter("address", address);
+ List<Server> list = q.getResultList();
+ return list.size() > 0 ? list.get(0) : null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.openmeetings.data.OmDAO#update(org.apache.openmeetings.persistence
+ * .beans.OmEntity, long)
+ */
+ @Override
+ public Server update(Server entity, Long userId) {
+ entity.setDeleted(false);
+ if (entity.getId() == null) {
+ entity.setInserted(new Date());
+ if (userId != null) {
+ entity.setInsertedby(userDao.get(userId));
+ }
+ em.persist(entity);
+ } else {
+ entity.setUpdated(new Date());
+ if (userId != null) {
+ entity.setUpdatedby(userDao.get(userId));
+ }
+ em.merge(entity);
+ }
+ return entity;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.openmeetings.data.OmDAO#delete(org.apache.openmeetings.persistence
+ * .beans.OmEntity, long)
+ */
+ @Override
+ public void delete(Server entity, Long userId) {
+ if (entity.getId() != null) {
+ entity.setUpdated(new Date());
+ if (userId != null) {
+ entity.setUpdatedby(userDao.get(userId));
+ }
+ entity.setDeleted(true);
+ em.merge(entity);
+ }
+ }
+
+ /**
+ * get {@link Server} by name
+ *
+ * @param name
+ * @return
+ */
+ public List<Server> getServersByName(String name) {
+ TypedQuery<Server> q = em.createNamedQuery("getServerByName",
+ Server.class);
+ q.setParameter("name", name);
+ return q.getResultList();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
index 423b05c..d74064e 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupDao.java
@@ -1,146 +1,146 @@
-/*
- * 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.dao.user;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.NoResultException;
-import javax.persistence.PersistenceContext;
-import javax.persistence.TypedQuery;
-
-import org.apache.openmeetings.db.dao.IGroupAdminDataProviderDao;
-import org.apache.openmeetings.db.entity.user.Group;
-import org.apache.openmeetings.util.DaoHelper;
-import org.springframework.transaction.annotation.Transactional;
-
-@Transactional
-public class GroupDao implements IGroupAdminDataProviderDao<Group> {
- public final static String[] searchFields = {"name"};
- @PersistenceContext
- private EntityManager em;
-
- @Override
- public Group get(long id) {
- return get(Long.valueOf(id));
- }
-
- @Override
- public Group get(Long id) {
- TypedQuery<Group> query = em.createNamedQuery("getGroupById", Group.class);
- query.setParameter("id", id);
- Group o = null;
- try {
- o = query.getSingleResult();
- } catch (NoResultException e) {
- // o = null;
- }
- return o;
- }
-
- public Group get(String name) {
- List<Group> groups = em.createNamedQuery("getGroupByName", Group.class).setParameter("name", name).getResultList();
- return groups == null || groups.isEmpty() ? null : groups.get(0);
- }
-
- @Override
- public List<Group> get(int start, int count) {
- TypedQuery<Group> q = em.createNamedQuery("getNondeletedGroups", Group.class);
- q.setFirstResult(start);
- q.setMaxResults(count);
- return q.getResultList();
- }
-
- @Override
- public List<Group> get(String search, int start, int count, String sort) {
- TypedQuery<Group> q = em.createQuery(DaoHelper.getSearchQuery("Group", "g", search, true, false, sort, searchFields), Group.class);
- q.setFirstResult(start);
- q.setMaxResults(count);
- return q.getResultList();
- }
-
- @Override
- public List<Group> get(String search, Long adminId, int start, int count, String order) {
- TypedQuery<Group> q = em.createQuery(DaoHelper.getSearchQuery("GroupUser gu, IN(gu.group)", "g", null, search, true, true, false
- , "gu.user.id = :adminId AND gu.moderator = true", order, searchFields), Group.class);
- q.setParameter("adminId", adminId);
- q.setFirstResult(start);
- q.setMaxResults(count);
- return q.getResultList();
- }
-
- @Override
- public long count() {
- TypedQuery<Long> q = em.createNamedQuery("countGroups", Long.class);
- return q.getSingleResult();
- }
-
- @Override
- public long count(String search) {
- TypedQuery<Long> q = em.createQuery(DaoHelper.getSearchQuery("Group", "o", search, true, true, null, searchFields), Long.class);
- return q.getSingleResult();
- }
-
- @Override
- public long count(String search, Long adminId) {
- TypedQuery<Long> q = em.createQuery(DaoHelper.getSearchQuery("GroupUser gu, IN(gu.group)", "g", null, search, true, true, true
- , "gu.user.id = :adminId AND gu.moderator = true", null, searchFields), Long.class);
- q.setParameter("adminId", adminId);
- return q.getSingleResult();
- }
-
- public List<Group> get(Collection<Long> ids) {
- return em.createNamedQuery("getGroupsByIds", Group.class).setParameter("ids", ids).getResultList();
- }
-
- public List<Group> getLimited() {
- return em.createNamedQuery("getLimitedGroups", Group.class).getResultList();
- }
-
- @Override
- public Group update(Group entity, Long userId) {
- if (entity.getId() == null) {
- if (userId != null) {
- entity.setInsertedby(userId);
- }
- entity.setInserted(new Date());
- em.persist(entity);
- } else {
- if (userId != null) {
- entity.setUpdatedby(userId);
- }
- entity.setUpdated(new Date());
- em.merge(entity);
- }
- return entity;
- }
-
- @Override
- public void delete(Group g, Long userId) {
- em.createNamedQuery("deleteGroupUsersByGroup").setParameter("id", g.getId()).executeUpdate();
-
- g.setDeleted(true);
- if (userId != null) {
- g.setUpdatedby(userId);
- }
- em.merge(g);
- }
-}
+/*
+ * 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.dao.user;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
+import javax.persistence.PersistenceContext;
+import javax.persistence.TypedQuery;
+
+import org.apache.openmeetings.db.dao.IGroupAdminDataProviderDao;
+import org.apache.openmeetings.db.entity.user.Group;
+import org.apache.openmeetings.util.DaoHelper;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class GroupDao implements IGroupAdminDataProviderDao<Group> {
+ public final static String[] searchFields = {"name"};
+ @PersistenceContext
+ private EntityManager em;
+
+ @Override
+ public Group get(long id) {
+ return get(Long.valueOf(id));
+ }
+
+ @Override
+ public Group get(Long id) {
+ TypedQuery<Group> query = em.createNamedQuery("getGroupById", Group.class);
+ query.setParameter("id", id);
+ Group o = null;
+ try {
+ o = query.getSingleResult();
+ } catch (NoResultException e) {
+ // o = null;
+ }
+ return o;
+ }
+
+ public Group get(String name) {
+ List<Group> groups = em.createNamedQuery("getGroupByName", Group.class).setParameter("name", name).getResultList();
+ return groups == null || groups.isEmpty() ? null : groups.get(0);
+ }
+
+ @Override
+ public List<Group> get(int start, int count) {
+ TypedQuery<Group> q = em.createNamedQuery("getNondeletedGroups", Group.class);
+ q.setFirstResult(start);
+ q.setMaxResults(count);
+ return q.getResultList();
+ }
+
+ @Override
+ public List<Group> get(String search, int start, int count, String sort) {
+ TypedQuery<Group> q = em.createQuery(DaoHelper.getSearchQuery("Group", "g", search, true, false, sort, searchFields), Group.class);
+ q.setFirstResult(start);
+ q.setMaxResults(count);
+ return q.getResultList();
+ }
+
+ @Override
+ public List<Group> get(String search, Long adminId, int start, int count, String order) {
+ TypedQuery<Group> q = em.createQuery(DaoHelper.getSearchQuery("GroupUser gu, IN(gu.group)", "g", null, search, true, true, false
+ , "gu.user.id = :adminId AND gu.moderator = true", order, searchFields), Group.class);
+ q.setParameter("adminId", adminId);
+ q.setFirstResult(start);
+ q.setMaxResults(count);
+ return q.getResultList();
+ }
+
+ @Override
+ public long count() {
+ TypedQuery<Long> q = em.createNamedQuery("countGroups", Long.class);
+ return q.getSingleResult();
+ }
+
+ @Override
+ public long count(String search) {
+ TypedQuery<Long> q = em.createQuery(DaoHelper.getSearchQuery("Group", "o", search, true, true, null, searchFields), Long.class);
+ return q.getSingleResult();
+ }
+
+ @Override
+ public long count(String search, Long adminId) {
+ TypedQuery<Long> q = em.createQuery(DaoHelper.getSearchQuery("GroupUser gu, IN(gu.group)", "g", null, search, true, true, true
+ , "gu.user.id = :adminId AND gu.moderator = true", null, searchFields), Long.class);
+ q.setParameter("adminId", adminId);
+ return q.getSingleResult();
+ }
+
+ public List<Group> get(Collection<Long> ids) {
+ return em.createNamedQuery("getGroupsByIds", Group.class).setParameter("ids", ids).getResultList();
+ }
+
+ public List<Group> getLimited() {
+ return em.createNamedQuery("getLimitedGroups", Group.class).getResultList();
+ }
+
+ @Override
+ public Group update(Group entity, Long userId) {
+ if (entity.getId() == null) {
+ if (userId != null) {
+ entity.setInsertedby(userId);
+ }
+ entity.setInserted(new Date());
+ em.persist(entity);
+ } else {
+ if (userId != null) {
+ entity.setUpdatedby(userId);
+ }
+ entity.setUpdated(new Date());
+ em.merge(entity);
+ }
+ return entity;
+ }
+
+ @Override
+ public void delete(Group g, Long userId) {
+ em.createNamedQuery("deleteGroupUsersByGroup").setParameter("id", g.getId()).executeUpdate();
+
+ g.setDeleted(true);
+ if (userId != null) {
+ g.setUpdatedby(userId);
+ }
+ em.merge(g);
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupUserDao.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupUserDao.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupUserDao.java
index 53d85a7..bcc6d5c 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupUserDao.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/dao/user/GroupUserDao.java
@@ -1,124 +1,124 @@
-/*
- * 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.dao.user;
-
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.TypedQuery;
-
-import org.apache.openmeetings.db.dao.IDataProviderDao;
-import org.apache.openmeetings.db.entity.user.GroupUser;
-import org.apache.openmeetings.util.DaoHelper;
-import org.springframework.transaction.annotation.Transactional;
-
-@Transactional
-public class GroupUserDao implements IDataProviderDao<GroupUser> {
- @PersistenceContext
- private EntityManager em;
- public final static String[] searchFields = {"user.lastname", "user.firstname", "user.login", "user.address.email"};
-
- @Override
- public GroupUser get(long id) {
- return get(Long.valueOf(id));
- }
-
- @Override
- public GroupUser get(Long id) {
- TypedQuery<GroupUser> q = em.createNamedQuery("getGroupUsersById", GroupUser.class);
- q.setParameter("id", id);
- return q.getSingleResult();
- }
-
- @Override
- public List<GroupUser> get(int start, int count) {
- throw new RuntimeException("Should not be used");
- }
-
- @Override
- public List<GroupUser> get(String search, int start, int count, String sort) {
- throw new RuntimeException("Should not be used");
- }
-
- public List<GroupUser> get(long groupId, String search, int start, int count, String sort) {
- TypedQuery<GroupUser> q = em.createQuery(DaoHelper.getSearchQuery(GroupUser.class.getSimpleName(), "ou", null, search, false, false, "ou.group.id = :groupId", sort, searchFields), GroupUser.class);
- q.setParameter("groupId", groupId);
- q.setFirstResult(start);
- q.setMaxResults(count);
- return q.getResultList();
- }
-
- public List<GroupUser> get(long groupId, int start, int count) {
- TypedQuery<GroupUser> q = em.createNamedQuery("getGroupUsersByGroupId", GroupUser.class);
- q.setParameter("id", groupId);
- q.setFirstResult(start);
- q.setMaxResults(count);
- return q.getResultList();
- }
-
- public GroupUser getByGroupAndUser(long groupId, long userId) {
- try {
- List<GroupUser> list = em.createNamedQuery("isUserInGroup", GroupUser.class)
- .setParameter("groupId", groupId).setParameter("userId", userId).getResultList();
- if (list != null && !list.isEmpty()) {
- return list.get(0);
- }
- } catch (Exception e) {
- //no-op
- }
- return null;
- }
-
- public boolean isUserInGroup(long groupId, long userId) {
- return em.createNamedQuery("isUserInGroup", GroupUser.class)
- .setParameter("groupId", groupId).setParameter("userId", userId).getResultList().size() > 0;
- }
-
- @Override
- public long count() {
- throw new RuntimeException("Should not be used");
- }
-
- @Override
- public long count(String search) {
- throw new RuntimeException("Should not be used");
- }
-
- public long count(long groupId, String search) {
- TypedQuery<Long> q = em.createQuery(DaoHelper.getSearchQuery(GroupUser.class.getSimpleName(), "ou", search, false, true, null, searchFields), Long.class);
- return q.getSingleResult();
- }
-
- public long count(long groupId) {
- TypedQuery<Long> q = em.createNamedQuery("countGroupUsers", Long.class);
- q.setParameter("id", groupId);
- return q.getSingleResult();
- }
-
- @Override
- public GroupUser update(GroupUser entity, Long userId) {
- throw new RuntimeException("Should not be used");
- }
-
- @Override
- public void delete(GroupUser entity, Long userId) {
- throw new RuntimeException("Should not be used");
- }
-}
+/*
+ * 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.dao.user;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.TypedQuery;
+
+import org.apache.openmeetings.db.dao.IDataProviderDao;
+import org.apache.openmeetings.db.entity.user.GroupUser;
+import org.apache.openmeetings.util.DaoHelper;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class GroupUserDao implements IDataProviderDao<GroupUser> {
+ @PersistenceContext
+ private EntityManager em;
+ public final static String[] searchFields = {"user.lastname", "user.firstname", "user.login", "user.address.email"};
+
+ @Override
+ public GroupUser get(long id) {
+ return get(Long.valueOf(id));
+ }
+
+ @Override
+ public GroupUser get(Long id) {
+ TypedQuery<GroupUser> q = em.createNamedQuery("getGroupUsersById", GroupUser.class);
+ q.setParameter("id", id);
+ return q.getSingleResult();
+ }
+
+ @Override
+ public List<GroupUser> get(int start, int count) {
+ throw new RuntimeException("Should not be used");
+ }
+
+ @Override
+ public List<GroupUser> get(String search, int start, int count, String sort) {
+ throw new RuntimeException("Should not be used");
+ }
+
+ public List<GroupUser> get(long groupId, String search, int start, int count, String sort) {
+ TypedQuery<GroupUser> q = em.createQuery(DaoHelper.getSearchQuery(GroupUser.class.getSimpleName(), "ou", null, search, false, false, "ou.group.id = :groupId", sort, searchFields), GroupUser.class);
+ q.setParameter("groupId", groupId);
+ q.setFirstResult(start);
+ q.setMaxResults(count);
+ return q.getResultList();
+ }
+
+ public List<GroupUser> get(long groupId, int start, int count) {
+ TypedQuery<GroupUser> q = em.createNamedQuery("getGroupUsersByGroupId", GroupUser.class);
+ q.setParameter("id", groupId);
+ q.setFirstResult(start);
+ q.setMaxResults(count);
+ return q.getResultList();
+ }
+
+ public GroupUser getByGroupAndUser(long groupId, long userId) {
+ try {
+ List<GroupUser> list = em.createNamedQuery("isUserInGroup", GroupUser.class)
+ .setParameter("groupId", groupId).setParameter("userId", userId).getResultList();
+ if (list != null && !list.isEmpty()) {
+ return list.get(0);
+ }
+ } catch (Exception e) {
+ //no-op
+ }
+ return null;
+ }
+
+ public boolean isUserInGroup(long groupId, long userId) {
+ return em.createNamedQuery("isUserInGroup", GroupUser.class)
+ .setParameter("groupId", groupId).setParameter("userId", userId).getResultList().size() > 0;
+ }
+
+ @Override
+ public long count() {
+ throw new RuntimeException("Should not be used");
+ }
+
+ @Override
+ public long count(String search) {
+ throw new RuntimeException("Should not be used");
+ }
+
+ public long count(long groupId, String search) {
+ TypedQuery<Long> q = em.createQuery(DaoHelper.getSearchQuery(GroupUser.class.getSimpleName(), "ou", search, false, true, null, searchFields), Long.class);
+ return q.getSingleResult();
+ }
+
+ public long count(long groupId) {
+ TypedQuery<Long> q = em.createNamedQuery("countGroupUsers", Long.class);
+ q.setParameter("id", groupId);
+ return q.getSingleResult();
+ }
+
+ @Override
+ public GroupUser update(GroupUser entity, Long userId) {
+ throw new RuntimeException("Should not be used");
+ }
+
+ @Override
+ public void delete(GroupUser entity, Long userId) {
+ throw new RuntimeException("Should not be used");
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/MailMessage.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/MailMessage.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/MailMessage.java
index 5562c37..dc14f03 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/MailMessage.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/basic/MailMessage.java
@@ -1,199 +1,199 @@
-/*
- * 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.entity.basic;
-
-import java.util.Calendar;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-
-import org.apache.openmeetings.db.entity.IDataProviderEntity;
-
-@Entity
-@NamedQueries({
- @NamedQuery(name = "getMailMessageById", query = "SELECT m FROM MailMessage m WHERE m.id = :id")
- , @NamedQuery(name = "getMailMessages", query = "SELECT m FROM MailMessage m ORDER BY m.updated, m.inserted")
- , @NamedQuery(name = "getMailMessagesByStatus", query = "SELECT m FROM MailMessage m WHERE m.status = :status ORDER BY m.updated, m.inserted")
- , @NamedQuery(name = "countMailMessages", query = "SELECT COUNT(m) FROM MailMessage m")
- , @NamedQuery(name = "resetMailStatusByDate", query = "UPDATE MailMessage m SET m.status = :noneStatus WHERE m.status = :sendingStatus AND m.updated < :date")
- , @NamedQuery(name = "resetMailStatusById", query = "UPDATE MailMessage m SET m.errorCount = 0, m.status = :noneStatus WHERE m.id = :id")
-})
-@Table(name = "email_queue")
-public class MailMessage implements IDataProviderEntity {
- private static final long serialVersionUID = 1L;
-
- public enum Status {
- NONE, SENDING, ERROR, DONE
- }
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "id")
- private Long id;
-
- @Lob
- @Column(name = "recipients")
- private String recipients;
-
- @Column(name = "replyTo")
- private String replyTo;
-
- @Column(name = "subject")
- private String subject;
-
- @Lob
- @Column(name = "body")
- private String body;
-
- @Lob
- @Column(name = "ics")
- private byte[] ics;
-
- @Column(name = "status", nullable = false)
- @Enumerated(EnumType.STRING)
- private Status status = Status.NONE;
-
- @Column(name = "inserted")
- private Calendar inserted;
-
- @Column(name = "updated")
- private Calendar updated;
-
- @Column(name = "error_count", nullable = false)
- private int errorCount = 0;
-
- @Lob
- @Column(name = "last_error")
- private String lastError;
-
- public MailMessage() {
- this(null, null, null, null, null);
- }
-
- public MailMessage(String recipients, String replyTo, String subject, String body) {
- this(recipients, replyTo, subject, body, null);
- }
-
- public MailMessage(String recipients, String replyTo, String subject, String body, byte[] ics) {
- this.recipients = recipients;
- this.replyTo = replyTo;
- this.subject = subject;
- this.body = body;
- this.ics = ics;
- }
-
- @Override
- public Long getId() {
- return id;
- }
-
- @Override
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getRecipients() {
- return recipients;
- }
-
- public void setRecipients(String recipients) {
- this.recipients = recipients;
- }
-
- public String getReplyTo() {
- return replyTo;
- }
-
- public void setReplyTo(String replyTo) {
- this.replyTo = replyTo;
- }
-
- public String getSubject() {
- return subject;
- }
-
- public void setSubject(String subject) {
- this.subject = subject;
- }
-
- public String getBody() {
- return body;
- }
-
- public void setBody(String body) {
- this.body = body;
- }
-
- public Status getStatus() {
- return status;
- }
-
- public void setStatus(Status status) {
- this.status = status;
- }
-
- public Calendar getInserted() {
- return inserted;
- }
-
- public void setInserted(Calendar inserted) {
- this.inserted = inserted;
- }
-
- public Calendar getUpdated() {
- return updated;
- }
-
- public void setUpdated(Calendar updated) {
- this.updated = updated;
- }
-
- public byte[] getIcs() {
- return ics;
- }
-
- public void setIcs(byte[] ics) {
- this.ics = ics;
- }
-
- public int getErrorCount() {
- return errorCount;
- }
-
- public void setErrorCount(int errorCount) {
- this.errorCount = errorCount;
- }
-
- public String getLastError() {
- return lastError;
- }
-
- public void setLastError(String lastError) {
- this.lastError = lastError;
- }
-}
+/*
+ * 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.entity.basic;
+
+import java.util.Calendar;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+import org.apache.openmeetings.db.entity.IDataProviderEntity;
+
+@Entity
+@NamedQueries({
+ @NamedQuery(name = "getMailMessageById", query = "SELECT m FROM MailMessage m WHERE m.id = :id")
+ , @NamedQuery(name = "getMailMessages", query = "SELECT m FROM MailMessage m ORDER BY m.updated, m.inserted")
+ , @NamedQuery(name = "getMailMessagesByStatus", query = "SELECT m FROM MailMessage m WHERE m.status = :status ORDER BY m.updated, m.inserted")
+ , @NamedQuery(name = "countMailMessages", query = "SELECT COUNT(m) FROM MailMessage m")
+ , @NamedQuery(name = "resetMailStatusByDate", query = "UPDATE MailMessage m SET m.status = :noneStatus WHERE m.status = :sendingStatus AND m.updated < :date")
+ , @NamedQuery(name = "resetMailStatusById", query = "UPDATE MailMessage m SET m.errorCount = 0, m.status = :noneStatus WHERE m.id = :id")
+})
+@Table(name = "email_queue")
+public class MailMessage implements IDataProviderEntity {
+ private static final long serialVersionUID = 1L;
+
+ public enum Status {
+ NONE, SENDING, ERROR, DONE
+ }
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private Long id;
+
+ @Lob
+ @Column(name = "recipients")
+ private String recipients;
+
+ @Column(name = "replyTo")
+ private String replyTo;
+
+ @Column(name = "subject")
+ private String subject;
+
+ @Lob
+ @Column(name = "body")
+ private String body;
+
+ @Lob
+ @Column(name = "ics")
+ private byte[] ics;
+
+ @Column(name = "status", nullable = false)
+ @Enumerated(EnumType.STRING)
+ private Status status = Status.NONE;
+
+ @Column(name = "inserted")
+ private Calendar inserted;
+
+ @Column(name = "updated")
+ private Calendar updated;
+
+ @Column(name = "error_count", nullable = false)
+ private int errorCount = 0;
+
+ @Lob
+ @Column(name = "last_error")
+ private String lastError;
+
+ public MailMessage() {
+ this(null, null, null, null, null);
+ }
+
+ public MailMessage(String recipients, String replyTo, String subject, String body) {
+ this(recipients, replyTo, subject, body, null);
+ }
+
+ public MailMessage(String recipients, String replyTo, String subject, String body, byte[] ics) {
+ this.recipients = recipients;
+ this.replyTo = replyTo;
+ this.subject = subject;
+ this.body = body;
+ this.ics = ics;
+ }
+
+ @Override
+ public Long getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getRecipients() {
+ return recipients;
+ }
+
+ public void setRecipients(String recipients) {
+ this.recipients = recipients;
+ }
+
+ public String getReplyTo() {
+ return replyTo;
+ }
+
+ public void setReplyTo(String replyTo) {
+ this.replyTo = replyTo;
+ }
+
+ public String getSubject() {
+ return subject;
+ }
+
+ public void setSubject(String subject) {
+ this.subject = subject;
+ }
+
+ public String getBody() {
+ return body;
+ }
+
+ public void setBody(String body) {
+ this.body = body;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+
+ public Calendar getInserted() {
+ return inserted;
+ }
+
+ public void setInserted(Calendar inserted) {
+ this.inserted = inserted;
+ }
+
+ public Calendar getUpdated() {
+ return updated;
+ }
+
+ public void setUpdated(Calendar updated) {
+ this.updated = updated;
+ }
+
+ public byte[] getIcs() {
+ return ics;
+ }
+
+ public void setIcs(byte[] ics) {
+ this.ics = ics;
+ }
+
+ public int getErrorCount() {
+ return errorCount;
+ }
+
+ public void setErrorCount(int errorCount) {
+ this.errorCount = errorCount;
+ }
+
+ public String getLastError() {
+ return lastError;
+ }
+
+ public void setLastError(String lastError) {
+ this.lastError = lastError;
+ }
+}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/server/Server.java
----------------------------------------------------------------------
diff --git a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/server/Server.java b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/server/Server.java
index 7859b49..046bc92 100644
--- a/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/server/Server.java
+++ b/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/server/Server.java
@@ -1,304 +1,304 @@
-/*
- * 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.entity.server;
-
-import java.util.Calendar;
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.openjpa.persistence.jdbc.ForeignKey;
-import org.apache.openmeetings.db.entity.IDataProviderEntity;
-import org.apache.openmeetings.db.entity.user.User;
-import org.simpleframework.xml.Element;
-import org.simpleframework.xml.Root;
-
-@Entity
-@NamedQueries({
- @NamedQuery(name = "getAllServers", query = "SELECT s FROM Server s WHERE s.deleted = false ORDER BY s.id"),
- @NamedQuery(name = "getServerCount", query = "SELECT COUNT(s) FROM Server s WHERE s.deleted = false"),
- @NamedQuery(name = "getServerById", query = "SELECT s FROM Server s LEFT JOIN FETCH s.insertedby LEFT JOIN FETCH s.updatedby WHERE s.deleted = false AND s.id = :id"),
- @NamedQuery(name = "getServerByName", query = "SELECT s FROM Server s WHERE s.deleted = false AND s.name LIKE :name"),
- @NamedQuery(name = "getServerByAddress", query = "SELECT s FROM Server s WHERE s.deleted = false AND s.address LIKE :address"),
- @NamedQuery(name = "getServersWithNoUsers", query = "SELECT s FROM Server s WHERE s.deleted = false AND s.id NOT IN (SELECT u.server.id FROM User u where u.server.id IS NOT NULL)"),
- @NamedQuery(name = "getServerWithMinimumUsers", query = "SELECT s.id, COUNT(u) AS cnt FROM User u JOIN u.server s WHERE s.deleted = false GROUP BY s.id ORDER BY cnt"),
- @NamedQuery(name = "getActiveServers", query = "SELECT s FROM Server s WHERE s.deleted = false AND s.active = true") //
-})
-@Table(name = "server")
-@Root
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class Server implements IDataProviderEntity {
- private static final long serialVersionUID = 1L;
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "id")
- @Element(data = true)
- private Long id;
-
- @Column(name = "name")
- @Element(data = true)
- private String name;
-
- @Column(name = "address")
- @Element(data = true)
- private String address;
-
- @Column(name = "inserted")
- public Date inserted;
-
- @Column(name = "updated")
- public Date updated;
-
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "insertedby_id", updatable = true, insertable = true)
- @ForeignKey(enabled = true)
- public User insertedby;
-
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "updatedby_id", updatable = true, insertable = true)
- @ForeignKey(enabled = true)
- public User updatedby;
-
- @Lob
- @Column(name = "comment", length = 2048)
- @Element(data = true, required = false)
- private String comment;
-
- @Column(name = "last_ping", nullable = true)
- @Element(data = true, required = false)
- private Calendar lastPing;
-
- @Column(name = "port", nullable = true)
- @Element(data = true, required = false)
- private int port;
-
- @Column(name = "protocol", nullable = true)
- @Element(data = true, required = false)
- private String protocol;
-
- @Column(name = "webapp", nullable = true)
- @Element(data = true, required = false)
- private String webapp;
-
- @Column(name = "login", nullable = true)
- @Element(data = true, required = false)
- private String user;
-
- @Column(name = "pass", nullable = true)
- @Element(data = true, required = false)
- private String pass;
-
- @Column(name = "active", nullable = false)
- @Element(data = true, required = false)
- private boolean active;
-
- @Column(name = "deleted", nullable = false)
- @Element(data = true)
- private boolean deleted = false;
-
- @Override
- public Long getId() {
- return id;
- }
-
- @Override
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getAddress() {
- return address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- }
-
- public boolean isDeleted() {
- return deleted;
- }
-
- public void setDeleted(boolean deleted) {
- this.deleted = deleted;
- }
-
- public Date getInserted() {
- return inserted;
- }
-
- public void setInserted(Date inserted) {
- this.inserted = inserted;
- }
-
- public Date getUpdated() {
- return updated;
- }
-
- public void setUpdated(Date updated) {
- this.updated = updated;
- }
-
- public User getInsertedby() {
- return insertedby;
- }
-
- public void setInsertedby(User insertedby) {
- this.insertedby = insertedby;
- }
-
- public User getUpdatedby() {
- return updatedby;
- }
-
- public void setUpdatedby(User updatedby) {
- this.updatedby = updatedby;
- }
-
- public String getComment() {
- return comment;
- }
-
- public void setComment(String comment) {
- this.comment = comment;
- }
-
- public Calendar getLastPing() {
- return lastPing;
- }
-
- public void setLastPing(Calendar lastPing) {
- this.lastPing = lastPing;
- }
-
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
- public String getProtocol() {
- return protocol;
- }
-
- public void setProtocol(String protocol) {
- this.protocol = protocol;
- }
-
- public String getWebapp() {
- return webapp;
- }
-
- public void setWebapp(String webapp) {
- this.webapp = webapp;
- }
-
- public String getUser() {
- return user;
- }
-
- public void setUser(String user) {
- this.user = user;
- }
-
- public String getPass() {
- return pass;
- }
-
- public void setPass(String pass) {
- this.pass = pass;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public boolean isActive() {
- return active;
- }
-
- public void setActive(boolean active) {
- this.active = active;
- }
-
- @Override
- public String toString() {
- return "Server [id=" + id + ", name=" + name + ", address=" + address
- + ", port=" + port + ", user=" + user + ", pass=" + pass
- + ", protocol=" + protocol
- + ", active=" + active + ", webapp=" + webapp + ", deleted="
- + deleted + "]";
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((address == null) ? 0 : address.hashCode());
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Server other = (Server) obj;
- if (address == null) {
- if (other.address != null)
- return false;
- } else if (!address.equals(other.address))
- return false;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- return true;
- }
-}
+/*
+ * 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.entity.server;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.openjpa.persistence.jdbc.ForeignKey;
+import org.apache.openmeetings.db.entity.IDataProviderEntity;
+import org.apache.openmeetings.db.entity.user.User;
+import org.simpleframework.xml.Element;
+import org.simpleframework.xml.Root;
+
+@Entity
+@NamedQueries({
+ @NamedQuery(name = "getAllServers", query = "SELECT s FROM Server s WHERE s.deleted = false ORDER BY s.id"),
+ @NamedQuery(name = "getServerCount", query = "SELECT COUNT(s) FROM Server s WHERE s.deleted = false"),
+ @NamedQuery(name = "getServerById", query = "SELECT s FROM Server s LEFT JOIN FETCH s.insertedby LEFT JOIN FETCH s.updatedby WHERE s.deleted = false AND s.id = :id"),
+ @NamedQuery(name = "getServerByName", query = "SELECT s FROM Server s WHERE s.deleted = false AND s.name LIKE :name"),
+ @NamedQuery(name = "getServerByAddress", query = "SELECT s FROM Server s WHERE s.deleted = false AND s.address LIKE :address"),
+ @NamedQuery(name = "getServersWithNoUsers", query = "SELECT s FROM Server s WHERE s.deleted = false AND s.id NOT IN (SELECT u.server.id FROM User u where u.server.id IS NOT NULL)"),
+ @NamedQuery(name = "getServerWithMinimumUsers", query = "SELECT s.id, COUNT(u) AS cnt FROM User u JOIN u.server s WHERE s.deleted = false GROUP BY s.id ORDER BY cnt"),
+ @NamedQuery(name = "getActiveServers", query = "SELECT s FROM Server s WHERE s.deleted = false AND s.active = true") //
+})
+@Table(name = "server")
+@Root
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+public class Server implements IDataProviderEntity {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ @Element(data = true)
+ private Long id;
+
+ @Column(name = "name")
+ @Element(data = true)
+ private String name;
+
+ @Column(name = "address")
+ @Element(data = true)
+ private String address;
+
+ @Column(name = "inserted")
+ public Date inserted;
+
+ @Column(name = "updated")
+ public Date updated;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "insertedby_id", updatable = true, insertable = true)
+ @ForeignKey(enabled = true)
+ public User insertedby;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "updatedby_id", updatable = true, insertable = true)
+ @ForeignKey(enabled = true)
+ public User updatedby;
+
+ @Lob
+ @Column(name = "comment", length = 2048)
+ @Element(data = true, required = false)
+ private String comment;
+
+ @Column(name = "last_ping", nullable = true)
+ @Element(data = true, required = false)
+ private Calendar lastPing;
+
+ @Column(name = "port", nullable = true)
+ @Element(data = true, required = false)
+ private int port;
+
+ @Column(name = "protocol", nullable = true)
+ @Element(data = true, required = false)
+ private String protocol;
+
+ @Column(name = "webapp", nullable = true)
+ @Element(data = true, required = false)
+ private String webapp;
+
+ @Column(name = "login", nullable = true)
+ @Element(data = true, required = false)
+ private String user;
+
+ @Column(name = "pass", nullable = true)
+ @Element(data = true, required = false)
+ private String pass;
+
+ @Column(name = "active", nullable = false)
+ @Element(data = true, required = false)
+ private boolean active;
+
+ @Column(name = "deleted", nullable = false)
+ @Element(data = true)
+ private boolean deleted = false;
+
+ @Override
+ public Long getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public boolean isDeleted() {
+ return deleted;
+ }
+
+ public void setDeleted(boolean deleted) {
+ this.deleted = deleted;
+ }
+
+ public Date getInserted() {
+ return inserted;
+ }
+
+ public void setInserted(Date inserted) {
+ this.inserted = inserted;
+ }
+
+ public Date getUpdated() {
+ return updated;
+ }
+
+ public void setUpdated(Date updated) {
+ this.updated = updated;
+ }
+
+ public User getInsertedby() {
+ return insertedby;
+ }
+
+ public void setInsertedby(User insertedby) {
+ this.insertedby = insertedby;
+ }
+
+ public User getUpdatedby() {
+ return updatedby;
+ }
+
+ public void setUpdatedby(User updatedby) {
+ this.updatedby = updatedby;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ public Calendar getLastPing() {
+ return lastPing;
+ }
+
+ public void setLastPing(Calendar lastPing) {
+ this.lastPing = lastPing;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public String getWebapp() {
+ return webapp;
+ }
+
+ public void setWebapp(String webapp) {
+ this.webapp = webapp;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public String getPass() {
+ return pass;
+ }
+
+ public void setPass(String pass) {
+ this.pass = pass;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public boolean isActive() {
+ return active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ @Override
+ public String toString() {
+ return "Server [id=" + id + ", name=" + name + ", address=" + address
+ + ", port=" + port + ", user=" + user + ", pass=" + pass
+ + ", protocol=" + protocol
+ + ", active=" + active + ", webapp=" + webapp + ", deleted="
+ + deleted + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((address == null) ? 0 : address.hashCode());
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Server other = (Server) obj;
+ if (address == null) {
+ if (other.address != null)
+ return false;
+ } else if (!address.equals(other.address))
+ return false;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+}