class PolicyUpdater {

    static void verifyTmpDirSetup(PolicyUpdaterConfiguration configuration) throws IOException {
        // ensure tmp dir exists
        String policyTmpDir = configuration.getPolicyFileTmpDir();
        Path tmpDir = Paths.get(policyTmpDir);
        if (java.nio.file.Files.exists(tmpDir)) {
            return;
        }

        LOG.warn("The temp dir doesnt exist so will create it: " + tmpDir);
        java.nio.file.Files.createDirectory(tmpDir);

        // get the user from config file to perform chown aginst the tmp dir
        // chown -R $zpu_user $ROOT/tmp/zpe
        String user = configuration.getZpuDirOwner();
        if (user == null) {
            LOG.warn("Cannot chown of the temp dir: " + tmpDir + " : no configured user");
            return;
        }

        try {
            java.nio.file.attribute.UserPrincipalLookupService lookupSvc =
                java.nio.file.FileSystems.getDefault().getUserPrincipalLookupService();
            java.nio.file.attribute.UserPrincipal uprinc = lookupSvc.lookupPrincipalByName(user);
            Files.setOwner(tmpDir, uprinc);
        } catch (Exception exc) {
            LOG.warn("Failed to chown of the temp dir: " + tmpDir
                    + ", user: " + user + ", exc: " + exc.getMessage());
        }
    }

}