Search in sources :

Example 1 with SoftLocator

use of org.fagu.fmv.soft.find.SoftLocator in project fmv by f-agu.

the class _7zSoftProvider method getSoftLocator.

/**
 * @see org.fagu.fmv.soft.find.SoftProvider#getSoftLocator()
 */
@Override
public SoftLocator getSoftLocator() {
    SoftLocator softLocator = super.getSoftLocator();
    if (SystemUtils.IS_OS_WINDOWS) {
        ProgramFilesLocatorSupplier.with(softLocator).findFolder("7-Zip").supplyIn();
        softLocator.addDefaultLocator();
    }
    return softLocator;
}
Also used : SoftLocator(org.fagu.fmv.soft.find.SoftLocator)

Example 2 with SoftLocator

use of org.fagu.fmv.soft.find.SoftLocator in project fmv by f-agu.

the class JavaSoftProvider method getSoftLocator.

/**
 * @see org.fagu.fmv.soft.find.SoftProvider#getSoftLocator()
 */
@Override
public SoftLocator getSoftLocator() {
    SoftLocator softLocator = new SoftLocator(getName()) {

        /**
         * @see org.fagu.fmv.soft.find.SoftLocator#getLocators(java.lang.String, org.fagu.fmv.soft.find.Locators,
         *      java.io.FileFilter)
         */
        @Override
        protected List<Locator> getLocators(Locators loc) {
            List<Locator> list = super.getLocators(loc);
            Locators locators = createLocators();
            list.add(0, locators.byPropertyPath("java.home"));
            if (SystemUtils.IS_OS_WINDOWS) {
                ProgramFilesLocatorSupplier.with(list::add, locators).find(programFile -> {
                    List<File> files = new ArrayList<>();
                    File[] javaFolders = programFile.listFiles(f -> "java".equalsIgnoreCase(f.getName()));
                    if (javaFolders != null) {
                        for (File folder : javaFolders) {
                            File[] subFolders = folder.listFiles();
                            if (subFolders != null) {
                                for (File subFolder : subFolders) {
                                    files.add(subFolder);
                                    files.add(new File(subFolder, "bin"));
                                }
                            }
                        }
                    }
                    return files;
                }).supplyIn();
            }
            return list;
        }
    };
    softLocator.setSoftPolicy(getSoftPolicy());
    softLocator.setEnvName("JAVA_HOME");
    return softLocator;
}
Also used : SoftFoundFactory(org.fagu.fmv.soft.find.SoftFoundFactory) SoftLocator(org.fagu.fmv.soft.find.SoftLocator) VersionParserManager(org.fagu.version.VersionParserManager) Locators(org.fagu.fmv.soft.find.Locators) SoftPolicy(org.fagu.fmv.soft.find.SoftPolicy) SystemUtils(org.apache.commons.lang3.SystemUtils) Locator(org.fagu.fmv.soft.find.Locator) ProgramFilesLocatorSupplier(org.fagu.fmv.soft.win32.ProgramFilesLocatorSupplier) File(java.io.File) ArrayList(java.util.ArrayList) SoftProvider(org.fagu.fmv.soft.find.SoftProvider) VersionSoftPolicy.minVersion(org.fagu.fmv.soft.find.policy.VersionSoftPolicy.minVersion) List(java.util.List) Matcher(java.util.regex.Matcher) VersionSoftPolicy(org.fagu.fmv.soft.find.policy.VersionSoftPolicy) ObjectUtils(org.apache.commons.lang3.ObjectUtils) Pattern(java.util.regex.Pattern) SoftLocator(org.fagu.fmv.soft.find.SoftLocator) Locator(org.fagu.fmv.soft.find.Locator) SoftLocator(org.fagu.fmv.soft.find.SoftLocator) Locators(org.fagu.fmv.soft.find.Locators) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File)

Example 3 with SoftLocator

use of org.fagu.fmv.soft.find.SoftLocator in project fmv by f-agu.

the class PdfSoftProvider method getSoftLocator.

/**
 * @see org.fagu.fmv.soft.find.SoftProvider#getSoftLocator()
 */
@Override
public SoftLocator getSoftLocator() {
    SoftLocator softLocator = super.getSoftLocator();
    if (SystemUtils.IS_OS_WINDOWS) {
        ProgramFilesLocatorSupplier.with(softLocator).find(programFile -> {
            File[] listFiles = programFile.listFiles(f -> f.getName().startsWith("xpdf"));
            if (listFiles == null || listFiles.length == 0) {
                return Collections.emptyList();
            }
            String arch = "bin" + System.getProperty("sun.arch.data.model");
            return Arrays.asList(listFiles).stream().map(f -> new File(f, arch)).collect(Collectors.toList());
        }).supplyIn();
        softLocator.addDefaultLocator();
    }
    return softLocator;
}
Also used : Arrays(java.util.Arrays) VersionParserManager(org.fagu.version.VersionParserManager) SoftFound(org.fagu.fmv.soft.find.SoftFound) ProgramFilesLocatorSupplier(org.fagu.fmv.soft.win32.ProgramFilesLocatorSupplier) ArrayList(java.util.ArrayList) SoftProvider(org.fagu.fmv.soft.find.SoftProvider) BiPredicate(java.util.function.BiPredicate) Matcher(java.util.regex.Matcher) VersionSoftPolicy(org.fagu.fmv.soft.find.policy.VersionSoftPolicy) ObjectUtils(org.apache.commons.lang3.ObjectUtils) ExceptionKnownAnalyzer(org.fagu.fmv.soft.exec.exception.ExceptionKnownAnalyzer) XpdfExceptionKnownAnalyzer(org.fagu.fmv.soft.xpdf.exception.XpdfExceptionKnownAnalyzer) Soft(org.fagu.fmv.soft.Soft) SoftFoundFactory(org.fagu.fmv.soft.find.SoftFoundFactory) SoftLocator(org.fagu.fmv.soft.find.SoftLocator) SoftPolicy(org.fagu.fmv.soft.find.SoftPolicy) SystemUtils(org.apache.commons.lang3.SystemUtils) SoftInfo(org.fagu.fmv.soft.find.SoftInfo) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) VersionSoftPolicy.minVersion(org.fagu.fmv.soft.find.policy.VersionSoftPolicy.minVersion) List(java.util.List) Parser(org.fagu.fmv.soft.find.ExecSoftFoundFactory.Parser) Pattern(java.util.regex.Pattern) Version(org.fagu.version.Version) Collections(java.util.Collections) SoftExecutor(org.fagu.fmv.soft.SoftExecutor) SoftLocator(org.fagu.fmv.soft.find.SoftLocator) File(java.io.File)

Example 4 with SoftLocator

use of org.fagu.fmv.soft.find.SoftLocator in project fmv by f-agu.

the class SoftSearch method search.

/**
 * @return
 */
public Soft search() {
    SoftLocator locator = getLocator();
    Founds founds = locator.find();
    return createAndfireEventFound(founds, locator);
}
Also used : SoftLocator(org.fagu.fmv.soft.find.SoftLocator) Founds(org.fagu.fmv.soft.find.Founds)

Example 5 with SoftLocator

use of org.fagu.fmv.soft.find.SoftLocator in project fmv by f-agu.

the class SoftSearch method search.

/**
 * @param softFoundFactory
 * @return
 */
public Soft search(SoftFoundFactory softFoundFactory) {
    checkUsed();
    SoftLocator locator = getLocator();
    Founds founds = locator.find((file, loc, softPol) -> {
        try {
            SoftFound softFound = softFoundFactory.create(file, loc, softPol);
            if (softFound == null) {
                return SoftFound.foundBadSoft(file);
            }
            return softFound;
        } catch (IOException e) {
            return SoftFound.foundError(file, e.getMessage()).setLocalizedBy(locator.toString());
        }
    });
    return createAndfireEventFound(founds, locator);
}
Also used : SoftLocator(org.fagu.fmv.soft.find.SoftLocator) SoftFound(org.fagu.fmv.soft.find.SoftFound) Founds(org.fagu.fmv.soft.find.Founds) IOException(java.io.IOException)

Aggregations

SoftLocator (org.fagu.fmv.soft.find.SoftLocator)12 File (java.io.File)6 Matcher (java.util.regex.Matcher)6 Pattern (java.util.regex.Pattern)6 SystemUtils (org.apache.commons.lang3.SystemUtils)6 SoftFoundFactory (org.fagu.fmv.soft.find.SoftFoundFactory)6 SoftProvider (org.fagu.fmv.soft.find.SoftProvider)6 ProgramFilesLocatorSupplier (org.fagu.fmv.soft.win32.ProgramFilesLocatorSupplier)6 VersionParserManager (org.fagu.version.VersionParserManager)6 SoftPolicy (org.fagu.fmv.soft.find.SoftPolicy)5 VersionSoftPolicy (org.fagu.fmv.soft.find.policy.VersionSoftPolicy)5 VersionSoftPolicy.minVersion (org.fagu.fmv.soft.find.policy.VersionSoftPolicy.minVersion)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ObjectUtils (org.apache.commons.lang3.ObjectUtils)4 ExceptionKnownAnalyzer (org.fagu.fmv.soft.exec.exception.ExceptionKnownAnalyzer)4 Version (org.fagu.version.Version)4 IOException (java.io.IOException)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Arrays (java.util.Arrays)3