use of org.kie.workbench.common.services.datamodeller.util.FileUtils in project kie-wb-common by kiegroup.
the class VFSFormFinderServiceImpl method findForms.
private List<FormDefinition> findForms(final Path path, final FormSearchConstraint constraint) {
List<FormDefinition> result = new ArrayList<>();
Module module = moduleService.resolveModule(path);
FileUtils utils = FileUtils.getInstance();
List<org.uberfire.java.nio.file.Path> nioPaths = new ArrayList<>();
nioPaths.add(Paths.convert(module.getRootPath()));
Collection<FileUtils.ScanResult> forms = utils.scan(ioService, nioPaths, FormResourceTypeDefinition.EXTENSION, true);
for (FileUtils.ScanResult form : forms) {
org.uberfire.java.nio.file.Path formPath = form.getFile();
try {
FormDefinition formDefinition = serializer.deserialize(ioService.readAllString(formPath).trim());
if (constraint == null || constraint.accepts(formDefinition)) {
result.add(formDefinition);
}
} catch (Exception ex) {
logger.warn("Unable to generate FormDefinition for {}", path, ex);
}
}
return result;
}
Aggregations