Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/backup/TestOldBackups.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/backup/TestOldBackups.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/backup/TestOldBackups.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/backup/TestOldBackups.java Fri Nov 6 06:18:44 2015 @@ -48,7 +48,7 @@ public class TestOldBackups extends Abst @Autowired private OrganisationDao organisationDao; @Autowired - private UserDao usersDao; + private UserDao userDao; @Autowired private RoomDao roomDao; @Autowired @@ -80,10 +80,10 @@ public class TestOldBackups extends Abst is = new FileInputStream(backup); backupController.performImport(is); long newOrgCount = organisationDao.count(); - long newUserCount = usersDao.count(); + long newUserCount = userDao.count(); long newRoomCount = roomDao.count(); long newRoomOrgCount = roomOrganisationDao.get().size(); - long newApptCount = appointmentDao.getAppointments().size(); + long newApptCount = appointmentDao.get().size(); log.debug("Now DB contains '" + newApptCount + "' appointments"); long newMeetingMembersCount = meetingMemberDao.getMeetingMembers().size(); assertTrue("Zero organizations were imported from " + name, newOrgCount > orgCount);
Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentAddAppointment.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentAddAppointment.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentAddAppointment.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentAddAppointment.java Fri Nov 6 06:18:44 2015 @@ -31,6 +31,7 @@ import org.junit.Test; import org.red5.logging.Red5LoggerFactory; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; + public class TestAppointmentAddAppointment extends AbstractWicketTester { private static final Logger log = Red5LoggerFactory.getLogger(TestAppointmentAddAppointment.class, webAppRootKey); @@ -52,28 +53,28 @@ public class TestAppointmentAddAppointme String appointmentName = "Test 01"; String appointmentDescription = "Descr"; - Long users_id = 1L; + Long userId = 1L; String appointmentLocation = "office"; Boolean isMonthly = false; Boolean isDaily = false; Long categoryId = 1L; Boolean isWeekly = false; - Long remind = 3L; + String remind = Appointment.Reminder.ical.name(); Boolean isYearly = false; String[] mmClient = new String[1]; for (int i = 0; i < 1; i++) { mmClient[0] = createClientObj("firstname" + i, "lastname" + i, "first" + i + ".last" + i + "@webbase-design.de", "Etc/GMT+1"); } - Long language_id = 1L; + Long languageId = 1L; Long roomType = 1L; Appointment a = appointmentLogic.getAppointment(appointmentName, appointmentLocation, appointmentDescription, start, end, isDaily, isWeekly, isMonthly, isYearly, categoryId, remind, mmClient, - roomType, language_id, false, "", -1, users_id); - a = appointmentDao.update(a, users_id); + roomType, languageId, false, "", -1, userId); + a = appointmentDao.update(a, userId); Thread.sleep(3000); Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentSchedulerTask.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentSchedulerTask.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentSchedulerTask.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestAppointmentSchedulerTask.java Fri Nov 6 06:18:44 2015 @@ -18,19 +18,18 @@ */ package org.apache.openmeetings.test.calendar; +import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; import static org.junit.Assert.assertTrue; import org.apache.openmeetings.service.calendar.AppointmentLogic; import org.apache.openmeetings.test.AbstractJUnitDefaults; -import org.apache.openmeetings.util.OpenmeetingsVariables; import org.junit.Test; import org.red5.logging.Red5LoggerFactory; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; public class TestAppointmentSchedulerTask extends AbstractJUnitDefaults { - - private static final Logger log = Red5LoggerFactory.getLogger(TestAppointmentSchedulerTask.class, OpenmeetingsVariables.webAppRootKey); + private static final Logger log = Red5LoggerFactory.getLogger(TestAppointmentSchedulerTask.class, webAppRootKey); @Autowired private AppointmentLogic appointmentLogic; Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureAppointment.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureAppointment.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureAppointment.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureAppointment.java Fri Nov 6 06:18:44 2015 @@ -18,7 +18,7 @@ */ package org.apache.openmeetings.test.calendar; - +import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; import java.text.SimpleDateFormat; import java.util.Calendar; @@ -26,18 +26,16 @@ import java.util.Date; import java.util.Iterator; import java.util.List; -import org.apache.log4j.Logger; import org.apache.openmeetings.db.dao.calendar.AppointmentDao; import org.apache.openmeetings.db.entity.calendar.Appointment; import org.apache.openmeetings.test.AbstractJUnitDefaults; import org.junit.Test; +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; - - public class TestDatabaseStructureAppointment extends AbstractJUnitDefaults { - - private static final Logger log = Logger.getLogger(TestDatabaseStructureAppointment.class); + private static final Logger log = Red5LoggerFactory.getLogger(TestDatabaseStructureAppointment.class, webAppRootKey); @Autowired private AppointmentDao appointmentDao; @@ -55,7 +53,7 @@ public class TestDatabaseStructureAppoin Date date = format.parse( "2008-17-08" ); Date date2 = format.parse( "2008-18-08" ); - List<Appointment> listAppoints = appointmentDao.getAppointmentsByRange(1L, date, date2); + List<Appointment> listAppoints = appointmentDao.getInRange(1L, date, date2); //List<Appointment> listAppoints = AppointmentDaoImpl.getInstance().searchAppointmentsByName("%"); //AppointmentDaoImpl.getInstance().getNextAppointmentById(1L); //AppointmentDaoImpl.getInstance().addAppointment("mezo",1L, "Pforzheim", "zweiter", Calendar.getInstance().getTime() , @@ -73,10 +71,6 @@ public class TestDatabaseStructureAppoin for (Iterator<Appointment> iter = listAppoints.iterator();iter.hasNext();) { log.debug(""+iter.next()); } - - //AppointmentDaoImpl.getInstance().updateAppointment(1L,"neu", "erster Test",Calendar.getInstance().getTime() , - //Calendar.getInstance().getTime(), true, false, false, false, new Long(1)); - //log.debug("AppointmentReminderTypDaoImpl: "+appointmentReminderTypDaoImpl.getAppointmentReminderTypById(1L)); } catch (Exception err) { log.error("[testAddingGroup]",err); Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetAppointmentByRange.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetAppointmentByRange.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetAppointmentByRange.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetAppointmentByRange.java Fri Nov 6 06:18:44 2015 @@ -18,22 +18,25 @@ */ package org.apache.openmeetings.test.calendar; +import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; import static org.junit.Assert.assertEquals; import java.util.ArrayList; import java.util.Calendar; import java.util.Random; -import org.apache.log4j.Logger; import org.apache.openmeetings.db.dao.calendar.AppointmentDao; import org.apache.openmeetings.db.entity.calendar.Appointment; import org.apache.openmeetings.db.entity.calendar.MeetingMember; import org.apache.openmeetings.test.AbstractJUnitDefaults; import org.junit.Test; +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; public class TestDatabaseStructureGetAppointmentByRange extends AbstractJUnitDefaults { - private static final Logger log = Logger.getLogger(TestDatabaseStructureGetAppointmentByRange.class); + private static final Logger log = Red5LoggerFactory.getLogger(TestDatabaseStructureGetAppointmentByRange.class, webAppRootKey); + @Autowired private AppointmentDao appointmentDao; @@ -82,7 +85,7 @@ public class TestDatabaseStructureGetApp a3 = appointmentDao.update(a3, userId); int a1found = 0, a2found = 0, a3found = 0; - for (Appointment a : appointmentDao.getAppointmentsByRange(userId, rangeStart.getTime(), rangeEnd.getTime())) { + for (Appointment a : appointmentDao.getInRange(userId, rangeStart.getTime(), rangeEnd.getTime())) { int mmCount = a.getMeetingMembers() == null ? 0 : a.getMeetingMembers().size(); if (a.getId().equals(a1.getId())) { assertEquals("Inapropriate MeetingMembers count", 0, mmCount); Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetUserStart.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetUserStart.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetUserStart.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureGetUserStart.java Fri Nov 6 06:18:44 2015 @@ -18,21 +18,25 @@ */ package org.apache.openmeetings.test.calendar; -import org.apache.log4j.Logger; +import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; + import org.apache.openmeetings.db.dao.user.UserDao; import org.apache.openmeetings.test.AbstractJUnitDefaults; import org.junit.Test; +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; public class TestDatabaseStructureGetUserStart extends AbstractJUnitDefaults { - private static final Logger log = Logger.getLogger(TestDatabaseStructureGetUserStart.class); + private static final Logger log = Red5LoggerFactory.getLogger(TestDatabaseStructureGetUserStart.class, webAppRootKey); + @Autowired - private UserDao usersDao; + private UserDao userDao; @Test public void testAddingGroup() { try { - usersDao.get(new Long(1)); + userDao.get(new Long(1)); } catch (Exception err) { log.error("[testAddingGroup]", err); } Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureUsersSearch.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureUsersSearch.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureUsersSearch.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestDatabaseStructureUsersSearch.java Fri Nov 6 06:18:44 2015 @@ -18,49 +18,33 @@ */ package org.apache.openmeetings.test.calendar; -import org.apache.log4j.Logger; -import org.apache.openmeetings.db.dto.basic.SearchResult; +import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; + +import java.util.List; + +import org.apache.openmeetings.db.dao.user.UserDao; import org.apache.openmeetings.db.entity.user.User; -import org.apache.openmeetings.service.user.UserManager; import org.apache.openmeetings.test.AbstractJUnitDefaults; import org.junit.Test; +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; - public class TestDatabaseStructureUsersSearch extends AbstractJUnitDefaults { - @Autowired - private UserManager userManager; + private static final Logger log = Red5LoggerFactory.getLogger(TestDatabaseStructureUsersSearch.class, webAppRootKey); - private static final Logger log = Logger.getLogger(TestDatabaseStructureUsersSearch.class); + @Autowired + private UserDao userDao; @Test public void testAddingGroup(){ - try { - - SearchResult<User> users = userManager.getAllUserByRange("first", 0, 10, "orderby", true); - log.debug("[result]" + users.getResult().size()); - log.debug("[records]"+ users.getRecords()); - - //GroupMemberDaoImpl.getInstance().addGroupMember("Ad", "dir", Calendar.getInstance().getTime(), "1", "2", "interpol155", 1L, 1L); - //GroupMemberDaoImpl.getInstance().addGroupMember(firstname, lastname, age, memberStatus, appointmentStatus, password, adresses_id, appointmentId); - - //GroupMemberDaoImpl.getInstance().getGroupMemberById(1L); - //GroupMemberDaoImpl.getInstance().deleteGroupMember(2L); - //GroupMemberDaoImpl.getInstance().updateGroupMember(1L, "Eugen", "Schwert", Calendar.getInstance().getTime(), "1", "2", "interpol155", 1L, 1L); + List<User> users = userDao.get("first", 0, 10, "lastname", false, 1); + log.debug("[result]" + users.size()); + log.debug("[records]"+ users); } catch (Exception err) { - log.error("[testAddingGroup]",err); - } - - - - - } - - - } Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestGetAppointment.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestGetAppointment.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestGetAppointment.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestGetAppointment.java Fri Nov 6 06:18:44 2015 @@ -18,20 +18,22 @@ */ package org.apache.openmeetings.test.calendar; +import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.util.Calendar; -import org.apache.log4j.Logger; import org.apache.openmeetings.db.dao.calendar.AppointmentDao; import org.apache.openmeetings.db.entity.calendar.Appointment; import org.apache.openmeetings.test.AbstractJUnitDefaults; import org.junit.Test; +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; public class TestGetAppointment extends AbstractJUnitDefaults { - private static final Logger log = Logger.getLogger(TestGetAppointment.class); + private static final Logger log = Red5LoggerFactory.getLogger(TestGetAppointment.class, webAppRootKey); @Autowired private AppointmentDao appointmentDao; Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestSendIcalMessage.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestSendIcalMessage.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestSendIcalMessage.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/calendar/TestSendIcalMessage.java Fri Nov 6 06:18:44 2015 @@ -18,6 +18,8 @@ */ package org.apache.openmeetings.test.calendar; +import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -62,7 +64,6 @@ import net.fortuna.ical4j.util.UidGenera import org.apache.openmeetings.db.dao.basic.ConfigurationDao; import org.apache.openmeetings.test.AbstractJUnitDefaults; -import org.apache.openmeetings.util.OpenmeetingsVariables; import org.apache.openmeetings.util.mail.ByteArrayDataSource; import org.apache.openmeetings.util.mail.IcalHandler; import org.apache.openmeetings.util.mail.SmtpAuthenticator; @@ -72,10 +73,7 @@ import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; public class TestSendIcalMessage extends AbstractJUnitDefaults { - - private static final Logger log = Red5LoggerFactory.getLogger( - TestAppointmentSchedulerTask.class, - OpenmeetingsVariables.webAppRootKey); + private static final Logger log = Red5LoggerFactory.getLogger(TestSendIcalMessage.class, webAppRootKey); @Autowired private ConfigurationDao configurationDao; @@ -132,7 +130,7 @@ public class TestSendIcalMessage extends meeting.getProperties().add(uid); } catch (SocketException e) { // TODO Auto-generated catch block - e.printStackTrace(); + log.error("Error", e); } // add attendees.. @@ -175,18 +173,12 @@ public class TestSendIcalMessage extends sendIcalMessage(); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + log.error("Error", e); } catch (ValidationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + log.error("Error", e); } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + log.error("Error", e); } - - - } Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestAddGroup.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestAddGroup.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestAddGroup.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestAddGroup.java Fri Nov 6 06:18:44 2015 @@ -18,9 +18,9 @@ */ package org.apache.openmeetings.test.domain; +import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; import static org.junit.Assert.assertNotNull; -import org.apache.log4j.Logger; import org.apache.openmeetings.db.dao.user.OrganisationDao; import org.apache.openmeetings.db.dao.user.UserDao; import org.apache.openmeetings.db.entity.user.Organisation; @@ -28,22 +28,24 @@ import org.apache.openmeetings.db.entity import org.apache.openmeetings.db.entity.user.User; import org.apache.openmeetings.test.AbstractJUnitDefaults; import org.junit.Test; +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; public class TestAddGroup extends AbstractJUnitDefaults { + private static final Logger log = Red5LoggerFactory.getLogger(TestAddGroup.class, webAppRootKey); + @Autowired private OrganisationDao orgDao; @Autowired private UserDao usersDao; - private static final Logger log = Logger.getLogger(TestAddGroup.class); - @Test public void testAddingGroup() { Organisation o = new Organisation(); o.setName("default"); o = orgDao.update(o, null); - assertNotNull("Id of organisation created should not be null", o.getOrganisation_id()); + assertNotNull("Id of organisation created should not be null", o.getId()); User us = usersDao.get(1L); assertNotNull("User should exist", us); @@ -53,6 +55,6 @@ public class TestAddGroup extends Abstra us = usersDao.update(us, null); log.error(us.getLastname()); - log.error(us.getAdresses().getTown()); + log.error(us.getAddress().getTown()); } } Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestUserGroupAggregation.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestUserGroupAggregation.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestUserGroupAggregation.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/domain/TestUserGroupAggregation.java Fri Nov 6 06:18:44 2015 @@ -18,19 +18,21 @@ */ package org.apache.openmeetings.test.domain; +import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import org.apache.log4j.Logger; import org.apache.openmeetings.db.dao.user.UserDao; import org.apache.openmeetings.db.entity.user.Organisation_Users; import org.apache.openmeetings.db.entity.user.User; import org.apache.openmeetings.test.AbstractJUnitDefaults; import org.junit.Test; +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; public class TestUserGroupAggregation extends AbstractJUnitDefaults { - private static final Logger log = Logger.getLogger(TestUserGroupAggregation.class); + private static final Logger log = Red5LoggerFactory.getLogger(TestUserGroupAggregation.class, webAppRootKey); @Autowired private UserDao userDao; @@ -43,7 +45,7 @@ public class TestUserGroupAggregation ex assertTrue("Default user must belong to at least one organisation", u.getOrganisation_users().size() > 0); for (Organisation_Users orgUserObj : u.getOrganisation_users()) { - log.error("testitNow: organisation Id: '" + orgUserObj.getOrganisation().getOrganisation_id() + "'; name: '" + orgUserObj.getOrganisation().getName() + "'"); + log.error("testitNow: organisation Id: '" + orgUserObj.getOrganisation().getId() + "'; name: '" + orgUserObj.getOrganisation().getName() + "'"); } } } Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/invitiation/TestInvitation.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/invitiation/TestInvitation.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/invitiation/TestInvitation.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/invitiation/TestInvitation.java Fri Nov 6 06:18:44 2015 @@ -24,6 +24,7 @@ import java.util.Date; import org.apache.openmeetings.core.remote.InvitationService; import org.apache.openmeetings.core.remote.MainService; import org.apache.openmeetings.db.dao.user.UserDao; +import org.apache.openmeetings.db.dto.basic.ServiceResult; import org.apache.openmeetings.db.entity.server.Sessiondata; import org.apache.openmeetings.db.entity.user.User; import org.apache.openmeetings.test.AbstractJUnitDefaults; @@ -46,11 +47,11 @@ public class TestInvitation extends Abst public void testSendInvitationLink() throws ServiceException { Sessiondata sessionData = mService.getsessiondata(); - Long uid = userWebService.loginUser(sessionData.getSession_id(), username, userpass); - User us = userDao.get(uid); + ServiceResult sr = userWebService.login(username, userpass); + User us = userDao.get(sr.getCode()); String date = new SimpleDateFormat("dd.MM.yyyy").format(new Date()); - invitationService.sendInvitationHash(sessionData.getSession_id(), "Testname", "Testlastname", "message", "[email protected]", + invitationService.sendInvitationHash(sessionData.getSessionId(), "Testname", "Testlastname", "message", "[email protected]", "subject", 1L, "", false, "", 1, date, "12:00", date, "14:00", 1L, us.getTimeZoneId(), true); } } Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/library/TestFileParser.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/library/TestFileParser.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/library/TestFileParser.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/library/TestFileParser.java Fri Nov 6 06:18:44 2015 @@ -18,16 +18,18 @@ */ package org.apache.openmeetings.test.library; -import org.apache.log4j.Logger; +import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; + import org.apache.openmeetings.core.documents.LibraryWmlLoader; import org.apache.openmeetings.test.AbstractJUnitDefaults; import org.junit.Test; +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; - public class TestFileParser extends AbstractJUnitDefaults { - - private static final Logger log = Logger.getLogger(TestFileParser.class); + private static final Logger log = Red5LoggerFactory.getLogger(TestFileParser.class, webAppRootKey); + @Autowired private LibraryWmlLoader libraryWmlLoader; Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestHashMapSession.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestHashMapSession.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestHashMapSession.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/session/TestHashMapSession.java Fri Nov 6 06:18:44 2015 @@ -68,7 +68,7 @@ public class TestHashMapSession extends rcm.setSwfurl("swfUrl"); rcm.setIsMod(new Boolean(false)); rcm.setCanDraw(new Boolean(false)); - rcm.setIsAVClient(false); + rcm.setAvClient(false); if (cache.containsKey(null, streamId)) { log.error("Tried to add an existing Client " + streamId); Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestStateToLower.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestStateToLower.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestStateToLower.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestStateToLower.java Fri Nov 6 06:18:44 2015 @@ -34,15 +34,15 @@ public class TestStateToLower extends Ab @Test public void doTestQuery() { - State state_alabania = stateDao.getStateByName("Albania"); + State state_alabania = stateDao.get("Albania"); - State state_alabania_lower = stateDao.getStateByName("albaNia"); + State state_alabania_lower = stateDao.get("albaNia"); assertTrue(state_alabania != null); assertTrue(state_alabania_lower != null); - assertTrue(state_alabania.getState_id().equals(3L)); - assertTrue(state_alabania_lower.getState_id().equals(3L)); - assertTrue(state_alabania.getState_id().equals(state_alabania_lower.getState_id())); + assertTrue(state_alabania.getId().equals(3L)); + assertTrue(state_alabania_lower.getId().equals(3L)); + assertTrue(state_alabania.getId().equals(state_alabania_lower.getId())); } Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserContact.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserContact.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserContact.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserContact.java Fri Nov 6 06:18:44 2015 @@ -53,9 +53,9 @@ public class TestUserContact extends Abs User u = getUser(rnd); u.getOrganisation_users().add(new Organisation_Users(orgDao.get(1L))); u = userDao.update(u, null); - assertTrue("Password should be set as expected", userDao.verifyPassword(u.getUser_id(), "pass" + rnd)); + assertTrue("Password should be set as expected", userDao.verifyPassword(u.getId(), "pass" + rnd)); - User u1 = userDao.get(u.getUser_id()); + 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.getOrganisation_users()); assertFalse("Just created user should have not empty org-users", u1.getOrganisation_users().isEmpty()); @@ -65,7 +65,7 @@ public class TestUserContact extends Abs public void createUser() throws Exception { int rnd = random.nextInt(); User u = createUser(rnd); - assertTrue("Password should be set as expected", userDao.verifyPassword(u.getUser_id(), "pass" + rnd)); + assertTrue("Password should be set as expected", userDao.verifyPassword(u.getId(), "pass" + rnd)); } @Test @@ -77,7 +77,7 @@ public class TestUserContact extends Abs assertFalse("User list should not be empty ", users.isEmpty()); User contact = createUserContact(random.nextInt(), getUserId()); - String email = contact.getAdresses().getEmail(); + 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); @@ -93,13 +93,13 @@ public class TestUserContact extends Abs User u = createUser(random.nextInt()); User u1 = createUser(random.nextInt()); - contact = createUserContact(random.nextInt(), u.getUser_id()); - email = contact.getAdresses().getEmail(); + contact = createUserContact(random.nextInt(), 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.getUser_id()); + 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.getUser_id()); + userDao.delete(contact, u.getId()); l = userDao.get(email, false, 0, 9999); assertTrue("Contact list should be empty after deletion", l.isEmpty()); } Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserCount.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserCount.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserCount.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserCount.java Fri Nov 6 06:18:44 2015 @@ -43,14 +43,14 @@ public class TestUserCount extends Abstr @Test public void testCountFilteredUsres() throws Exception { User u = createUser(random.nextInt()); - User contact = createUserContact(random.nextInt(), u.getUser_id()); - assertTrue("Account of filtered user should be one", userDao.count(contact.getFirstname(), true, u.getUser_id()) == 1); + User contact = createUserContact(random.nextInt(), u.getId()); + assertTrue("Account of filtered user should be one", userDao.count(contact.getFirstname(), true, u.getId()) == 1); } @Test public void testCountUnfilteredUsres() throws Exception { User u = createUser(random.nextInt()); - createUserContact(random.nextInt(), u.getUser_id()); + createUserContact(random.nextInt(), u.getId()); assertTrue("Account of unfiltered should be more then one", userDao.count("firstname", false, getUserId()) > 1); } Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserOrganisation.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserOrganisation.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserOrganisation.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/user/TestUserOrganisation.java Fri Nov 6 06:18:44 2015 @@ -58,19 +58,19 @@ public class TestUserOrganisation extend @Test public void getUsersByOrganisationId() { User u = getValidUser(); - Long orgId = u.getOrganisation_users().get(0).getOrganisation().getOrganisation_id(); + Long orgId = u.getOrganisation_users().get(0).getOrganisation().getId(); List<Organisation_Users> ul = orgUserDao.get(orgId, 0, 9999); assertTrue("Default Organisation should contain at least 1 user: " + ul.size(), ul.size() > 0); - Organisation_Users ou = orgUserDao.getByOrganizationAndUser(orgId, u.getUser_id()); - assertNotNull("Unable to found [organisation, user] pair - [" + orgId + "," + u.getUser_id() + "]", ou); + Organisation_Users ou = orgUserDao.getByOrganizationAndUser(orgId, u.getId()); + assertNotNull("Unable to found [organisation, user] pair - [" + orgId + "," + u.getId() + "]", ou); } @Test public void addOrganisation() { Organisation o = new Organisation(); o.setName(ORG_NAME); - Long orgId = orgDao.update(o, null).getOrganisation_id(); //inserted by not checked + Long orgId = orgDao.update(o, null).getId(); //inserted by not checked assertNotNull("New Organisation have valid id", orgId); List<Organisation_Users> ul = orgUserDao.get(orgId, 0, 9999); Modified: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/userdata/TestAuth.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/userdata/TestAuth.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/userdata/TestAuth.java (original) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/userdata/TestAuth.java Fri Nov 6 06:18:44 2015 @@ -33,7 +33,7 @@ public class TestAuth extends AbstractJU public void testTestAuth() { Sessiondata sessionData = mService.getsessiondata(); - System.out.println("sessionData: " + sessionData.getSession_id()); + System.out.println("sessionData: " + sessionData.getSessionId()); String tTemp = ManageCryptStyle.getInstanceOfCrypt().createPassPhrase("test"); Added: openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/UserServiceTest.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/UserServiceTest.java?rev=1712911&view=auto ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/UserServiceTest.java (added) +++ openmeetings/branches/3.1.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/UserServiceTest.java Fri Nov 6 06:18:44 2015 @@ -0,0 +1,41 @@ +/* + * 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.webservice; + +import static org.junit.Assert.assertNotNull; + +import org.apache.cxf.jaxrs.client.WebClient; +import org.apache.openmeetings.db.dto.basic.ServiceResult; +import org.apache.openmeetings.test.AbstractJUnitDefaults; +import org.junit.Test; + +public class UserServiceTest extends AbstractJUnitDefaults { + public final static String BASE_SERVICES_URL = "http://localhost:5080/openmeetings/services"; + public final static String USER_SERVICE_URL = BASE_SERVICES_URL + "/user"; + + protected static WebClient getClient(String url) { + return WebClient.create(url).accept("application/json").type("application/json"); + } + + @Test + public void loginTest() { + ServiceResult r = getClient(USER_SERVICE_URL).path("/login").query("user", username).query("pass", userpass).get(ServiceResult.class); + assertNotNull(r); + } +} Modified: openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/CalendarWebService.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/CalendarWebService.java?rev=1712911&r1=1712910&r2=1712911&view=diff ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/CalendarWebService.java (original) +++ openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/CalendarWebService.java Fri Nov 6 06:18:44 2015 @@ -20,28 +20,30 @@ package org.apache.openmeetings.webservi import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; -import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Set; -import org.apache.openmeetings.db.dao.calendar.AppointmentCategoryDao; +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.calendar.AppointmentDao; -import org.apache.openmeetings.db.dao.calendar.AppointmentReminderTypDao; -import org.apache.openmeetings.db.dao.room.RoomTypeDao; import org.apache.openmeetings.db.dao.server.SessiondataDao; import org.apache.openmeetings.db.dao.user.UserDao; -import org.apache.openmeetings.db.dto.calendar.AppointmentCategoryDTO; import org.apache.openmeetings.db.dto.calendar.AppointmentDTO; -import org.apache.openmeetings.db.dto.calendar.AppointmentReminderTypeDTO; import org.apache.openmeetings.db.entity.calendar.Appointment; -import org.apache.openmeetings.db.entity.calendar.AppointmentReminderTyps; -import org.apache.openmeetings.db.entity.calendar.MeetingMember; -import org.apache.openmeetings.db.entity.user.User; import org.apache.openmeetings.db.entity.user.User.Right; import org.apache.openmeetings.db.util.AuthLevelUtil; -import org.apache.openmeetings.service.calendar.AppointmentLogic; import org.apache.openmeetings.webservice.error.ServiceException; import org.red5.logging.Red5LoggerFactory; import org.slf4j.Logger; @@ -54,373 +56,247 @@ import org.springframework.beans.factory * @webservice CalendarService * */ +@WebService(serviceName="org.apache.openmeetings.webservice.CalendarWebService") +@Features(features = "org.apache.cxf.feature.LoggingFeature") +@Produces({MediaType.APPLICATION_JSON}) +@Path("/calendar") public class CalendarWebService { private static final Logger log = Red5LoggerFactory.getLogger(CalendarWebService.class, webAppRootKey); @Autowired private AppointmentDao appointmentDao; @Autowired - private AppointmentLogic appointmentLogic; - @Autowired - private SessiondataDao sessiondataDao; + private SessiondataDao sessionDao; @Autowired private UserDao userDao; - @Autowired - private AppointmentCategoryDao appointmentCategoryDao; - @Autowired - private AppointmentReminderTypDao appointmentReminderTypDao; - @Autowired - private RoomTypeDao roomTypeDao; - private List<AppointmentDTO> getAppointments(List<Appointment> list) { - List<AppointmentDTO> result = new ArrayList<>(list.size()); - for (Appointment a : list) { - result.add(new AppointmentDTO(a)); - } - return result; - } - /** * Load appointments by a start / end range for the current SID * - * @param SID + * @param sid * The SID of the User. This SID must be marked as Loggedin - * @param starttime - * start time, yyyy-mm-dd - * @param endtime - * end time, yyyy-mm-dd + * @param start + * start time + * @param end + * end time * * @return - list of appointments in range + * @throws {@link ServiceException} in case of any error */ - public List<AppointmentDTO> getAppointmentByRange(String SID, Calendar starttime, Calendar endtime) { - log.debug("getAppointmentByRange : startdate - " + starttime.getTime() + ", enddate - " + endtime.getTime()); - try { - Long users_id = sessiondataDao.checkSession(SID); - if (AuthLevelUtil.hasUserLevel(userDao.getRights(users_id))) { - return getAppointments(appointmentDao.getAppointmentsByRange(users_id, starttime.getTime(), endtime.getTime())); + @GET + @Path("/{start}/{end}") + public List<AppointmentDTO> range(@QueryParam("sid") @WebParam(name="sid") String sid + , @PathParam("start") @WebParam(name="start") Calendar start + , @PathParam("end") @WebParam(name="end") Calendar end + ) throws ServiceException + { + log.debug("range : startdate - " + start.getTime() + ", enddate - " + end.getTime()); + try { + Long userId = sessionDao.checkSession(sid); + if (AuthLevelUtil.hasUserLevel(userDao.getRights(userId))) { + return AppointmentDTO.list(appointmentDao.getInRange(userId, start.getTime(), end.getTime())); + } else { + throw new ServiceException("Insufficient permissins"); //TODO code -26 } + } catch (ServiceException err) { + throw err; } catch (Exception err) { - log.error("[getAppointmentByRange]", err); + log.error("[range]", err); + throw new ServiceException(err.getMessage()); } - return null; } /** * Load appointments by a start / end range for the userId * - * @param SID + * @param sid * The SID of the User. This SID must be marked as Loggedin - * @param userId + * @param userid * the userId the calendar events should be loaded - * @param starttime - * start time, yyyy-mm-dd - * @param endtime - * end time, yyyy-mm-dd + * @param start + * start time + * @param end + * end time * * @return - list of appointments in range + * @throws {@link ServiceException} in case of any error */ - public List<AppointmentDTO> getAppointmentByRangeForUserId(String SID, long userId, Calendar starttime, Calendar endtime) { - log.debug("getAppointmentByRangeForUserId : startdate - " + starttime.getTime() + ", enddate - " + endtime.getTime()); - try { - Long users_id = sessiondataDao.checkSession(SID); - if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(users_id))) { - return getAppointments(appointmentDao.getAppointmentsByRange(userId, starttime.getTime(), endtime.getTime())); + @GET + @Path("/{userid}/{start}/{end}") + public List<AppointmentDTO> rangeForUser( + @QueryParam("sid") @WebParam(name="sid") String sid + , @PathParam("userid") @WebParam(name="userid") long userid + , @PathParam("start") @WebParam(name="start") Calendar start + , @PathParam("end") @WebParam(name="end") Calendar end + ) throws ServiceException + { + log.debug("rangeForUser : startdate - " + start.getTime() + ", enddate - " + end.getTime()); + try { + Long authUserId = sessionDao.checkSession(sid); + if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(authUserId))) { + return AppointmentDTO.list(appointmentDao.getInRange(userid, start.getTime(), end.getTime())); + } else { + throw new ServiceException("Insufficient permissins"); //TODO code -26 } + } catch (ServiceException err) { + throw err; } catch (Exception err) { - log.error("[getAppointmentByRangeForUserId]", err); + log.error("[rangeForUser]", err); + throw new ServiceException(err.getMessage()); } - return null; } /** * Get the next Calendar event for the current user of the SID * - * @param SID + * @param sid * The SID of the User. This SID must be marked as Loggedin * @return - next Calendar event + * @throws {@link ServiceException} in case of any error */ - public AppointmentDTO getNextAppointment(String SID) { - try { - Long users_id = sessiondataDao.checkSession(SID); - if (AuthLevelUtil.hasUserLevel(userDao.getRights(users_id))) { - return new AppointmentDTO(appointmentDao.getNextAppointment(users_id, new Date())); + @GET + @Path("/next") + public AppointmentDTO next(@QueryParam("sid") @WebParam(name="sid") String sid) throws ServiceException { + try { + Long userId = sessionDao.checkSession(sid); + if (AuthLevelUtil.hasUserLevel(userDao.getRights(userId))) { + return new AppointmentDTO(appointmentDao.getNext(userId, new Date())); + } else { + throw new ServiceException("Insufficient permissins"); //TODO code -26 } + } catch (ServiceException err) { + throw err; } catch (Exception err) { - log.error("[getNextAppointmentById]", err); + log.error("[next]", err); + throw new ServiceException(err.getMessage()); } - return null; - } /** * Get the next Calendar event for userId * - * @param SID + * @param sid * The SID of the User. This SID must be marked as Loggedin + * @param userid + * the userId the calendar events should be loaded * * @return - next Calendar event + * @throws {@link ServiceException} in case of any error */ - public AppointmentDTO getNextAppointmentForUserId(String SID, long userId) { - try { - Long users_id = sessiondataDao.checkSession(SID); - if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(users_id))) { - return new AppointmentDTO(appointmentDao.getNextAppointment(userId, new Date())); + @GET + @Path("/next/{userid}") + public AppointmentDTO nextForUser(@QueryParam("sid") @WebParam(name="sid") String sid, @PathParam("userid") @WebParam(name="userid") long userid) throws ServiceException { + try { + Long authUserId = sessionDao.checkSession(sid); + if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(authUserId))) { + return new AppointmentDTO(appointmentDao.getNext(userid, new Date())); + } else { + throw new ServiceException("Insufficient permissins"); //TODO code -26 } + } catch (ServiceException err) { + throw err; } catch (Exception err) { - log.error("[getNextAppointmentById]", err); + log.error("[nextForUser]", err); + throw new ServiceException(err.getMessage()); } - return null; - } /** - * Search a calendar event for the current SID * - * @param SID - * The SID of the User. This SID must be marked as Loggedin - * @param appointmentName - * the search string - * - * @return - calendar event list - */ - public List<AppointmentDTO> searchAppointmentByTitle(String SID, String appointmentName) { - try { - Long users_id = sessiondataDao.checkSession(SID); - if (AuthLevelUtil.hasUserLevel(userDao.getRights(users_id))) { - return getAppointments(appointmentDao.searchAppointmentsByTitle(users_id, appointmentName)); - } - } catch (Exception err) { - log.error("[searchAppointmentByName]", err); - } - return null; - - } - - /** - * Save an appointment + * Load a calendar event by its room id * - * @param SID - * The SID of the User. This SID must be marked as Loggedin - * @param appointmentName - * name of the calendar event - * @param appointmentLocation - * location info text of the calendar event - * @param appointmentDescription - * description test of the calendar event - * @param appointmentstart - * start as Date yyyy-mm-ddThh:mm:ss - * @param appointmentend - * end as Date yyyy-mm-ddThh:mm:ss - * @param isDaily - * if the calendar event should be repeated daily (not - * implemented) - * @param isWeekly - * if the calendar event should be repeated weekly (not - * implemented) - * @param isMonthly - * if the calendar event should be repeated monthly (not - * implemented) - * @param isYearly - * if the calendar event should be repeated yearly (not - * implemented) - * @param categoryId - * the category id of the calendar event - * @param remind - * the reminder type of the calendar event - * @param mmClient - * List of clients, comma separated string, <br/> - * sample: '1,firstname,lastname,[email protected],1,Etc/GMT+1' - * to add multiple clients you can use the same GET parameter in - * the URL multiple times, for example: - * &mmClient='1,firstname,lastname,[email protected],1,Etc/GMT+1'&mmClient='2,firstname,lastname,[email protected],1,Etc/GMT+1' - * (Please NOTE mmClient value is enclosed in single quotes) - * @param roomType - * the room type for the calendar event - * @param languageId - * the language id of the calendar event, notification emails - * will be send in this language - * @param isPasswordProtected - * if the room is password protected - * @param password - * the password for the room - * - * @return - id of appointment saved + * @param sid + * @param roomid + * @return - calendar event by its room id + * @throws {@link ServiceException} in case of any error */ - public Long saveAppointment(String SID, String appointmentName, - String appointmentLocation, String appointmentDescription, - Calendar appointmentstart, Calendar appointmentend, - Boolean isDaily, Boolean isWeekly, Boolean isMonthly, - Boolean isYearly, Long categoryId, Long remind, String[] mmClient, - Long roomType, Long languageId, - Boolean isPasswordProtected, String password, long roomId) { - //Seems to be create - log.debug("saveAppointMent SID:" + SID); - - try { - Long users_id = sessiondataDao.checkSession(SID); - log.debug("saveAppointMent users_id:" + users_id); - - if (AuthLevelUtil.hasUserLevel(userDao.getRights(users_id))) { - Appointment a = appointmentLogic.getAppointment(appointmentName, appointmentLocation, appointmentDescription, - appointmentstart, appointmentend, isDaily, isWeekly, isMonthly, isYearly, categoryId, remind, - mmClient, roomType, languageId, isPasswordProtected, password, roomId, users_id); - return appointmentDao.update(a, users_id).getId(); + @GET + @Path("/room/{roomid}") + public AppointmentDTO getByRoom(@QueryParam("sid") @WebParam(name="sid") String sid, @PathParam("roomid") @WebParam(name="roomid") long roomid) throws ServiceException { + try { + Long userId = sessionDao.checkSession(sid); + if (AuthLevelUtil.hasUserLevel(userDao.getRights(userId))) { + Appointment app = appointmentDao.getByRoom(userId, roomid); + if (app != null) { + return new AppointmentDTO(app); + } } else { - log.error("saveAppointment : wrong user level"); + throw new ServiceException("Insufficient permissins"); //TODO code -26 } + } catch (ServiceException err) { + throw err; } catch (Exception err) { - log.error("[saveAppointment]", err); + log.error("[getByRoom]", err); + throw new ServiceException(err.getMessage()); } return null; - } /** - * Update an calendar event time only + * Search a calendar event for the current SID * - * @param SID + * @param sid * The SID of the User. This SID must be marked as Loggedin - * @param appointmentId - * the calendar event that should be updated - * @param appointmentstart - * start yyyy-mm-dd - * @param appointmentend - * end yyyy-mm-dd - * @param languageId - * the language id + * @param title + * the search string * - * @return - id of appointment updated + * @return - calendar event list + * @throws {@link ServiceException} in case of any error */ - public Long updateAppointmentTimeOnly(String SID, Long appointmentId, Date appointmentstart, Date appointmentend, Long languageId) { - try { - Long users_id = sessiondataDao.checkSession(SID); - Set<Right> rights = userDao.getRights(users_id); - if (AuthLevelUtil.hasUserLevel(rights)) { - Appointment a = appointmentDao.get(appointmentId); - if (!AuthLevelUtil.hasAdminLevel(rights) && !a.getOwner().getUser_id().equals(users_id)) { - throw new ServiceException("The Appointment cannot be updated by the given user"); - } - if (!a.getStart().equals(appointmentstart) || !a.getEnd().equals(appointmentend)) { - a.setStart(appointmentstart); - a.setEnd(appointmentend); - //FIXME this might change the owner!!!!! - return appointmentDao.update(a, users_id).getId(); - } + @GET + @Path("/title/{title}") + public List<AppointmentDTO> getByTitle(@QueryParam("sid") @WebParam(name="sid") String sid, @PathParam("title") @WebParam(name="title") String title) throws ServiceException { + try { + Long userId = sessionDao.checkSession(sid); + if (AuthLevelUtil.hasUserLevel(userDao.getRights(userId))) { + return AppointmentDTO.list(appointmentDao.searchAppointmentsByTitle(userId, title)); + } else { + throw new ServiceException("Insufficient permissins"); //TODO code -26 } + } catch (ServiceException err) { + throw err; } catch (Exception err) { - log.error("[updateAppointment]", err); + log.error("[getByTitle]", err); + throw new ServiceException(err.getMessage()); } - return null; - } /** * Save an appointment * - * @param SID + * @param sid * The SID of the User. This SID must be marked as Loggedin - * @param appointmentId - * the id to update - * @param appointmentName - * name of the calendar event - * @param appointmentLocation - * location info text of the calendar event - * @param appointmentDescription - * description test of the calendar event - * @param appointmentstart - * start as Date yyyy-mm-ddThh:mm:ss - * @param appointmentend - * end as Date yyyy-mm-ddThh:mm:ss - * @param isDaily - * if the calendar event should be repeated daily (not - * implemented) - * @param isWeekly - * if the calendar event should be repeated weekly (not - * implemented) - * @param isMonthly - * if the calendar event should be repeated monthly (not - * implemented) - * @param isYearly - * if the calendar event should be repeated yearly (not - * implemented) - * @param categoryId - * the category id of the calendar event - * @param remind - * the reminder type of the calendar event - * @param mmClient - * List of clients, comma separated string, <br/> - * sample: '1,firstname,lastname,[email protected],1,Etc/GMT+1' - * to add multiple clients you can use the same GET parameter in - * the URL multiple times, for example: - * &mmClient='1,firstname,lastname,[email protected],1,Etc/GMT+1'&mmClient='2,firstname,lastname,[email protected],1,Etc/GMT+1' - * (Please NOTE mmClient value is enclosed in single quotes) - * @param roomType - * the room type for the calendar event - * @param languageId - * the language id of the calendar event, notification emails - * will be send in this language - * @param isPasswordProtected - * if the room is password protected - * @param password - * the password for the room + * @param appointment + * calendar event * - * @return - id of appointment updated + * @return - appointment saved + * @throws {@link ServiceException} in case of any error */ - public Long updateAppointment(String SID, Long appointmentId, - String appointmentName, String appointmentLocation, - String appointmentDescription, Calendar appointmentstart, - Calendar appointmentend, Boolean isDaily, Boolean isWeekly, - Boolean isMonthly, Boolean isYearly, Long categoryId, Long remind, - String[] mmClient, Long roomType, Long languageId, - Boolean isPasswordProtected, String password) throws ServiceException { - try { + @POST + @Path("/") //TODO FIXME update is also here for now + public AppointmentDTO save(@QueryParam("sid") @WebParam(name="sid") String sid, @QueryParam("appointment") @WebParam(name="appointment") AppointmentDTO appointment) throws ServiceException { + //Seems to be create + log.debug("save SID:" + sid); - Long users_id = sessiondataDao.checkSession(SID); - Set<Right> rights = userDao.getRights(users_id); + try { + Long userId = sessionDao.checkSession(sid); + log.debug("save userId:" + userId); - if (AuthLevelUtil.hasWebServiceLevel(rights) || AuthLevelUtil.hasAdminLevel(rights)) { - // fine - } else if (AuthLevelUtil.hasUserLevel(rights)) { - // check if the appointment belongs to the current user - Appointment a = appointmentDao.get(appointmentId); - if (!a.getOwner().getUser_id().equals(users_id)) { - throw new ServiceException("The Appointment cannot be updated by the given user"); - } + if (AuthLevelUtil.hasUserLevel(userDao.getRights(userId))) { + Appointment a = appointment.get(userDao, appointmentDao); + return new AppointmentDTO(appointmentDao.update(a, userId)); } else { - throw new ServiceException("Not allowed to preform that action, Authenticate the SID first"); - } - - Appointment a = appointmentDao.get(appointmentId); - a.setTitle(appointmentName); - a.setLocation(appointmentLocation); - a.setDescription(appointmentDescription); - a.setStart(appointmentstart.getTime()); - a.setEnd(appointmentend.getTime()); - a.setIsDaily(isDaily); - a.setIsWeekly(isWeekly); - a.setIsMonthly(isMonthly); - a.setIsYearly(isYearly); - a.setCategory(appointmentCategoryDao.get(categoryId)); - a.setRemind(appointmentReminderTypDao.get(remind)); - a.getRoom().setComment(appointmentDescription); - a.getRoom().setName(appointmentName); - a.getRoom().setRoomtype(roomTypeDao.get(roomType)); - a.setOwner(userDao.get(users_id)); - a.setPasswordProtected(isPasswordProtected); - a.setPassword(password); - a.setMeetingMembers(new ArrayList<MeetingMember>()); - for (String singleClient : mmClient) { - MeetingMember mm = appointmentLogic.getMeetingMember(users_id, languageId, singleClient); - mm.setAppointment(a); - a.getMeetingMembers().add(mm); + log.error("save : wrong user level"); + throw new ServiceException("Insufficient permissins"); //TODO code -26 } - return appointmentDao.update(a, users_id).getId(); + } catch (ServiceException err) { + throw err; } catch (Exception err) { - log.error("[updateAppointment]", err); + log.error("[save]", err); throw new ServiceException(err.getMessage()); } } - + /** * * delete a calendar event @@ -430,114 +306,36 @@ public class CalendarWebService { * If the SID is assigned to a simple user, he can only delete appointments * where he is also the owner/creator of the appointment * - * @param SID + * @param sid * an authenticated SID - * @param appointmentId + * @param id * the id to delete - * @param language_id - * the language id in which the notifications for the deleted - * appointment are send - * @return - id of appointment deleted + * @throws {@link ServiceException} in case of any error */ - public Long deleteAppointment(String SID, Long appointmentId, Long language_id) throws ServiceException { + @DELETE + @Path("/{id}") + public void delete(@QueryParam("sid") @WebParam(name="sid") String sid, @PathParam("id") @WebParam(name="id") Long id) throws ServiceException { try { - Long users_id = sessiondataDao.checkSession(SID); - Set<Right> rights = userDao.getRights(users_id); + Long userId = sessionDao.checkSession(sid); + Set<Right> rights = userDao.getRights(userId); - Appointment a = appointmentDao.get(appointmentId); + Appointment a = appointmentDao.get(id); if (AuthLevelUtil.hasWebServiceLevel(rights) || AuthLevelUtil.hasAdminLevel(rights)) { // fine } else if (AuthLevelUtil.hasUserLevel(rights)) { // check if the appointment belongs to the current user - if (!a.getOwner().getUser_id().equals(users_id)) { + if (!a.getOwner().getId().equals(userId)) { throw new ServiceException("The Appointment cannot be updated by the given user"); } } else { throw new ServiceException("Not allowed to preform that action, Authenticate the SID first"); } - appointmentDao.delete(a, users_id); //FIXME check this !!!! - return a.getId(); + appointmentDao.delete(a, userId); + } catch (ServiceException err) { + throw err; } catch (Exception err) { - log.error("[deleteAppointment]", err); + log.error("[delete]", err); throw new ServiceException(err.getMessage()); } } - - /** - * - * Load a calendar event by its room id - * - * @param SID - * @param room_id - * @return - calendar event by its room id - */ - public AppointmentDTO getAppointmentByRoomId(String SID, Long room_id) { - try { - Long users_id = sessiondataDao.checkSession(SID); - if (AuthLevelUtil.hasUserLevel(userDao.getRights(users_id))) { - Appointment appStored = appointmentDao.getAppointmentByRoomId(users_id, room_id); - if (appStored != null) { - return new AppointmentDTO(appStored); - } - } - } catch (Exception err) { - log.error("[getAppointmentByRoomId]", err); - } - return null; - } - - /** - * Get all categories of calendar events - * - * @param SID - * @return - all categories of calendar events - */ - public List<AppointmentCategoryDTO> getAppointmentCategoryList(String SID) { - log.debug("AppointmenetCategoryService.getAppointmentCategoryList SID : " + SID); - - try { - Long users_id = sessiondataDao.checkSession(SID); - - if (AuthLevelUtil.hasUserLevel(userDao.getRights(users_id))) { - return AppointmentCategoryDTO.list(appointmentCategoryDao.getAppointmentCategoryList()); - } else { - log.error("AppointmenetCategoryService.getAppointmentCategoryList : UserLevel Error"); - } - } catch (Exception err) { - log.error("[getAppointmentCategory]", err); - } - return null; - - } - - private List<AppointmentReminderTypeDTO> getReminders(List<AppointmentReminderTyps> list) { - List<AppointmentReminderTypeDTO> result = new ArrayList<>(list.size()); - for (AppointmentReminderTyps rt : list) { - result.add(new AppointmentReminderTypeDTO(rt)); - } - return result; - } - /** - * Get all reminder types for calendar events - * - * @param SID - * @return - all reminder types for calendar events - */ - public List<AppointmentReminderTypeDTO> getAppointmentReminderTypList(String SID) { - log.debug("getAppointmentReminderTypList"); - - try { - Long users_id = sessiondataDao.checkSession(SID); - if (AuthLevelUtil.hasUserLevel(userDao.getRights(users_id))) { - - User user = userDao.get(users_id); - long language_id = (user == null) ? 1 : user.getLanguage_id(); - return getReminders(appointmentReminderTypDao.getAppointmentReminderTypList(language_id)); - } else - log.debug("getAppointmentReminderTypList :error - wrong authlevel!"); - } catch (Exception err) { - log.error("[getAppointmentReminderTypList]", err); - } - return null; - } } Added: openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/ErrorWebService.java URL: http://svn.apache.org/viewvc/openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/ErrorWebService.java?rev=1712911&view=auto ============================================================================== --- openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/ErrorWebService.java (added) +++ openmeetings/branches/3.1.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/ErrorWebService.java Fri Nov 6 06:18:44 2015 @@ -0,0 +1,96 @@ +/* + * 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 javax.jws.WebParam; +import javax.jws.WebService; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.apache.cxf.feature.Features; +import org.apache.openmeetings.db.dao.basic.ErrorDao; +import org.apache.openmeetings.db.dao.label.LabelDao; +import org.apache.openmeetings.db.dto.basic.ServiceResult; +import org.apache.openmeetings.db.entity.basic.ErrorValue; +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * + * The Service contains methods to get localized errors + * + * @author solomax + * @webservice ErrorService + * + */ +@WebService(serviceName="org.apache.openmeetings.webservice.ErrorWebService") +@Features(features = "org.apache.cxf.feature.LoggingFeature") +@Produces({MediaType.APPLICATION_JSON}) +@Path("/error") +public class ErrorWebService { + private static final Logger log = Red5LoggerFactory.getLogger(ErrorWebService.class, webAppRootKey); + + @Autowired + private ErrorDao errorDao; + @Autowired + private LabelDao labelDao; + + /** + * loads an Error-Object. If a Method returns a negative Result, its an + * Error-id, it needs a languageId to specify in which language you want to + * display/read the error-message. English has the Language-ID one, for + * different one see the list of languages + * + * @param id + * the error id (negative Value here!) + * @param lang + * The id of the language + * + * @return - error with the code given + */ + @GET + @Path("/{id}/{lang}") + public ServiceResult get(@WebParam(name="id") @PathParam("id") long id, @WebParam(name="lang") @PathParam("lang") long lang) { + try { + if (id < 0) { + ErrorValue eValues = errorDao.get(-1 * id); + if (eValues != null) { + log.debug("eValues.getLabelId() = " + eValues.getLabelId()); + log.debug("eValues.getErrorType() = " + eValues.getType()); + String eValue = labelDao.getString(eValues.getLabelId(), lang); + String tValue = labelDao.getString("error.type." + eValues.getType().name(), lang); + if (eValue != null) { + return new ServiceResult(id, eValue, tValue); + } + } + } else { + return new ServiceResult(id, "Error ... please check your input", "Error"); + } + } catch (Exception err) { + log.error("[get] ", err); + } + return null; + } +}
