本文整理汇总了Java中org.eclipse.che.api.user.server.Constants类的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Constants类属于org.eclipse.che.api.user.server包,在下文中一共展示了Constants类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.eclipse.che.api.user.server.Constants; //导入依赖的package包/类
@BeforeMethod
private void setUp() throws TckRepositoryException {
UserImpl[] users = new UserImpl[COUNT_OF_PROFILES];
profiles = new ProfileImpl[COUNT_OF_PROFILES];
for (int i = 0; i < COUNT_OF_PROFILES; i++) {
final String userId = NameGenerator.generate("user", Constants.ID_LENGTH);
users[i] = new UserImpl(userId, userId + "@eclipse.org", userId, "password", emptyList());
final Map<String, String> attributes = new HashMap<>();
attributes.put("firstName", "first-name-" + i);
attributes.put("lastName", "last-name-" + i);
attributes.put("company", "company-" + i);
profiles[i] = new ProfileImpl(userId, attributes);
}
userTckRepository.createAll(Arrays.asList(users));
profileTckRepository.createAll(Arrays.asList(profiles));
}
示例2: setUp
import org.eclipse.che.api.user.server.Constants; //导入依赖的package包/类
@BeforeMethod
public void setUp() throws TckRepositoryException {
users = new UserImpl[COUNT_OF_USERS];
for (int i = 0; i < users.length; i++) {
final String id = NameGenerator.generate("user", Constants.ID_LENGTH);
final String name = NAME_PREFIX + i;
final String email = name + "@eclipse.org";
final String password = NameGenerator.generate("", Constants.PASSWORD_LENGTH);
final List<String> aliases = new ArrayList<>(asList("google:" + name, "github:" + name));
users[i] = new UserImpl(id, email, name, password, aliases);
}
tckRepository.createAll(Arrays.asList(users));
}
示例3: register
import org.eclipse.che.api.user.server.Constants; //导入依赖的package包/类
@Transactional
public User register(String email, String username, String password) throws ConflictException {
try {
/**
* Creates the user
*/
UserEntity userEntity = new UserEntity();
userEntity.getAliases().add(email);
userEntity.getAliases().add(username);
userEntity.setPasswordHash(userEntityService.generatePasswordHash(password));
userEntity.getRoles().addAll(DEFAULT_USER_ROLES);
userEntity.setUserId(NameGenerator.generate("user-", Constants.ID_LENGTH));
userEntity.getPreferences().put(UserPreferences.Notification.EMAIL, email);
userEntity = userEntityService.save(userEntity);
/**
* Profile
*/
profileEntityService.save(profileEntityService.toProfileEntity(new Profile().
withId(userEntity.getUserId()).
withUserId(userEntity.getUserId()), Optional.empty()));
/**
* Account
*/
AccountEntity account = new AccountEntity();
account.setAccountId(NameGenerator.generate("acc-", org.eclipse.che.api.account.server.Constants.ID_LENGTH));
account.setName(username + "-account");
account = accountEntityService.save(account);
accountMemberEntityService.create(new Member()
.withAccountId(account.getAccountId())
.withUserId(userEntity.getUserId())
.withRoles(DEFAULT_ACCOUNT_ROLES));
/**
* Workspace
*/
WorkspaceEntity workspaceEntity = new WorkspaceEntity();
workspaceEntity.setAccount(account);
workspaceEntity.setWorkspaceId(NameGenerator.generate(Workspace.class.getSimpleName().toLowerCase(), org.eclipse.che.api.workspace.server.Constants.ID_LENGTH));
workspaceEntity.setName(username + "-ws");
workspaceEntity.setTemporary(false);
workspaceEntity = workspaceEntityService.create(workspaceEntity);
workspaceMemberService.create(new org.eclipse.che.api.workspace.server.dao.Member().
withUserId(userEntity.getUserId())
.withWorkspaceId(workspaceEntity.getWorkspaceId())
.withRoles(DEFAULT_WORKSPACE_ROLES));
NotificationEntity notificationEntity = new NotificationEntity();
notificationEntity.setStatus(NotificationStatus.CREATED);
notificationEntity.setUserNotified(userEntity);
notificationEntity.setEvent(NotificationEvent.USER_REGISTERED);
notificationEntity.setChannel(NotificationChannel.EMAIL);
notificationEntity.setDestination(email);
notificationEntity = notificationRepository.save(notificationEntity);
//notificationSender.releaseNotification(notificationEntity);
return userEntityService.toUser(userEntity);
} catch (Exception e) {
LOGGER.warn("Error registering user", e);
throw new ConflictException("Error creating user");
}
}