private void generate(final File filePath, final File result) {
        try {
            val validator = new RegisteredServiceJsonSerializer(applicationContext);
            val basicFileAttributes = Files.readAttributes(filePath.toPath(), BasicFileAttributes.class);
            if (basicFileAttributes.isRegularFile() && filePath.exists()
                && filePath.canRead() && basicFileAttributes.size() > 0) {
                val svc = validator.from(filePath);
                LOGGER.info("Service [{}] is valid at [{}].", svc.getName(), filePath.getCanonicalPath());
                val yaml = new RegisteredServiceYamlSerializer(applicationContext);
                try (val writer = new StringWriter()) {
                    yaml.to(writer, svc);
                    LOGGER.info(writer.toString());

                    if (result != null) {
                        yaml.to(result, svc);
                        LOGGER.info("YAML service definition is saved at [{}].", result.getCanonicalPath());
                    }
                }
            } else {
                LOGGER.warn("File [{}] is does not exist, is not readable or is empty", filePath.getCanonicalPath());
            }
        } catch (final Exception e) {
            LOGGER.error("Could not understand and validate [{}]: [{}]", filePath.getPath(), e.getMessage());
        } finally {
            LOGGER.info("-".repeat(SEP_LINE_LENGTH));
        }

    }
Validate service.

@param file        the file
@param destination the destination
@return the file
support/cas-server-support-shell-core/src/main/java/org/apereo/cas/shell/commands/services/GenerateYamlRegisteredServiceCommand.java