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 2015/11/06 07:18:49 UTC

svn commit: r1712911 [14/16] - in /openmeetings/branches/3.1.x: openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/ openmeetings-core/src/main/java/org/apache/openmeetings/core/data/conference/ openmeetings-core/src/main/java/org/ap...

Modified: openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/FileWebService.java
URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/FileWebService.java?rev=1712911&r1=1712910&r2=1712911&view=diff
==============================================================================
--- openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/FileWebService.java (original)
+++ openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/FileWebService.java Fri Nov  6 06:18:44 2015
@@ -26,7 +26,14 @@ import java.io.InputStream;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.LinkedHashMap;
+import java.util.List;
 
+import javax.jws.WebService;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.cxf.feature.Features;
 import org.apache.openmeetings.core.data.file.FileProcessor;
 import org.apache.openmeetings.core.data.file.FileUtils;
 import org.apache.openmeetings.core.documents.LoadLibraryPresentation;
@@ -56,7 +63,12 @@ import org.springframework.beans.factory
  * @webservice FileService
  * 
  */
+@WebService(serviceName="org.apache.openmeetings.webservice.FileWebService")
+@Features(features = "org.apache.cxf.feature.LoggingFeature")
+@Produces({MediaType.APPLICATION_JSON})
+@Path("/file")
 public class FileWebService {
+
 	private static final Logger log = Red5LoggerFactory.getLogger(FileWebService.class, webAppRootKey);
 	@Autowired
 	private SessiondataDao sessiondataDao;
@@ -73,76 +85,65 @@ public class FileWebService {
 	 * 
 	 * Import file from external source
 	 * 
-	 * to upload a file to a room-drive you specify: externalUserId, user if of
-	 * openmeetings user for which we upload the file room_id = openmeetings
-	 * room id isOwner = 0 parentFolderId = 0
-	 * 
-	 * to upload a file to a private-drive you specify: externalUserId, user if
-	 * of openmeetings user for which we upload the file room_id = openmeetings
-	 * room id isOwner = 1 parentFolderId = -2
+	 * to upload a file to a room-drive you specify: externalUserId, user if of openmeetings user for which we upload
+	 * the file roomId = openmeetings room id isOwner = 0 parentFolderId = 0
 	 * 
-	 * @param SID The logged in session id with minimum webservice level
+	 * to upload a file to a private-drive you specify: externalUserId, user if of openmeetings user for which we upload
+	 * the file roomId = openmeetings room id isOwner = 1 parentFolderId = -2
+	 * 
+	 * @param SID
+	 *            The logged in session id with minimum webservice level
 	 * @param externalUserId
-	 *            the external user id => If the file should goto a private
-	 *            section of any user, this number needs to be set
+	 *            the external user id => If the file should goto a private section of any user, this number needs to
+	 *            be set
 	 * @param externalFileId
 	 *            the external file-type to identify the file later
 	 * @param externalType
 	 *            the name of the external system
-	 * @param room_id
-	 *            the room Id, if the file goes to the private folder of an
-	 *            user, you can set a random number here
+	 * @param roomId
+	 *            the room Id, if the file goes to the private folder of an user, you can set a random number here
 	 * @param isOwner
-	 *            specify a 1/true AND parentFolderId==-2 to make the file goto
-	 *            the private section
+	 *            specify a 1/true AND parentFolderId==-2 to make the file goto the private section
 	 * @param path
-	 *            http-path where we can grab the file from, the file has to be
-	 *            accessible from the OpenMeetings server
+	 *            http-path where we can grab the file from, the file has to be accessible from the OpenMeetings server
 	 * @param parentFolderId
-	 *            specify a parentFolderId==-2 AND isOwner == 1/true AND to make
-	 *            the file goto the private section
+	 *            specify a parentFolderId==-2 AND isOwner == 1/true AND to make the file goto the private section
 	 * @param fileSystemName
 	 *            the filename => Important WITH file extension!
-	 *            
+	 * 
 	 * @return - array of file import errors
 	 * @throws ServiceException
 	 */
-	public FileImportError[] importFile(String SID, String externalUserId,
-			Long externalFileId, String externalType, Long room_id,
-			boolean isOwner, String path, Long parentFolderId,
-			String fileSystemName) throws ServiceException {
+	public FileImportError[] importFile(String SID, String externalUserId, Long externalFileId, String externalType,
+			Long roomId, boolean isOwner, String path, Long parentFolderId, String fileSystemName)
+			throws ServiceException {
 		try {
 
-			Long users_id = sessiondataDao.checkSession(SID);
+			Long userId = sessiondataDao.checkSession(SID);
 
-			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(users_id))) {
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
 
 				URL url = new URL(path);
 				URLConnection uc = url.openConnection();
-				InputStream inputstream = new BufferedInputStream(
-						uc.getInputStream());
+				InputStream inputstream = new BufferedInputStream(uc.getInputStream());
 
 				User externalUser = userDao.getExternalUser(externalUserId, externalType);
 
 				LinkedHashMap<String, Object> hs = new LinkedHashMap<String, Object>();
 				hs.put("user", externalUser);
 
-				ConverterProcessResultList returnError = fileProcessor
-						.processFile(externalUser.getUser_id(), room_id,
-								isOwner, inputstream, parentFolderId,
-								fileSystemName,
-								externalFileId, externalType);
+				ConverterProcessResultList returnError = fileProcessor.processFile(externalUser.getId(), roomId,
+						isOwner, inputstream, parentFolderId, fileSystemName, externalFileId, externalType);
 
 				// Flash cannot read the response of an upload
 				// httpServletResponse.getWriter().print(returnError);
 				hs.put("message", "library");
 				hs.put("action", "newFile");
-				hs.put("fileExplorerItem", fileExplorerItemDao
-						.getFileExplorerItemsById(returnError.getFileExplorerItemId()));
+				hs.put("fileExplorerItem", fileExplorerItemDao.get(returnError.getFileExplorerItemId()));
 				hs.put("error", returnError.getLogMessage());
 				hs.put("fileName", returnError.getCompleteName());
-				
-				//FIXME: Send event to UI that there is a new file
+
+				// FIXME: Send event to UI that there is a new file
 
 				return returnError.convertToFileImportErrors();
 
@@ -156,77 +157,65 @@ public class FileWebService {
 	/**
 	 * Import file from external source
 	 * 
-	 * to upload a file to a room-drive you specify: internalUserId, user if of
-	 * openmeetings user for which we upload the file room_id = openmeetings
-	 * room id isOwner = 0 parentFolderId = 0
-	 * 
-	 * to upload a file to a private-drive you specify: internalUserId, user if
-	 * of openmeetings user for which we upload the file room_id = openmeetings
-	 * room id isOwner = 1 parentFolderId = -2
+	 * to upload a file to a room-drive you specify: internalUserId, user if of openmeetings user for which we upload
+	 * the file roomId = openmeetings room id isOwner = 0 parentFolderId = 0
+	 * 
+	 * to upload a file to a private-drive you specify: internalUserId, user if of openmeetings user for which we upload
+	 * the file roomId = openmeetings room id isOwner = 1 parentFolderId = -2
 	 * 
 	 * @param SID
 	 *            The SID of the User. This SID must be marked as logged in
 	 * @param internalUserId
-	 *            the openmeetings user id =&gt; If the file should goto a private
-	 *            section of any user, this number needs to be se
+	 *            the openmeetings user id =&gt; If the file should goto a private section of any user, this number
+	 *            needs to be se
 	 * @param externalFileId
 	 *            the external file-type to identify the file later
 	 * @param externalType
 	 *            the name of the external system
-	 * @param room_id
-	 *            the room Id, if the file goes to the private folder of an
-	 *            user, you can set a random number here
+	 * @param roomId
+	 *            the room Id, if the file goes to the private folder of an user, you can set a random number here
 	 * @param isOwner
-	 *            specify a 1/true AND parentFolderId==-2 to make the file goto
-	 *            the private section
+	 *            specify a 1/true AND parentFolderId==-2 to make the file goto the private section
 	 * @param path
-	 *            http-path where we can grab the file from, the file has to be
-	 *            accessible from the OpenMeetings server
+	 *            http-path where we can grab the file from, the file has to be accessible from the OpenMeetings server
 	 * @param parentFolderId
-	 *            specify a parentFolderId==-2 AND isOwner == 1/true AND to make
-	 *            the file goto the private section
+	 *            specify a parentFolderId==-2 AND isOwner == 1/true AND to make the file goto the private section
 	 * @param fileSystemName
 	 *            the filename =&gt; Important WITH file extension!
-	 *            
+	 * 
 	 * @return - array of file import errors
 	 * @throws ServiceException
 	 */
-	public FileImportError[] importFileByInternalUserId(String SID,
-			Long internalUserId, Long externalFileId, String externalType,
-			Long room_id, boolean isOwner, String path, Long parentFolderId,
-			String fileSystemName) throws ServiceException {
+	public FileImportError[] importFileByInternalUserId(String SID, Long internalUserId, Long externalFileId,
+			String externalType, Long roomId, boolean isOwner, String path, Long parentFolderId, String fileSystemName)
+			throws ServiceException {
 		try {
 
-			Long users_id = sessiondataDao.checkSession(SID);
+			Long userId = sessiondataDao.checkSession(SID);
 
-			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(users_id))) {
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
 
 				URL url = new URL(path);
 				URLConnection uc = url.openConnection();
-				InputStream inputstream = new BufferedInputStream(
-						uc.getInputStream());
+				InputStream inputstream = new BufferedInputStream(uc.getInputStream());
 
 				User internalUser = userDao.get(internalUserId);
 
 				LinkedHashMap<String, Object> hs = new LinkedHashMap<String, Object>();
 				hs.put("user", internalUser);
 
-				ConverterProcessResultList returnError = fileProcessor
-						.processFile(internalUser.getUser_id(), room_id,
-								isOwner, inputstream, parentFolderId,
-								fileSystemName, 
-								externalFileId, externalType);
+				ConverterProcessResultList returnError = fileProcessor.processFile(internalUser.getId(), roomId,
+						isOwner, inputstream, parentFolderId, fileSystemName, externalFileId, externalType);
 
 				// Flash cannot read the response of an upload
 				// httpServletResponse.getWriter().print(returnError);
 				hs.put("message", "library");
 				hs.put("action", "newFile");
-				hs.put("fileExplorerItem", fileExplorerItemDao
-						.getFileExplorerItemsById(returnError.getFileExplorerItemId()));
+				hs.put("fileExplorerItem", fileExplorerItemDao.get(returnError.getFileExplorerItemId()));
 				hs.put("error", returnError);
 				hs.put("fileName", returnError.getCompleteName());
-				
-				//FIXME: Notificate UI of clients of new file
+
+				// FIXME: Notificate UI of clients of new file
 
 				return returnError.convertToFileImportErrors();
 
@@ -238,54 +227,49 @@ public class FileWebService {
 	}
 
 	/**
-	 * to add a folder to the private drive, set parentFileExplorerItemId = 0
-	 * and isOwner to 1/true and externalUserId/externalUserType to a valid user
+	 * to add a folder to the private drive, set parentFileExplorerItemId = 0 and isOwner to 1/true and
+	 * externalUserId/externalUserType to a valid user
 	 * 
 	 * @param SID
 	 *            The SID of the User. This SID must be marked as logged in
 	 * @param externalUserId
 	 *            the external file-type to identify the file later
-	 * @param parentFileExplorerItemId
+	 * @param parentId
 	 * @param folderName
 	 *            the name of the folder
-	 * @param room_id
-	 *            the room Id, if the file goes to the private folder of an
-	 *            user, you can set a random number here
+	 * @param roomId
+	 *            the room Id, if the file goes to the private folder of an user, you can set a random number here
 	 * @param isOwner
-	 *            specify a 1/true AND parentFolderId==-2 to make the file goto
-	 *            the private section
+	 *            specify a 1/true AND parentFolderId==-2 to make the file goto the private section
 	 * @param externalFilesid
 	 *            the external file-type to identify the file later
 	 * @param externalType
 	 *            the name of the external system
-	 *            
+	 * 
 	 * @return - id of folder added
 	 * @throws ServiceException
 	 */
-	public Long addFolderByExternalUserIdAndType(String SID,
-			String externalUserId, Long parentFileExplorerItemId,
-			String folderName, Long room_id, Boolean isOwner,
-			Long externalFilesid, String externalType) throws ServiceException {
+	public Long addFolderByExternalUserIdAndType(String SID, String externalUserId, Long parentId, String folderName,
+			Long roomId, Boolean isOwner, Long externalFilesid, String externalType) throws ServiceException {
 		try {
 
-			Long users_id = sessiondataDao.checkSession(SID);
+			Long authUserId = sessiondataDao.checkSession(SID);
 
-			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(users_id))) {
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(authUserId))) {
 
 				User userExternal = userDao.getExternalUser(externalUserId, externalType);
 
-				Long userId = userExternal.getUser_id();
+				Long userId = userExternal.getId();
 
-				log.debug("addFolder " + parentFileExplorerItemId);
+				log.debug("addFolder " + parentId);
 
-				if (parentFileExplorerItemId == -2 && isOwner) {
-					// users_id (OwnerID) => only set if its directly root in
+				if (parentId == -2 && isOwner) {
+					// userId (OwnerID) => only set if its directly root in
 					// Owner Directory,
 					// other Folders and Files maybe are also in a Home
 					// directory
 					// but just because their parent is
-					return fileExplorerItemDao.add(folderName, "", 0L, userId,
-							room_id, userId, true, // isFolder
+					return fileExplorerItemDao.add(folderName, "", 0L, userId, roomId, userId, true, // isFolder
 							false, // isImage
 							false, // isPresentation
 							"", // WML Path
@@ -293,9 +277,7 @@ public class FileWebService {
 							false, // isXmlFile
 							externalFilesid, externalType);
 				} else {
-					return fileExplorerItemDao.add(folderName, "",
-							parentFileExplorerItemId, null, room_id, userId,
-							true, // isFolder
+					return fileExplorerItemDao.add(folderName, "", parentId, null, roomId, userId, true, // isFolder
 							false, // isImage
 							false, // isPresentation
 							"", // WML Path
@@ -312,41 +294,46 @@ public class FileWebService {
 	}
 
 	/**
-	 * to add a folder to the private drive, set parentFileExplorerItemId = 0
-	 * and isOwner to 1/true and userId to a valid user
+	 * to add a folder to the private drive, set parentFileExplorerItemId = 0 and isOwner to 1/true and userId to a
+	 * valid user
+	 * 
+	 * @param SID
+	 *            The SID of the User. This SID must be marked as logged in
+	 * @param userId
+	 *            the openmeetings user id
+	 * @param parentId
+	 *            specify a parentFolderId==-2 AND isOwner == 1/true AND to make the file goto the private section
+	 * @param folderName
+	 *            the name of the folder
+	 * @param roomId
+	 *            the room Id, if the file goes to the private folder of an user, you can set a random number here
+	 * @param isOwner
+	 *            specify a 1/true AND parentFolderId==-2 to make the file goto the private section
+	 * @param externalFilesid
+	 *            the external file-type to identify the file later
+	 * @param externalType
+	 *            the name of the external system
 	 * 
-	 * @param SID The SID of the User. This SID must be marked as logged in
-	 * @param userId the openmeetings user id 
-	 * @param parentFileExplorerItemId specify a parentFolderId==-2 AND isOwner == 1/true AND to make the file goto the private section  
-	 * @param folderName the name of the folder 
-	 * @param room_id the room Id, if the file goes to the private folder of an user, you can set a random number here 
-	 * @param isOwner specify a 1/true AND parentFolderId==-2 to make the file goto the private section 
-	 * @param externalFilesid the external file-type to identify the file later 
-	 * @param externalType the name of the external system
-	 *  
 	 * @return - id of the folder
 	 * @throws ServiceException
 	 */
-	public Long addFolderByUserId(String SID, Long userId,
-			Long parentFileExplorerItemId, String folderName, Long room_id,
-			Boolean isOwner, Long externalFilesid, String externalType)
-			throws ServiceException {
+	public Long addFolderByUserId(String SID, Long userId, Long parentId, String folderName, Long roomId,
+			Boolean isOwner, Long externalFilesid, String externalType) throws ServiceException {
 		try {
 
-			Long users_id = sessiondataDao.checkSession(SID);
+			Long authUserId = sessiondataDao.checkSession(SID);
 
-			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(users_id))) {
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(authUserId))) {
 
-				log.debug("addFolder " + parentFileExplorerItemId);
+				log.debug("addFolder " + parentId);
 
-				if (parentFileExplorerItemId == -2 && isOwner) {
+				if (parentId == -2 && isOwner) {
 					// users_id (OwnerID) => only set if its directly root in
 					// Owner Directory,
 					// other Folders and Files maybe are also in a Home
 					// directory
 					// but just because their parent is
-					return fileExplorerItemDao.add(folderName, "", 0L, userId,
-							room_id, userId, true, // isFolder
+					return fileExplorerItemDao.add(folderName, "", 0L, userId, roomId, userId, true, // isFolder
 							false, // isImage
 							false, // isPresentation
 							"", // WML Path
@@ -354,9 +341,7 @@ public class FileWebService {
 							false, // isXmlFile
 							externalFilesid, externalType);
 				} else {
-					return fileExplorerItemDao.add(folderName, "",
-							parentFileExplorerItemId, null, room_id, userId,
-							true, // isFolder
+					return fileExplorerItemDao.add(folderName, "", parentId, null, roomId, userId, true, // isFolder
 							false, // isImage
 							false, // isPresentation
 							"", // WML Path
@@ -378,32 +363,30 @@ public class FileWebService {
 	 * 
 	 * @param SID
 	 *            The SID of the User. This SID must be marked as logged in
-	 * @param parentFileExplorerItemId
+	 * @param parentId
 	 *            parent folder id
 	 * @param fileName
 	 *            the file name
-	 * @param room_id
+	 * @param roomId
 	 *            the room id
 	 * @param isOwner
 	 * @return - id of the folder
 	 */
-	public Long addFolderSelf(String SID, Long parentFileExplorerItemId,
-			String fileName, Long room_id, Boolean isOwner) throws ServiceException {
+	public Long addFolderSelf(String SID, Long parentId, String fileName, Long roomId, Boolean isOwner)
+			throws ServiceException {
 		try {
-			Long users_id = sessiondataDao.checkSession(SID);
-			if (AuthLevelUtil.hasUserLevel(userDao.getRights(users_id))) {
+			Long userId = sessiondataDao.checkSession(SID);
+			if (AuthLevelUtil.hasUserLevel(userDao.getRights(userId))) {
 
-				log.debug("addFolder " + parentFileExplorerItemId);
+				log.debug("addFolder " + parentId);
 
-				if (parentFileExplorerItemId == 0 && isOwner) {
+				if (parentId == 0 && isOwner) {
 					// users_id (OwnerID) => only set if its directly root in
 					// Owner Directory,
 					// other Folders and Files maybe are also in a Home
 					// directory
 					// but just because their parent is
-					return fileExplorerItemDao.add(fileName, "",
-							parentFileExplorerItemId, users_id, room_id,
-							users_id, true, // isFolder
+					return fileExplorerItemDao.add(fileName, "", parentId, userId, roomId, userId, true, // isFolder
 							false, // isImage
 							false, // isPresentation
 							"", // WML Path
@@ -411,9 +394,7 @@ public class FileWebService {
 							false // isXmlFile
 							, 0L, "");
 				} else {
-					return fileExplorerItemDao.add(fileName, "",
-							parentFileExplorerItemId, null, room_id, users_id,
-							true, // isFolder
+					return fileExplorerItemDao.add(fileName, "", parentId, null, roomId, userId, true, // isFolder
 							false, // isImage
 							false, // isPresentation
 							"", // WML Paht
@@ -440,17 +421,16 @@ public class FileWebService {
 	 *            the externalType
 	 * @return - null
 	 */
-	public Long deleteFileOrFolderByExternalIdAndType(String SID,
-			Long externalFilesid, String externalType) throws ServiceException {
+	public Long deleteFileOrFolderByExternalIdAndType(String SID, Long externalFilesid, String externalType)
+			throws ServiceException {
 
 		try {
 
-			Long users_id = sessiondataDao.checkSession(SID);
+			Long userId = sessiondataDao.checkSession(SID);
 
-			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(users_id))) {
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
 
-				fileExplorerItemDao.deleteFileExplorerItemByExternalIdAndType(
-						externalFilesid, externalType);
+				fileExplorerItemDao.deleteFileExplorerItemByExternalIdAndType(externalFilesid, externalType);
 
 			}
 
@@ -466,20 +446,19 @@ public class FileWebService {
 	 * 
 	 * @param SID
 	 *            The SID of the User. This SID must be marked as logged in
-	 * @param fileExplorerItemId
+	 * @param fileId
 	 *            the id of the file or folder
 	 * @return - null
 	 */
-	public Long deleteFileOrFolder(String SID, Long fileExplorerItemId)
-			throws ServiceException {
+	public Long deleteFileOrFolder(String SID, Long fileId) throws ServiceException {
 
 		try {
 
-			Long users_id = sessiondataDao.checkSession(SID);
+			Long userId = sessiondataDao.checkSession(SID);
 
-			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(users_id))) {
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
 
-				fileExplorerItemDao.deleteFileExplorerItem(fileExplorerItemId);
+				fileExplorerItemDao.delete(fileId);
 
 			}
 
@@ -495,22 +474,21 @@ public class FileWebService {
 	 * 
 	 * @param SID
 	 *            The SID of the User. This SID must be marked as logged in
-	 * @param fileExplorerItemId
+	 * @param fileId
 	 *            the id of the file or folder
 	 * @return - null
 	 */
-	public Long deleteFileOrFolderSelf(String SID, Long fileExplorerItemId)
-			throws ServiceException {
+	public Long deleteFileOrFolderSelf(String SID, Long fileId) throws ServiceException {
 
 		try {
 
-			Long users_id = sessiondataDao.checkSession(SID);
+			Long userId = sessiondataDao.checkSession(SID);
 
-			if (AuthLevelUtil.hasUserLevel(userDao.getRights(users_id))) {
+			if (AuthLevelUtil.hasUserLevel(userDao.getRights(userId))) {
 
 				// TODO: Check if user has access or not to the file
 
-				fileExplorerItemDao.deleteFileExplorerItem(fileExplorerItemId);
+				fileExplorerItemDao.delete(fileId);
 
 			}
 
@@ -546,14 +524,14 @@ public class FileWebService {
 	 * @return - LibraryPresentation-Object for a certain file
 	 * @throws ServiceException
 	 */
-	public LibraryPresentation getPresentationPreviewFileExplorer(String SID,
-			String parentFolder) throws ServiceException {
+	public LibraryPresentation getPresentationPreviewFileExplorer(String SID, String parentFolder)
+			throws ServiceException {
 
 		try {
 
-			Long users_id = sessiondataDao.checkSession(SID);
+			Long userId = sessiondataDao.checkSession(SID);
 
-			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(users_id))) {
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
 
 				File working_dir = new File(OmFileHelper.getUploadProfilesDir(), parentFolder);
 				log.debug("############# working_dir : " + working_dir);
@@ -584,53 +562,46 @@ public class FileWebService {
 	 * 
 	 * @param SID
 	 *            The SID of the User. This SID must be marked as logged in
-	 * @param room_id
+	 * @param roomId
 	 *            Room id
-	 * @param owner_id
+	 * @param ownerId
 	 *            Owner id
 	 * @return - File Explorer Object by a given Room and owner id
 	 * @throws ServiceException
 	 */
-	public FileExplorerObject getFileExplorerByRoom(String SID, Long room_id,
-			Long owner_id) throws ServiceException {
+	public FileExplorerObject getFileExplorerByRoom(String SID, Long roomId, Long ownerId) throws ServiceException {
 
 		try {
 
-			Long webservice_users_id = sessiondataDao.checkSession(SID);
+			Long userId = sessiondataDao.checkSession(SID);
 
-			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(webservice_users_id))) {
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
 
-				log.debug("room_id " + room_id);
+				log.debug("roomId " + roomId);
 
 				FileExplorerObject fileExplorerObject = new FileExplorerObject();
 
 				// Home File List
-				FileExplorerItem[] fList = fileExplorerItemDao
-						.getFileExplorerItemsByOwner(owner_id, 0L);
+				List<FileExplorerItem> fList = fileExplorerItemDao.getByOwner(ownerId);
 
 				long homeFileSize = 0;
 
 				for (FileExplorerItem homeChildExplorerItem : fList) {
-					log.debug("FileExplorerItem fList "
-							+ homeChildExplorerItem.getFileName());
-					homeFileSize += fileUtils
-							.getSizeOfDirectoryAndSubs(homeChildExplorerItem);
+					log.debug("FileExplorerItem fList " + homeChildExplorerItem.getFileName());
+					homeFileSize += fileUtils.getSizeOfDirectoryAndSubs(homeChildExplorerItem);
 				}
 
 				fileExplorerObject.setUserHome(fList);
 				fileExplorerObject.setUserHomeSize(homeFileSize);
 
 				// Public File List
-				FileExplorerItem[] rList = fileExplorerItemDao
-						.getFileExplorerItemsByRoom(room_id, 0L);
+				List<FileExplorerItem> rList = fileExplorerItemDao.getByRoom(roomId);
 
 				long roomFileSize = 0;
 
 				for (FileExplorerItem homeChildExplorerItem : rList) {
-					log.debug("FileExplorerItem rList "
-							+ homeChildExplorerItem.getFileName());
-					roomFileSize += fileUtils
-							.getSizeOfDirectoryAndSubs(homeChildExplorerItem);
+					log.debug("FileExplorerItem rList " + homeChildExplorerItem.getFileName());
+					roomFileSize += fileUtils.getSizeOfDirectoryAndSubs(homeChildExplorerItem);
 				}
 
 				fileExplorerObject.setRoomHome(rList);
@@ -655,51 +626,44 @@ public class FileWebService {
 	 * 
 	 * @param SID
 	 *            The SID of the User. This SID must be marked as logged in
-	 * @param room_id
+	 * @param roomId
 	 *            Room Id
 	 * @return - File Explorer Object by a given Room
 	 * @throws ServiceException
 	 */
-	public FileExplorerObject getFileExplorerByRoomSelf(String SID, Long room_id)
-			throws ServiceException {
+	public FileExplorerObject getFileExplorerByRoomSelf(String SID, Long roomId) throws ServiceException {
 
 		try {
 
-			Long users_id = sessiondataDao.checkSession(SID);
+			Long userId = sessiondataDao.checkSession(SID);
 
-			if (AuthLevelUtil.hasUserLevel(userDao.getRights(users_id))) {
+			if (AuthLevelUtil.hasUserLevel(userDao.getRights(userId))) {
 
-				log.debug("room_id " + room_id);
+				log.debug("roomId " + roomId);
 
 				FileExplorerObject fileExplorerObject = new FileExplorerObject();
 
 				// Home File List
-				FileExplorerItem[] fList = fileExplorerItemDao
-						.getFileExplorerItemsByOwner(users_id, 0L);
+				List<FileExplorerItem> fList = fileExplorerItemDao.getByOwner(userId);
 
 				long homeFileSize = 0;
 
 				for (FileExplorerItem homeChildExplorerItem : fList) {
-					log.debug("FileExplorerItem fList "
-							+ homeChildExplorerItem.getFileName());
-					homeFileSize += fileUtils
-							.getSizeOfDirectoryAndSubs(homeChildExplorerItem);
+					log.debug("FileExplorerItem fList " + homeChildExplorerItem.getFileName());
+					homeFileSize += fileUtils.getSizeOfDirectoryAndSubs(homeChildExplorerItem);
 				}
 
 				fileExplorerObject.setUserHome(fList);
 				fileExplorerObject.setUserHomeSize(homeFileSize);
 
 				// Public File List
-				FileExplorerItem[] rList = fileExplorerItemDao
-						.getFileExplorerItemsByRoom(room_id, 0L);
+				List<FileExplorerItem> rList = fileExplorerItemDao.getByRoom(roomId);
 
 				long roomFileSize = 0;
 
 				for (FileExplorerItem homeChildExplorerItem : rList) {
-					log.debug("FileExplorerItem rList "
-							+ homeChildExplorerItem.getFileName());
-					roomFileSize += fileUtils
-							.getSizeOfDirectoryAndSubs(homeChildExplorerItem);
+					log.debug("FileExplorerItem rList " + homeChildExplorerItem.getFileName());
+					roomFileSize += fileUtils.getSizeOfDirectoryAndSubs(homeChildExplorerItem);
 				}
 
 				fileExplorerObject.setRoomHome(rList);
@@ -724,41 +688,36 @@ public class FileWebService {
 	 * 
 	 * @param SID
 	 *            The SID of the User. This SID must be marked as logged in
-	 * @param parentFileExplorerItemId
+	 * @param parentId
 	 *            the parent folder id
-	 * @param room_id
+	 * @param roomId
 	 *            the room id
 	 * @param isOwner
 	 *            true if its a private drive
-	 * @param owner_id
+	 * @param ownerId
 	 *            the owner id
 	 * @return - FileExplorerItem list by parent folder
 	 * @throws ServiceException
 	 */
-	public FileExplorerItem[] getFileExplorerByParent(String SID,
-			Long parentFileExplorerItemId, Long room_id, Boolean isOwner,
-			Long owner_id) throws ServiceException {
+	public FileExplorerItem[] getFileExplorerByParent(String SID, Long parentId, Long roomId, Boolean isOwner,
+			Long ownerId) throws ServiceException {
 
 		try {
 
-			Long webservice_users_id = sessiondataDao.checkSession(SID);
+			Long userId = sessiondataDao.checkSession(SID);
 
-			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(webservice_users_id))) {
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
 
-				log.debug("parentFileExplorerItemId "
-						+ parentFileExplorerItemId);
+				log.debug("parentFileExplorerItemId " + parentId);
 
-				if (parentFileExplorerItemId == 0) {
+				if (parentId == 0) {
 					if (isOwner) {
-						return fileExplorerItemDao.getFileExplorerItemsByOwner(
-								owner_id, parentFileExplorerItemId);
+						return fileExplorerItemDao.getByOwner(ownerId).toArray(new FileExplorerItem[0]);
 					} else {
-						return fileExplorerItemDao.getFileExplorerItemsByRoom(
-								room_id, parentFileExplorerItemId);
+						return fileExplorerItemDao.getByRoom(roomId).toArray(new FileExplorerItem[0]);
 					}
 				} else {
-					return fileExplorerItemDao
-							.getFileExplorerItemsByParent(parentFileExplorerItemId);
+					return fileExplorerItemDao.getByParent(parentId).toArray(new FileExplorerItem[0]);
 				}
 
 			}
@@ -774,41 +733,35 @@ public class FileWebService {
 	 * 
 	 * @param SID
 	 *            SID The SID of the User. This SID must be marked as logged in
-	 * @param parentFileExplorerItemId
+	 * @param parentId
 	 *            the parent folder id
-	 * @param room_id
+	 * @param roomId
 	 *            the room id
 	 * @param isOwner
 	 *            true to request private drive
 	 * @return - list of file explorer items
 	 * @throws ServiceException
 	 */
-	public FileExplorerItem[] getFileExplorerByParentSelf(String SID,
-			Long parentFileExplorerItemId, Long room_id, Boolean isOwner)
+	public FileExplorerItem[] getFileExplorerByParentSelf(String SID, Long parentId, Long roomId, Boolean isOwner)
 			throws ServiceException {
 
 		try {
 
-			Long users_id = sessiondataDao.checkSession(SID);
+			Long userId = sessiondataDao.checkSession(SID);
 
-			if (AuthLevelUtil.hasUserLevel(userDao.getRights(users_id))) {
+			if (AuthLevelUtil.hasUserLevel(userDao.getRights(userId))) {
 
-				log.debug("parentFileExplorerItemId "
-						+ parentFileExplorerItemId);
+				log.debug("parentFileExplorerItemId " + parentId);
 
-				if (parentFileExplorerItemId == 0) {
+				if (parentId == 0) {
 					if (isOwner) {
-						return fileExplorerItemDao.getFileExplorerItemsByOwner(
-								users_id, parentFileExplorerItemId);
+						return fileExplorerItemDao.getByOwner(userId).toArray(new FileExplorerItem[0]);
 					} else {
-						return fileExplorerItemDao.getFileExplorerItemsByRoom(
-								room_id, parentFileExplorerItemId);
+						return fileExplorerItemDao.getByRoom(roomId).toArray(new FileExplorerItem[0]);
 					}
 				} else {
-					return fileExplorerItemDao
-							.getFileExplorerItemsByParent(parentFileExplorerItemId);
+					return fileExplorerItemDao.getByParent(parentId).toArray(new FileExplorerItem[0]);
 				}
-
 			}
 		} catch (Exception err) {
 			log.error("[getFileExplorerByParentSelf] ", err);
@@ -821,26 +774,24 @@ public class FileWebService {
 	 * 
 	 * @param SID
 	 *            SID The SID of the User. This SID must be marked as logged in
-	 * @param fileExplorerItemId
+	 * @param fileId
 	 *            file or folder id
 	 * @param fileName
 	 *            new file or folder name
 	 * @return - null
 	 * @throws ServiceException
 	 */
-	public Long updateFileOrFolderName(String SID, Long fileExplorerItemId,
-			String fileName) throws ServiceException {
+	public Long updateFileOrFolderName(String SID, Long fileId, String fileName) throws ServiceException {
 
 		try {
 
-			Long webservice_users_id = sessiondataDao.checkSession(SID);
+			Long userId = sessiondataDao.checkSession(SID);
 
-			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(webservice_users_id))) {
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
 
-				log.debug("deleteFileOrFolder " + fileExplorerItemId);
+				log.debug("deleteFileOrFolder " + fileId);
 
-				fileExplorerItemDao.updateFileOrFolderName(fileExplorerItemId,
-						fileName);
+				fileExplorerItemDao.updateFileOrFolderName(fileId, fileName);
 
 			}
 		} catch (Exception err) {
@@ -855,39 +806,32 @@ public class FileWebService {
 	 * 
 	 * @param SID
 	 *            SID The SID of the User. This SID must be marked as logged in
-	 * @param fileExplorerItemId
+	 * @param fileId
 	 *            file or folder id
 	 * @param fileName
 	 *            new file or folder name
 	 * @return - null
 	 * @throws ServiceException
 	 */
-	public Long updateFileOrFolderNameSelf(String SID, Long fileExplorerItemId,
-			String fileName) throws ServiceException {
+	public Long updateFileOrFolderNameSelf(String SID, Long fileId, String fileName) throws ServiceException {
 
 		try {
 
-			Long users_id = sessiondataDao.checkSession(SID);
+			Long userId = sessiondataDao.checkSession(SID);
 
-			if (AuthLevelUtil.hasUserLevel(userDao.getRights(users_id))) {
+			if (AuthLevelUtil.hasUserLevel(userDao.getRights(userId))) {
 
 				// TODO: check if this user is allowed to change this file
 				/*
-				 * FileExplorerItem fileExItem =
-				 * fileExplorerItemDao.getFileExplorerItemsById
-				 * (fileExplorerItemId);
+				 * FileExplorerItem fileExItem = fileExplorerItemDao.getFileExplorerItemsById (fileExplorerItemId);
 				 * 
-				 * if (fileExItem.getOwnerId() != null &&
-				 * !fileExItem.getOwnerId().equals(users_id)) { throw new
-				 * Exception(
-				 * "This user is not the owner of the file and not allowed to edit its name"
-				 * ); }
+				 * if (fileExItem.getOwnerId() != null && !fileExItem.getOwnerId().equals(users_id)) { throw new
+				 * Exception( "This user is not the owner of the file and not allowed to edit its name" ); }
 				 */
 
-				log.debug("deleteFileOrFolder " + fileExplorerItemId);
+				log.debug("deleteFileOrFolder " + fileId);
 
-				fileExplorerItemDao.updateFileOrFolderName(fileExplorerItemId,
-						fileName);
+				fileExplorerItemDao.updateFileOrFolderName(fileId, fileName);
 
 			}
 		} catch (Exception err) {
@@ -901,50 +845,43 @@ public class FileWebService {
 	 * 
 	 * @param SID
 	 *            SID The SID of the User. This SID must be marked as logged in
-	 * @param fileExplorerItemId
+	 * @param fileId
 	 *            current file or folder id to be moved
-	 * @param newParentFileExplorerItemId
+	 * @param newParentId
 	 *            new parent folder id
-	 * @param room_id
+	 * @param roomId
 	 *            room id
 	 * @param isOwner
 	 *            if true owner id will be set
 	 * @param moveToHome
 	 *            if true move to private drive
-	 * @param owner_id
+	 * @param ownerId
 	 *            owner id
 	 * @return - null
 	 * @throws ServiceException
 	 */
-	public Long moveFile(String SID, Long fileExplorerItemId,
-			Long newParentFileExplorerItemId, Long room_id, Boolean isOwner,
-			Boolean moveToHome, Long owner_id) throws ServiceException {
+	public Long moveFile(String SID, Long fileId, Long newParentId, Long roomId, Boolean isOwner, Boolean moveToHome,
+			Long ownerId) throws ServiceException {
 
 		try {
 
-			Long webservice_users_id = sessiondataDao.checkSession(SID);
+			Long userId = sessiondataDao.checkSession(SID);
 
-			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(webservice_users_id))) {
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
 
-				log.debug("deleteFileOrFolder " + fileExplorerItemId);
+				log.debug("deleteFileOrFolder " + fileId);
 
-				fileExplorerItemDao
-						.moveFile(fileExplorerItemId,
-								newParentFileExplorerItemId, room_id, isOwner,
-								owner_id);
+				fileExplorerItemDao.moveFile(fileId, newParentId, roomId, isOwner, ownerId);
 
-				FileExplorerItem fileExplorerItem = fileExplorerItemDao
-						.getFileExplorerItemsById(fileExplorerItemId);
+				FileExplorerItem fileExplorerItem = fileExplorerItemDao.get(fileId);
 
 				if (moveToHome) {
 					// set this file and all subfiles and folders the ownerId
-					fileUtils.setFileToOwnerOrRoomByParent(fileExplorerItem,
-							owner_id, null);
+					fileUtils.setFileToOwnerOrRoomByParent(fileExplorerItem, ownerId, null);
 
 				} else {
-					// set this file and all subfiles and folders the room_id
-					fileUtils.setFileToOwnerOrRoomByParent(fileExplorerItem,
-							null, room_id);
+					// set this file and all subfiles and folders the roomId
+					fileUtils.setFileToOwnerOrRoomByParent(fileExplorerItem, null, roomId);
 
 				}
 
@@ -960,11 +897,11 @@ public class FileWebService {
 	 * 
 	 * @param SID
 	 *            SID The SID of the User. This SID must be marked as logged in
-	 * @param fileExplorerItemId
+	 * @param fileId
 	 *            current file or folder id to be moved
-	 * @param newParentFileExplorerItemId
+	 * @param newParentId
 	 *            new parent folder id
-	 * @param room_id
+	 * @param roomId
 	 *            room id
 	 * @param isOwner
 	 *            if true owner id will be set
@@ -973,37 +910,30 @@ public class FileWebService {
 	 * @return - null
 	 * @throws ServiceException
 	 */
-	public Long moveFileSelf(String SID, Long fileExplorerItemId,
-			Long newParentFileExplorerItemId, Long room_id, Boolean isOwner,
+	public Long moveFileSelf(String SID, Long fileId, Long newParentId, Long roomId, Boolean isOwner,
 			Boolean moveToHome) throws ServiceException {
 
 		try {
 
-			Long users_id = sessiondataDao.checkSession(SID);
+			Long userId = sessiondataDao.checkSession(SID);
+
+			if (AuthLevelUtil.hasUserLevel(userDao.getRights(userId))) {
 
-			if (AuthLevelUtil.hasUserLevel(userDao.getRights(users_id))) {
-				
 				// A test is required that checks if the user is allowed to move the file
 
-				log.debug("moveFileSelf " + fileExplorerItemId);
+				log.debug("moveFileSelf " + fileId);
 
-				fileExplorerItemDao
-						.moveFile(fileExplorerItemId,
-								newParentFileExplorerItemId, room_id, isOwner,
-								users_id);
+				fileExplorerItemDao.moveFile(fileId, newParentId, roomId, isOwner, userId);
 
-				FileExplorerItem fileExplorerItem = fileExplorerItemDao
-						.getFileExplorerItemsById(fileExplorerItemId);
+				FileExplorerItem fileExplorerItem = fileExplorerItemDao.get(fileId);
 
 				if (moveToHome) {
 					// set this file and all subfiles and folders the ownerId
-					fileUtils.setFileToOwnerOrRoomByParent(fileExplorerItem,
-							users_id, null);
+					fileUtils.setFileToOwnerOrRoomByParent(fileExplorerItem, userId, null);
 
 				} else {
-					// set this file and all subfiles and folders the room_id
-					fileUtils.setFileToOwnerOrRoomByParent(fileExplorerItem,
-							null, room_id);
+					// set this file and all subfiles and folders the roomId
+					fileUtils.setFileToOwnerOrRoomByParent(fileExplorerItem, null, roomId);
 
 				}
 

Added: openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java
URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java?rev=1712911&view=auto
==============================================================================
--- openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java (added)
+++ openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/GroupWebService.java Fri Nov  6 06:18:44 2015
@@ -0,0 +1,240 @@
+/*
+ * 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.webservice;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
+
+import java.util.ArrayList;
+
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.cxf.feature.Features;
+import org.apache.openmeetings.db.dao.room.RoomDao;
+import org.apache.openmeetings.db.dao.server.SessiondataDao;
+import org.apache.openmeetings.db.dao.user.OrganisationDao;
+import org.apache.openmeetings.db.dao.user.OrganisationUserDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.dto.basic.SearchResult;
+import org.apache.openmeetings.db.dto.basic.ServiceResult;
+import org.apache.openmeetings.db.dto.basic.ServiceResult.Type;
+import org.apache.openmeetings.db.dto.user.UserSearchResult;
+import org.apache.openmeetings.db.entity.room.Room;
+import org.apache.openmeetings.db.entity.room.RoomOrganisation;
+import org.apache.openmeetings.db.entity.user.Organisation;
+import org.apache.openmeetings.db.entity.user.Organisation_Users;
+import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.db.util.AuthLevelUtil;
+import org.apache.openmeetings.webservice.error.ServiceException;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * 
+ * The Service contains methods to login and create hash to directly enter
+ * conference rooms, recordings or the application in general
+ * 
+ * @author sebawagner
+ * @webservice GroupService
+ * 
+ */
+@WebService(serviceName="org.apache.openmeetings.webservice.GroupWebService")
+@Features(features = "org.apache.cxf.feature.LoggingFeature")
+@Produces({MediaType.APPLICATION_JSON})
+@Path("/group")
+public class GroupWebService {
+	private static final Logger log = Red5LoggerFactory.getLogger(GroupWebService.class, webAppRootKey);
+
+	@Autowired
+	private OrganisationDao groupDao;
+	@Autowired
+	private OrganisationUserDao groupUserDao;
+	@Autowired
+	private UserDao userDao;
+	@Autowired
+	private RoomDao roomDao;
+	@Autowired
+	private SessiondataDao sessionDao;
+
+	/**
+	 * add a new group
+	 * 
+	 * @param sid
+	 *            The SID from getSession
+	 * @param name
+	 *            the name of the org
+	 * @return the new id of the org or -1 in case an error happened
+	 * @throws ServiceException
+	 */
+	@POST
+	@Path("/")
+	public ServiceResult add(@QueryParam("sid") @WebParam(name="sid") String sid, @QueryParam("name") @WebParam(name="name") String name) throws ServiceException {
+		Long userId = sessionDao.checkSession(sid);
+		if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
+			Organisation o = new Organisation();
+			o.setName(name);
+			return new ServiceResult(groupDao.update(o, userId).getId(), "Success", Type.SUCCESS);
+		} else {
+			log.error("Could not create group");
+			return new ServiceResult(-26L, "Insufficient permissins", Type.ERROR);
+		}
+	}
+	
+	/**
+	 * 
+	 * Add a user to a certain group
+	 * 
+	 * @param sid
+	 *            The SID from getSession
+	 * @param userid
+	 *            the user id
+	 * @param id
+	 *            the group id
+	 * @return - id of the user added, or error id in case of the error
+	 */
+	@POST
+	@Path("/{id}/users/add/{userid}")
+	public ServiceResult addUser(
+			@QueryParam("sid") @WebParam(name="sid") String sid
+			, @PathParam("id") @WebParam(name="id") Long id
+			, @PathParam("userid") @WebParam(name="userid") Long userid
+			) throws ServiceException
+	{
+		try {
+			Long authUserId = sessionDao.checkSession(sid);
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(authUserId))) {
+				if (!groupUserDao.isUserInOrganization(id, userid)) {
+					User u = userDao.get(userid);
+					u.getOrganisation_users().add(new Organisation_Users(groupDao.get(id)));
+					userDao.update(u, authUserId);
+				}
+				return new ServiceResult(userid, "Success", Type.SUCCESS);
+			} else {
+				return new ServiceResult(-26L, "Insufficient permissins", Type.ERROR);
+			}
+		} catch (Exception err) {
+			log.error("addUser", err);
+			throw new ServiceException(err.getMessage());
+		}
+	}
+
+	/**
+	 * Adds a room to an group
+	 * 
+	 * @param sid - The SID of the User. This SID must be marked as Loggedin
+	 * @param id - Id of group that the room is being paired with
+	 * @param roomid - Id of room to be added
+	 * 
+	 * @return Id of the relation created, null or -1 in case of the error
+	 */
+	@POST
+	@Path("/{id}/rooms/add/{roomId}")
+	public ServiceResult addRoom(
+			@QueryParam("sid") @WebParam(name="sid") String sid
+			, @PathParam("id") @WebParam(name="id") Long id
+			, @PathParam("roomid") @WebParam(name="roomid") Long roomid
+			) throws ServiceException
+	{
+		try {
+			Long userId = sessionDao.checkSession(sid);
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
+				Room r = roomDao.get(roomid);
+				if (r != null) {
+					if (r.getRoomOrganisations() == null) {
+						r.setRoomOrganisations(new ArrayList<RoomOrganisation>());
+					}
+					boolean found = false;
+					for (RoomOrganisation ro : r.getRoomOrganisations()) {
+						if (ro.getOrganisation().getId().equals(id)) {
+							found = true;
+						}
+					}
+					if (!found) {
+						r.getRoomOrganisations().add(new RoomOrganisation(groupDao.get(id), r));
+						roomDao.update(r, userId);
+						return new ServiceResult(1L, "Success", Type.SUCCESS);
+					}
+				}
+				return new ServiceResult(0L, "Not added", Type.SUCCESS);
+			} else {
+				return new ServiceResult(-26L, "Insufficient permissins", Type.ERROR);
+			}
+		} catch (Exception err) {
+			log.error("[addRoom]", err);
+			throw new ServiceException(err.getMessage());
+		}
+	}
+
+	/**
+	 * Search users and return them
+	 * 
+	 * @param sid
+	 *            The SID from getSession
+	 * @param id
+	 *            the group id
+	 * @param start
+	 *            first record
+	 * @param max
+	 *            max records
+	 * @param orderby
+	 *            orderby clause
+	 * @param asc
+	 *            asc or desc
+	 * @return - users found
+	 */
+	@GET
+	@Path("/users/{id}")
+	public UserSearchResult getUsers(
+			@QueryParam("sid") @WebParam(name="sid") String sid
+			, @PathParam("id") @WebParam(name="id") long id
+			, @QueryParam("start") @WebParam(name="start") int start
+			, @QueryParam("max") @WebParam(name="max") int max
+			, @QueryParam("orderby") @WebParam(name="orderby") String orderby
+			, @QueryParam("asc") @WebParam(name="asc") boolean asc
+			) throws ServiceException
+	{
+		try {
+			Long userId = sessionDao.checkSession(sid);
+			SearchResult<User> result = new SearchResult<User>();
+			result.setObjectName(User.class.getName());
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
+				result.setRecords(groupUserDao.count(id));
+				result.setResult(new ArrayList<User>());
+				for (Organisation_Users ou : groupUserDao.get(id, null, start, max, orderby + " " + (asc ? "ASC" : "DESC"))) {
+					result.getResult().add(ou.getUser());
+				}
+			} else {
+				log.error("Need Administration Account");
+				result.setErrorId(-26L);
+			}
+			return new UserSearchResult(result);
+		} catch (Exception err) {
+			log.error("getUsers", err);
+			throw new ServiceException(err.getMessage());
+		}
+	}
+}

Added: openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RecordingWebService.java
URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RecordingWebService.java?rev=1712911&view=auto
==============================================================================
--- openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RecordingWebService.java (added)
+++ openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/RecordingWebService.java Fri Nov  6 06:18:44 2015
@@ -0,0 +1,190 @@
+/*
+ * 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.webservice;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
+
+import java.util.List;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.cxf.feature.Features;
+import org.apache.openmeetings.db.dao.record.RecordingDao;
+import org.apache.openmeetings.db.dao.server.SessiondataDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.dto.record.RecordingDTO;
+import org.apache.openmeetings.db.util.AuthLevelUtil;
+import org.apache.openmeetings.webservice.error.ServiceException;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * 
+ * The Service contains methods to work with recordings
+ * 
+ * @author solomax
+ * @webservice RecordingService
+ * 
+ */
+@WebService(serviceName="org.apache.openmeetings.webservice.RecordingWebService")
+@Features(features = "org.apache.cxf.feature.LoggingFeature")
+@Produces({MediaType.APPLICATION_JSON})
+@Path("/record")
+public class RecordingWebService {
+	private static final Logger log = Red5LoggerFactory.getLogger(RecordingWebService.class, webAppRootKey);
+	@Autowired
+	private SessiondataDao sessionDao;
+	@Autowired
+	private UserDao userDao;
+	@Autowired
+	private RecordingDao recordingDao;
+
+	/**
+	 * Deletes a flv recording
+	 * 
+	 * @param sid
+	 *            The SID of the User. This SID must be marked as Loggedin
+	 * @param id
+	 *            the id of the recording
+	 *            
+	 * @throws {@link ServiceException} in case of any error
+	 */
+	@DELETE
+	@Path("/{id}")
+	public void delete(@QueryParam("sid") @WebParam(name="sid") String sid, @PathParam("id") @WebParam(name="id") Long id) throws ServiceException {
+		try {
+			Long userId = sessionDao.checkSession(sid);
+
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
+				recordingDao.delete(id);
+			} else {
+				throw new ServiceException("Not allowed to preform that action, Authenticate the SID first");
+			}
+		} catch (ServiceException err) {
+			throw err;
+		} catch (Exception err) {
+			log.error("[delete] ", err);
+			throw new ServiceException(err.getMessage());
+		}
+	}
+
+	/**
+	 * Gets a list of flv recordings
+	 * 
+	 * @param sid The SID of the User. This SID must be marked as Loggedin
+	 * @param externalId the externalUserId
+	 * @param externalType the externalUserType
+	 *            
+	 * @return - list of flv recordings
+	 * @throws ServiceException
+	 */
+	@WebMethod
+	@GET
+	@Path("/{externaltype}/{externalid}")
+	public List<RecordingDTO> getExternal(@WebParam(name="sid") @QueryParam("sid") String sid
+			, @PathParam("externaltype") @WebParam(name="externaltype") String externalType
+			, @PathParam("externalid") @WebParam(name="externalid") String externalId) throws ServiceException {
+		try {
+			Long userId = sessionDao.checkSession(sid);
+
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
+				return RecordingDTO.list(recordingDao.getByExternalId(externalId, externalType));
+			} else {
+				throw new ServiceException("Not allowed to preform that action, Authenticate the SID first");
+			}
+		} catch (ServiceException err) {
+			throw err;
+		} catch (Exception err) {
+			log.error("[getExternal] ", err);
+			throw new ServiceException(err.getMessage());
+		}
+	}
+
+	/**
+	 * Gets a list of flv recordings
+	 * 
+	 * @param sid
+	 *            The SID of the User. This SID must be marked as Loggedin
+	 * @param externalType
+	 *            externalRoomType specified when creating the room
+	 * @return - list of flv recordings
+	 * @throws ServiceException
+	 */
+	@WebMethod
+	@GET
+	@Path("/{externaltype}")
+	public List<RecordingDTO> getExternalByType(@WebParam(name="sid") @QueryParam("sid") String sid
+			, @PathParam("externaltype") @WebParam(name="externaltype") String externalType) throws ServiceException {
+		try {
+			Long userId = sessionDao.checkSession(sid);
+
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
+				return RecordingDTO.list(recordingDao.getByExternalType(externalType));
+			} else {
+				throw new ServiceException("Not allowed to preform that action, Authenticate the SID first");
+			}
+		} catch (ServiceException err) {
+			throw err;
+		} catch (Exception err) {
+			log.error("[getByExternalTypeByList] ", err);
+			throw new ServiceException(err.getMessage());
+		}
+	}
+
+	/**
+	 * Get list of recordings
+	 * 
+	 * @param sid
+	 *            The SID of the User. This SID must be marked as Loggedin
+	 * @param roomId
+	 *            the room id
+	 * @return - list of recordings
+	 * @throws ServiceException
+	 */
+	@WebMethod
+	@GET
+	@Path("/room/{id}")
+	public List<RecordingDTO> getExternalByRoom(@WebParam(name="sid") @QueryParam("sid") String sid
+			, @PathParam("id") @WebParam(name="id") Long roomId) throws ServiceException {
+		try {
+			Long userId = sessionDao.checkSession(sid);
+
+			if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) {
+				return RecordingDTO.list(recordingDao.getByRoomId(roomId));
+			} else {
+				throw new ServiceException("Not allowed to preform that action, Authenticate the SID first");
+			}
+		} catch (ServiceException err) {
+			throw err;
+		} catch (Exception err) {
+			log.error("[getByRoomId] ", err);
+			throw new ServiceException(err.getMessage());
+		}
+	}
+}