當前位置: 首頁>>代碼示例>>Java>>正文


Java Account類代碼示例

本文整理匯總了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;
  }
}
 
開發者ID:codenvy,項目名稱:codenvy,代碼行數:19,代碼來源:HostedWorkspaceActivityManager.java

示例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);
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:19,代碼來源:WorkspacePermissionsFilter.java

示例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");
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:22,代碼來源:LicenseServicePermissionsFilter.java

示例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);
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:24,代碼來源:ResourcesLocks.java

示例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();
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:20,代碼來源:WorkspaceResourceUsageTracker.java

示例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();
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:21,代碼來源:RuntimeResourceUsageTracker.java

示例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;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:26,代碼來源:WorkspaceImpl.java

示例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;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:25,代碼來源:WorkspaceManager.java

示例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");
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:33,代碼來源:ResourceUsageServicePermissionsFilter.java

示例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);
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:21,代碼來源:ResourceUsageManager.java

示例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();
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:36,代碼來源:RamResourceUsageTracker.java

示例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;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:14,代碼來源:FreeResourcesProvider.java

示例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();
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:36,代碼來源:SuborganizationResourcesProvider.java

示例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));
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:4,代碼來源:TestObjectsFactory.java

示例15: AccountImpl

import org.eclipse.che.account.shared.model.Account; //導入依賴的package包/類
public AccountImpl(Account account) {
  this(account.getId(), account.getName(), account.getType());
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:4,代碼來源:AccountImpl.java


注:本文中的org.eclipse.che.account.shared.model.Account類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。