Java Code Examples for org.netbeans.modules.php.api.util.FileUtils#validateFile()

The following examples show how to use org.netbeans.modules.php.api.util.FileUtils#validateFile() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HudsonOptionsValidator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static String validateFile(String fileLabel, String filePath, String fileNameError, String... fileNames) {
    String error = FileUtils.validateFile(fileLabel, filePath, false);
    if (error != null) {
        return error;
    }
    // check file name
    boolean found = false;
    for (String fileName : fileNames) {
        if (fileName.equals(new File(filePath).getName())) {
            found = true;
            break;
        }
    }
    if (!found) {
        return fileNameError;
    }
    return null;
}
 
Example 2
Source File: SymfonyOptionsValidator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "SymfonyOptionsValidator.sandbox=Sandbox",
    "SymfonyOptionsValidator.sandbox.notZip=Sandbox is not ZIP file.",
})
public SymfonyOptionsValidator validateSandbox(@NullAllowed String sandbox) {
    String warning = FileUtils.validateFile(Bundle.SymfonyOptionsValidator_sandbox(), sandbox, false);
    if (warning != null) {
        result.addWarning(new ValidationResult.Message(SymfonyOptions.SANDBOX, warning));
    } else if (!new File(sandbox).getName().toLowerCase().endsWith(".zip")) { // NOI18N
        result.addWarning(new ValidationResult.Message(SymfonyOptions.SANDBOX, Bundle.SymfonyOptionsValidator_sandbox_notZip()));
    }
    return this;
}
 
Example 3
Source File: AtoumPreferencesValidator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void validatePath(boolean pathEnabled, String path, String label, String source) {
    if (!pathEnabled) {
        return;
    }
    String warning = FileUtils.validateFile(label, path, false);
    if (warning != null) {
        result.addWarning(new ValidationResult.Message(source, warning));
    }
}
 
Example 4
Source File: PhpUnitPreferencesValidator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void validatePath(boolean pathEnabled, String path, String label, String source) {
    if (!pathEnabled) {
        return;
    }
    String warning = FileUtils.validateFile(label, path, false);
    if (warning != null) {
        result.addWarning(new ValidationResult.Message(source, warning));
    }
}
 
Example 5
Source File: AnalysisOptionsValidator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private AnalysisOptionsValidator validatePHPStanConfiguration(String configuration) {
    if (!StringUtils.isEmpty(configuration)) {
        String warning = FileUtils.validateFile("Configuration file", configuration, false); // NOI18N
        if (warning != null) {
            result.addWarning(new ValidationResult.Message("phpStan.configuration", warning)); // NOI18N
        }
    }
    return this;
}
 
Example 6
Source File: ApiGenPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages("ApiGenPanel.warn.configNotNeon=Neon file is expected for configuration.")
private String validateConfigFile(boolean forErrors) {
    String config = getConfig();
    if (forErrors) {
        // errors
        return FileUtils.validateFile(config, false);
    }
    // warnings
    File configFile = new File(config);
    if (!configFile.getName().endsWith(".neon")) { // NOI18N
        return Bundle.ApiGenPanel_warn_configNotNeon();
    }
    return null;
}
 
Example 7
Source File: PhpExecutableValidator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Validate the given command and return error if it is not valid, {@code null} otherwise.
 * @param command command to be validated, can be {@code null}
 * @param executableName the name of the executable (e.g. "Doctrine script"), can be {@code null} (in such case, "File" is used)
 * @return error if it is not valid, {@code null} otherwise
 */
public static String validateCommand(@NullAllowed String command, @NullAllowed String executableName) {
    String executable = null;
    if (command != null) {
        executable = PhpExecutable.parseCommand(command).first();
    }
    if (executableName == null) {
        return FileUtils.validateFile(executable, false);
    }
    return FileUtils.validateFile(executableName, executable, false);
}
 
Example 8
Source File: CodeceptionPreferencesValidator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void validatePath(boolean pathEnabled, String path, String label, String source) {
    if (!pathEnabled) {
        return;
    }
    String warning = FileUtils.validateFile(label, path, false);
    if (warning != null) {
        result.addError(new ValidationResult.Message(source, warning));
    }
}
 
Example 9
Source File: TesterUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages("TesterUtils.php.ini.error=Absolute path to file or directory must be set for php.ini.")
@CheckForNull
public static String validatePhpIniPath(@NullAllowed String phpIniPath) {
    if (FileUtils.validateDirectory(phpIniPath, false) != null
            && FileUtils.validateFile(phpIniPath, false) != null) {
        return Bundle.TesterUtils_php_ini_error();
    }
    return null;
}
 
Example 10
Source File: OptionsValidator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "OptionsValidator.skeleton.title=Skeleton",
    "OptionsValidator.skeleton.notZip=Skeleton is not Zip file."
})
private String validateSkeleton(String skeleton) {
    String error = FileUtils.validateFile(Bundle.OptionsValidator_skeleton_title(), skeleton, false);
    if (error == null) {
        if (!new File(skeleton).getName().toLowerCase().endsWith(".zip")) { // NOI18N
            error = Bundle.OptionsValidator_skeleton_notZip();
        }
    }
    return error;
}
 
Example 11
Source File: SftpConfigurationValidator.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@NbBundle.Messages({
    "SftpConfigurationValidator.identityFile=Private Key",
    "SftpConfigurationValidator.knownHosts=Known Hosts"
})
public SftpConfigurationValidator validate(String host, String port, String user, String identityFile, String knownHostsFile, String initialDirectory,
        String timeout, String keepAliveInterval) {
    String err = RemoteValidator.validateHost(host);
    if (err != null) {
        result.addError(new ValidationResult.Message("host", err)); // NOI18N
    }

    err = RemoteValidator.validatePort(port);
    if (err != null) {
        result.addError(new ValidationResult.Message("port", err)); // NOI18N
    }

    err = RemoteValidator.validateUser(user);
    if (err != null) {
        result.addError(new ValidationResult.Message("user", err)); // NOI18N
    }

    if (StringUtils.hasText(identityFile)) {
        err = FileUtils.validateFile(Bundle.SftpConfigurationValidator_identityFile(), identityFile, false);
        if (err != null) {
            result.addError(new ValidationResult.Message("identityFile", err)); // NOI18N
        }
    }

    if (StringUtils.hasText(knownHostsFile)) {
        err = FileUtils.validateFile(Bundle.SftpConfigurationValidator_knownHosts(), knownHostsFile, false);
        if (err != null) {
            result.addError(new ValidationResult.Message("knownHostsFile", err)); // NOI18N
        }
    }

    err = RemoteValidator.validateUploadDirectory(initialDirectory);
    if (err != null) {
        result.addError(new ValidationResult.Message("initialDirectory", err)); // NOI18N
    }

    err = RemoteValidator.validateTimeout(timeout);
    if (err != null) {
        result.addError(new ValidationResult.Message("timeout", err)); // NOI18N
    }

    err = RemoteValidator.validateKeepAliveInterval(keepAliveInterval);
    if (err != null) {
        result.addError(new ValidationResult.Message("keepAliveInterval", err)); // NOI18N
    }
    return this;
}
 
Example 12
Source File: Doctrine2OptionsPanelController.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@NbBundle.Messages("Doctrine2OptionsPanelController.script=Doctrine2 script")
public static String validateScript(String script) {
    return FileUtils.validateFile(Bundle.Doctrine2OptionsPanelController_script(), script, false);
}