use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class TestRecordingService method getExternalUser.
private User getExternalUser() throws Exception {
String uuid = UUID.randomUUID().toString();
User u = getUser(uuid);
u.setExternalType(UNIT_TEST_EXT_TYPE);
u.setExternalId(uuid);
webCreateUser(u);
return u;
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class TestRecordingService method testExternal.
@Test
public void testExternal() throws Exception {
User u = getExternalUser();
Recording r = new Recording();
r.setInsertedBy(u.getId());
r.setComment("Created by Unit Tests");
r.setRoomId(5L);
r = getBean(RecordingDao.class).update(r);
ServiceResult sr = login();
Collection<? extends RecordingDTO> recs = getClient(getRecordUrl()).path("/" + UNIT_TEST_EXT_TYPE).query("sid", sr.getMessage()).getCollection(RecordingDTO.class);
assertNotNull("Valid collection should be returned", recs);
assertFalse("Collection of the recordings should not be empty", recs.isEmpty());
boolean found = false;
for (RecordingDTO rdo : recs) {
if (r.getId().equals(rdo.getId())) {
// TODO check room, user
found = true;
break;
}
}
assertTrue("Just created recording was not found by the service", found);
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class CalendarWebService method save.
/**
* Save an appointment
*
* @param sid
* The SID of the User. This SID must be marked as Loggedin
* @param appointment
* calendar event
*
* @return - appointment saved
*/
@WebMethod
@POST
@Path("/")
public AppointmentDTO save(@QueryParam("sid") @WebParam(name = "sid") String sid, @FormParam("appointment") @WebParam(name = "appointment") AppointmentDTO appointment) {
// Seems to be create
log.debug("save SID: {}", sid);
return performCall(sid, sd -> {
User u = userDao.get(sd.getUserId());
if (!AuthLevelUtil.hasUserLevel(u.getRights())) {
log.error("save: not authorized");
return false;
}
return AuthLevelUtil.hasWebServiceLevel(u.getRights()) || appointment.getOwner() == null || appointment.getOwner().getId().equals(u.getId());
}, sd -> {
User u = userDao.get(sd.getUserId());
Appointment a = appointment.get(userDao, fileDao, dao, u);
if (a.getRoom().getId() != null) {
if (a.getRoom().isAppointment()) {
a.getRoom().setIspublic(false);
} else {
a.setRoom(roomDao.get(a.getRoom().getId()));
}
}
return new AppointmentDTO(dao.update(a, u.getId()));
});
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class GroupWebService method removeUser.
/**
* Remove user from a certain group
*
* @param sid
* The SID from getSession
* @param userid
* the user id
* @param id
* the group id
* @return {@link ServiceResult} with result type, and id of the user added, or error id in case of the error as text
*/
@DELETE
@Path("/{id}/users/{userid}")
public ServiceResult removeUser(@QueryParam("sid") @WebParam(name = "sid") String sid, @PathParam("id") @WebParam(name = "id") Long id, @PathParam("userid") @WebParam(name = "userid") Long userid) {
return performCall(sid, User.Right.Soap, sd -> {
if (groupUserDao.isUserInGroup(id, userid)) {
User u = userDao.get(userid);
for (Iterator<GroupUser> iter = u.getGroupUsers().iterator(); iter.hasNext(); ) {
GroupUser gu = iter.next();
if (id.equals(gu.getGroup().getId())) {
iter.remove();
}
}
userDao.update(u, sd.getUserId());
}
return new ServiceResult(String.valueOf(userid), Type.SUCCESS);
});
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class GroupWebService method getUsers.
/**
* Search users and return them
*
* @param sid
* The SID from getSession
* @param id
* the group id
* @param start
* first record
* @param max
* max records
* @param orderby
* orderby clause
* @param asc
* asc or desc
* @return - users found
*/
@GET
@Path("/users/{id}")
public UserSearchResult getUsers(@QueryParam("sid") @WebParam(name = "sid") String sid, @PathParam("id") @WebParam(name = "id") long id, @QueryParam("start") @WebParam(name = "start") int start, @QueryParam("max") @WebParam(name = "max") int max, @QueryParam("orderby") @WebParam(name = "orderby") String orderby, @QueryParam("asc") @WebParam(name = "asc") boolean asc) {
return performCall(sid, User.Right.Soap, sd -> {
SearchResult<User> result = new SearchResult<>();
result.setObjectName(User.class.getName());
result.setRecords(groupUserDao.count(id));
result.setResult(new ArrayList<User>());
String order = isAlphanumeric(orderby) ? orderby : "id";
for (GroupUser ou : groupUserDao.get(id, null, start, max, order + " " + (asc ? "ASC" : "DESC"))) {
result.getResult().add(ou.getUser());
}
return new UserSearchResult(result);
});
}
Aggregations