from parallels.common.workflow.shared_hosting_workflow import SharedHostingWorkflow
from parallels.common.actions.base.legacy_action \
	import LegacyAction

from parallels.helm_migrator.actions.hosting_settings.convert.dns \
	import DNS as ActionHostingSettingsConvertDNS
from parallels.helm_migrator.actions.content.web.copy_windows_content \
	import CopyWindowsWebContent
from parallels.plesks_migrator.actions.content.web.reset_permissions \
	import ResetPermissions
from parallels.helm_migrator.actions.hosting_settings.transfer_virtual_directories \
	import TransferVirtualDirectories
from parallels.helm_migrator.actions.hosting_settings.transfer_mime_types \
	import TransferMIMETypes
from parallels.helm_migrator.actions.hosting_settings.transfer_error_documents \
	import TransferErrorDocuments


class FromHelm4Workflow(SharedHostingWorkflow):
	def __init__(self):
		super(FromHelm4Workflow, self).__init__()

		self.get_shared_action('fetch-source').insert_action(
			'fetch-data', LegacyAction(
				description='Fetch data from source Helm',
				function=lambda ctx: ctx.migrator._fetch_source(
					ctx.options, ctx.options.reload_source_data
				)
			)
		)
		self.get_path('transfer-accounts/restore-hosting/convert-hosting').replace(
			'convert-dns', ActionHostingSettingsConvertDNS()
		)
		self.get_path('transfer-accounts/copy-content/web').insert_action(
			'copy-files', CopyWindowsWebContent()
		)
		self.get_path('transfer-accounts/copy-content/web').insert_action(
			'reset-permissions', ResetPermissions()
		)
		self.get_path('transfer-accounts/copy-content/web').insert_action(
			'transfer-virtual-directories', TransferVirtualDirectories()
		)
		self.get_path('transfer-accounts/copy-content/web').insert_action(
			'transfer-mime-types', TransferMIMETypes()
		)
		self.get_path('transfer-accounts/copy-content/web').insert_action(
			'transfer-error-documents', TransferErrorDocuments()
		)
