http://git-wip-us.apache.org/repos/asf/openmeetings/blob/8e63647c/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserContact.java ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserContact.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserContact.java index 6ff7ea0..0cce759 100644 --- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserContact.java +++ b/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserContact.java @@ -1,105 +1,105 @@ -/* - * 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.test.user; - -import static org.apache.openmeetings.web.app.WebSession.getUserId; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.List; -import java.util.UUID; - -import org.apache.openmeetings.db.dao.user.GroupDao; -import org.apache.openmeetings.db.dao.user.UserDao; -import org.apache.openmeetings.db.entity.user.GroupUser; -import org.apache.openmeetings.db.entity.user.User; -import org.apache.openmeetings.test.AbstractWicketTester; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -public class TestUserContact extends AbstractWicketTester { - @Autowired - private UserDao userDao; - @Autowired - private GroupDao groupDao; - - @Test - public void testGetUser() { - assertNull("Null should be returned in case User does not exist", userDao.get(Long.MAX_VALUE)); - } - - @Test - public void createUserWithGroup() throws Exception { - String uuid = UUID.randomUUID().toString(); - User u = getUser(uuid); - u.getGroupUsers().add(new GroupUser(groupDao.get(1L), u)); - u = userDao.update(u, null); - assertTrue("Password should be set as expected", userDao.verifyPassword(u.getId(), getRandomPass(uuid))); - - User u1 = userDao.get(u.getId()); - assertNotNull("Just created user should not be null", u1); - assertNotNull("Just created user should have non null org-users", u1.getGroupUsers()); - assertFalse("Just created user should have not empty org-users", u1.getGroupUsers().isEmpty()); - } - - @Test - public void testCreateUser() throws Exception { - String uuid = UUID.randomUUID().toString(); - User u = createUser(uuid); - assertTrue("Password should be set as expected", userDao.verifyPassword(u.getId(), getRandomPass(uuid))); - } - - @Test - public void addContactByOwner() throws Exception { - login(null, null); - - List<User> users = userDao.getAllUsers(); - assertNotNull("User list should not be null ", users); - assertFalse("User list should not be empty ", users.isEmpty()); - - User contact = createUserContact(getUserId()); - String email = contact.getAddress().getEmail(); - List<User> l = userDao.get(email, false, 0, 9999); - // check that contact is visible for admin - assertNotNull("Contact list should not be null for admin ", l); - assertFalse("Contact list should not be empty for admin ", l.isEmpty()); - - // check that contact is visible for owner - l = userDao.get(email, 0, 9999, null, true, getUserId()); - assertTrue("Contact list should not be empty for owner ", !l.isEmpty()); - //delete contact - userDao.delete(contact, getUserId()); - l = userDao.get(email, false, 0, 9999); - assertTrue("Contact list should be empty after deletion", l.isEmpty()); - - User u = createUser(); - User u1 = createUser(); - contact = createUserContact(u.getId()); - email = contact.getAddress().getEmail(); - // check that contact is not visible for user that is not owner of this contact - l = userDao.get(email, 0, 9999, null, true, u1.getId()); - assertTrue("Contact list should be empty for another user", l.isEmpty()); - //delete contact - userDao.delete(contact, u.getId()); - l = userDao.get(email, false, 0, 9999); - assertTrue("Contact list should be empty after deletion", l.isEmpty()); - } -} +/* + * 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.test.user; + +import static org.apache.openmeetings.web.app.WebSession.getUserId; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.List; +import java.util.UUID; + +import org.apache.openmeetings.db.dao.user.GroupDao; +import org.apache.openmeetings.db.dao.user.UserDao; +import org.apache.openmeetings.db.entity.user.GroupUser; +import org.apache.openmeetings.db.entity.user.User; +import org.apache.openmeetings.test.AbstractWicketTester; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +public class TestUserContact extends AbstractWicketTester { + @Autowired + private UserDao userDao; + @Autowired + private GroupDao groupDao; + + @Test + public void testGetUser() { + assertNull("Null should be returned in case User does not exist", userDao.get(Long.MAX_VALUE)); + } + + @Test + public void createUserWithGroup() throws Exception { + String uuid = UUID.randomUUID().toString(); + User u = getUser(uuid); + u.getGroupUsers().add(new GroupUser(groupDao.get(1L), u)); + u = userDao.update(u, null); + assertTrue("Password should be set as expected", userDao.verifyPassword(u.getId(), getRandomPass(uuid))); + + User u1 = userDao.get(u.getId()); + assertNotNull("Just created user should not be null", u1); + assertNotNull("Just created user should have non null org-users", u1.getGroupUsers()); + assertFalse("Just created user should have not empty org-users", u1.getGroupUsers().isEmpty()); + } + + @Test + public void testCreateUser() throws Exception { + String uuid = UUID.randomUUID().toString(); + User u = createUser(uuid); + assertTrue("Password should be set as expected", userDao.verifyPassword(u.getId(), getRandomPass(uuid))); + } + + @Test + public void addContactByOwner() throws Exception { + login(null, null); + + List<User> users = userDao.getAllUsers(); + assertNotNull("User list should not be null ", users); + assertFalse("User list should not be empty ", users.isEmpty()); + + User contact = createUserContact(getUserId()); + String email = contact.getAddress().getEmail(); + List<User> l = userDao.get(email, false, 0, 9999); + // check that contact is visible for admin + assertNotNull("Contact list should not be null for admin ", l); + assertFalse("Contact list should not be empty for admin ", l.isEmpty()); + + // check that contact is visible for owner + l = userDao.get(email, 0, 9999, null, true, getUserId()); + assertTrue("Contact list should not be empty for owner ", !l.isEmpty()); + //delete contact + userDao.delete(contact, getUserId()); + l = userDao.get(email, false, 0, 9999); + assertTrue("Contact list should be empty after deletion", l.isEmpty()); + + User u = createUser(); + User u1 = createUser(); + contact = createUserContact(u.getId()); + email = contact.getAddress().getEmail(); + // check that contact is not visible for user that is not owner of this contact + l = userDao.get(email, 0, 9999, null, true, u1.getId()); + assertTrue("Contact list should be empty for another user", l.isEmpty()); + //delete contact + userDao.delete(contact, u.getId()); + l = userDao.get(email, false, 0, 9999); + assertTrue("Contact list should be empty after deletion", l.isEmpty()); + } +}
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/8e63647c/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserCount.java ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserCount.java b/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserCount.java index 0fba6e5..530dae7 100644 --- a/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserCount.java +++ b/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserCount.java @@ -1,58 +1,58 @@ -/* - * 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.test.user; - -import static org.apache.openmeetings.web.app.WebSession.getUserId; -import static org.junit.Assert.assertTrue; - -import org.apache.openmeetings.db.dao.user.UserDao; -import org.apache.openmeetings.db.entity.user.User; -import org.apache.openmeetings.test.AbstractWicketTester; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -public class TestUserCount extends AbstractWicketTester { - @Autowired - private UserDao userDao; - - @Test - public void testCountSearchUsers() throws Exception { - User u = createUser(); - assertTrue("Account of search users should be one", userDao.count(u.getFirstname()) == 1); - } - - @Test - public void testCountFilteredUsers() throws Exception { - User u = createUser(); - User contact = createUserContact(u.getId()); - assertTrue("Account of filtered user should be one", userDao.count(contact.getFirstname(), true, u.getId()) == 1); - } - - @Test - public void testCountUnfilteredUsers() throws Exception { - User u = createUser(); - createUserContact(u.getId()); - assertTrue("Account of unfiltered should be more then one", userDao.count("firstname", false, getUserId()) > 1); - } - - @Test - public void testCountAllUsers() { - assertTrue("Account of users should be positive", userDao.count() > 0); - } -} +/* + * 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.test.user; + +import static org.apache.openmeetings.web.app.WebSession.getUserId; +import static org.junit.Assert.assertTrue; + +import org.apache.openmeetings.db.dao.user.UserDao; +import org.apache.openmeetings.db.entity.user.User; +import org.apache.openmeetings.test.AbstractWicketTester; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +public class TestUserCount extends AbstractWicketTester { + @Autowired + private UserDao userDao; + + @Test + public void testCountSearchUsers() throws Exception { + User u = createUser(); + assertTrue("Account of search users should be one", userDao.count(u.getFirstname()) == 1); + } + + @Test + public void testCountFilteredUsers() throws Exception { + User u = createUser(); + User contact = createUserContact(u.getId()); + assertTrue("Account of filtered user should be one", userDao.count(contact.getFirstname(), true, u.getId()) == 1); + } + + @Test + public void testCountUnfilteredUsers() throws Exception { + User u = createUser(); + createUserContact(u.getId()); + assertTrue("Account of unfiltered should be more then one", userDao.count("firstname", false, getUserId()) > 1); + } + + @Test + public void testCountAllUsers() { + assertTrue("Account of users should be positive", userDao.count() > 0); + } +} http://git-wip-us.apache.org/repos/asf/openmeetings/blob/8e63647c/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/ServerWebService.java ---------------------------------------------------------------------- diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/ServerWebService.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/ServerWebService.java index 949c79e..919f9df 100644 --- a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/ServerWebService.java +++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/ServerWebService.java @@ -1,180 +1,180 @@ -/* - * 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 static org.apache.openmeetings.webservice.Constants.TNS; - -import java.util.List; - -import javax.jws.WebMethod; -import javax.jws.WebParam; -import javax.jws.WebService; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -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.server.ServerDao; -import org.apache.openmeetings.db.dao.server.SessiondataDao; -import org.apache.openmeetings.db.dao.user.UserDao; -import org.apache.openmeetings.db.dto.basic.ServiceResult; -import org.apache.openmeetings.db.dto.basic.ServiceResult.Type; -import org.apache.openmeetings.db.dto.server.ServerDTO; -import org.apache.openmeetings.db.entity.server.Server; -import org.apache.openmeetings.db.entity.server.Sessiondata; -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; - -/** - * This class provides method implementations necessary for OM to manage servers - * participating in cluster. - * - * @author solomax, sebawagner - * - */ -@WebService(serviceName="org.apache.openmeetings.webservice.ServerWebService", targetNamespace = TNS) -@Features(features = "org.apache.cxf.feature.LoggingFeature") -@Produces({MediaType.APPLICATION_JSON}) -@Path("/server") -public class ServerWebService { - private static final Logger log = Red5LoggerFactory.getLogger(ServerWebService.class, webAppRootKey); - - @Autowired - private SessiondataDao sessionDao; - @Autowired - private UserDao userDao; - @Autowired - private ServerDao serverDao; - - /** - * Method to retrieve the list of the servers participating in cluster - * - * @param sid - * - session id to identify the user making request - * @param start - * - server index to start with - * @param max - * - Maximum server count - * @return The list of servers participating in cluster - */ - @WebMethod - @GET - @Path("/{start}/{max}") - public List<ServerDTO> getServers(@QueryParam("sid") @WebParam(name="sid") String sid - , @PathParam("start") @WebParam(name="start") int start - , @PathParam("max") @WebParam(name="max") int max - ) throws ServiceException - { - log.debug("getServers enter"); - Sessiondata sd = sessionDao.check(sid); - - if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(sd.getUserId()))) { - return ServerDTO.list(serverDao.get(start, max)); - } else { - log.warn("Insuffisient permissions"); - throw new ServiceException("Insufficient permissions"); //TODO code -26 - } - } - - /** - * Method to retrieve the total count of the servers participating in - * cluster - * - * @param sid - * - session id to identify the user making request - * @return total count of the servers participating in cluster - */ - @WebMethod - @GET - @Path("/count") - public long count(@QueryParam("sid") @WebParam(name="sid") String sid) throws ServiceException { - log.debug("getServerCount enter"); - Sessiondata sd = sessionDao.check(sid); - - if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(sd.getUserId()))) { - return serverDao.count(); - } else { - throw new ServiceException("Insufficient permissions"); //TODO code -26 - } - } - - /** - * Method to add/update server - * - * @param sid - * - session id to identify the user making request - * @param server - * - server to add/update - * @return the id of saved server - */ - @WebMethod - @POST - @Path("/") - public ServerDTO add(@WebParam(name="sid") @QueryParam("sid") String sid, @WebParam(name="server") @QueryParam("server") ServerDTO server) throws ServiceException { - log.debug("saveServerCount enter"); - Sessiondata sd = sessionDao.check(sid); - Long userId = sd.getUserId(); - if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) { - Server s = server.get(); - return new ServerDTO(serverDao.update(s, userId)); - } else { - log.warn("Insuffisient permissions"); - throw new ServiceException("Insufficient permissions"); //TODO code -26 - } - } - - /** - * Method to delete server - * - * @param sid - * - session id to identify the user making request - * @param id - * - the id of the server to delete - * @return true if the server was deleted, false otherwise - */ - @WebMethod - @DELETE - @Path("/{id}") - public ServiceResult delete(@WebParam(name="sid") @QueryParam("sid") String sid, @WebParam(name="id") @PathParam("id") long id) throws ServiceException { - log.debug("saveServerCount enter"); - Sessiondata sd = sessionDao.check(sid); - Long userId = sd.getUserId(); - - if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) { - Server s = serverDao.get(id); - if (s != null) { - serverDao.delete(s, userId); - return new ServiceResult(id, "Deleted", Type.SUCCESS); - } - return new ServiceResult(0L, "Not found", Type.SUCCESS); - } else { - log.warn("Insuffisient permissions"); - throw new ServiceException("Insufficient permissions"); //TODO code -26 - } - } -} +/* + * 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 static org.apache.openmeetings.webservice.Constants.TNS; + +import java.util.List; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +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.server.ServerDao; +import org.apache.openmeetings.db.dao.server.SessiondataDao; +import org.apache.openmeetings.db.dao.user.UserDao; +import org.apache.openmeetings.db.dto.basic.ServiceResult; +import org.apache.openmeetings.db.dto.basic.ServiceResult.Type; +import org.apache.openmeetings.db.dto.server.ServerDTO; +import org.apache.openmeetings.db.entity.server.Server; +import org.apache.openmeetings.db.entity.server.Sessiondata; +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; + +/** + * This class provides method implementations necessary for OM to manage servers + * participating in cluster. + * + * @author solomax, sebawagner + * + */ +@WebService(serviceName="org.apache.openmeetings.webservice.ServerWebService", targetNamespace = TNS) +@Features(features = "org.apache.cxf.feature.LoggingFeature") +@Produces({MediaType.APPLICATION_JSON}) +@Path("/server") +public class ServerWebService { + private static final Logger log = Red5LoggerFactory.getLogger(ServerWebService.class, webAppRootKey); + + @Autowired + private SessiondataDao sessionDao; + @Autowired + private UserDao userDao; + @Autowired + private ServerDao serverDao; + + /** + * Method to retrieve the list of the servers participating in cluster + * + * @param sid + * - session id to identify the user making request + * @param start + * - server index to start with + * @param max + * - Maximum server count + * @return The list of servers participating in cluster + */ + @WebMethod + @GET + @Path("/{start}/{max}") + public List<ServerDTO> getServers(@QueryParam("sid") @WebParam(name="sid") String sid + , @PathParam("start") @WebParam(name="start") int start + , @PathParam("max") @WebParam(name="max") int max + ) throws ServiceException + { + log.debug("getServers enter"); + Sessiondata sd = sessionDao.check(sid); + + if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(sd.getUserId()))) { + return ServerDTO.list(serverDao.get(start, max)); + } else { + log.warn("Insuffisient permissions"); + throw new ServiceException("Insufficient permissions"); //TODO code -26 + } + } + + /** + * Method to retrieve the total count of the servers participating in + * cluster + * + * @param sid + * - session id to identify the user making request + * @return total count of the servers participating in cluster + */ + @WebMethod + @GET + @Path("/count") + public long count(@QueryParam("sid") @WebParam(name="sid") String sid) throws ServiceException { + log.debug("getServerCount enter"); + Sessiondata sd = sessionDao.check(sid); + + if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(sd.getUserId()))) { + return serverDao.count(); + } else { + throw new ServiceException("Insufficient permissions"); //TODO code -26 + } + } + + /** + * Method to add/update server + * + * @param sid + * - session id to identify the user making request + * @param server + * - server to add/update + * @return the id of saved server + */ + @WebMethod + @POST + @Path("/") + public ServerDTO add(@WebParam(name="sid") @QueryParam("sid") String sid, @WebParam(name="server") @QueryParam("server") ServerDTO server) throws ServiceException { + log.debug("saveServerCount enter"); + Sessiondata sd = sessionDao.check(sid); + Long userId = sd.getUserId(); + if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) { + Server s = server.get(); + return new ServerDTO(serverDao.update(s, userId)); + } else { + log.warn("Insuffisient permissions"); + throw new ServiceException("Insufficient permissions"); //TODO code -26 + } + } + + /** + * Method to delete server + * + * @param sid + * - session id to identify the user making request + * @param id + * - the id of the server to delete + * @return true if the server was deleted, false otherwise + */ + @WebMethod + @DELETE + @Path("/{id}") + public ServiceResult delete(@WebParam(name="sid") @QueryParam("sid") String sid, @WebParam(name="id") @PathParam("id") long id) throws ServiceException { + log.debug("saveServerCount enter"); + Sessiondata sd = sessionDao.check(sid); + Long userId = sd.getUserId(); + + if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(userId))) { + Server s = serverDao.get(id); + if (s != null) { + serverDao.delete(s, userId); + return new ServiceResult(id, "Deleted", Type.SUCCESS); + } + return new ServiceResult(0L, "Not found", Type.SUCCESS); + } else { + log.warn("Insuffisient permissions"); + throw new ServiceException("Insufficient permissions"); //TODO code -26 + } + } +} http://git-wip-us.apache.org/repos/asf/openmeetings/blob/8e63647c/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/SlaveHTTPConnectionManager.java ---------------------------------------------------------------------- diff --git a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/SlaveHTTPConnectionManager.java b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/SlaveHTTPConnectionManager.java index ad3cdf7..1f83615 100644 --- a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/SlaveHTTPConnectionManager.java +++ b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/cluster/SlaveHTTPConnectionManager.java @@ -1,99 +1,99 @@ -/* - * 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.cluster; - -import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.openmeetings.core.remote.ISlaveHTTPConnectionManager; -import org.apache.openmeetings.db.entity.server.Server; -import org.red5.logging.Red5LoggerFactory; -import org.slf4j.Logger; - -/** - * Manages connections to the other nodes of the cluster. - * - * Use-case: When you kick a user via the admin-panel, it is probably on anther server. - * So you need to perform a REST call to the node and let that node do the actual disconnect. - * - * @author sebawagner - * - */ -public class SlaveHTTPConnectionManager implements ISlaveHTTPConnectionManager { - private static Logger log = Red5LoggerFactory.getLogger(SlaveHTTPConnectionManager.class, webAppRootKey); - - /** - * We store the list of RestClients in the memory, so that we can simply - * call ping to get the load, without the need to get a new session Hash and - * to login again. <br/> - * There can be only one RestClient per server, so we use the primary key of - * the server to store the RestClient. - */ - private static Map<Long, RestClient> restClientsSessionStore = new ConcurrentHashMap<>(); - - /** - * Synchronized, cause nobody should manipulate the object while another - * process requests it, the scheduler could run several times and request - * the same object, add or remove it.<br/> - * If there is no object yet, create one. - * - * @param server - */ - private static RestClient getRestClient(Server server) { - RestClient restClient = restClientsSessionStore.get(server.getId()); - - // check if any values of the server have been changed, - // if yes, we need a new RestClient to make sure it will re-login to the - // changed server details - if (restClient != null && restClient.hasServerDetailsChanged(server)) { - log.debug("Server details changed, get new rest client"); - restClient = null; - } - - if (restClient == null) { - restClient = new RestClient(server); - restClientsSessionStore.put(server.getId(), restClient); - } - return restClient; - } - - /** - * Gets the current {@link RestClient} from the session store and then - * performs a kickUser on that. It is not possible that there is no - * {@link RestClient}, because if you want to kick a user from a slave, the - * master <i>must</i> already have loaded the sessions from the slave, so - * there logically <i>must</i> by a {@link RestClient} available that has an - * open connection to that slave / {@link Server} - * - * @param serverId - * @param publicSID - */ - @Override - public void kickSlaveUser(Server server, String publicSID) throws Exception { - RestClient rClient = getRestClient(server); - - if (rClient == null) { - throw new Exception("No RestClient found for server " + server); - } - - rClient.kickUser(publicSID); - } -} +/* + * 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.cluster; + +import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.openmeetings.core.remote.ISlaveHTTPConnectionManager; +import org.apache.openmeetings.db.entity.server.Server; +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; + +/** + * Manages connections to the other nodes of the cluster. + * + * Use-case: When you kick a user via the admin-panel, it is probably on anther server. + * So you need to perform a REST call to the node and let that node do the actual disconnect. + * + * @author sebawagner + * + */ +public class SlaveHTTPConnectionManager implements ISlaveHTTPConnectionManager { + private static Logger log = Red5LoggerFactory.getLogger(SlaveHTTPConnectionManager.class, webAppRootKey); + + /** + * We store the list of RestClients in the memory, so that we can simply + * call ping to get the load, without the need to get a new session Hash and + * to login again. <br/> + * There can be only one RestClient per server, so we use the primary key of + * the server to store the RestClient. + */ + private static Map<Long, RestClient> restClientsSessionStore = new ConcurrentHashMap<>(); + + /** + * Synchronized, cause nobody should manipulate the object while another + * process requests it, the scheduler could run several times and request + * the same object, add or remove it.<br/> + * If there is no object yet, create one. + * + * @param server + */ + private static RestClient getRestClient(Server server) { + RestClient restClient = restClientsSessionStore.get(server.getId()); + + // check if any values of the server have been changed, + // if yes, we need a new RestClient to make sure it will re-login to the + // changed server details + if (restClient != null && restClient.hasServerDetailsChanged(server)) { + log.debug("Server details changed, get new rest client"); + restClient = null; + } + + if (restClient == null) { + restClient = new RestClient(server); + restClientsSessionStore.put(server.getId(), restClient); + } + return restClient; + } + + /** + * Gets the current {@link RestClient} from the session store and then + * performs a kickUser on that. It is not possible that there is no + * {@link RestClient}, because if you want to kick a user from a slave, the + * master <i>must</i> already have loaded the sessions from the slave, so + * there logically <i>must</i> by a {@link RestClient} available that has an + * open connection to that slave / {@link Server} + * + * @param serverId + * @param publicSID + */ + @Override + public void kickSlaveUser(Server server, String publicSID) throws Exception { + RestClient rClient = getRestClient(server); + + if (rClient == null) { + throw new Exception("No RestClient found for server " + server); + } + + rClient.kickUser(publicSID); + } +} http://git-wip-us.apache.org/repos/asf/openmeetings/blob/8e63647c/openmeetings-webservice/src/site/site.xml ---------------------------------------------------------------------- diff --git a/openmeetings-webservice/src/site/site.xml b/openmeetings-webservice/src/site/site.xml index c26954e..0d9f35c 100644 --- a/openmeetings-webservice/src/site/site.xml +++ b/openmeetings-webservice/src/site/site.xml @@ -1,40 +1,40 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed 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. - --> -<project xmlns="http://maven.apache.org/DECORATION/1.7.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/DECORATION/1.7.0 http://maven.apache.org/xsd/decoration-1.7.0.xsd" - name="Apache OpenMeetings Project"> - - <body> - <menu ref="parent"/> - <menu name="Project"> - <item name="About" href="/index.html" /> - <item name="Info" href="/project-info.html" /> - <item name="Summary" href="/project-summary.html" /> - <item name="License" href="/license.html" /> - <item name="Dependencies" href="/dependencies.html" /> - <item name="Dependency Convergence" href="/dependency-convergence.html" /> - <item name="RAT Report" href="/rat-report.html" /> - <item name="JavaDoc" href="/apidocs/index.html" target="_blank" /> - </menu> - </body> - <custom> - <reflowSkin> - <bottomNav maxSpan="12"> - <column>Parent Project</column> - <column>Project</column> - </bottomNav> - </reflowSkin> - </custom> -</project> +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed 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. + --> +<project xmlns="http://maven.apache.org/DECORATION/1.7.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/DECORATION/1.7.0 http://maven.apache.org/xsd/decoration-1.7.0.xsd" + name="Apache OpenMeetings Project"> + + <body> + <menu ref="parent"/> + <menu name="Project"> + <item name="About" href="/index.html" /> + <item name="Info" href="/project-info.html" /> + <item name="Summary" href="/project-summary.html" /> + <item name="License" href="/license.html" /> + <item name="Dependencies" href="/dependencies.html" /> + <item name="Dependency Convergence" href="/dependency-convergence.html" /> + <item name="RAT Report" href="/rat-report.html" /> + <item name="JavaDoc" href="/apidocs/index.html" target="_blank" /> + </menu> + </body> + <custom> + <reflowSkin> + <bottomNav maxSpan="12"> + <column>Parent Project</column> + <column>Project</column> + </bottomNav> + </reflowSkin> + </custom> +</project> http://git-wip-us.apache.org/repos/asf/openmeetings/blob/8e63647c/src/site/site.xml ---------------------------------------------------------------------- diff --git a/src/site/site.xml b/src/site/site.xml index aa78843..5727f48 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -1,77 +1,77 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed 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. - --> -<project xmlns="http://maven.apache.org/DECORATION/1.7.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/DECORATION/1.7.0 http://maven.apache.org/xsd/decoration-1.7.0.xsd" - name="Apache OpenMeetings Project"> - - <bannerLeft> - <name>Apache OpenMeetings</name> - <src>http://openmeetings.apache.org/images/logo.png</src> - <href>http://openmeetings.apache.org/index.html</href> - </bannerLeft> - <bannerRight> - <name>Apache</name> - <src>http://apache.org/img/asf_logo.png</src> - <href>http://apache.org</href> - </bannerRight> - - <skin> - <groupId>lt.velykis.maven.skins</groupId> - <artifactId>reflow-maven-skin</artifactId> - <version>1.1.1</version> - </skin> - - <version position="none"/> - - <body> - <head><![CDATA[ - <link rel="stylesheet" href="$resourcePath/css/site.css"/> - ]]></head> - <links> - <item name="Demo" href="http://openmeetings.apache.org/demo.html"/> - <item name="Download" href="http://openmeetings.apache.org/downloads.html"/> - <item name="Wiki" href="https://cwiki.apache.org/confluence/display/OPENMEETINGS"/> - </links> - <menu ref="modules" inherit="top"/> - </body> - - <poweredBy></poweredBy> - - <custom> - <reflowSkin> - <brand> - <name><![CDATA[ - <span class="color-highlight">Apache</span> OpenMeetings - ]]></name> - </brand> - <!--absoluteResourceURL>http://localhost:5080/openmeetings/docs</absoluteResourceURL--><!-- DEVELOPMENT --> - <absoluteResourceURL>http://openmeetings.apache.org</absoluteResourceURL> - <protocolRelativeURLs>true</protocolRelativeURLs> - <localResources>true</localResources> - <theme>site</theme><!-- http://bootswatch.com/2/cerulean offline --> - <bottomNav maxSpan="12"> - <column>General</column> - <column>Installation</column> - <column>Community</column> - <column>Development</column> - </bottomNav> - <toc>sidebar</toc> - <skinAttribution>false</skinAttribution> - <endContent> - <script src="$resourcePath/js/site.js"></script> - </endContent> - </reflowSkin> - </custom> -</project> +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed 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. + --> +<project xmlns="http://maven.apache.org/DECORATION/1.7.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/DECORATION/1.7.0 http://maven.apache.org/xsd/decoration-1.7.0.xsd" + name="Apache OpenMeetings Project"> + + <bannerLeft> + <name>Apache OpenMeetings</name> + <src>http://openmeetings.apache.org/images/logo.png</src> + <href>http://openmeetings.apache.org/index.html</href> + </bannerLeft> + <bannerRight> + <name>Apache</name> + <src>http://apache.org/img/asf_logo.png</src> + <href>http://apache.org</href> + </bannerRight> + + <skin> + <groupId>lt.velykis.maven.skins</groupId> + <artifactId>reflow-maven-skin</artifactId> + <version>1.1.1</version> + </skin> + + <version position="none"/> + + <body> + <head><![CDATA[ + <link rel="stylesheet" href="$resourcePath/css/site.css"/> + ]]></head> + <links> + <item name="Demo" href="http://openmeetings.apache.org/demo.html"/> + <item name="Download" href="http://openmeetings.apache.org/downloads.html"/> + <item name="Wiki" href="https://cwiki.apache.org/confluence/display/OPENMEETINGS"/> + </links> + <menu ref="modules" inherit="top"/> + </body> + + <poweredBy></poweredBy> + + <custom> + <reflowSkin> + <brand> + <name><![CDATA[ + <span class="color-highlight">Apache</span> OpenMeetings + ]]></name> + </brand> + <!--absoluteResourceURL>http://localhost:5080/openmeetings/docs</absoluteResourceURL--><!-- DEVELOPMENT --> + <absoluteResourceURL>http://openmeetings.apache.org</absoluteResourceURL> + <protocolRelativeURLs>true</protocolRelativeURLs> + <localResources>true</localResources> + <theme>site</theme><!-- http://bootswatch.com/2/cerulean offline --> + <bottomNav maxSpan="12"> + <column>General</column> + <column>Installation</column> + <column>Community</column> + <column>Development</column> + </bottomNav> + <toc>sidebar</toc> + <skinAttribution>false</skinAttribution> + <endContent> + <script src="$resourcePath/js/site.js"></script> + </endContent> + </reflowSkin> + </custom> +</project>
