/**
   * Validates the provided parameters. All resource paths are resolved agains the local file
   * system.
   *
   * @return <code>true</code> if the parameters are valid
   */
  public boolean validate(MessageLog log) {
    boolean valid = true;

    // Either root dir or css files are required
    if (!hasRootDir() && !hasCssFiles()) {
      log.error(MessageType.EITHER_ROOT_DIR_OR_CSS_FILES_IS_REQIRED);
      return false;
    }

    // If there is no output dir, we can't have both root dir or css files
    if (!hasOutputDir() && hasRootDir() && hasCssFiles()) {
      log.error(MessageType.ROOT_DIR_AND_CSS_FILES_CANNOT_BE_BOTH_SPECIFIED_UNLESS_WITH_OUTPUT_DIR);
      return false;
    }

    // Check root dir if provided
    if (hasRootDir()) {
      final File rootDir = FileUtils.getCanonicalOrAbsoluteFile(this.rootDir);
      if ((!rootDir.exists() || !rootDir.isDirectory())) {
        log.error(MessageType.ROOT_DIR_DOES_NOT_EXIST_OR_IS_NOT_DIRECTORY, this.rootDir);
        valid = false;
      }
    }

    // Check output dir if provided
    if (hasOutputDir()) {
      // For output dir, we need root dir
      if (!hasRootDir()) {
        log.error(MessageType.ROOT_DIR_IS_REQIRED_FOR_OUTPUT_DIR);
        return false;
      }

      final File outputDir = FileUtils.getCanonicalOrAbsoluteFile(this.outputDir);
      if (outputDir.exists() && !outputDir.isDirectory()) {
        log.error(MessageType.OUTPUT_DIR_IS_NOT_DIRECTORY, this.outputDir);
        valid = false;
      }
    }

    if (!hasOutputDir() && StringUtils.isBlank(cssFileSuffix)) {
      log.error(MessageType.CSS_FILE_SUFFIX_IS_REQUIRED_IF_NO_OUTPUT_DIR);
      valid = false;
    }

    if (hasDocumentRootDir()) {
      final File documentRootDir = FileUtils.getCanonicalOrAbsoluteFile(this.documentRootDir);
      if (!documentRootDir.exists() || !documentRootDir.isDirectory()) {
        log.error(
            MessageType.DOCUMENT_ROOT_DIR_DOES_NOT_EXIST_OR_IS_NOT_DIRECTORY, this.documentRootDir);
        valid = false;
      }
    }

    return valid;
  }
 public boolean hasDocumentRootDir() {
   return StringUtils.isNotBlank(documentRootDir);
 }
 public boolean hasOutputDir() {
   return StringUtils.isNotBlank(outputDir);
 }
 public boolean hasRootDir() {
   return StringUtils.isNotBlank(rootDir);
 }
Esempio n. 5
0
 @Override
 public String toString() {
   return StringUtils.identifierToHumanReadable(name());
 }
Esempio n. 6
0
 /**
  * Formats this cluster's label. If there is more than one phrase describing this cluster, phrases
  * will be separated by a comma followed by a space, e.g. "Phrase one, Phrase two". To format
  * multi-phrase label in a different way, use {@link #getPhrases()}.
  *
  * @return formatted label of this cluster
  */
 public String getLabel() {
   if (labelCache == null) {
     labelCache = StringUtils.toString(phrases, ", ");
   }
   return labelCache;
 }