private void mkdir(PrintWriter writer, Path path) { LOG.debug("mkdir: {}", path); try { FileSystem fs = path.getFileSystem(dataSourceParameter.getConfiguration()); if (stat(fs, path) .filter(FileStatus::isDirectory) .isPresent()) { verboseParameter.printf(writer, "already exists: %s%n", path); } else { if (fs.mkdirs(path) == false && stat(fs, path) .filter(s -> s.isDirectory() == false) .isPresent() == false) { throw new CommandException(MessageFormat.format( "cannot create directory: {0}", path)); } verboseParameter.printf(writer, "create directory: %s%n", path); } } catch (IOException e) { throw new CommandException(MessageFormat.format( "error occurred while creating directory: {0}", path), e); } }
@Override public void run() { LOG.debug("starting {}", getClass().getSimpleName()); List<HiveCreateTable> statements = getStatements(); if (statements.isEmpty()) { throw new CommandConfigurationException("there are no available tables to generate DDL"); } try (PrintWriter writer = outputParameter.open()) { for (HiveCreateTable statement : statements) { HiveQlEmitter.emit(statement, writer); writer.printf("%s%n%n", STATEMENT_SEPARATOR); } } catch (IOException e) { throw new CommandException("error occurred while generating Hive DDL", e); } }
lines = Files.readAllLines(file); } catch (IOException e) { throw new CommandException(MessageFormat.format( Messages.getString("VersionCommand.errorInvalidVersionFile"), //$NON-NLS-1$ file), e);