Search in sources :

Example 21 with ContainerDTO

use of org.phoenicis.containers.dto.ContainerDTO in project POL-POM-5 by PlayOnLinux.

the class GenericContainersManager method fetchContainers.

/**
 * {@inheritDoc}
 */
@Override
public void fetchContainers(Consumer<List<ContainerCategoryDTO>> onSuccess, Consumer<Exception> onError) {
    final File containersFile = new File(containersPath);
    containersFile.mkdirs();
    final File[] engineDirectories = containersFile.listFiles();
    if (engineDirectories == null) {
        onSuccess.accept(Collections.emptyList());
    } else {
        final List<ContainerCategoryDTO> containerCategories = new ArrayList<>();
        for (File engineDirectory : engineDirectories) {
            final List<ContainerDTO> containers = fetchContainers(engineDirectory);
            if (!CollectionUtils.isEmpty(containers)) {
                containerCategories.add(new ContainerCategoryDTO.Builder().withName(engineDirectory.getName()).withContainers(containers).build());
            }
        }
        onSuccess.accept(containerCategories);
    }
}
Also used : ContainerCategoryDTO(org.phoenicis.containers.dto.ContainerCategoryDTO) ArrayList(java.util.ArrayList) ContainerDTO(org.phoenicis.containers.dto.ContainerDTO) WinePrefixContainerDTO(org.phoenicis.containers.dto.WinePrefixContainerDTO) File(java.io.File) ConfigFile(org.phoenicis.tools.config.ConfigFile)

Aggregations

ContainerDTO (org.phoenicis.containers.dto.ContainerDTO)21 File (java.io.File)12 WinePrefixContainerDTO (org.phoenicis.containers.dto.WinePrefixContainerDTO)12 ContainerCategoryDTO (org.phoenicis.containers.dto.ContainerCategoryDTO)11 ArrayList (java.util.ArrayList)10 ConfigFile (org.phoenicis.tools.config.ConfigFile)10 List (java.util.List)9 Consumer (java.util.function.Consumer)8 ScriptInterpreter (org.phoenicis.scripts.interpreter.ScriptInterpreter)8 Logger (org.slf4j.Logger)8 LoggerFactory (org.slf4j.LoggerFactory)8 IOException (java.io.IOException)7 Collectors (java.util.stream.Collectors)7 TypeReference (com.fasterxml.jackson.core.type.TypeReference)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 Collections (java.util.Collections)6 Map (java.util.Map)6 ScriptObjectMirror (jdk.nashorn.api.scripting.ScriptObjectMirror)6 Safe (org.phoenicis.configuration.security.Safe)6 LibraryManager (org.phoenicis.library.LibraryManager)6