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;
}
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;
}
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;
}
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();
}
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();
}
Aggregations