Search in sources :

Example 1 with ResourceUsageTracker

use of org.eclipse.che.multiuser.resource.api.ResourceUsageTracker in project che-server by eclipse-che.

the class ResourceManager method getUsedResources.

/**
 * Returns list of resources which are used by given account.
 *
 * @param accountId id of account
 * @return list of resources which are used 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> getUsedResources(String accountId) throws NotFoundException, ServerException {
    List<Resource> usedResources = new ArrayList<>();
    for (ResourceUsageTracker usageTracker : usageTrackers) {
        Optional<Resource> usedResource = usageTracker.getUsedResource(accountId);
        usedResource.ifPresent(usedResources::add);
    }
    return usedResources;
}
Also used : Resource(org.eclipse.che.multiuser.resource.model.Resource) ArrayList(java.util.ArrayList) ResourceUsageTracker(org.eclipse.che.multiuser.resource.api.ResourceUsageTracker)

Example 2 with ResourceUsageTracker

use of org.eclipse.che.multiuser.resource.api.ResourceUsageTracker in project devspaces-images by redhat-developer.

the class ResourceManager method getUsedResources.

/**
 * Returns list of resources which are used by given account.
 *
 * @param accountId id of account
 * @return list of resources which are used 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> getUsedResources(String accountId) throws NotFoundException, ServerException {
    List<Resource> usedResources = new ArrayList<>();
    for (ResourceUsageTracker usageTracker : usageTrackers) {
        Optional<Resource> usedResource = usageTracker.getUsedResource(accountId);
        usedResource.ifPresent(usedResources::add);
    }
    return usedResources;
}
Also used : Resource(org.eclipse.che.multiuser.resource.model.Resource) ArrayList(java.util.ArrayList) ResourceUsageTracker(org.eclipse.che.multiuser.resource.api.ResourceUsageTracker)

Aggregations

ArrayList (java.util.ArrayList)2 ResourceUsageTracker (org.eclipse.che.multiuser.resource.api.ResourceUsageTracker)2 Resource (org.eclipse.che.multiuser.resource.model.Resource)2