Search in sources :

Example 86 with UserVO

use of org.olat.user.restapi.UserVO in project OpenOLAT by OpenOLAT.

the class ImportUserPage method append.

/**
 * Append a line in the form:<br/>
 * Benutzername *	Passwort	Sprache	Vorname *	Nachname *	E-Mail *	Institution	Institutionsnummer	Institutions E-Mail<br/>
 * demo	olat4you	de	Peter	Muster	peter.muster@openolat.org	Universität Zürich	08-123-987	peter.muster@uzh.ch<br/>
 *
 * @param username
 * @param password
 * @param firstName
 * @param lastName
 * @param sb
 */
public UserVO append(String username, String password, String firstName, String lastName, StringBuilder sb) {
    if (sb.length() > 0) {
        sb.append("\\n");
    }
    String email = username.replace("-", "") + "@frentix.com";
    String institution = "frentix GmbH";
    String institutionNumber = "034-" + System.currentTimeMillis();
    String institutionEmail = username.replace("-", "") + "@openolat.org";
    sb.append(username).append("	").append(password).append("	").append("de").append("	").append(firstName).append("	").append(lastName).append("	").append(email).append("	").append(institution).append("	").append(institutionNumber).append("	").append(institutionEmail);
    UserVO userVo = new UserVO();
    userVo.setLogin(username);
    userVo.setFirstName(firstName);
    userVo.setLastName(lastName);
    userVo.setEmail(email);
    return userVo;
}
Also used : UserVO(org.olat.user.restapi.UserVO)

Example 87 with UserVO

use of org.olat.user.restapi.UserVO in project OpenOLAT by OpenOLAT.

the class UserAdminPage method createUserVO.

public static UserVO createUserVO(String username, String firstName, String lastName, String email, String password) {
    UserVO userVo = new UserVO();
    userVo.setLogin(username);
    userVo.setFirstName(firstName);
    userVo.setLastName(lastName);
    userVo.setEmail(email);
    userVo.setPassword(password);
    return userVo;
}
Also used : UserVO(org.olat.user.restapi.UserVO)

Example 88 with UserVO

use of org.olat.user.restapi.UserVO in project OpenOLAT by OpenOLAT.

the class UserRestClient method createUser.

private UserVO createUser(RestConnection restConnection, String name, String role) throws URISyntaxException, IOException {
    String uuid = Integer.toString(counter.incrementAndGet()) + UUID.randomUUID().toString();
    UserVO vo = new UserVO();
    String rndUsername = (name + "-" + uuid).substring(0, 24);
    vo.setLogin(rndUsername.toLowerCase());
    String rndPassword = ("passwd-" + uuid).substring(0, 24);
    vo.setPassword(rndPassword);
    vo.setFirstName(name + "-" + role + "-" + uuid);
    vo.setLastName("Smith");
    vo.setEmail(rndUsername + "@frentix.com");
    vo.putProperty("telOffice", "39847592");
    vo.putProperty("telPrivate", "39847592");
    vo.putProperty("telMobile", "39847592");
    // male or female
    vo.putProperty("gender", "Female");
    vo.putProperty("birthDay", "12/12/2009");
    URI request = getUsersURIBuilder().build();
    HttpPut method = restConnection.createPut(request, MediaType.APPLICATION_JSON, true);
    restConnection.addJsonEntity(method, vo);
    method.addHeader("Accept-Language", "en");
    HttpResponse response = restConnection.execute(method);
    int responseCode = response.getStatusLine().getStatusCode();
    assertTrue(responseCode == 200 || responseCode == 201);
    InputStream body = response.getEntity().getContent();
    UserVO current = restConnection.parse(body, UserVO.class);
    Assert.assertNotNull(current);
    current.setPassword(vo.getPassword());
    return current;
}
Also used : UserVO(org.olat.user.restapi.UserVO) InputStream(java.io.InputStream) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) HttpPut(org.apache.http.client.methods.HttpPut)

Example 89 with UserVO

use of org.olat.user.restapi.UserVO in project openolat by klemens.

the class NotificationsWebService method subscribe.

@PUT
@Path("subscribers")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response subscribe(PublisherVO publisherVO, @Context HttpServletRequest request) {
    if (!isAdmin(request)) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
    NotificationsManager notificationsMgr = NotificationsManager.getInstance();
    BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
    SubscriptionContext subscriptionContext = new SubscriptionContext(publisherVO.getResName(), publisherVO.getResId(), publisherVO.getSubidentifier());
    PublisherData publisherData = new PublisherData(publisherVO.getType(), publisherVO.getData(), publisherVO.getBusinessPath());
    List<UserVO> userVoes = publisherVO.getUsers();
    List<Long> identityKeys = new ArrayList<>();
    for (UserVO userVo : userVoes) {
        identityKeys.add(userVo.getKey());
    }
    List<Identity> identities = securityManager.loadIdentityByKeys(identityKeys);
    notificationsMgr.subscribe(identities, subscriptionContext, publisherData);
    return Response.ok().build();
}
Also used : UserVO(org.olat.user.restapi.UserVO) NotificationsManager(org.olat.core.commons.services.notifications.NotificationsManager) ArrayList(java.util.ArrayList) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Identity(org.olat.core.id.Identity) PublisherData(org.olat.core.commons.services.notifications.PublisherData) BaseSecurity(org.olat.basesecurity.BaseSecurity) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Example 90 with UserVO

use of org.olat.user.restapi.UserVO in project openolat by klemens.

the class PortfolioV2Test method deletePage.

/**
 * A user create a binder with a section and two pages. It deletes
 * one, go to the trash, find the delete page, restore it and go
 * again in the binder. It move a second time the page to the trash
 * and delete it definitively.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void deletePage(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    UserVO author = new UserRestClient(deploymentUrl).createRandomUser("rei");
    loginPage.loginAs(author.getLogin(), author.getPassword()).resume();
    UserToolsPage userTools = new UserToolsPage(browser);
    PortfolioV2HomePage portfolio = userTools.openUserToolsMenu().openPortfolioV2();
    String binderTitle = "Binder del " + UUID.randomUUID();
    BinderPage binder = portfolio.openMyBinders().createBinder(binderTitle, "A binder where I want to delete some pages");
    String sectionTitle = "Section one " + UUID.randomUUID();
    binder.selectEntries().createSection(sectionTitle).assertOnSectionTitleInEntries(sectionTitle);
    String pageTitle = "Page two " + UUID.randomUUID();
    String pageToDelete = "Page del " + UUID.randomUUID();
    binder.createEntry(pageToDelete).assertOnPage(pageToDelete).selectEntries().createEntry(pageTitle).assertOnPage(pageTitle).selectTableOfContent().selectEntryInToc(pageToDelete).moveEntryToTrash().assertOnPageInToc(pageTitle).assertOnPageNotInToc(pageToDelete);
    EntriesPage trash = portfolio.clickToolbarBack().clickToolbarBack().openDeletedEntries();
    trash.assertOnPage(pageToDelete).switchTableView().restore(pageToDelete, binderTitle, sectionTitle);
    portfolio.clickToolbarBack().openMyBinders().selectBinder(binderTitle).assertOnPageInToc(pageToDelete).selectEntryInToc(pageToDelete).moveEntryToTrash();
    trash = portfolio.clickToolbarBack().clickToolbarBack().openDeletedEntries();
    trash.switchTableView().assertOnPageTableView(pageToDelete).switchTableView().selectPageInTableView(pageToDelete).deleteEntry().assertEmptyTableView();
}
Also used : UserToolsPage(org.olat.selenium.page.user.UserToolsPage) EntriesPage(org.olat.selenium.page.portfolio.EntriesPage) UserVO(org.olat.user.restapi.UserVO) PortfolioV2HomePage(org.olat.selenium.page.portfolio.PortfolioV2HomePage) UserRestClient(org.olat.test.rest.UserRestClient) BinderPage(org.olat.selenium.page.portfolio.BinderPage) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Aggregations

UserVO (org.olat.user.restapi.UserVO)364 Test (org.junit.Test)332 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)260 UserRestClient (org.olat.test.rest.UserRestClient)258 LoginPage (org.olat.selenium.page.LoginPage)114 NavigationPage (org.olat.selenium.page.NavigationPage)110 CoursePageFragment (org.olat.selenium.page.course.CoursePageFragment)102 QTI21Page (org.olat.selenium.page.qti.QTI21Page)96 URL (java.net.URL)90 File (java.io.File)88 CourseEditorPageFragment (org.olat.selenium.page.course.CourseEditorPageFragment)84 URI (java.net.URI)72 HttpResponse (org.apache.http.HttpResponse)72 Identity (org.olat.core.id.Identity)72 UserToolsPage (org.olat.selenium.page.user.UserToolsPage)64 WebElement (org.openqa.selenium.WebElement)48 QTI21EditorPage (org.olat.selenium.page.qti.QTI21EditorPage)46 HttpGet (org.apache.http.client.methods.HttpGet)40 MembersPage (org.olat.selenium.page.course.MembersPage)36 AuthoringEnvPage (org.olat.selenium.page.repository.AuthoringEnvPage)34