use of org.phoenicis.repository.dto.RepositoryDTO in project phoenicis by PhoenicisOrg.
the class GitRepository method fetchInstallableApplications.
@Override
public synchronized RepositoryDTO fetchInstallableApplications() {
LOGGER.info("Begin fetching process of " + this);
boolean folderExists = this.localFolder.exists();
// check that the repository folder exists
if (!folderExists) {
LOGGER.info("Creating local folder for " + this);
if (!this.localFolder.mkdirs()) {
throw new RepositoryException("Couldn't create local folder for " + this);
}
}
RepositoryDTO result = null;
Git gitRepository = null;
try {
/*
* if the repository folder previously didn't exist, clone the
* repository now and checkout the correct branch
*/
if (!folderExists) {
LOGGER.info("Cloning " + this);
gitRepository = Git.cloneRepository().setURI(this.repositoryUri.toString()).setDirectory(this.localFolder).setBranch(this.branch).call();
} else /*
* otherwise open the folder and pull the newest updates from the
* repository
*/
{
LOGGER.info("Opening " + this);
gitRepository = Git.open(localFolder);
LOGGER.info("Pulling new commits from " + this);
gitRepository.pull().call();
}
result = localRepositoryFactory.createInstance(this.localFolder, this.repositoryUri).fetchInstallableApplications();
} catch (RepositoryNotFoundException | GitAPIException e) {
throw new RepositoryException(String.format("Folder '%s' is no git-repository", this.localFolder.getAbsolutePath()), e);
} catch (IOException e) {
throw new RepositoryException("An unknown error occurred", e);
} finally {
// close repository to free resources
if (gitRepository != null) {
gitRepository.close();
}
}
return result;
}
use of org.phoenicis.repository.dto.RepositoryDTO in project POL-POM-5 by PlayOnLinux.
the class GitRepository method fetchInstallableApplications.
@Override
public RepositoryDTO fetchInstallableApplications() {
try {
cloneOrUpdateWithLock();
final RepositoryDTO result = this.localRepositoryFactory.createInstance(this.localFolder, this.repositoryUri).fetchInstallableApplications();
return result;
} catch (RepositoryException e) {
final String message = String.format("Could not fetch installable applications for git-repository %s", this.toString());
throw new RepositoryException(message, e);
}
}
use of org.phoenicis.repository.dto.RepositoryDTO in project POL-POM-5 by PhoenicisOrg.
the class GitRepository method fetchInstallableApplications.
@Override
public RepositoryDTO fetchInstallableApplications() {
try {
cloneOrUpdateWithLock();
final RepositoryDTO result = this.localRepositoryFactory.createInstance(this.localFolder, this.repositoryUri).fetchInstallableApplications();
return result;
} catch (RepositoryException e) {
final String message = String.format("Could not fetch installable applications for git-repository %s", this.toString());
throw new RepositoryException(message, e);
}
}
use of org.phoenicis.repository.dto.RepositoryDTO in project POL-POM-5 by PlayOnLinux.
the class EngineSettingsManager method fetchAvailableEngineSettings.
/**
* Fetches the available engine settings
*
* @param repositoryDTO The repository containing the engine settings
* @param callback The callback which recieves the found engine settings
* @param errorCallback The callback which will be executed if an error occurs
*/
public void fetchAvailableEngineSettings(RepositoryDTO repositoryDTO, Consumer<Map<String, List<EngineSetting>>> callback, Consumer<Exception> errorCallback) {
executorService.execute(() -> {
final List<SettingConfig> configurations = fetchSettingConfigurations(repositoryDTO);
// the script engine needs to be created inside the correct thread otherwise GraalJS throws an error
final PhoenicisScriptEngine phoenicisScriptEngine = phoenicisScriptEngineFactory.createEngine();
final Map<String, List<EngineSetting>> result = configurations.stream().collect(Collectors.groupingBy(configuration -> configuration.engineId, Collectors.mapping(configuration -> {
final String include = String.format("include(\"engines.%s.settings.%s\");", configuration.engineId, configuration.settingId);
final Value settingClass = (Value) phoenicisScriptEngine.evalAndReturn(include, errorCallback);
return settingClass.newInstance().as(EngineSetting.class);
}, Collectors.toList())));
callback.accept(result);
});
}
use of org.phoenicis.repository.dto.RepositoryDTO in project POL-POM-5 by PlayOnLinux.
the class EnginesManager method fetchAvailableEngines.
/**
* Fetches the available engines
*
* @param repositoryDTO The repository containing the engines
* @param callback The callback which receives the fetched engines
* @param errorCallback The callback which is executed if an error occurs
*/
public void fetchAvailableEngines(RepositoryDTO repositoryDTO, Consumer<Map<String, Engine>> callback, Consumer<Exception> errorCallback) {
final List<String> engineIds = repositoryDTO.getTypes().stream().filter(type -> type.getId().equals("engines")).flatMap(type -> type.getCategories().stream()).map(engine -> engine.getId().replaceAll("^.*\\.", "")).collect(Collectors.toList());
executorService.execute(() -> {
final PhoenicisScriptEngine phoenicisScriptEngine = phoenicisScriptEngineFactory.createEngine();
Map<String, Engine> result = engineIds.stream().collect(Collectors.toMap(Function.identity(), engineId -> {
final String include = String.format("include(\"engines.%s.engine.implementation\");", engineId);
final Value engineClass = (Value) phoenicisScriptEngine.evalAndReturn(include, errorCallback);
return engineClass.newInstance().as(Engine.class);
}));
callback.accept(result);
});
}
Aggregations