Search in sources :

Example 16 with ProvidedResourcesImpl

use of org.eclipse.che.multiuser.resource.spi.impl.ProvidedResourcesImpl in project devspaces-images by redhat-developer.

the class SuborganizationResourcesProvider method getResources.

@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 = resourceManagerProvider.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();
}
Also used : Account(org.eclipse.che.account.shared.model.Account) ProvidedResourcesImpl(org.eclipse.che.multiuser.resource.spi.impl.ProvidedResourcesImpl) ServerException(org.eclipse.che.api.core.ServerException) ConflictException(org.eclipse.che.api.core.ConflictException)

Aggregations

ProvidedResourcesImpl (org.eclipse.che.multiuser.resource.spi.impl.ProvidedResourcesImpl)16 ResourceImpl (org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl)14 Test (org.testng.annotations.Test)10 ProvidedResources (org.eclipse.che.multiuser.resource.model.ProvidedResources)8 NotFoundException (org.eclipse.che.api.core.NotFoundException)4 AbstractModule (com.google.inject.AbstractModule)2 JpaPersistModule (com.google.inject.persist.jpa.JpaPersistModule)2 PostConstruct (jakarta.annotation.PostConstruct)2 AccountManager (org.eclipse.che.account.api.AccountManager)2 AccountModule (org.eclipse.che.account.api.AccountModule)2 Account (org.eclipse.che.account.shared.model.Account)2 AccountDao (org.eclipse.che.account.spi.AccountDao)2 ConflictException (org.eclipse.che.api.core.ConflictException)2 ServerException (org.eclipse.che.api.core.ServerException)2 EventService (org.eclipse.che.api.core.notification.EventService)2 UserDevfileDao (org.eclipse.che.api.devfile.server.spi.UserDevfileDao)2 FactoryJpaModule (org.eclipse.che.api.factory.server.jpa.FactoryJpaModule)2 FactoryDao (org.eclipse.che.api.factory.server.spi.FactoryDao)2 SshJpaModule (org.eclipse.che.api.ssh.server.jpa.SshJpaModule)2 SshDao (org.eclipse.che.api.ssh.server.spi.SshDao)2