+
+ public static String importGenericFileWithExtension(String path, String extension) throws Exception {
+ IGenericFileImport service = findServiceForExtension(extension);
+ Optional<String> result = service.perform(Paths.get(path));
+ return result.get();
+ }
+
+ public static Resource importGenericFileWithExtensionAndParent(Resource parent, String path, String extension) throws Exception {
+ IGenericFileImport service = findServiceForExtension(extension);
+ Optional<Resource> result = service.perform(parent, Paths.get(path));
+ return result.get();
+ }
+
+ private static boolean isPerfectMatch(Set<String> candidates, String extension) {
+ for (String ext : candidates) {
+ if (ext.startsWith("*"))
+ ext = ext.substring(1);
+ if (ext.equals(extension))
+ return true;
+ }
+ return false;
+ }