'Copy XML and the jar_path files from Java or MR actions to the deployment directory.
This should run as the workflow user.'

def _copy_files(self, deployment_dir, oozie_xml):

    xml_path = self.fs.join(deployment_dir, self.job.get_application_filename())
    self.fs.create(xml_path, overwrite=True, permission=420, data=smart_str(oozie_xml))
    LOG.debug(('Created    %s' % (xml_path,)))
    files = []
    lib_path = self.fs.join(deployment_dir, 'lib')
    if hasattr(self.job, 'node_list'):
        for node in self.job.node_list:
            if (hasattr(node, 'jar_path') and (not node.jar_path.startswith(lib_path))):
                files.append(node.jar_path)
    if files:
        for jar_file in files:
            LOG.debug(('Updating    %s' % jar_file))
            jar_lib_path = self.fs.join(lib_path, self.fs.basename(jar_file))
            if self.fs.exists(jar_lib_path):
                stat_src = self.fs.stats(jar_file)
                stat_dest = self.fs.stats(jar_lib_path)
                if (stat_src.fileId != stat_dest.fileId):
                    self.fs.remove(jar_lib_path, skip_trash=True)
            self.fs.copyfile(jar_file, jar_lib_path)
