本文整理汇总了Java中org.eclipse.che.account.shared.model.Account类的典型用法代码示例。如果您正苦于以下问题:Java Account类的具体用法?Java Account怎么用?Java Account使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Account类属于org.eclipse.che.account.shared.model包,在下文中一共展示了Account类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIdleTimeout
import org.eclipse.che.account.shared.model.Account; //导入依赖的package包/类
@Override
protected long getIdleTimeout(String workspaceId) throws NotFoundException, ServerException {
WorkspaceImpl workspace = workspaceManager.getWorkspace(workspaceId);
Account account = accountManager.getByName(workspace.getNamespace());
List<? extends Resource> availableResources =
resourceUsageManager.getAvailableResources(account.getId());
Optional<? extends Resource> timeoutOpt =
availableResources
.stream()
.filter(resource -> TimeoutResourceType.ID.equals(resource.getType()))
.findAny();
if (timeoutOpt.isPresent()) {
return timeoutOpt.get().getAmount() * 60 * 1000;
} else {
return -1;
}
}
示例2: checkAccountPermissions
import org.eclipse.che.account.shared.model.Account; //导入依赖的package包/类
void checkAccountPermissions(String accountName, AccountOperation operation)
throws ForbiddenException, NotFoundException, ServerException {
if (accountName == null) {
// default namespace will be used
return;
}
final Account account = accountManager.getByName(accountName);
AccountPermissionsChecker accountPermissionsChecker =
accountTypeToPermissionsChecker.get(account.getType());
if (accountPermissionsChecker == null) {
throw new ForbiddenException("User is not authorized to use specified namespace");
}
accountPermissionsChecker.checkPermissions(account.getId(), operation);
}
示例3: filter
import org.eclipse.che.account.shared.model.Account; //导入依赖的package包/类
@Override
protected void filter(GenericResourceMethod genericMethodResource, Object[] arguments)
throws ApiException {
String accountId;
switch (genericMethodResource.getMethod().getName()) {
case GET_LICENSE_METHOD:
accountId = ((String) arguments[0]);
break;
default:
throw new ForbiddenException("The user does not have permission to perform this operation");
}
final Account account = accountManager.getById(accountId);
final AccountPermissionsChecker permissionsChecker = permissionsCheckers.get(account.getType());
if (permissionsChecker != null) {
permissionsChecker.checkPermissions(accountId, AccountOperation.SEE_RESOURCE_INFORMATION);
} else {
throw new ForbiddenException("User is not authorized to perform given operation");
}
}
示例4: lock
import org.eclipse.che.account.shared.model.Account; //导入依赖的package包/类
/**
* Acquire resources lock for specified account.
*
* @param accountId account id to lock resources
* @return lock for unlocking resources when resources operation finishes
* @throws NotFoundException when account with specified {@code account id} was not found
* @throws ServerException when any other error occurs
*/
public Unlocker lock(String accountId) throws NotFoundException, ServerException {
final Account account = accountManager.getById(accountId);
final ResourceLockKeyProvider resourceLockKeyProvider =
accountTypeToLockProvider.get(account.getType());
String lockKey;
if (resourceLockKeyProvider == null) {
// this account type doesn't have custom lock provider.
// Lock resources by current account
lockKey = accountId;
} else {
lockKey = resourceLockKeyProvider.getLockKey(accountId);
}
return stripedLocks.writeLock(lockKey);
}
示例5: getUsedResource
import org.eclipse.che.account.shared.model.Account; //导入依赖的package包/类
@Override
public Optional<Resource> getUsedResource(String accountId)
throws NotFoundException, ServerException {
final Account account = accountManager.getById(accountId);
final List<WorkspaceImpl> accountWorkspaces =
Pages.stream(
(maxItems, skipCount) ->
workspaceManagerProvider
.get()
.getByNamespace(account.getName(), false, maxItems, skipCount))
.collect(Collectors.toList());
if (!accountWorkspaces.isEmpty()) {
return Optional.of(
new ResourceImpl(
WorkspaceResourceType.ID, accountWorkspaces.size(), WorkspaceResourceType.UNIT));
} else {
return Optional.empty();
}
}
示例6: getUsedResource
import org.eclipse.che.account.shared.model.Account; //导入依赖的package包/类
@Override
public Optional<Resource> getUsedResource(String accountId)
throws NotFoundException, ServerException {
final Account account = accountManager.getById(accountId);
final long currentlyUsedRuntimes =
Pages.stream(
(maxItems, skipCount) ->
workspaceManagerProvider
.get()
.getByNamespace(account.getName(), false, maxItems, skipCount))
.filter(ws -> STOPPED != ws.getStatus())
.count();
if (currentlyUsedRuntimes > 0) {
return Optional.of(
new ResourceImpl(
RuntimeResourceType.ID, currentlyUsedRuntimes, RuntimeResourceType.UNIT));
} else {
return Optional.empty();
}
}
示例7: WorkspaceImpl
import org.eclipse.che.account.shared.model.Account; //导入依赖的package包/类
public WorkspaceImpl(
String id,
Account account,
WorkspaceConfig config,
Runtime runtime,
Map<String, String> attributes,
boolean isTemporary,
WorkspaceStatus status) {
this.id = id;
if (account != null) {
this.account = new AccountImpl(account);
}
if (config != null) {
this.config = new WorkspaceConfigImpl(config);
}
if (runtime != null) {
this.runtime =
new RuntimeImpl(runtime.getActiveEnv(), runtime.getMachines(), runtime.getOwner());
}
if (attributes != null) {
this.attributes = new HashMap<>(attributes);
}
this.isTemporary = isTemporary;
this.status = status;
}
示例8: doCreateWorkspace
import org.eclipse.che.account.shared.model.Account; //导入依赖的package包/类
private WorkspaceImpl doCreateWorkspace(
WorkspaceConfig config, Account account, Map<String, String> attributes, boolean isTemporary)
throws NotFoundException, ServerException, ConflictException {
WorkspaceImpl workspace =
WorkspaceImpl.builder()
.generateId()
.setConfig(config)
.setAccount(account)
.setAttributes(attributes)
.setTemporary(isTemporary)
.setStatus(STOPPED)
.build();
workspace.getAttributes().put(CREATED_ATTRIBUTE_NAME, Long.toString(currentTimeMillis()));
workspaceDao.create(workspace);
LOG.info(
"Workspace '{}/{}' with id '{}' created by user '{}'",
account.getName(),
workspace.getConfig().getName(),
workspace.getId(),
sessionUserNameOrUndefined());
eventService.publish(new WorkspaceCreatedEvent(workspace));
return workspace;
}
示例9: filter
import org.eclipse.che.account.shared.model.Account; //导入依赖的package包/类
@Override
protected void filter(GenericResourceMethod genericMethodResource, Object[] arguments)
throws ApiException {
String accountId;
switch (genericMethodResource.getMethod().getName()) {
case GET_TOTAL_RESOURCES_METHOD:
case GET_AVAILABLE_RESOURCES_METHOD:
case GET_USED_RESOURCES_METHOD:
Subject currentSubject = EnvironmentContext.getCurrent().getSubject();
if (currentSubject.hasPermission(
SystemDomain.DOMAIN_ID, null, SystemDomain.MANAGE_SYSTEM_ACTION)) {
// user is admin and he is able to see resources of all accounts
return;
}
accountId = ((String) arguments[0]);
break;
default:
throw new ForbiddenException("The user does not have permission to perform this operation");
}
final Account account = accountManager.getById(accountId);
final AccountPermissionsChecker resourcesPermissionsChecker =
permissionsCheckers.get(account.getType());
if (resourcesPermissionsChecker != null) {
resourcesPermissionsChecker.checkPermissions(
accountId, AccountOperation.SEE_RESOURCE_INFORMATION);
} else {
throw new ForbiddenException("User is not authorized to perform given operation");
}
}
示例10: getAvailableResources
import org.eclipse.che.account.shared.model.Account; //导入依赖的package包/类
/**
* Returns list of resources which are available for usage by given account.
*
* @param accountId id of account
* @return list of resources which are available for usage by given account
* @throws NotFoundException when account with specified id was not found
* @throws ServerException when some exception occurred while resources fetching
*/
public List<? extends Resource> getAvailableResources(String accountId)
throws NotFoundException, ServerException {
final Account account = accountManager.getById(accountId);
final AvailableResourcesProvider availableResourcesProvider =
accountTypeToAvailableResourcesProvider.get(account.getType());
if (availableResourcesProvider == null) {
return defaultAvailableResourcesProvider.getAvailableResources(accountId);
}
return availableResourcesProvider.getAvailableResources(accountId);
}
示例11: getUsedResource
import org.eclipse.che.account.shared.model.Account; //导入依赖的package包/类
@Override
public Optional<Resource> getUsedResource(String accountId)
throws NotFoundException, ServerException {
final Account account = accountManager.getById(accountId);
List<WorkspaceImpl> activeWorkspaces =
Pages.stream(
(maxItems, skipCount) ->
workspaceManagerProvider
.get()
.getByNamespace(account.getName(), true, maxItems, skipCount))
.filter(ws -> STOPPED != ws.getStatus())
.collect(Collectors.toList());
long currentlyUsedRamMB = 0;
for (WorkspaceImpl activeWorkspace : activeWorkspaces) {
if (WorkspaceStatus.STARTING.equals(activeWorkspace.getStatus())) {
// starting workspace may not have all machine in runtime
// it is need to calculate ram from environment config
final EnvironmentImpl startingEnvironment =
activeWorkspace
.getConfig()
.getEnvironments()
.get(activeWorkspace.getRuntime().getActiveEnv());
currentlyUsedRamMB += environmentRamCalculator.calculate(startingEnvironment);
} else {
currentlyUsedRamMB += environmentRamCalculator.calculate(activeWorkspace.getRuntime());
}
}
if (currentlyUsedRamMB > 0) {
return Optional.of(
new ResourceImpl(RamResourceType.ID, currentlyUsedRamMB, RamResourceType.UNIT));
} else {
return Optional.empty();
}
}
示例12: getDefaultResources
import org.eclipse.che.account.shared.model.Account; //导入依赖的package包/类
private List<ResourceImpl> getDefaultResources(String accountId)
throws NotFoundException, ServerException {
List<ResourceImpl> defaultResources = new ArrayList<>();
final Account account = accountManager.getById(accountId);
final DefaultResourcesProvider defaultResourcesProvider =
defaultResourcesProviders.get(account.getType());
if (defaultResourcesProvider != null) {
defaultResources.addAll(defaultResourcesProvider.getResources(accountId));
}
return defaultResources;
}
示例13: getResources
import org.eclipse.che.account.shared.model.Account; //导入依赖的package包/类
@Override
public List<ProvidedResources> getResources(String accountId)
throws NotFoundException, ServerException {
final Account account = accountManager.getById(accountId);
String parent;
if (!OrganizationImpl.ORGANIZATIONAL_ACCOUNT.equals(account.getType())
|| (parent = organizationManager.getById(accountId).getParent()) == null) {
return emptyList();
}
// given account is suborganization's account and can have resources provided by parent
List<? extends Resource> parentTotalResources =
usageManagerProvider.get().getTotalResources(parent);
if (!parentTotalResources.isEmpty()) {
try {
List<? extends Resource> resourcesCaps =
distributorProvider.get().getResourcesCaps(accountId);
return singletonList(
new ProvidedResourcesImpl(
PARENT_RESOURCES_PROVIDER,
null,
accountId,
-1L,
-1L,
cap(parentTotalResources, resourcesCaps)));
} catch (ConflictException e) {
throw new ServerException(e.getLocalizedMessage());
}
}
return emptyList();
}
示例14: createWorkspace
import org.eclipse.che.account.shared.model.Account; //导入依赖的package包/类
public static WorkspaceImpl createWorkspace(String id, Account account) {
return new WorkspaceImpl(id, account, createWorkspaceConfig(id));
}
示例15: AccountImpl
import org.eclipse.che.account.shared.model.Account; //导入依赖的package包/类
public AccountImpl(Account account) {
this(account.getId(), account.getName(), account.getType());
}