use of org.apache.openmeetings.db.dto.basic.ServiceResult in project openmeetings by apache.
the class TestUserService method invalidLoginTest.
@Test
public void invalidLoginTest() {
ServiceResult r = loginNoCheck("invalid-user", "bad pass");
assertNotNull("Valid ServiceResult should be returned", r);
assertEquals("Login should NOT be successful", Type.ERROR.name(), r.getType());
}
use of org.apache.openmeetings.db.dto.basic.ServiceResult in project openmeetings by apache.
the class TestUserService method hashTest.
@Test
public void hashTest() throws OmException {
ServiceResult r = login();
ServiceResult r1 = getHash(r.getMessage(), false);
assertEquals("OM Call should be successful", Type.SUCCESS.name(), r1.getType());
// to ensure WebSession is attached
ensureApplication(-1L);
WebSession ws = WebSession.get();
assertTrue(ws.signIn(adminUsername, userpass, User.Type.user, null));
Long userId0 = WebSession.getUserId();
ws.checkHashes(StringValue.valueOf(r1.getMessage()), StringValue.valueOf(""));
assertTrue("Login via secure hash should be successful", ws.isSignedIn());
Long userId1 = WebSession.getUserId();
Assert.assertNotEquals(userId0, userId1);
}
use of org.apache.openmeetings.db.dto.basic.ServiceResult in project openmeetings by apache.
the class FileWebService method delete.
/**
* deletes files or folders based on it id
*
* @param sid
* The SID of the User. This SID must be marked as logged in
* @param id
* the id of the file or folder
* @return {@link ServiceResult} with result type
*/
@DELETE
@Path("/{id}")
public ServiceResult delete(@QueryParam("sid") @WebParam(name = "sid") String sid, @PathParam("id") @WebParam(name = "id") Long id) {
FileItem f = fileDao.get(id);
return performCall(sid, sd -> {
Long userId = sd.getUserId();
Set<Right> rights = getRights(userId);
return AuthLevelUtil.hasWebServiceLevel(rights) || (AuthLevelUtil.hasUserLevel(rights) && userId.equals(f.getOwnerId()));
}, sd -> {
if (f == null) {
return new ServiceResult("Bad id", Type.ERROR);
}
fileDao.delete(f);
return new ServiceResult("Deleted", Type.SUCCESS);
});
}
use of org.apache.openmeetings.db.dto.basic.ServiceResult in project openmeetings by apache.
the class FileWebService method deleteExternal.
/**
* deletes a file by its external Id and type
*
* @param sid
* The SID of the User. This SID must be marked as logged in
* @param externalId
* the od of the file or folder
* @param externalType
* the externalType
* @return {@link ServiceResult} with result type
*/
@DELETE
@Path("/{externaltype}/{externalid}")
public ServiceResult deleteExternal(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "externaltype") @PathParam("externaltype") String externalType, @WebParam(name = "externalid") @PathParam("externalid") String externalId) {
return performCall(sid, User.Right.Soap, sd -> {
FileItem f = fileDao.get(externalId, externalType);
fileDao.delete(f);
return new ServiceResult("Deleted", Type.SUCCESS);
});
}
use of org.apache.openmeetings.db.dto.basic.ServiceResult 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);
});
}
Aggregations